akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
const int mod=1000000007;
inline void add(int &a,int b){if((a+=b)>=mod)a-=mod;}
int p[30],q[30],go[3<<19][23],put[1<<21],f[1<<21],n,m,k;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	while(k--)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		a--;b--;
		p[a]|=1<<b;
		q[a]|=c<<b;
	}
	n--;
	memset(go,-1,sizeof go);
	for(int t=0;t<(1<<n);t++)
	{
		int id=0;
		for(int i=0;i<n;i++)
			if(t&(1<<i))
			{
				if(i&&!(t&(1<<(i-1))))go[t][id]=t^(1<<i)^(1<<(i-1));
				id++;
			}
	}
	memset(put,-1,sizeof put);
	for(int t=0;t<(1<<n);t++)
		for(int i=n-1;i>=0;i--)
			if(!(t&(1<<i))){put[t]=t^(1<<i);break;}
	f[0]=1;
	for(int i=0;i<m;i++)
	{
		for(int t=0;t<(1<<n)-1;t++)add(f[put[t]],f[t]);
		for(int j=0;j<n;j++)
			for(int t=(1<<n)-1;t>=0;t--)
				if(go[t][j]!=-1)add(f[go[t][j]],f[t]);
		for(int t=0;t<(1<<n);t++)
			if((t&p[i])!=q[i])f[t]=0;
	}
	int ans=0;
	for(int t=0;t<(1<<n);t++)add(ans,f[t]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 153728
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll a,s,d;
  cin>>a>>s>>d;
  rep(i,10){
    d=d*a-s;
    COUT(d);
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#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>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
 long long int n,ans = 0;
  cin >> n;
  ans = n*(n-1)/2;
  cout << ans << endl;
  return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fio() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
#define MOD 998244353
using namespace std;
int32_t main()
{
	fio();
	int n;
	cin>>n;
	string s;
	cin>>s;
	int a[7]={0};
	memset(a,0,sizeof(a));
	a[0]=n;
	int ans=1;

	for(int i=0;i<3*n;i++)
	{
		if(s[i]=='R')
		{
			if(a[5]>0)
			{
				ans*=a[5];
				ans%=MOD;
				a[5]--;
			}
			else if(a[2]>0)
			{
				ans*=a[2];
				ans%=MOD;
				a[2]--;
				a[4]++;
			}
			else if(a[3]>0)
			{
				ans*=a[3];
				ans%=MOD;
				a[3]--;
				a[6]++;
			}
			else
			{
				ans*=a[0];
				ans%=MOD;
				a[0]--;
				a[1]++;
				//cout<<ans<<endl;
			}
		}
		else if(s[i]=='B')
		{
			if(a[6]>0)
			{
				ans*=a[6];
				ans%=MOD;
				a[6]--;
			}
			else if(a[1]>0)
			{
				ans*=a[1];
				ans%=MOD;
				a[1]--;
				a[4]++;
			}
			else if(a[3]>0)
			{
				ans*=a[3];
				ans%=MOD;
				a[3]--;
				a[5]++;
			}
			else
			{
				ans*=a[0];
				ans%=MOD;
				a[0]--;
				a[2]++;
			}
		}
		else
		{
			if(a[4]>0)
			{
				ans*=a[4];
				ans%=MOD;
				a[4]--;
			}
			else if(a[1]>0)
			{
				ans*=a[1];
				ans%=MOD;
				a[1]--;
				a[6]++;
			}
			else if(a[2]>0)
			{
				ans*=a[2];
				ans%=MOD;
				a[2]--;
				a[5]++;
			}
			else
			{
				ans*=a[0];
				ans%=MOD;
				a[0]--;
				a[3]++;
			}
		}
		//cout<<ans<<endl;
	}

	cout<<ans;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> q(n, 0);

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    q[a]++;
    q[b]++;
  }

  for (auto& v : q) {
    if (v % 2 != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}


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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'




int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


const int MOD = 1000000007;

//////////////////////////////////////////



int n;
int m[200005];
void Input() {

    cin >> n;
}



void Solve() {


    int a[n];
    int s[n];

    int m = 0, s_m = 0;
    for(int i = 0; i < n; i++) {

        cin >> a[i];
        s[i] = a[i];

    }

    sort(a, a+n);

    m = a[n-1];
    s_m = a[n-2];

    for(int i = 0 ; i < n; i++) {

        if(s[i] == m) {

            cout << s_m << endl;
        }
        else {

            cout << m << endl;
        }
    }
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();


  return 0;

}



Measured memory_bytes: 3200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String first_line = input.readLine();

		// ?????°??¨?????°?????????
		String[] array_of_li_col = first_line.split(" ");

		// ?????°
		int line_r = Integer.parseInt(array_of_li_col[0]);

		// ?????°
		int column_c = Integer.parseInt(array_of_li_col[1]);
		// ??¨????????????????¬????????????????
		int graph_array[][] = new int[line_r][column_c];

		int column_sum = 0;

		int line_sum=0;

		int All_sum=0;

		// ??¨?????????????????¨?????¨??????????¨???????????????¨????????¨??????????¬??????????
		for (int line_spot = 0; line_spot < line_r; line_spot++) {


			String input_column = input.readLine();

			String[] array_of_column = input_column.split(" ");


			for (int column_spot = 0; column_spot < column_c; column_spot++) {

				int element_column = Integer.parseInt(array_of_column[column_spot]);

				graph_array[line_spot][column_spot] = element_column;

				column_sum+=graph_array[line_spot][column_spot] ;




				System.out.print(graph_array[line_spot][column_spot]+" ");
			}

			System.out.println(column_sum);
			All_sum+=column_sum;
			column_sum = 0;

		}

		for(int column_spot=0; column_spot<column_c; column_spot++){
			for(int line_spot = 0; line_spot < line_r; line_spot++){
				line_sum+=graph_array[line_spot][column_spot] ;
			}
			System.out.print(line_sum+" ");

			line_sum=0;
		}
		System.out.println(All_sum);

	}

}

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

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
  
    for (int i = 0; i < N; i++) {
      cin >> p.at(i);
    }
  
    int count = 0;
    for (int i = 0; i < N; i++) {
        if(0 < i && i < N-1) {
          if (p.at(i-1) < p.at(i) && p.at(i) < p.at(i+1)) {
            count++;
          } else if (p.at(i-1) > p.at(i) && p.at(i) > p.at(i+1)) {
            count++;
          }
        } else {
          continue;
        }
    }
  cout << count << endl;
}

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

int N, M, res, cnt, ncnt, ncount;
int arr[510][510];

int main(){
	int i, j, flag;
	scanf("%d %d", &N, &M);
	for(i = 1; i <= N; i++){
		for(j = 1; j <= M; j++){
			scanf("%d", &arr[i][j]);
			if(arr[i][j] % 2) cnt++;
		}
	}
	flag = 0;
	for(i = 1; i <= N; i++){
		if(flag == 0 && cnt - ncnt <= 1) break;
		if(i % 2){
			for(j = 1; j <= M; j++){
				if(flag == 0 && cnt - ncnt <= 1) break;
				if(arr[i][j] % 2) flag++, ncnt++, flag %= 2;
				if(flag) ncount++;
			}
		}else{
			for(j = M; j >= 1; j--){
				if(flag == 0 && cnt - ncnt <= 1) break;
				if(arr[i][j] % 2) flag++, ncnt++, flag %= 2;
				if(flag) ncount++;
			}
		}
	}
	printf("%d\n", ncount); ncnt = 0;
	for(i = 1; i <= N; i++){
		if(flag == 0 && cnt - ncnt <= 1) break;
		if(i % 2){
			for(j = 1; j <= M; j++){
				if(flag == 0 && cnt - ncnt <= 1) break;
				if(arr[i][j] % 2) flag++, ncnt++, flag %= 2;
				if(flag){
					if(j == M) printf("%d %d %d %d\n", i, j, i + 1, j);
					else printf("%d %d %d %d\n", i, j, i, j + 1);
				}
			}
		}else{
			for(j = M; j >= 1; j--){
				if(flag == 0 && cnt - ncnt <= 1) break;
				if(arr[i][j] % 2) flag++, ncnt++, flag %= 2;
				if(flag){
					if(j == 1) printf("%d %d %d %d\n", i, j, i + 1, j);
					else printf("%d %d %d %d\n", i, j, i, j - 1);
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;

int main() {
    set < string> st;
    string s;
    cin >> s;
    int n = s.size();
    int k; cin >> k;
    for (int len = 1; len <= k; ++len) {
        for(int i = 0; i + len - 1 < n; i++) {
            st.emplace(s.substr(i, len));
            if(st.size() > k) st.erase(--st.end());
        }
    }
   cout << *(--st.end()) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

const int MX=100005;

int main()
{
    int h1,m1,h2,m2,k,m;
    cin>> h1 >> m1 >> h2 >> m2 >> k;
    if(h1==h2) m=m2-m1;
    else{
        m=60-m1+m2,h1++;
        if(h1<h2) m+=60*(h2-h1);
    }
    printf("%d\n",m-k);
    return 0;
}

Measured memory_bytes: 3764
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

let rec f x = function
    | [] -> true
    | y :: ys -> if x = y then false else f y ys

[<EntryPoint>]
let main argv =
    let s = read string
    s.ToCharArray()
    |> Array.sort
    |> fun [|a;b;c;d|] -> if a = b && c = d && a <> c then "Yes" else "No"
    |> printfn "%s"
    0

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

int main(){
    int N;
    cin >> N;

    if (N % 2 == 0) cout << N / 2 << endl;
    else cout << N / 2 + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
	ll N, mod = 1000000007;
	cin >> N;
	vector<ll> X(N);
	rep(i, N) { cin >> X.at(i); }
	ll A = 0, B = 0;
	rep(i, N) {
		A += X.at(i);
		A %= mod;
		B += X.at(i) * X.at(i);
		B %= mod;
	}
	ll pre = (A * A - B) % mod;
	if (pre % 2 == 0) {
		cout << pre / 2;
	} else {
		cout << (pre + mod) / 2;
	}
}

Measured memory_bytes: 4764
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;


int main(){
	ll n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	vl sum(n+1,0);
	rep(i,n) sum[i+1] += sum[i] + a[i];
	vpl v(4);
	ll ans = linf;
	REP(i,2,n-1){
		ll left = sum[i];
		ll right = sum[n] - sum[i];
		auto itrl = lower_bound(all(sum),(sum[i]+1)/2);
		v[0].first = *itrl; v[0].second = sum[i] - *itrl;
		if(itrl == sum.begin()) v[1] = make_pair(0,inf);
		else{
			itrl--;
			v[1].first = *itrl; v[1].second = sum[i] - *itrl;
		}
		auto itrr = lower_bound(all(sum),sum[i] + (right+1)/2);
		v[2].first = *itrr - sum[i]; v[2].second = sum[n] - *itrr;
		if(itrr == sum.begin()) v[3] = make_pair(0,inf);
		else{
			itrr--;
			v[3].first = *itrr - sum[i]; v[3].second = sum[n] - *itrr;
		}
		rep(j,2){
			REP(k,2,4){
				ll mx = max({v[j].first,v[j].second,v[k].first,v[k].second});
				ll mn = min({v[j].first,v[j].second,v[k].first,v[k].second});
				//print2(j,k);
				//print2(v[j].first,v[j].second);
				//print3(v[k].first,v[k].second,mx-mn);
				chmin(ans,mx-mn);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
def g(A,l,m,r):
    global c
    L,R =A[l:m]+ [1e9],A[m:r]+[1e9]
    i = j = 0
    for k in range(l,r):
        if L[i]<R[j]:A[k]=L[i];i+=1;c+=j
        else:A[k]=R[j];j+=1
def s(A,l,r):
    if l+1<r:
        m=(l+r)//2
        s(A,l,m)
        s(A,m,r)
        g(A,l,m,r)
c=0
n=int(input())
A =list(map(int,input().split()))
s(A,0,n)
print(c)



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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  ll N; cin>>N;
  set<string> m;
  rep(i,N){
    string s; cin>>s;
    m.insert(s);
  }
  cout<<m.size()<<endl;
}

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

int main(int argc, char const *argv[])
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    for (int i = 0; i < n; i++)
    {
        if (i == k - 1)
        {
            if (s[i] == 'A')
            {
                cout << 'a';
            }
            else if (s[i] == 'B')
            {
                cout << 'b';
            }
            else if (s[i] == 'C')
            {
                cout << 'c';
            }
        }
        else
        {
            cout << s[i];
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
n,m,q=map(int,input().split())
t=[list(map(int,input().split())) for _ in range(q)]
ans=0
import itertools
for p in itertools.combinations_with_replacement(range(1,m+1),n):
    d=0
    for i in t:
        if p[i[1]-1]-p[i[0]-1]==i[2]:
            d+=i[3]
    ans=max(d,ans)        
print(ans)

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

int main(){
    long long n,a,s1=0,s2=0,c1=0,c2=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        s1+=a;
        s2+=a;
        if(i%2){
            if(s1<=0){
                c1+=1-s1;
                s1=1;
            }
            if(s2>=0){
                c2+=1+s2;
                s2=-1;
            }
        }
        else{
            if(s1>=0){
                c1+=1+s1;
                s1=-1;
            }
            if(s2<=0){
                c2+=1-s2;
                s2=1;
            }
        }
    }
    cout<<min(c1,c2)<<endl;
}

Measured memory_bytes: 256
h, w, d = gets.split.map(&:to_i)
color = { 0 => 'R', 1 => 'Y', 2 => 'G', 3 => 'B' }
if d.odd?
  h.times do |i|
    puts w.times.map { |j| color[(i + j) % 2] }.join
  end
else
  h.times do |i|
    puts w.times.map { |j|
      if ((i + j) / d).odd?
        if (i % d) < (d / 2)
          ((i + j) % d) > ((i % (d / 2)) * 2) ? 'R' : 'Y'
        else
          ((i + j) % d) > ((i % (d / 2)) * 2) ? 'Y' : 'R'
        end
      else
        if (i % d) < (d / 2)
          ((i + j) % d) > ((i % (d / 2)) * 2) ? 'G' : 'B'
        else
          ((i + j) % d) > ((i % (d / 2)) * 2) ? 'B' : 'G'
        end
      end
    }.join
  end
end


Measured memory_bytes: 4860
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 100000 + 5;
const int M = 3000 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

int a, b, c;
int n;

int main() {
    std::cin >> a >> b >> c;
    for (int i = std::min(a, b); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            n++;
            if (n == c) {
                printf("%d\n", i);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import heapq
heappush = heapq.heappush
heappop = heapq.heappop
heapreplace = heapq.heapreplace
input = sys.stdin.readline

D = int(input())
cost = list(map(int, input().strip().split()))
S = [list(map(int, input().strip().split())) for _ in range(D)]
k = 26
last_held = [[-1 for i in range(26)] for _ in range(k)]
ans = [[] for _ in range(k)]
for date, daily_scores in enumerate(S):
    max_score = []
    minus_scores = []
    for state in range(k):
        minus_score = 0
        for i in range(26):
            minus_score += cost[i] * (date - last_held[state][i])

        for i in range(k-len(max_score)):
            tmp = daily_scores[i] + cost[i] * (date - last_held[state][i]) - minus_score
            heappush(max_score, (tmp, i, state))

        for i, daily_score in enumerate(daily_scores):
            if state == 0 and i < k:
                continue
            tmp = daily_score + cost[i] * (date - last_held[state][i]) - minus_score
            if max_score[0][0] < tmp:
                heapreplace(max_score, (tmp, i, state))
        if date == 0:
            break
    if date != D-1:
        #print(max_score)
        #print(ans)
        next_last_held = []
        next_ans = []
        for score, i, state in max_score:
            next_last_held.append(last_held[state][:])
            next_last_held[-1][i] = date
            next_ans.append(ans[state][:])
            next_ans[-1].append(i+1)
        ans = next_ans
        last_held = next_last_held
    else:
        score, i, state = max(max_score)
        next_ans = ans[state][:]
        next_ans.append(i+1)
        ans = next_ans

print("\n".join(map(str, ans)))


Measured memory_bytes: 70748
from collections import defaultdict


n, m = map(int, (input().split()))
route_dict = defaultdict(int)

for i in range(m):
    a, b = map(int, input().split())
    route_dict[a] += 1
    route_dict[b] += 1

for k in range(1, n+1):
    print(route_dict[k])

Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class CNextPrime
    {
        static void Main(string[] args)
        {
            var x = long.Parse(Console.ReadLine());

            while (!IsPrime(x))
            {
                x++;
            }

            Console.WriteLine(x);
            Console.ReadLine();
        }

        static bool IsPrime(long x)
        {
            if (x < 2) return false;            
            if (x == 2) return true;
            if (x % 2 == 0) return false;

            for (long i = 3; i < x; i+=2)
            {
                if (x % i == 0) return false;
            }
            
            return true;
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes() {
  cout << "APPROVED" << endl;
  exit(0);
}

void no() {
  cout << "DENIED" << endl;
  exit(0);
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  REP(i, n) {
    if (a[i] % 2 == 1) {
      continue;
    }
    if (a[i] % 3 != 0 && a[i] % 5 != 0) {
      no();
    }
  }
  yes();
}

Measured memory_bytes: 256
import sys

h, w, k = map(int, input().split())
mod = 10 ** 9 + 7
if w == 1:
    print(1)
    sys.exit()
row = [0 for i in range(w + 1)]
row[0] = 1
row[1] = 1
for i in range(w - 1):
    row[i + 2] = row[i + 1] + row[i]

dp = [[0 for i in range(w)] for j in range(h + 1)]
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        if j == 0:
            dp[i + 1][j] = dp[i][j] * row[w - 1] + dp[i][j + 1] * row[w - 2]
            dp[i + 1][j] %= mod
        elif j == w - 1:
            dp[i + 1][j] = dp[i][j] * row[w - 1] + dp[i][j - 1] * row[w - 2]
            dp[i + 1][j] %= mod
        else:
            dp[i + 1][j] = dp[i][j - 1] * row[j - 1] * row[w - j - 1] + dp[i][j] * row[j] * row[w - j - 1] + dp[i][j + 1] * row[j] * row[w - j - 2]
            dp[i + 1][j] %= mod
print(dp[h][k - 1])

Measured memory_bytes: 9284
/// In the name of God
#include <bits/stdc++.h>
//#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define y1 def1
#define X first
#define Y second
#define endl '\n'
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
const int maxn = 1000 + 10;
int a[maxn][maxn];
int n, m;
bool isv(int i,int j){
    if(i >= 0 && i < n && j >= 0 && j < m && a[i][j]) return 1;
    return 0;
}
int d[maxn][maxn];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
int main(){
    IOS;
    int k;
    cin >> n >> m >> k;
    pii st;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        for(int j=0; j<m; j++){
            a[i][j] = (s[j] != '#');
            if(s[j] == 'S') st = {i, j};
        }
    }
    queue<pii> q;
    q.push(st);
    memset(d, 63, sizeof d);
    d[st.X][st.Y] = 0;
    while(q.size()){
        auto v = q.front();
        q.pop();
        int x = v.X, y = v.Y;
        for(int t=0; t<4; t++){
            int nx = x + dx[t];
            int ny = y + dy[t];
            if(isv(nx, ny) && d[nx][ny] > d[x][y] + 1){
                d[nx][ny] = d[x][y] + 1;
                q.push({nx, ny});
            }
        }
    }
    int ans = 1e9;
    /*for(int i=0; i<n; i++,cout<<endl)
        for(int j=0; j<m; j++)
            cout << d[i][j] << " ";*/
    for(int i=0; i<n; i++)
    for(int j=0; j<m; j++){
        if(d[i][j] <= k){
            int x = min(abs(0 - i), abs(n - 1 - i));
            int y = min(abs(0 - j), abs(m - 1 - j));
            int tot = min(x, y);
            //cout << i << "  " << j << " " << tot << endl;
            int ez = (tot + k - 1) / k;
            ans = min(ans, ez + 1);
        }
    }
    cout << ans << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

array<bool,1000050> ret{};
bool getPrime(vector<int> &a){
    map<int,int> m;
    for(auto & b : a){
        m.clear();
        for(int i=2;i*i<=b;++i)if(b%i == 0){
            m[i]++;
            m[b]++;
            if((ret[b] and b!=1) or ret[i])return false;
            while(b%i == 0){b/=i;m[b]++;
                           if(ret[b] and b != 1)return false;}
        }
        if(b != 1){m[b]++;if(ret[b])return false;}
        for(auto cur : m)ret[cur.first]= true;
    }
    return true;
}
int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<int> a(n);
    int allg =0;
    for(auto & b: a) cin>>b,allg=gcd(allg,b);
    
    bool parOk = getPrime(a);
    bool setOk = true;
    if(allg != 1)setOk = false;
    
    string ret;
    if(parOk){
        ret = "pairwise coprime";
    }else if(setOk){
        ret = "setwise coprime";
    }else ret = "not coprime";
    cout << ret << endl;
    return 0;
    
}


Measured memory_bytes: 7096
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int N;
	char S[101];
	cin >> N >> S;
	int ans,max = 0;

//	sort(S,S+N);

	//cout << S << endl;

	char str1[101],str2[101];

	for(int i = 0; i < N; i++) {
		for(int j = 0; j <= i ;j++)
			str1[j] = S[j];

		for(int k = 0; k < N - i ;k++)
			str2[k] = S[k+i+1];

//		cout << str1 << "     2:" << str2 << endl;

		sort(str1, str1 + i + 1);
		sort(str2, str2 + N - i - 1);

//		cout << str1 << "     2:" << str2 << endl;

		char lastchar;

		for(int j = 0; j <= i ;j++){
			if(str1[j] == lastchar) continue;
			for(int k = 0; k < N - i ;k++){
				if (str1[j] == str2[k]){
//					cout << str1[j] << " ";
					ans++;
					break;
				}
			}
			lastchar = str1[j];
		}
		
		
//		cout << endl;
//		cout << ans << endl << endl;
		max = max < ans ? ans : max;
		ans = 0;
		lastchar = 0;

		for(int i;i < 101; i++){
			str1[i] = 0;
			str2[i] = 0;
		}

	}

	cout << max;
	return 0;


}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

#define prev aewrxew
#define next fawexsr
using namespace std;
typedef long long ll;
typedef long double ld;
const ll inf = numeric_limits<ll>::max() / 2 - 1;
const ld eps = 1e-7;
const ll mod = 1e9 + 7;
const ll maxn = 2456;

signed run() {
    ll n;
    cin >> n;
    vector<ll> mas(n);
    ll cur = 0;
    for (int i = 0; i < n; ++i) {
        cin >> mas[i];
        if (mas[i] > mas[cur]) cur = i;
    }
    ll curspeed = 0;
    map<ll, ll> mp;
    vector<ll> ans(n);
    set<pair<ll, ll>> st;
    for (int i = 0; i < cur; ++i) {
        st.insert({-mas[i], i});
    }
    for (int i = n - 1; i > cur; --i) {
        mp[mas[i]]++;
    }
    while (cur != -1) {
        ll curcnt = 0;
        ll nextcur = cur;
        while (!st.empty() && nextcur >= cur) {
            nextcur = st.begin()->second;
            st.erase(st.begin());
        }
        if (nextcur >= cur && st.empty()) nextcur = -1;
        while (!mp.empty() && (nextcur == -1 || mp.rbegin()->first > mas[nextcur])) {
            curcnt += (mas[cur] - mp.rbegin()->first) * curspeed + mas[cur] - mp.rbegin()->first;
            mas[cur] = mp.rbegin()->first;
            curspeed += mp.rbegin()->second;
            mp.erase(--mp.end());
        }
        ans[cur] += curcnt + (nextcur == -1 ? (curspeed + 1) * mas[cur] : (curspeed + 1) * (mas[cur] - mas[nextcur]));
        if (nextcur != -1) mas[cur] = mas[nextcur];
        while (cur != nextcur) {
            mp[mas[cur]]++;
            cur--;
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#else
#define TASK ""
    if(strlen(TASK)>0) {
        freopen(TASK".in","r",stdin);
        freopen(TASK".out","w",stdout);
    }
#endif
    run();
    cout.flush();
    cerr << "time: " << clock() * 1000 / CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 10368
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        String s = rd.readLine();
        String rev = new StringBuilder(s).reverse().toString();
        out(s.equals(rev)?"Yes":"No");
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}


Measured memory_bytes: 22612
from collections import defaultdict 
import sys
import math 

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()


(n,m) = map(int,input().split())
cnt = 0
for i in range(n):
	(x,y) = get_ints()
	if math.sqrt(x*x+y*y)<=m:
		cnt+=1
print(cnt)

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

int main() {
    int N, M;
    cin >> N >> M;

    vector<int> height(N);

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

    bitset<100000> is_bad;

    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;

        if (height[A - 1] > height[B - 1]) {
            is_bad[B - 1] = 1;
            continue;
        }

        if (height[A - 1] < height[B - 1]) {
            is_bad[A - 1] = 1;
            continue;
        }

        is_bad[A - 1] = 1;
        is_bad[B - 1] = 1;
    }

    cout << N - is_bad.count() << endl;
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  string S;
  std::cin >> S;
  if(S=="Sunny") std::cout << "Cloudy" << '\n';
  if(S=="Cloudy") std::cout << "Rainy" << '\n';
  if(S=="Rainy") std::cout << "Sunny" << '\n';
  return 0;
}


Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.io.IOException;
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
 
public class Main {
    public static void main(String[] args) throws IOException {
         
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[] s = new int[n];
        for(int i = 0; i < n; ++i) s[i] = sc.nextInt();
        
        int q = sc.nextInt();
        int[] t = new int[q];
        for(int i = 0; i < q; ++i) t[i] = sc.nextInt();
         
        int cnt = 0;
        for(int p : t)
            if(Arrays.binarySearch(s, p) >= 0) ++cnt;
        
        System.out.println(cnt);
    }
}


Measured memory_bytes: 67488
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>

using namespace std;
int main(){
    int k,r;
    cin>>k>>r;
    if(k<10)
        cout<<r+100*(10-k)<<endl;
    else
        cout<<r<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long qq[100005];
int main()
{
	int k=-1,n,l,x
	;
	scanf("%d %d",&n,&l);
	for(int i=1;i<=n;i++)scanf("%d",&x),qq[i]=qq[i-1]+x;
	for(int i=1;i<=n;i++)
	{
		if(qq[i+1]-qq[i-1]>=l)
		{
			k=i;
			break;	
		}
	}
	if(k==-1)
	{
		printf("Impossible");
	}
	else
	{
		printf("Possible\n");
		for(int i=1;i<=k-1;i++)printf("%d\n",i);
		for(int i=n-1;i>=k+1;i--)printf("%d\n",i);
		printf("%d\n",k);
	}
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  cin >> s;
  cout << "A" << s[0] << "C" << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BBuffet {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> A(N), B(N), C(N);
        REP(i, N) {
            cin >> A[i];
            A[i]--;
        }
        REP(i, N) {
            cin >> B[i];
        }
        REP(i, N) {
            cin >> C[i];
        }

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


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BBuffet solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

//ユークリッドの互除法で最大公約数(GCD)を求め，c,dの最小公倍数(LCM)を算出．
// ll LMC(ll c,ll d){
//     ll lmc = 0;
//     ll r = max(c,d)%min(c,d);

//     if(r==0){
//         lmc = c*d;
//         return lmc;
//     }
//     bool t = true;
//     ll r_ = 10;
//     ll ans;
//     while(r_ != 0){
//         if(t){
//             ans = r;
//             r_ = min(c,d)%r;
//             t = false;
//         }
//         else{
//             ans = r_;
//             r_ = r%r_;
//             r = ans;
//         }
//     }
//     lmc = (c*d)/ans;
//     return lmc;
// }

ll gcd_(ll a, ll b) { return b ? gcd_(b,a%b) : a;}
ll lcm_(ll a, ll b) { return a/gcd_(a,b)*b;}

int main(){
    ll a,b;//10^18までの整数
    int c,d;//10^9までの整数
    cin >> a >> b >> c >> d;

    ll cnt_a=0;
    ll cnt_b=0;
    ll lcm = lcm_(c,d);

    cnt_b = b - b/c - b/d + b/(lcm);
    cnt_a = (a-1) - (a-1)/c - (a-1)/d + (a-1)/(lcm);

    cout<<(ll)(cnt_b-cnt_a)<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}}; ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
int main() {
    i64 N;
    cin >> N;
    i64 ans = 0;
    ans = (N * (N + 1) * (N + 2)) / 6;
    for(int i = 0; i < N - 1; i++) {
        i64 u, v;
        cin >> u >> v;
        u--, v--;
        if(v < u) swap(u, v);
        ans -= (u + 1) * (N - v);
    }
    cout << ans << endl;
    return 0;
}

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

const int N = 100010;

struct edge {
    int to, next;
} e[N * 2];

int head[N], ecnt, ind[N];

inline void adde(int from, int to) {
    e[++ecnt] = (edge){to, head[from]}, head[from] = ecnt;
    e[++ecnt] = (edge){from, head[to]}, head[to] = ecnt;
    ind[from]++, ind[to]++;
}

int dep[N], mx, pos, tmp[N]; vector<int> hh, ans1, ans2;

void dfs(int u, int f) {
    dep[u] = dep[f] + 1, tmp[u] = 0;
    if (dep[u] > mx) mx = dep[u], pos = u;
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f) dfs(e[i].to, u), tmp[u] = max(tmp[u], tmp[e[i].to] + 1);
}

void dfs2(int u, int f) {
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f && tmp[e[i].to] + 1== tmp[u]) {
            dfs2(e[i].to, u); break;
        }
    hh.push_back(ind[u] - (!!f) - (!!tmp[u]) + 1);
}

int main() {
    int n; scanf("%d", &n);
    for (int i = 1, a, b; i < n; i++) 
        scanf("%d%d", &a, &b), adde(a, b);
    dfs(1, 0); int tp = 0, tot = 0, u = pos; ans1.resize(n + 1);
    dfs(u, 0),dfs2(u, 0);
    for (auto t : hh) {
        ans1[tp + t] = ++tot;
        for (int i = tp + 1; i < tp + t; i++) ans1[i] = ++tot;
        tp += t;
    }
    reverse(hh.begin(), hh.end()), ans2.resize(n + 1), tot = 0, tp = 0;
    for (auto t : hh) {
        ans2[tp + t] = ++tot;
        for (int i = tp + 1; i < tp + t; i++) ans2[i] = ++tot;
        tp += t;
    }
    if (ans1 > ans2) swap(ans1, ans2);
    for (int i = 1; i <= n; i++) if (!ans1[i]) 
        return puts("-1"), 0;
    for (int i = 1; i <= n; i++) printf("%d ", ans1[i]);
}


Measured memory_bytes: 9976
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<algorithm>

using namespace std;

typedef pair<int, int> P;
typedef long long int ll;

int N, K;

int main() {
	string s;
	cin >> N >> K;
	cin >> s;
	string S = s;
	transform(s.begin(), s.end(), s.begin(), ::tolower);
	for (int i = 0; i < N; i++) {
		if (i == K - 1) {
			cout << s[i] << flush;
		}
		else {
			cout << S[i] << flush;
		}
	}
	cout << endl;

}

Measured memory_bytes: 256
#include<stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    return *(int*)a-*(int*)b;
}
int main()
{   int a,b,x,y=0,i,n,k,m=1000000002;
    scanf("%d%d",&n,&k);
    int h[n];
    for(i=0;i<n;i++){
        scanf("%d",&h[i]);
    }qsort(h,n,sizeof(int),compare);
    
    for(i=0;i<=n-k;i++){
        if(h[i+k-1]-h[i]<m){
            m=h[i+k-1]-h[i];
        }
    }
    printf("%d",m);
    

    return 0;
}


Measured memory_bytes: 892
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public char[,] S;

        public void Run()
        {
            N = Input.ReadInt();
            S = new char[N, N];
            for (int i = 0; i < N; i++)
            {
                var line = Console.ReadLine();
                for (int j = 0; j < N; j++)
                    S[i, j] = line[j];
            }

            int[] F = new int[N];
            for (int i = 0; i < N; i++)
            {
                var flag = true;
                for (int y = 0; y < N; y++)
                for (int x = 0; x < N; x++)
                {
                    if (S[y, (x - i + 2 * N) % N ] != S[x, (y - i + 2 * N) % N]) flag = false;
                }

                F[i] = flag ? 1 : 0;
            }

            int ret = 0;
            for (int y = 0; y < N; y++)
            for (int x = 0; x < N; x++)
            {
                int i = (y - x + 2 * N) % N;
                ret += F[i];
            }

            Console.WriteLine(ret);
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13212
#include <stdio.h>
#include <math.h>
int main(){
    double a,b,c;
    double PI=acos(-1);
    scanf("%lf %lf %lf",&a,&b,&c);
    c/=180.0;
    c*=PI;
    printf("%lf\n%lf\n%lf\n",a*b*0.5*sin(c),a+b+sqrt(a*a+b*b-2.0*a*b*cos(c)),a*b*sin(c)/a);
    return 0;
}


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

int main(){ 
    string s;
    cin >> s;
    
    if(s=="SUN") cout << "7" << endl;
    if(s=="MON") cout << "6" << endl;
    if(s=="TUE") cout << "5" << endl;
    if(s=="WED") cout << "4" << endl;
    if(s=="THU") cout << "3" << endl;
    if(s=="FRI") cout << "2" << endl;
    if(s=="SAT") cout << "1" << endl;
     return 0;
} 


Measured memory_bytes: 256
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int n;
  cin>>n;
  if(n<1200){
    cout<<"ABC"<<endl;
  }
  else if(n<2800){
    cout<<"ARC"<<endl;
  }
  else{
    cout<<"AGC"<<endl;
  }
} 
  
	

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

int main(){
  int A,B,C,N;
  cin >> A >> B >> C >> N;
  
  int answer=0;
  if(A >= N){
    answer+=N;
  }
  else{
    answer+=A;
    if(B >= N-A){
      answer+=0;
    }
    else{
      answer-=N-A-B;
    }
  }
  cout << answer <<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
int n,m,i,j,k,a[25],b[25],ans=-1,d[25];
vector<pair<int,int> > v0,v1;
struct ii
{
	int v,id,m2;
}c[25];
int main()
{
	read(n);
	fz0k(i,n){
		read(a[i]);
	}
	fz0k(i,n){
		read(b[i]);
	}
	fz0k(i,(1<<n)) if(__builtin_popcount(i)==n/2){
		v0.clear();v1.clear();
		fz0k(j,n){
			int t=((j&1)==((i>>j)&1))?a[j]:b[j];
			if((i>>j)&1) v1.push_back(make_pair(t,j));else v0.push_back(make_pair(t,j));
			c[j]=(ii){t,j,(i>>j)&1};
		}
		sort(v0.begin(),v0.end());sort(v1.begin(),v1.end());
		int lst=-1;
		fz0k(j,n){
			if(j&1){
				d[j]=v1[j/2].second;
				if(v1[j/2].first<lst) break; else lst=v1[j/2].first;
			}
			else{
				d[j]=v0[j/2].second;
				if(v0[j/2].first<lst) break; else lst=v0[j/2].first;
			}
		}
		if(j<n) continue;
		int s=0;
		fz0k(j,n){
			fz0k(k,n-1){
				if(d[k]>d[k+1]){
					s++;
					swap(d[k],d[k+1]);
				}
			}
		}
		if(ans==-1||s<ans){
			ans=s;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int i = 0;
  
  
  //yellowを検出
  for (; i < N; i++) {
    string letter;
    cin >> letter;
    
    if (letter == "Y") {
      cout << "Four" << endl;
      break;
    }
  }
  
  if (i == N) 
    cout << "Three" << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#define N 1000000
using namespace std;
int cnt;

void insertionSort(int* array, int n, int g){
  for (int i=g; i<n ;++i){
    int v = array[i];
    int j = i - g;
    while ( j>=0  && array[j] > v ){
      array[j+g] = array[j];
      j = j - g;
      ++cnt;
    }
    array[j+g] = v;
  }
}


void shellSort(int* A, int n){
  cnt = 0;
  constexpr int m   = 13;
  int g[m], skipm;
  g[m-1] = 1;
  for (int i=m-1;i>0;--i)
    g[i-1] = 3*g[i] + 1;
  for (skipm=0;g[skipm]>n;++skipm);
  cout << m-skipm << endl;
  for (int i=skipm;i<m;++i){
    if (i==skipm) cout << g[i];
    else cout << " " << g[i];
    insertionSort(A, n, g[i]);
  }
  cout << endl;
  cout << cnt << endl;
}

int main(){
  int n;
  int array[N];
  ios_base::sync_with_stdio(false);

  cin >> n;
  for (int i=0;i<n;++i)
    cin >> array[i];
  shellSort(array, n);
  for (int i=0;i<n;++i)
    cout <<  array[i] << endl;
  return 0;
}



Measured memory_bytes: 6936