akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T)(in string str, T fix) { auto r = str.split.to!(T[]); foreach (ref e; r) e += fix; return r;}
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool INSIDE(T)(T x, T b, T e) { return x >= b && x < e; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}

long[] dijkstra(long from, long to, long[][] edges)
{
	long[] path;
	auto cost = new long[](edges.length); fill(cost, long.max); cost[from] = 0;
	long[][] open = [[from]];
	while (!open.empty)
	{
		auto n = open.front; open.popFront;
		auto p = n[0];
		foreach (i; 0..edges.length)
		{
			if (edges[p][i] == -1) continue;
			auto c = cost[p] + edges[p][i];
			if (c < cost[to] && c < cost[i]) { cost[i] = c; if (i == to) path = i ~ n; else open ~= i ~ n; }
		}
	}
	return cost[to] ~ path;
}

void main()
{
	auto N = RD!long;
	auto M = RD!long;
	auto R = RD!long;
	auto r = RDR.ARR!long(-1);
	auto V = new long[][](N, N);
	foreach (i; 0..N) fill(V[i], -1);
	foreach (i; 0..M)
	{
		auto A = RD!long - 1;
		auto B = RD!long - 1;
		auto C = RD!long;
		V[A][B] = V[B][A] = C;
	}
	stderr.writeln(V);

	auto d = new long[][](R, R);
	foreach (i; 0..R)
	{
		foreach (j; i+1..R)
		{
			auto tmp = dijkstra(r[i], r[j], V);
			d[i][j] = d[j][i] = tmp[0];
		}
	}
	stderr.writeln(d);

	long f(long last, ulong used, long cnt)
	{
		if (used == (1LU << R) - 1) return cnt;

		long ans = long.max;
		foreach (i; 0..R)
		{
			auto bit = 1LU << i;
			if (used & bit) continue;
			ans = min(ans, f(i, used | bit, cnt + d[last][i]));
		}
		return ans;
	}

	long ans = long.max;
	foreach (i; 0..R)
	{
		auto bit = 1LU << i;
		ans = min(ans, f(i, bit, 0));
	}

	writeln(ans);
	stdout.flush();
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  ll n,x,m[110],sum=0;
  cin>>n>>x;
  rep(i,n){
    cin>>m[i];
    sum+=m[i];
  }
  sort(m,m+n);
  if(x-sum<0){
    cout<<0<<endl;
    return 0;
  }
  cout<<n+(x-sum)/m[0]<<endl;
  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		solve100();
	}

	public static void solve100(){
		Scanner sc = new Scanner(System.in);
		while(true) {
			int e = sc.nextInt();
			if(0==e) { break; }
			int m = 1000000;

			for(int z=0;z<=100;z++) {
				for(int y=0;y<1000;y++) {
					int x = e-z*z*z-y*y;
					if(m>(x+y+z)&&x>=0){
						m = x+y+z;
					}
					if(m<0) {
						break;
					}
				}
			}
			System.out.println(m);
		}
	}

}


Measured memory_bytes: 34524
x, y = map(int, input().split())
dif = abs(abs(x) - abs(y))
if x < 0 and y < 0:
    if x < y:
        print(dif)
        exit()
    else:
        print(dif+2)
        exit()
if x >= 0 and y >= 0:
    if x > y:
        if y == 0:
            print(dif+1)
            exit()
        print(dif+2)
        exit()
    else:
        print(dif)
        exit()
if x >= 0:
    print(dif+1)
else:
    if y == 0:
        print(dif)
    else:
        print(dif+1)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int n;
  cin >> n;
  string s[n];
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  int a=0,b=0,count=0,t=0;
  for(int i=0;i<n;i++){
    int k=s[i].size();
    if(s[i].at(0)=='B') b++;
    if(s[i].at(k-1)=='A') a++;
    if(s[i].at(0)=='B'&&s[i].at(k-1)=='A') t++;
    for(int j=0;j<k-1;j++){
      if(s[i].at(j)=='A'&&s[i].at(j+1)=='B'){
        count++;
      }
    }
  }
  if(t==a&&t==b&&t!=0) count--;
  cout << count+min(a,b) << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5+10;
char str[MAXN];
int len;

int main()
{
	int s = -1, e = -1;
	scanf("%s",str);
	len = strlen(str);
	for(int i = 0; i < len-1; ++i)
	{
		if(str[i] == str[i+1])
		{
			s = i+1;
			e = i+2;
			break;
		}
		if(i+2 < len && str[i] == str[i+2])
        {
            s = i+1;
            e = i+3;
            break;
        }
	}
	printf("%d %d\n",s,e);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,W;cin>>n>>W;
	vector<ll> w(n);
	vector<ll> v(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	vector<vector<ll>> dp(n + 1,vector<ll>(100001,LINF));
	dp[0][0] = 0LL;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= 100000; j++) {
			if(j - v[i - 1] >= 0){
				dp[i][j] = min(dp[i - 1][j],dp[i - 1][j - v[i - 1]] + w[i - 1]);
			}
			else{
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	for(int i = 100000; i >= 0; i--) { 
		if (dp[n][i] <= W){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;

int main(){
  string str;
  int n, i, ans=0;
  cin>>n>>str;

  for(i=0; i<n-2; i++){
    if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C')
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
X, Y = gets.chomp.split(" ").map(&:to_i)

ans = 0
ans += 100000 if X <= 3
ans += 100000 if X <= 2
ans += 100000 if X <= 1
ans += 100000 if Y <= 3
ans += 100000 if Y <= 2
ans += 100000 if Y <= 1
ans += 400000 if X == 1 && Y == 1

puts ans


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, k;
int ans;
int d[100010];

signed main() {
	cin >> n >> k;
	for (int i = k; i >= 1; i--) {
		int cnt = mod_pow(k / i, n, mod);
		for (int j = i * 2; j <= k; j += i)cnt = (cnt + mod - d[j]) % mod;
		ans += cnt * i;
		ans %= mod;
		d[i] = cnt;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4436
#include<iostream>
#define FOR(xxx,begin,num) for(int xxx=(begin);i<(begin+num);xxx++)
using namespace std;
int main(){
  int N, A[110], FLG=1;
  cin >> N;
  FOR(i,0,N) cin >> A[i];
  FOR(i,0,N){
    if((A[i]%2==0)&&(A[i]%3!=0)&&(A[i]%5!=0)){
      FLG = 0;
      i = 105;
    }
  }
  if(FLG) cout << "APPROVED";
  else cout << "DENIED";
  return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include <iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
//#include<unordered_map>
//#include<stack>
#include<algorithm>
#define ll long long
#define eps 1e-9
#define endl "\n"
#define PI acos(-1)
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
   string s;
   cin>>s;
   if((s[2]==s[3])&&(s[4]==s[5]))
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),

signed main(){
    FASTER;
    string s;cin>>s;
    int cnt=0;
    for(char c:s)cnt+=(c=='o');
    
    if(15-(int)s.size()+cnt>=8){
        cout<<"YES";
    }else cout<<"NO";
    
}

Measured memory_bytes: 3640
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int N, a;
  cin >> N;
  int ans = 101;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++){
    cin >> a;
    vec.at(i) = a;
  }

  int sumA = 0;
  for (int i = 0; i < N; i++) {
    sumA += vec.at(i);
    int sumB = 0;
    for (int j = i+1; j < N; j++) {
      sumB += vec.at(j);
    }
    ans = min(ans, abs(sumA - sumB));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

signed main() {
     int n;
     cin >> n;
     vector<vector<int>> g(n, vector<int>(n));
     for (int i = 0; i < n; ++i) {
          for (int j = 0; j < n; ++j) {
               cin >> g[i][j];
          }
     }
     int ans = 0;
     for (int i = 0; i < n; ++i) {
          for (int k = i + 1; k < n; ++k) {
               int mn = 1e18;
               for (int j = 0; j < n; ++j) {
                    if (g[i][j] + g[j][k] < g[i][k]) {
                         cout << -1 << endl;
                         return 0;
                    }
                    if (j != i && j != k) {
                    mn = min(g[i][j] + g[j][k], mn);
                    }
               }
               if (mn > g[i][k]) {
                    ans += g[i][k];
               }
          }
     }
     cout << ans << endl;
     return 0; 
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

set<int> s;
map<int,vector<int> >m;

void solve(int key, int depth){
	if(!depth)return;
	s.insert(key);
	int i;
	vector<int> &z=m[key];
	for(i=0;i<z.size();i++)solve(z[i],depth-1);
}

main(){
	int n,i,x,y;
	for(;cin>>n>>n,n;cout<<s.size()-1<<endl){
		m.clear();
		s.clear();
		for(i=0;i<n;i++){
			cin>>x>>y;
			m[x].push_back(y);
			m[y].push_back(x);
		}
		solve(1,3);
	}
}

Measured memory_bytes: 0
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#define ll long long
using namespace std;



int main(){
   
  ll N,M;
  ll ans=0;
  cin>>N>>M;

  ans=N*(N-1)/2+M*(M-1)/2;

  cout<<ans<<endl;


  
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

short nails[5050][5050];

int main()
{
  int N, M;
  N = in(), M = in();
  for (int i = 0; i < M; i++){
    int a, b, x;
    a = in(), b = in(), x = in();
    nails[a][b] = max<short>(nails[a][b], x + 1);
  }
  for (int i = 1; i <= N; i++){
    for (int j = 1; j <= i; j++){
      nails[i][j] = max<short>(nails[i][j], max(nails[i - 1][j], nails[i - 1][j - 1]) - 1);
    }
  }
  int cnt = 0;
  for (int i = 1; i <= N; i++){
    for (int j = 1; j <= i; j++){
      if (nails[i][j]) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 49352
#include <iostream>
#include <vector>
#include <algorithm>
using i64 = long long;

int main() {
    int r, c, k;
    std::cin >> r >> c >> k;
    std::vector t(r, std::vector<i64>(c));
    for (int i = 0; i < k; i++) {
        int r, c, v;
        std::cin >> r >> c >> v;
        t[r - 1][c - 1] = v;
    }

    std::vector dp(r, std::vector(c, std::vector<i64>(4, -1)));
    dp[0][0][0] = 0;
    if (t[0][0] > 0) dp[0][0][1] = t[0][0];
    for (int i = 0; i < r; i++) for (int j = 0; j < c; j++) for (int p = 0; p <= 3; p++) {
        const i64 curr = dp[i][j][p];
        if (curr < 0) continue;
        if (i + 1 < r) {
            if (t[i + 1][j] > 0) dp[i + 1][j][1] = std::max(dp[i + 1][j][1], curr + t[i + 1][j]);
            dp[i + 1][j][0] = std::max(dp[i + 1][j][0], curr);
        }
        if (j + 1 < c) {
            if (t[i][j + 1] > 0 && p < 3) dp[i][j + 1][p + 1] = std::max(dp[i][j + 1][p + 1], curr + t[i][j + 1]);
            dp[i][j + 1][p] = std::max(dp[i][j + 1][p], curr);
        }
    }

    const auto v = dp.back().back();
    std::cout << *std::max_element(v.begin(), v.end()) << std::endl;

    return 0;
}


Measured memory_bytes: 706616
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
//	inp_out();
	ll n,k;
	cin>>n>>k;
	cout<<min((n%k),abs(k-(n%k)));
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP(x) cerr << #x << " = " << (x) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent=false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);

template<typename T = int> inline T in() { T x; cin >> x; return x; }
template<typename T = int> inline vector<T> in(int n) { vector<T> xs(n); rep(i, n) cin >> xs[i]; return xs; }
template<typename T = int> inline vector<vector<T>> in(int n, int m) { vector<vector<T>> xs(n, vector<T>(m)); rep(i, n) rep(j, m) cin >> xs[i][j]; return xs; }

int main(void) {
    VS s = in<string>(3);
    VI p(3);

    int t = 0;
    while (p[t] < (int)s[t].size())  t = s[t][p[t]++] - 'a';

    cout << (char)('A' + t) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

vector<int> x[MAX_N];
int a[MAX_N]; //いくつあるか
int b[MAX_N]; //vectorごとに値を保持

int main()
{
	int n,m,buff,ans=0;
	cin >> n >> m;
	fill(a,a+n,0);
	fill(b,b+n,0);
	rep(i,n){
		scanf("%d",&buff);
		a[buff]++;
		x[buff%m].push_back(buff); 
	}
	for(int i=1;i<=100000;i++){
		int pair = a[i]/2;
		b[i%m] += pair;
	}
	int hoge;
	ans+=x[0].size()/2;
	if(m%2==0){
		ans += x[m/2].size()/2;
		for(int i=1;i<m/2;i++){
			if(x[i].size()>x[m-i].size()){
				hoge = x[i].size()-x[m-i].size();
				ans += (x[m-i].size() + min(hoge/2,b[i]));
			}else if(x[i].size()==x[m-i].size()){
				ans += x[i].size();
			}else{
				hoge = x[m-i].size()-x[i].size();
				ans += (x[i].size() + min(hoge/2,b[m-i]));
			}
		}
	}else{
		for(int i=1;i<=(m-1)/2;i++){
			if(x[i].size()>x[m-i].size()){
				hoge = x[i].size()-x[m-i].size();
				ans += (x[m-i].size() + min(hoge/2,b[i]));
			}else if(x[i].size()==x[m-i].size()){
				ans += x[i].size();
			}else{
				hoge = x[m-i].size()-x[i].size();
				ans += (x[i].size() + min(hoge/2,b[m-i]));
			}
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 6528
#include<stdio.h>

int A[2000001];
int B[2000001];

void CountingSort(int *,int *,int k,int n);

int main(){
  int i,n;
  int mx=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%d",&A[i]);
    if(mx<A[i]) mx=A[i];
  }
  CountingSort(A,B,mx,n);
  
  return 0;
}

void CountingSort(int A[],int B[],int k,int n){
  int C[10001];
  int i,j;
  for(i=0;i<=k;i++) C[i]=0;
  for(i=0;i<n;i++) C[A[i]]++;
  for(i=1;i<=k;i++) C[i]+=C[i-1];
  /*
  for(i=0;i<=k;i++){
    printf("%d\n",C[i]);
  }
  */
  for(j=n-1;j>=0;j--) {
    B[C[A[j]]-1] = A[j];
    C[A[j]]--;
  }

  for(i=0;i<n;i++){
    printf("%d",B[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
}




Measured memory_bytes: 18296
// Author : Rajat Kumar Singh
#include <bits/stdc++.h>
using namespace std;
int main() 
{
	int ans = 0;
	long long a, b;
	scanf("%lld %lld", &a, &b);
	while (a <= b) 
	{
		a *= 2LL;
		++ans;
	}
	printf("%d\n", ans);
	return 0;
}
/**
 * Heaven cannot brook two suns, nor earth two masters. 
 * 																					- Alexander the Great
 */



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

int n, ans;

int main() {
	read(n);
	for (int i = 1; i <= n; ++i)
		if (i & 1) ++ans;
	printf("%.10lf\n", ans * 1.0 / n);
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		sc.close();

		double r1 = h / 12.0 + m / (12.0 * 60);
		r1 *=  Math.PI * 2;
		double x1 = a * Math.cos(r1);
		double y1 = a * Math.sin(r1);

		double r2 = m / 60.0 * Math.PI * 2;
		double x2 = b * Math.cos(r2);
		double y2 = b * Math.sin(r2);

		System.out.println(Math.hypot(x1 - x2, y1 - y2));
	}
}


Measured memory_bytes: 35976
N, L = map(int, input().split())
lis = []

for i in range(1, N+1):
  lis.append(L + i - 1)
  
lis.sort()

if lis[0] < 0 and lis[N-1] < 0:
  print(sum(lis[:N-1]))
elif lis[0] < 0 and lis[N-1] >= 0:
  print(sum(lis))
elif lis[0] >= 0:
  print(sum(lis[1:]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define ll long long
using namespace std;
const int N=3e5+5,mo=1e9+7;
int n;
ll f[2][3][7];
char c[N];
inline void up(ll &x){x%=mo;}
int main(){
	scanf("%s",c+1);n=strlen(c+1);c[n+1]='1';
	f[0][0][0]=1;
	fo(o,1,n+1){
		int p=o&1,q=!p;
		memset(f[p],0,sizeof f[p]);
		bool is=c[o]=='?';
		if(is)c[o]='0';
		if(c[o]=='0'){
			fo(j,0,2)fo(i,0,6)
				up(f[p][j==0?1:j%2+1][i]+=f[q][j][i]);
		}
		if(is)c[o]='1';
		if(c[o]=='1'){
			fo(i,0,6)up(f[p][0][i]+=f[q][1][i]);
			up(f[p][0][0]+=f[q][0][4]+f[q][2][4]);
			up(f[p][0][1]+=f[q][0][0]+f[q][0][5]+f[q][2][5]);
			up(f[p][0][2]+=f[q][0][1]+f[q][0][6]+f[q][2][6]);
			up(f[p][0][3]+=f[q][0][2]+f[q][0][3]+f[q][2][3]);
			up(f[p][0][4]+=f[q][2][0]);
			up(f[p][0][5]+=f[q][2][1]);
			up(f[p][0][6]+=f[q][2][2]);
		}
	}
	int p=(n+1)&1;
	cout<<(f[p][0][2]+f[p][0][3])%mo;
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;
namespace mytest
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ');
            var dict = new Dictionary<int, int>();
            for(int i = 0; i< N ; i++)
            {
                dict.Add(i+1, int.Parse(A[i]));
            }

            Console.WriteLine(string.Join(" ", dict.OrderBy(x => x.Value).Select(x=>x.Key)));
        }
    }
}


Measured memory_bytes: 30300
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int main() {
	int A, B, C;
	cin >> A >> B >> C;

	int deliciousCookies = 0;

	if (C >= A) {
		deliciousCookies += A;
		C -= A;
		if (C > B) {
			deliciousCookies += 2 * B + 1;
		}
		else {
			deliciousCookies += C + B;
		}
	}
	else {
		deliciousCookies += C;
		deliciousCookies += B;
	}

	cout << deliciousCookies << endl;

	system("pause");
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef double dd;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, L;
  cin >> N >> L;
  vector<int> len(N);
  for(int& l : len)
    cin >> l;
  for(int i = 0; i + 1 < N; ++i) {
    if (len[i] + len[i+1] >= L) {
      cout << "Possible\n";
      for(int j=0;j<i;++j){
        cout << (j+1) << '\n';
      }
      for(int j = N-2;j>i;--j){
        cout << (j+1) << '\n';
      }
      cout << (i+1) << '\n';
      return 0;
    }
  }
  cout << "Impossible\n";
  return 0;
}

Measured memory_bytes: 1280
N = int(input())
x3 = N//2
x2 = N - x3

if N==3:
    print(2, 5, 63)
else:
    f = lambda x:x*(x+1)//2
    s = set([3*i for i in range(1, x3)])
    v = x3*3
    while 1:
        if (f(x3-1)+v)%2==0:
            s.add(v)
            break
        v += 3

    v = 2
    cnt = 0
    s2 = 0
    while cnt<x2-1:
        if not v in s:
            s2 += v
            s.add(v)
            cnt += 1
        v += 2

    v = 2
    while 1:
        if (v+s2)%3==0 and v not in s:
            s.add(v)
            break
        v += 2

    print(*s)

Measured memory_bytes: 43120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,s,n) for(int i = s; i < (int)(n); i++)

vector<ll>prime_factorize(ll n) {
    vector<ll> res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        while (n % p == 0) n /= p;
        res.push_back(p);
    }
    if (n != 1) res.push_back(n);
    return res;
}

int main() {
  int n;
  cin >> n;
  vector<int>data(1e6+1);
  rep(i,0,n){
    int a;
    cin >> a;
    vector<ll>res = prime_factorize(a);
    rep(j,0,res.size()) data[res[j]]++;
  }
  int cnt = 0;
  rep(i,0,data.size()) cnt = max(cnt,data[i]);
  if(cnt <= 1) cout << "pairwise coprime" << endl;
  else if(cnt < n) cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
}

Measured memory_bytes: 7216
# 2019-11-19 19:43:48(JST)
import sys
# import collections
import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n = int(sys.stdin.readline().rstrip())

    dist = n
    for i in range(1, math.floor(math.sqrt(n)) + 1):
        if n % i == 0:
            j = n // i
            dist = min(dist, i + j - 2)
    print(dist)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const int MOD = 1000000007;

ll dp[2010][2010];

ll f1(ll in, ll i, ll n, vector<pair<ll, ll>> &a) {
    if (in == a.size())
        return 0;

    if (dp[in][i] != -1)
        return dp[in][i];
    int end = n - 1 - (in - i);

    ll ans1 = (a[in].first * (a[in].second - i)) + f1(in + 1, i + 1, n, a);
    ll ans2 = (a[in].first * (end - a[in].second)) + f1(in + 1, i, n, a);

    return dp[in][i] = max(ans1, ans2);
}

ll f2(ll l, ll r, ll n, vector<pair<ll, ll>> &a) {
    if (l > r) return 0;

    if (dp[l][r] >= 0) return dp[l][r];

    ll ind = l + (n - 1 - r);

    ll ans1 = (a[ind].first * (a[ind].second - l)) + f2(l + 1, r, n, a);
    ll ans2 = (a[ind].first * (r - a[ind].second)) + f2(l, r - 1, n, a);

    return dp[l][r] = max(0LL, max(ans1, ans2));
}
void solve() {
    ll n;
    cin >> n;
    vector<pair<ll, ll>> a;

    for (ll i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        a.push_back(make_pair(x, i));
    }

    memset(dp, -1, sizeof(dp));
    sort(a.rbegin(), a.rend());

    //ll ans = f1(0, 0, n, a);
    ll ans = f2(0, n - 1, n, a);
    cout << ans << "\n";
}

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin >> t;

    // while (t--)
    solve();

    return 0;
}


Measured memory_bytes: 35404
import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ac = math.ceil(a / 10) * 10
bc = math.ceil(b / 10) * 10
cc = math.ceil(c / 10) * 10
dc = math.ceil(d / 10) * 10
ec = math.ceil(e / 10) * 10

max_diff = max((ac - a, bc - b, cc - c, dc - d, ec - e))
print(ac + bc + cc + dc + ec - max_diff)


Measured memory_bytes: 3064
ABCD=input()
A=int(ABCD[0])
B=int(ABCD[1])
C=int(ABCD[2])
D=int(ABCD[3])

p1 = "+"
p2 = "+"
p3 = "+"
flag = False

for op1 in [0,1]:
    for op2 in [0,1]:
        for op3 in [0,1]:
            if  A + (-1)**op1*B + (-1)**op2*C + (-1)**op3*D == 7:
                flag = True
                break
        if flag == True:
            break
    if flag == True:
        break

if op1 == 1:
    p1 = "-"
if op2 == 1:
    p2 = "-"
if op3 == 1:
    p3 = "-"

output = str(A)+p1+str(B)+p2+str(C)+p3+str(D)+"=7"

print(output)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse -> greater<long long>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

int main(){
    string s,t;cin>>s>>t;
    int n=sz(s),m=sz(t);
    vector<VI> is(26);
    rep(i,n)is[s[i]-'a'].emplace_back(i);
    rep(i,n)is[s[i]-'a'].emplace_back(i+n);
    ll ans=0;
    int p=0;//after p
    rep(i,m){
        int c=t[i]-'a';
        if(sz(is[c])==0){
            puts("-1");
            return 0;
        }
        p=*lower_bound(ALL(is[c]),p)+1;
        if(p>=n){
            p-=n;
            ans+=n;
        }
    }
    ans+=p;
    cout<<ans<<endl;
}


Measured memory_bytes: 5700
readInt    = read :: String -> Int
getInt     = readInt <$> getLine
getIntList = map readInt . words <$> getLine
main = do
  [k, a, b] <- getIntList
  print $ solve k a b

solve k a b
  | 2 >= b - a =
      1 + k
  | otherwise =
      let x = 0 `max` ((k - (a - 1)) `div` 2) in
      if x > 0 then a + (b - a) * x + k - (a - 1 + 2 * x)
      else 1 + k

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,p1[444],p2[444],coef,path[444][444],ans,dp1[444][444][144],dp2[444][444][144],cf;
int pos1[444],pos2[444],cnt,sum1[444][444],sum2[444][444];
bool f[444][444];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&p1[i]);
	for (int i=1;i<=n;i++) scanf("%d",&p2[i]);
	if (p1[1]==p2[1])
	{
		printf("0\n");
		return 0;
	}
	for (int i=1;i<=n;i++)
	{
		pos1[p1[i]]=i;
		pos2[p2[i]]=i;
	}
	path[0][0]=1;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<=i;j++)
		{
			if (!path[i][j]) continue;
			path[i+1][j+1]=(path[i+1][j+1]+path[i][j])%mod;
			if (j*3-i>0) path[i+1][j]=(1ll*path[i][j]*(j*3-i)+path[i+1][j])%mod;
		}
	}
	coef=path[n][n/3];
	dp1[1][1][1]=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			f[i][j]=(pos2[p1[i]]<=j || pos1[p2[j]]<=i);
		}
	}
	for (int i=1;i<=n;i++) f[n+1][i]=f[i][n+1]=1;
	for (int i=1;i<=n+1;i++)
	{
		for (int j=1;j<=n+1;j++)
		{
			for (int k=0;k<=n/3;k++)
			{
				if (dp1[i][j][k])
				{
					if (pos2[p1[i+1]]>j && k) dp1[i+1][j][k-1]=(1ll*dp1[i][j][k]*k+dp1[i+1][j][k-1])%mod;
					else if (pos2[p1[i+1]]<=j) dp1[i+1][j][k]=(dp1[i][j][k]+dp1[i+1][j][k])%mod;
					dp2[i+1][j][k]=(dp1[i][j][k]+dp2[i+1][j][k])%mod;
				}
				if (dp2[i][j][k])
				{
					if (pos1[p2[j+1]]>i && k) dp2[i][j+1][k-1]=(1ll*dp2[i][j][k]*k+dp2[i][j+1][k-1])%mod;
					else if (pos1[p2[j+1]]<=i) dp2[i][j+1][k]=(dp2[i][j][k]+dp2[i][j+1][k])%mod;
					if (!f[i][j+1]) dp1[i][j+1][k+1]=(dp2[i][j][k]+dp1[i][j+1][k+1])%mod;
				}
			}
		}
	}
	ans=1ll*dp1[n+1][n+1][1]*coef%mod;
	printf("%d\n",(ans+mod)%mod);
	return 0;
}

Measured memory_bytes: 203904
#include <stdio.h>
#include <stdlib.h>

int main (void) {
	int n, i, j, swaps = 0, tmp, min_i;
	int* data;
	scanf("%d", &n);
	data = (int*)malloc(sizeof(int) * n);
	for (i = 0; i < n; i++) {
		scanf("%d", data + i);
	}
	for (i = 0; i < n; i++) {
		min_i = i;
		for (j = i; j < n; j++) {
			if (data[j] < data[min_i]) {
				min_i = j;
			}
		}
		if (min_i != i) {
			tmp = data[i];
			data[i] = data[min_i];
			data[min_i] = tmp;
			swaps++;
		}
	}
	for (i = 0; i < n; i++) {
		printf("%d", *(data + i));
		if (i < n - 1) printf(" ");
		else printf("\n");
	}
	printf("%d\n", swaps);
	free(data);
	return 0;
}


Measured memory_bytes: 1932
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	
	int cnt = 0;

	for (int i = 0; i < 3; i++)
	{
		if (s[i] == t[i])
		{
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main()
{
	int N, a[1000];

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	int k = a[0];
	for (int i = 1; i < N; i++) {
		if (k == a[i]&&k!=-1) {
			a[i] = -1;
		}
		k = a[i];
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] == -1)ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    deque<int> b;
    for(int i=0; i<n; ++i){
        if(i % 2 == 0)
            b.push_back(a[i]);
        else
            b.push_front(a[i]);
    }
    if(n % 2 != 0)
        reverse(b.begin(), b.end());

    cout << b[0];
    for(int i=1; i<n; ++i)
        cout << ' ' << b[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    sort(v.begin(), v.end());
    int a = v[n-1], b = 0;
    for (int j = 1; j < n-1; ++j) {
        if(fabs(a/2.0-v[j]) < fabs(a/2.0-v[b])) b = j;
    }
    cout << a << " " << v[b] << "\n";
    return 0;
}


Measured memory_bytes: 640
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
	string s;
	cin >> s;

	sort(s.begin(), s.end());

	if(s == "abc"){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s; cin >> s;
    ll foo = 0;
    for(int i = 0; i < s.length(); i++){
        foo += (ll)s[i]-'0';
    }
    if(foo%9 == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;

int main(){
    int N;cin >> N;
    vector<int> A(N),B(N),C(N-1);
    rep(i,N){
        cin >> A[i];
        A[i]--;
    }
    rep(i,N)cin >> B[i];
    rep(i,N-1)cin >> C[i];

    int res = 0;
    rep(i,N){
        if(i == 0){
            res += B[A[i]];
        }else{
            res += B[A[i]];
            if(A[i-1]+1 == A[i]){
                res += C[A[i]-1];
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
len_s=len(s)
lst=[0]
dic=defaultdict(int)
dic[0]=1
ten=1
for i in range(len_s):
    lst.append((lst[i]+int(s[-i-1])*pow(10,i,2019))%2019)
    # ten=ten*10%2019
    dic[lst[-1]]+=1
# print(lst)
# print(dic)
ans=0
for i in dic.values():
    ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 77328
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>
#include<string>
#include<string.h>
using namespace std;
int main(){
    char str1[1000],str2[1000],str3[1000];
    scanf("%s %s",str1,str2);
    strcpy(str3,str1);
    strcat(str3,str1);
    if(strstr(str3,str2)==NULL){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
    
}




Measured memory_bytes: 3136
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))
d = [0] * (M - 1)
ans = 0

if N >= M:
    print(ans)
else:
    for i in range(M - 1):
        d[i] = abs(X[i + 1] - X[i])
    d.sort(reverse=True)
    b = d[:N - 1]
    for i in range(M - 1):
        if d[i] in b:
            b.remove(d[i])
        else:
            ans += d[i]
    print(ans)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()
#define sz(x) x.size()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
    int h,w,m;
    cin>>h>>w>>m;
    unordered_map<int,unordered_set<int>> mpx;
    unordered_map<int,unordered_set<int>> mpy;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        mpx[x].insert(y);
        mpy[y].insert(x);
    }
    int mxx=-1,mxy=-1;
    for(auto P:mpx){
        mxx=max(mxx,int(P.second.size()));
    }
    for(auto P:mpy){
        mxy=max(mxy,int(P.second.size()));
    }
    // deb(mxx);deb(mxy);
    vector<int> a,b;
    for(auto P:mpx){
        if(P.second.size()==mxx){
            a.emplace_back(P.first);
        }
    }
    for(auto P:mpy){
        if(P.second.size()==mxy)b.emplace_back(P.first);
    }
    if(sz(a)*sz(b)>300000){
        int x=a[0],y=b[0];
        cout<<int(mpx[x].size()+mpy[y].size())<<"\n";
        return;
    }
    int ans=0;
    int cnt=0;
    for(auto x:a){
        for(auto y:b){
            // cout<<x<<":"<<y<<"\n";
            ++cnt;
            ans=max(ans,int(mpx[x].size()+mpy[y].size()-(mpx[x].count(y)||mpy[y].count(x))));
        }
        if(cnt==1000000)break;
    }
    cout<<ans<<"\n";
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 100224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    String S;
    int K;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        N = sc.nextInt();
        S = sc.next();
        K = sc.nextInt();
    }
    
    //解答処理
    private String solve() {
        String answer = "";
        String[] str = S.split("");
        
        for (int i=0; i<S.length(); i++) {
        	if (!str[i].equals(String.valueOf(S.charAt(K-1)))) {
        		str[i] = "*";
        	}
        	answer += str[i];
        }
        
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }
}


Measured memory_bytes: 39516
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;

  map<int, int> pf;
  reps(i, 2, n+1) {
    int m = i;
    reps(j, 2, m+1) {
      while(m%j == 0) ++pf[j], m /= j;
    }
  }

  int ans = 1;
  for(auto p : pf) {
    (ans *= (p.second + 1)) %= mod;
  }
  cout << ans % mod << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
inline int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(int x){if (x<0)putchar('-'),x=-x;if (x)write(x/10),putchar(x%10+'0');}
void writeln(int x){write(x);if (x==0)putchar('0');puts("");}
int n,l,r; 
signed main(){
	n=read();l=read();r=read();
	if (abs(r-l)&1)puts("Borys");else puts("Alice");
} 

Measured memory_bytes: 256
A = []
for i in range(3):
  a = input()
  A.append(a)
x = 0
while 1:
  if len(A[x]) == 0:
    print(chr(65 + x))
    break
  s = A[x][0]
  A[x] = A[x][1:]
  x = ord(s) - 97

Measured memory_bytes: 62068
import math

def distance(X, Y):
    ans = 0
    for x, y in zip(X,Y):
        ans = ans + (x - y)**2

    return math.sqrt(ans)

N, D = map(int, input().split())
X = []
for _ in range(N):
    x = tuple(map(int, input().split()))
    X.append(x)

ans = 0

for i in range(N):
    for j in range(i+1, N):
        if distance(X[i], X[j]).is_integer():
            ans = ans + 1

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;

int main() {
  ll a,b,k;
  cin>>a>>b>>k;
  if (a > k) { cout << a-k << " " << b;
  } else {
    b = b-(k-a);
    if (b < 0) b = 0;
    cout << 0 << " " << b;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const long long int MOD = 1e9 + 7;
const int MAXN = 2e5 + 10, MAX_FACTORIAL = 1e6 + 10;

ll REM( ll a )
{
	a %= MOD;
	if ( a < 0 )
	   a += MOD;
	return a;
}

ll ADD( ll a, ll b )
{
	return REM( REM( a ) + REM( b ) );
}

ll SUB( ll a, ll b )
{
	return REM( REM( a ) - REM( b ) );
}

ll MUL( ll a, ll b )
{
	return REM( REM( a ) * REM( b ) );
}

ll POT( ll n, ll k )
{
	if ( k == 0 )
		return 1;

	ll ret = POT( n, k / 2 );
	ret = MUL( ret, ret );

	if ( k % 2 )
		return MUL( ret, n );
	return ret;
}

ll DIV( ll a, ll b )
{
	return MUL( a, POT( b, MOD - 2 ) );
}

bool isPrime( ll x )
{
	for ( ll i = 2;i <= sqrt( x ); i++ )
		if ( x % i == 0 )
			return false;
	return true;
}

ll fact[ MAX_FACTORIAL ];
void factorials( )
{
	fact[ 0 ] = 1;
	FOR( i, 1, MAX_FACTORIAL )
	{
		fact[ i ] = MUL( fact[ i - 1 ], i );
	}
}

ll CHOOSE( ll n, ll k )
{
	return DIV( fact[ n ], MUL( fact[ k ], fact[ n - k ] ) );
}

ll x;

int main()
{
	cin >> x;
	while ( true )
	{
		if ( isPrime( x ) )
		{
			cout << x << "\n";break;
		}
		x++;
	}
	return 0;
}


Measured memory_bytes: 256