akhauriyash/Code-Regression huggingface dataset:
using System;
class main
{
    static void Main(string[] args)
    {
        string s = string.Empty;
        while ((s = Console.ReadLine()) != null)
        {
            string[] s1 = s.Split(' ');
            long[] a = new long[3];
            a[0] = long.Parse(s1[0]);
            a[1] = long.Parse(s1[1]);
            a[2] = 0;
            Array.Sort(a);
            Array.Reverse(a);
            long c = a[0] * a[1];
            if (a[1] != 0)
            {
                while (true)
                {
                    a[2] = a[1];
                    a[1] = a[0] % a[1];
                    a[0] = a[2];
                    if (a[1] == 0)
                    {
                        Console.WriteLine("{0} {1}", a[0], (c / a[0]));
                        break;
                    }
                }
            }
            else
            {
                Console.WriteLine("{0} {1}", a[0], (c / a[0]));
            }
        }
    }
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    rep(i, n) {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        rep(k, n) {
            cout << a[k];
            if (k != n-1) cout << ' ';
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3096
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

ll fib[120];

ll A,B,Ans;

int q,ans;

void calc(ll x,ll y,ll k){
	if(x*(k==ans-1?0:fib[ans-k-2])+y*fib[ans-k-1]>A||x*fib[ans-k-1]+y*fib[ans-k]>B)return;
	if(k==ans){Ans++;return;}
	if(k+1==ans&&y<=A&&x<=B){Ans+=(B-x)/y;return;}
	calc(y,x+y,k+1);calc(y,x+y+y,k+1);
}

void Work(){
	read(q);
	while(q--){
		read(A,B);
		if(A>B)swap(A,B);
		REP(i,1,100)if(fib[i]>A||fib[i+1]>B){
			ans=i-1;
			break;
		}
		if(!ans)ans=1; 
		printf("%d ",ans);
		if(ans==1)printf("%lld\n",A*B%mod);
		else{
			Ans=0;
			calc(1,1,0);
			swap(A,B);
			calc(1,1,0);
			printf("%lld\n",Ans%mod);
		}
	}
}

void Init(){
	fib[0]=fib[1]=1;
	REP(i,2,100)fib[i]=fib[i-1]+fib[i-2];
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 3968
a = [[0 for i in range(3)] for j in range(3)]
f = [[False for i in range(3)] for j in range(3)]

for i in range(3):
  a[i] = list(map(int, input().split()))

n = int(input())
for i in range(n):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k] == b:
        f[j][k] = True

ans = (f[0][0] and f[1][1] and f[2][2]) or (f[0][2] and f[1][1] and f[2][0])
for i in range(3):
  ans = ans or (f[i][0] and f[i][1] and f[i][2])
  ans = ans or (f[0][i] and f[1][i] and f[2][i])

print("Yes" if ans else "No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
   
    vector<int> Ans = {2,4,8,16,32,64,128};
    int n; cin >> n;
    cout << *upper_bound(Ans.begin(),Ans.end(),n) / 2 << endl;
    
    
}



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

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

	int tmp=s.size();
	int ans=0;
	for(int i=0; i<tmp/2; i++){
		if(s.at(i) != s.at(tmp-1-i)){
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3564
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define R 1000000007

using namespace std;

int N;
int dp[101][64];

bool modeq(int a, int b, int mod) {
    return a % mod == b % mod;
}

int ch2i(char ch) {
    if(ch == 'T') return 0;
    if(ch == 'A') return 1;
    if(ch == 'C') return 2;
    if(ch == 'G') return 3;
    return 0;
}

int get_id(char ch1, char ch2, char ch3) {
    int res = 0;
    res += ch2i(ch1);
    res = res << 2;
    res += ch2i(ch2);
    res = res << 2;
    res += ch2i(ch3);
    return res;
}

int get_nextid(int id, char next) {
    int res = id % 16;
    res = res << 2;
    return res + ch2i(next);
}

int solve() {
    for(int i = 0; i <= N; ++i)
        for(int j = 0; j < 64; ++j)
            dp[i][j] = 0;
    
    dp[0][0] = 1;

    for(int i = 0; i < N; ++i)
        for(int j = 0; j < 64; ++j) {
            if(modeq(j, get_id(' ', 'A', 'C'), 16)) {
                    dp[i + 1][get_nextid(j, 'A')] = (dp[i + 1][get_nextid(j, 'A')] + dp[i][j]) % R;
                    dp[i + 1][get_nextid(j, 'C')] = (dp[i + 1][get_nextid(j, 'C')] + dp[i][j]) % R;
                    dp[i + 1][get_nextid(j, 'T')] = (dp[i + 1][get_nextid(j, 'T')] + dp[i][j]) % R;
            } else if(
                modeq(j, get_id(' ', 'A', 'G'), 16) || 
                modeq(j, get_id(' ', 'G', 'A'), 16) ||

                j == get_id('A', 'A', 'G') || 
                j == get_id('A', 'C', 'G') || 
                j == get_id('A', 'G', 'G') || 
                j == get_id('A', 'T', 'G') || 

                j == get_id('A', 'G', 'A') || 
                j == get_id('A', 'G', 'C') || 
                j == get_id('A', 'G', 'G') || 
                j == get_id('A', 'G', 'T') ) 
                {
                    dp[i + 1][get_nextid(j, 'A')] = (dp[i + 1][get_nextid(j, 'A')] + dp[i][j]) % R;
                    dp[i + 1][get_nextid(j, 'G')] = (dp[i + 1][get_nextid(j, 'G')] + dp[i][j]) % R;
                    dp[i + 1][get_nextid(j, 'T')] = (dp[i + 1][get_nextid(j, 'T')] + dp[i][j]) % R;

            } else {
                    dp[i + 1][get_nextid(j, 'A')] = (dp[i + 1][get_nextid(j, 'A')] + dp[i][j]) % R;
                    dp[i + 1][get_nextid(j, 'C')] = (dp[i + 1][get_nextid(j, 'C')] + dp[i][j]) % R;
                    dp[i + 1][get_nextid(j, 'G')] = (dp[i + 1][get_nextid(j, 'G')] + dp[i][j]) % R;
                    dp[i + 1][get_nextid(j, 'T')] = (dp[i + 1][get_nextid(j, 'T')] + dp[i][j]) % R;
            }
        }

    int res = 0;
    for(int j = 0; j < 64; ++j)
        res = (res + dp[N][j]) % R;
    return res;
}

int main(int argc, char **argv) {
    scanf("%d", &N);

    printf("%d\n", solve());
}

Measured memory_bytes: 128
A, B = map(int, input().split())
xorA = [0] * 41
xorB = [0] * 41
def xor_list(l, N):
    k = 1
    while 2 ** k // 2 <= N:
        tmp = (N+1) % (2 ** k)
        if k == 1:
            l[k-1] = (N+1) // (2 ** k)
            k += 1
        elif tmp <= 2 ** k // 2:
            k += 1
            continue
        else:
            l[k-1] = (tmp - 2 ** k // 2) % 2
            k += 1
        if k == 1:
            count = (N + 1) // (2 ** k) + tmp + 1
            l[0] = (count % 2)
xor_list(xorA, A-1)
xor_list(xorB, B)
ans = 0
for i in range(41):
    ans += abs(xorA[i] - xorB[i]) % 2 * (2 ** i)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long

using namespace std;

const int mxn = 1e5 + 10;
const int mod = 1e9 + 7;
vector<int> adj[mxn];

int mult(int a, int b) {
	return (ll) a * b % mod;
}

// TODO

// p.first - number of ways to color the tree such that u is black
// p.second - number of ways to color the tree such that u is white
pair<int, int> dfs(int u, int parent) {
	int all_white = 1;
	int sth_is_black = 0;

	for (int v: adj[u]) {
		if (v != parent) {
			pair<int,int> p = dfs(v, u);
			int tmp = all_white;
			all_white = mult(all_white, p.second);
			sth_is_black = (mult(tmp, p.first) + mult(sth_is_black, p.first + p.second)) % mod;
		}
	}

	return make_pair(all_white, (all_white + sth_is_black) % mod);
}


void solve() {
	int n;
	cin >> n;

	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	pair<int, int> p = dfs(1, -1);
	int res = (p.first + p.second) % mod;
	cout << res << endl;
}

int main() {
    FAST_INPUT;

    solve();

    return 0;
}


Measured memory_bytes: 12672
N, K = gets.split.map(&:to_i)

# arr = gets.split.map(&:to_i)
gets
# binding.pry
if (N - K) % (K - 1) != 0
  puts (N - K) / (K - 1) + 1 + 1
else
  puts (N - K) / (K - 1) + 1
end

Measured memory_bytes: 3836
n = int(input())
a = list(map(int,input().split()))
 
mod = 10**9+7
 
 
 
ans = 0
q2 = 1
for j in range(60):
    mm1 = 0
    for i in range(n):
        if a[i]>>j&1:
            mm1 += 1
 
    ttl = ((n-mm1)*mm1)
    ans += ((q2)*((ttl)%mod))%mod
    ans %= mod
    q2 = (q2*2)%mod
 
print(ans)

Measured memory_bytes: 122936
#include <cstdio>
#include <cstring>
#include <algorithm>
using std::sort;
using std::min;
const int MAXN=400010;
const int INF=2e9;
struct Edge {
	int u,v,w;
	friend bool operator<(Edge a,Edge b) {
		return a.w<b.w;
	}
}ed[MAXN];
int cnt=0;
inline void join(int x,int y,int z) {
	ed[++cnt].u=x;
	ed[cnt].v=y;
	ed[cnt].w=z;
	return;
}
int f[MAXN];
inline void init(int n) {
	for(int i=0;i<=n;++i) {
		f[i]=i;
	}
}
int find(int x) {
	return x==f[x]?x:(f[x]=find(f[x]));
}
int best[MAXN];
int main() {
	int n,q;
	scanf("%d%d",&n,&q);
	for(int i=0;i<=n;++i) {
		best[i]=INF;
	}
	int x,y,z;
	for(int i=1;i<=q;++i) {
		scanf("%d%d%d",&x,&y,&z);
		join(x,y,z);
		best[x]=min(best[x],z+1);
		best[y]=min(best[y],z+2);
	}	
	for(int i=0;i<n*2;++i) {
		best[(i+1)%n]=min(best[(i+1)%n],best[i%n]+2); //n*2·ÀÖ¹¸üÐÂÁËn-1µ½0 
	}
	for(int i=0;i<n;++i) {
		if(best[i]!=INF) join(i,(i+1)%n,best[i]);
	}
	init(n);
	sort(ed+1,ed+1+cnt);
	long long ans=0;
	for(int i=1;i<=cnt;++i) {
		int a=find(ed[i].u),b=find(ed[i].v);
		if(a!=b) {
			ans+=ed[i].w;
			f[a]=b;
		}
	}
	printf("%lld",ans);
	return 0;
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int n;

signed main()
{
    cin >> n;

    int temp = 1;
    int x = n;

    while (1)
    {
        if ((x / 10) > 0)
        {
            temp++;
            x = x / 10;
        }
        else
        {
            break;
        }
    }

    int ans = 0;

    if (temp == 1)
    {
        cout << n << endl;
        ans += n;
        return 0;
    }

    else
    {

        ans += 9;
        for (int i = 2; i <= temp; i++)
        {
            if (i % 2 == 0)
            {
                continue;
            }
            else
            {
                if (i == temp)
                {
                    ans += n + 1 - pow(10, temp - 1);
                }

                else
                {
                    ans += pow(10, i) - pow(10, i - 1);
                }
            }
        }

        cout << ans << endl;
        return 0;
    }
}


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int a,b,c;
    cin>>a>>b>>c;
    
    if(a+b+c>=22) cout<< "bust";
    else cout<< "win";


    return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  queue<string> q;
  q.push("a");
  rep(i,0,n-1){
    int a=q.size();
    rep(j,0,a){
      string s=q.front();
      q.pop();
      int b=97;
      rep(k,0,s.size()){
        b=max(b,(int)s[k]);
      }
      rep(k,97,b+2){
        string t=s+(char)k;
        q.push(t);
      }
    }
  }
  while(q.size()){
    string u=q.front();
    cout<<u<<endl;
    q.pop();
  }
}


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

#define int long long

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

  int K, N;
  cin >> K >> N;

  cout << K-N+1 << endl;
  
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,A) for(int i = 0;i < A;i++)

int main() {
  double A,B;
  cin >> A >> B;
  double x,y;
  int count = 0;
    rep(i,A){
      cin >> x >> y;
      double z = x * x + y * y;
      
      if(pow(z,0.5) <= B){
        count++;
      }
    }
      cout << count << endl;
 
}


Measured memory_bytes: 4484
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using std::cin;
using std::cout;
using std::endl;

using std::min;
using std::max;

using std::string;

using std::vector;


int main(void) {
    int n;
    cin >> n;

    vector<int> x(1e5);
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        x[a]++;
    }

    int ans = 0;
    for(int i = 1; i < 1e5 - 1; i++){
        ans = max(ans, x[i-1] + x[i] + x[i+1]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define int long long
const int N=1e5+7;
int n,k,a[N];
signed main() {
    cin>>n>>k;
    for (int i=1;i<=n;i++) cin>>a[i];
    int ans=1e18;
    for (int i=1;i+k-1<=n;i++) {
        int j=i+k-1;
        ans=min(ans,a[j]-a[i]+min(abs(a[i]),abs(a[j])));
    }
    cout<<ans;
    return 0;
}

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=0;i<max(a,b);++i)
        cout<<min(a,b);
    return 0;
}


























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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a * a + b * b == c * c)
        OP(a * b / 2);
    if (a * a + c * c == b * b)
        OP(a * c / 2);
    if (b * b + c * c == a * a)
        OP(b * c / 2);

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private int[] a;
	private int count;
	private int n, s;

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			n = scan.nextInt();
			s = scan.nextInt();
			if ((n | s) == 0) break;
			
			a = new int[n];
			Arrays.fill(a, 0);
			
			count = 0;
			
			for (int i = 0; i < 10; i++) {
				deep(i + 1, 1, i);
			}
			
			System.out.println(count);
		}
	}
	
	private void deep(int b, int bn, int sum) {
		//System.out.println(b+" "+bn+" "+sum);
		if (bn < n) {
			if (sum >= s) {
				return;
			}else {
				for (int i = b; i < 10; i++) {
					deep(i + 1, bn + 1, sum + i);
				}
			}
		}else if (bn == n) {
			if (sum == s) {
				//System.out.println("this");
				count++;
				return;
			}else {
				return;
			}
		}else {
			return;
		}
	}
	
	private void debug() {
		System.out.println();
	}

}

Measured memory_bytes: 18076
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+9;
int t,j,cs=0,n,a,b,i;
string s;

int main()
{
    cin>>n;
    map<string ,int> s1;
    cin.ignore();
    while(n--){
        cin>>s;
        s1[s]++;
    }

    cout<<"AC x "<<s1["AC"]<<endl<<"WA x "<<s1["WA"]<<endl<<"TLE x "<<s1["TLE"]<<endl<<"RE x "<<s1["RE"]<<endl;

}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N;
vi edge[10000+10];
vi c;
int assigned[10000+10];

signed main(void) {
    cin >> N;
    REP(i,1,N-1) {
        int a,b;
        cin>>a>>b;
        edge[a].pb(b);
        edge[b].pb(a);
    }
    REP(i,0,N-1) {
        int tmp;
        cin>>tmp;
        c.pb(tmp);
    }
    sort(all(c));
    reverse(all(c));

    int M=0;
    Rep(i, 1, N)  {
        M+=c[i];
//        cout << M << endl;
    }

    //幅優先探索
    queue<int> Q;
    set<int> visited;
    Q.push(1);
    int assign = 0;
    while(visited.size() < N) {
        int now = Q.front(); Q.pop();
        if (visited.count(now) > 0) continue;
        visited.insert(now);
        assigned[now] = c[assign]; assign++;
        for (auto e : edge[now]) {
            Q.push(e);
        }
    }

    cout << M << endl;

    REP(i,1,N) {
        cout << assigned[i];
        if (i < N) cout << " ";
    }
    cout << endl;





    return 0;
}

Measured memory_bytes: 1664
N = int(input())
la = list(map(int, input().split()))

S = sum(la)
lsum = 0
i = 0
while lsum < S/2:
    lsum += la[i]
    i += 1

sm = min(lsum , lsum-la[i-1])

if lsum - S/2 > S/2 - (lsum-la[i-1]):
    print(S - 2*(lsum-la[i-1]))
else:
    print(2*lsum - S)

Measured memory_bytes: 26220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		String str1 = sc1.next();
		StringBuilder sb1 = new StringBuilder();
		StringBuilder sb2 = new StringBuilder();
		sb1.append(str1);
		sb2.append(str1.toLowerCase());
		String str2 = sb2.toString();

		boolean flg = true;

		if ( str1.charAt(0) != 'A') {
			flg = false;
			//System.out.println("test1");
		}
		sb1.deleteCharAt(0);
		sb1.insert(0,"a");

		int tmp = str1.indexOf('C');

		if ( tmp < 2 | tmp > str1.length()-2) {
			flg = false;
			//System.out.println("test2");
		}
		else {
			sb1.deleteCharAt(tmp);
			sb1.insert(tmp,"c");
			tmp = str1.indexOf('C', tmp + 1);
			if ( tmp > 0) {
				flg = false;
				//System.out.println("test3");
			}
		}

		str1 = sb1.toString();

		if ( !(str1.equals(str2)) ) {
			flg = false;
			//System.out.println("test4");
		}

		//System.out.println(sb1);
		//System.out.println(sb2);

		if (flg) {
			System.out.println("AC");
		}
		else {
			System.out.println("WA");
		}

		sc1.close();
	}

}

Measured memory_bytes: 24916
#include <math.h>
#include <stdio.h>

#define N 1000

int main() {
	static int aa[N];
	int n, t, a, i, i_;
	double x, min;

	scanf("%d%d%d", &n, &t, &a);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	min = 1000000;
	i_ = -1;
	for (i = 0; i < n; i++)
		if (min > (x = fabs(a - ((double) t - aa[i] * 0.006)))) {
			min = x;
			i_ = i;
		}
	printf("%d\n", i_ + 1);
	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>
inline void read(T &x) {
	Finish_read=0;x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x*=f;Finish_read=1;
}
template<class T>
inline void print(T x) {
	if(x/10!=0)
		print(x/10);
	putchar(x%10+'0');
}
template<class T>
inline void writeln(T x) {
	if(x<0)
		putchar('-');
	x=abs(x);
	print(x);
	putchar('\n');
}
template<class T>
inline void write(T x) {
	if(x<0)
		putchar('-');
	x=abs(x);
	print(x);
}
/*================Header Template==============*/
int arr[15],a[15],n,ans=0;
ll sum=1;
inline void dfs(int pos) {
	if(pos==n+1) {
		sum=1;
		for(int i=1;i<=n;i++)
			sum*=a[i];
		if(sum%2==0)
			ans++;
		return;
	}
	for(int i=arr[pos]-1;i<=arr[pos]+1;i++) {
		a[pos]=i;
		dfs(pos+1);
	}
}
int main() {
	read(n);
	for(int i=1;i<=n;i++)
		read(arr[i]);
	dfs(1);
	writeln(ans);
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  priority_queue<ll> a;
  ll n;cin>>n;
  for(i=0;i<n;i++){
    cin>>buf;
    a.push(buf);
  }
  buf=0;
  while(!a.empty()&&buf2==0){
    //cout<<a.top()<<endl;
    if(buf==a.top()){
      if(buf1==0){
        buf1=a.top();
        buf=0;
      }
      else buf2=a.top();
    }
    else buf=a.top();
    a.pop();
  }
  //cout<<buf1 spa buf2<<endl;
  cout<<buf1*buf2<<endl;


  return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> H(N);
    REP(i, N) cin >> H[i];
    priority_queue<ll> q[N];
    REP(i, M)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        q[a].push(H[b]);
        q[b].push(H[a]);
    }
    ll ans = 0;
    REP(i, N)
    {
        if (q[i].empty())
        {
            ans++;
            continue;
        }
        if (H[i] > q[i].top()) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 10648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}


signed main(void)
{
	IOS;
	int n; cin>>n;
	vi a(n);
	for(int i = 0; i < n; i++)
		cin>>a[i];
	int no=0;
	for(int i = 0; i < n; i++) {
		if(a[i]%2==0) {
			if(a[i]%5==0 || a[i]%3==0)
				continue;
			else {
				no=1;
				break;
			}
		}
	}
	if(!no) cout<<"APPROVED"<<endl;
	else cout<<"DENIED"<<endl;
	return 0;
}

Measured memory_bytes: 256
f=f=1,*(1..m=1000003).map{f=f*_1%m}
gets
$<.map{x,d,n=_1.split.map &:to_i
p d<1?x.pow(n,m):(u=f[n+t=x*d.pow(m-2,m)%m-1])?u*f[t].pow(m-2,m)*d.pow(n,m)%m:0}

Measured memory_bytes: 31028
s = input()

ans1 = 0
ans2 = 0
for i,j in enumerate(s):
    if i % 2 == 0 and j == '0':
        ans1 += 1
    if i % 2 == 1 and j == '1':
        ans1 += 1
    if i % 2 == 0 and j == '1':
        ans2 += 1
    if i % 2 == 1 and j == '0':
        ans2 += 1
print(min(ans1, ans2))

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;

bool is_prime(int x){
    for(int i = 2; i*i <= x; i++){
        if(x % i == 0)return false;
    }

    return true;
}

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int x;
    cin >> x;

    int ans = x;
    while (!is_prime(ans)) ans ++;

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
xyz=[list(map(int,input().split())) for i in range(N)]
MAX=0
for index in [[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]:
    LIST=sorted([sum([p[a]*index[a] for a in range(3)]) for p in xyz])[::-1]
    if sum(LIST[0:M])>MAX:
        MAX=sum(LIST[0:M])
print(MAX)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

void dfs(vector<pair<int, int>> &ans, const vector<vector<int>> &G, int v, int d, int c){
    if(ans[v].second >= d) return;
    if(ans[v].first == 0)
        ans[v].first = c;
    ans[v].second = d;
    for(auto to : G[v])
        dfs(ans, G, to, d-1, c);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M, Q;
    cin >> N >> M;
    vector<vector<int>> G(N);
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    cin >> Q;
    vector<int> v(Q), d(Q), c(Q);
    for(int i=0; i<Q; i++) {
        cin >> v[i] >> d[i] >> c[i];
        v[i]--;
    }

    vector<pair<int, int>> ans(N);
    for(int i=0; i<N; i++){
        ans[i].first = 0;
        ans[i].second = -1;
    }
    for(int i=Q-1; i>=0; i--)
        dfs(ans, G, v[i], d[i], c[i]);

    for(int i=0; i<N; i++) cout << ans[i].first << endl;

    return 0;
}


Measured memory_bytes: 8440
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

vector<pair<string,int> > kuji;

int main() {
	int n,m;
	while(cin>>n>>m,n){
		kuji.clear();
		string str;
		int buf,i;
		for(i=0;i<n;i++){
			cin>>str>>buf;
			kuji.push_back(mp(str,buf));
		}
		int j;
		int res=0;
		for(j=0;j<m;j++){
			cin>>str;
			for(i=0;i<n;i++){
				int k;
				bool ok=true;
				for(k=0;k<str.size();k++){
					if(kuji[i].first[k]!='*'&&kuji[i].first[k]!=str[k])ok=false;
				}
				if(ok)res+=kuji[i].second;
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void){
     int n,i,x;
	scanf("%d",&n);
	for(i=1;i<n+1;i++){
		if(i%3==0){
			printf(" %d",i);
		}
		else{
			x=i;
			do{
				if(x%10==3){
					printf(" %d",i);
					break;
				}
				x/=10;
			}while(x);
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if(a!=1 && b!=1){
        if(a>b){
            cout << "Alice" << endl;
        }else if (a==b){
            cout << "Draw" << endl;
        }else{
            cout << "Bob" << endl;
        }
    }else{
        if(a==b){
            cout << "Draw" << endl;
        }else{
            if(a<b){
                cout << "Alice" << endl;
            }else{
                cout << "Bob" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let h: usize = it.next().unwrap().parse().unwrap();
    it.next();
    let mut sum = 0;
    for s in it {
        let a: usize = s.parse().unwrap();
        sum += a;
    }
    if sum >= h {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    run();
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

const double PI = acos(-1);
double DegreeToRadian(double degree)
{
    return degree * PI / 180.0;
}
double RadianToDegree(double radian)
{
    return radian * 180.0 / PI;
}
void solve()
{
    cout << fixed << setprecision(10);
    double a, b, h, m; cin >> a >> b >> h >> m;
    h *= 30;
    h += 0.5 * m;
    m *= 6;
    double degree = abs(h - m);
    double rad = DegreeToRadian(degree);
    double ans = a * a + b * b - 2 * a * b * cos(rad);
    cout << sqrt(ans) << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 4208
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()
ans = 0
while any([x >= N for x in a]):
	S = sum([x//N for x in a])
	for i in range(N):
		tmp = a[i]//N  # i番目の要素に対する操作回数
		a[i] -= N*tmp
		a[i] += (S-tmp)
		ans += tmp

print(ans)


Measured memory_bytes: 63704
#include <stdio.h>

int main (void){
  int d,i,s;
  int saidai,hikaku,saisyou;
  int a[200000];
  i=0;
  saidai=-10000000000;
  saisyou=6000000;
 scanf("%d",&d);
  while(d>i){
    scanf("%d",&a[i]);
    i++;
  }
  saisyou=a[0];
  for(i=0;i<d;i++){
    while(a[i]>saisyou){
      i++;
    }
saisyou=a[i];
    for( s=d-1;s>i;s--){
      hikaku=a[s]-a[i];
      if(hikaku>saidai){
	saidai=hikaku;
     }
    }
  }
 printf("%d\n",saidai);
  return 0;
}

Measured memory_bytes: 2632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	vector<int> a(n);

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

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

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] - b[i] > 0) {
			ans += a[i] - b[i];
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  int ans = 0;
  FOR(i,1,n+1) {
    ans += i-1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n , m ;
    cin >> n >> m;
    int a[n][n] , b[m][m];
    char d;
    for (int i = 0 ; i < n ; i++ ) {
        for (int j = 0 ; j < n ; j++ ) {
            cin >> d;
            a[i][j] = 1;
            if ( d == '#' ) a[i][j] = 0;
        }
    }
    for (int i = 0 ; i < m ; i++ ) {
        for (int j = 0 ; j < m ; j++ ) {
            cin >> d;
            b[i][j] = 1;
            if ( d == '#' ) b[i][j] = 0;
        }
    }
    if ( n == m ) {
        for (int i = 0 ; i < m ; i++ ) {
            for (int j = 0 ; j < n ; j++ ) {
                if ( a[i][j] != b[i][j] ) {
                    cout << "No\n";
                    return 0;
                }
            }
        }
        cout << "Yes\n";
    } else {
        for (int i = 0 ; i < n - m + 1 ; i++ ) {
            for (int j = 0 ; j < n - m + 1 ; j++ ) {
                bool c = 0;
                for (int k = i ; k < i + m ; k++) {
                    for (int l = j ; l < j + m ; l++ ) {
                        if ( a[k][l] != b[k - i][l - j] ) {
                            c = 1;
                            break;
                        }
                    }
                }
                if ( c == 0 ) {
                    cout << "Yes\n";
                    return 0;
                }
            }
        }
        cout << "No\n";
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
        int[][] a = new int[3][3];
	for (int i=0; i<3; i++)
	    for (int j=0; j<3; j++)
		a[i][j] = sc.nextInt();
	int n = sc.nextInt();
	int b;
	boolean[][] is = new boolean[3][3];
	for (int k=0; k<n; k++) {
	    b = sc.nextInt();
	    for (int i=0; i<3; i++) {
		for (int j=0; j<3; j++) {
		    if (a[i][j] == b) {
			is[i][j] = true;
			break;
		    }
		}
	    }
	}
	boolean result = false;
	if (is[1][1]) {
	    if ((is[0][0] && is[2][2]) || (is[0][1] && is[2][1])
		|| (is[0][2] && is[2][0]) || (is[1][0] && is[1][2])) {
		result = true;
	    }
	} else {
	    if ((is[0][0] && is[0][1] && is[0][2]) ||
		(is[0][0] && is[1][0] && is[2][0]) ||
		(is[0][2] && is[1][2] && is[2][2]) ||
		(is[2][0] && is[2][1] && is[2][2])) {
		result = true;
	    }
	}
	System.out.print(result ? "Yes" : "No");
    }
}


Measured memory_bytes: 35704
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int K,Q;cin >> K >> Q;
  vector<ll> v(K);
  rep(k,K) cin >> v[k];
  rep(q,Q){
    ll n,x,m;cin >> n >> x >> m;
    --n;
    ll ans = n;
    x %= m;
    ll vsum = 0;
    rep(k,K){
      vsum += v[k]%m;
      if((v[k]%m) == 0) ans -= ((n+K-1-k)/K);
    }
    vsum *= (n/K);

    rep(k,n%K) vsum += v[k]%m;

    ans -= (x+vsum)/m - x/m;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
#include <set>

using namespace std;


int main(){
  string s; cin >> s;
  const char *c = "AZ";

  int len = 0;
  REP(i,s.size()) if(c[len % 2] == s[i]) len++;

  len -= len % 2;
  if(len == 0) puts("-1");
  else{
    REP(i,len) putchar(c[i % 2]);
    puts("");
  }

  return 0;
}

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

int main() {
  int n,m; ll l;
  cin >> n >> m >> l;
  ll inf = 1000000000000;
  vector<vector<ll>> d(n, vector<ll>(n,inf));
  rep(i,0,n) d[i][i] = 0;
  rep(i,0,m) {
    int a,b; ll c;
    cin >> a >> b >> c;
    a--; b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  rep(k,0,n) rep(i,0,n) rep(j,0,n) {
    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  }
  vector<vector<ll>> G(n, vector<ll>(n,inf));
  rep(i,0,n) rep(j,0,n) {
    if (i == j) {
      G[i][j] = 0;
      continue;
    }
    if (d[i][j] <= l) {
      G[i][j] = 1;
    }
  }
  rep(k,0,n) rep(i,0,n) rep(j,0,n) {
    G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
  }
  int q;
  cin >> q;
  rep(i,0,q) {
    int s,t;
    cin >> s >> t;
    s--; t--;
    if (G[s][t] == inf) {
      cout << -1 << endl;
    } else {
      cout << G[s][t]-1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 5024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 200000
#define mod1 1000000007
#define mod2 1000000009
#define mod3 998244353
#define endl '\n'
ll INF = 1e12;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    IO
	clock_t begin = clock();
    ll n,W;
    cin>>n>>W;
    ll w[n+1],v[n+1];
    ll sum = 0;
    for(ll i=1;i<=n;i++)
    {
    	cin>>w[i]>>v[i];
    	sum+=v[i];
    }
    ll dp[n+1][sum+1];
    for(ll i=0;i<=n;i++)
    {
    	for(ll j=1;j<=sum;j++)
    		dp[i][j] = INF;
    }
    for(ll i=0;i<=n;i++)
    	dp[i][0] = 0;
    for(ll i=1;i<=n;i++)
    {
    	for(ll j=0;j<=sum;j++)
    	{
    		dp[i][j] = min(dp[i][j],min((j-v[i]>=0?dp[i-1][j-v[i]]:INF) + w[i],dp[i-1][j]));
    	}
    }
    // for(ll i=1;i<=n;i++)
    // {
    // 	for(ll j=0;j<=sum;j++)
    // 		cout<<dp[i][j]<<' ';
    // 	cout<<endl;
    // }
    for(ll i=sum;i>=0;i--)
    {
    	if(dp[n][i]<=W)
    	{
    		cout<<i<<endl;
    		return 0;
    	}
    }
    // cout<<double(clock() - begin)/CLOCKS_PER_SEC<<endl;
    return 0;
}

Measured memory_bytes: 82408
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;


template <class T> T gcd(T a, T b){
    if(b>a) T tmp = a, a=b, b=tmp;
    if(b==0) return a;
    else return gcd(b,a%b);
}

template <class T> T gcd_n(const vector<T> &V){
    T tmp=V[0];
    for( auto v : V) tmp = gcd(tmp, v);
    return tmp;
}

template <class T> T lcm(T a, T b){
    if(a==0 || b==0) return 0;
    else 
    {
        T g=gcd(a,b);
        return g*(a/g)*(b/g);
    }
}
template <class T> T lcm_n(const vector<T> &V){
    T gcd_ = gcd_n(V);
    T tmp = V[0];
    for(auto v : V) tmp = lcm(tmp, v);
    return tmp;
}
int main(){
    int n;
    cin >> n;
    vector<ll> T(n);
    REP(i,n) cin >> T[i];
    // REP(i,n) cout << T[i] << " ";
    // cout << endl;
    cout << lcm_n(T) << endl;
    return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int par[100002];
int rk[100002];
ll dw[100002];

void init(int n){
	for(int i=0; i<n; i++){
		par[i]=i;
	}
}

int root(int x){
	if(par[x]==x) return x;
	int p=root(par[x]);
	dw[x]+=dw[par[x]];
	return par[x]=p;
}

ll weight(int x){
	root(x);
	return dw[x];
}

ll diff(int x, int y){
	return weight(y)-weight(x);
}

bool unite(int x, int y, ll w){
	w=w+weight(x)-weight(y);
	x=root(x); y=root(y);
	if(x==y){
		if(w!=0) return false;
	}
	if(rk[x]<rk[y]) swap(x, y), w=-w;
	if(rk[x]==rk[y]) rk[x]++;
	par[y]=x;
	dw[y]=w;
	return true;
}

int main()
{
	int n, m;
	cin>>n>>m;
	init(n);
	for(int i=0; i<m; i++){
		int l, r;
		ll d;
		cin>>l>>r>>d;
		l--; r--;
		if(!unite(l, r, d)){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n - k; ++i) {
        if (a[i] < a[i + k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 4048