akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;


signed main(){
    int aa, bb, xx;
    cin >> aa >> bb >> xx;
    auto f = [&](double val){
        double a = aa;
        double b = bb;
        double x = xx;
        double v = x / a;

        if(b * cos(val) < a * sin(val)){
            double c = a * b * cos(val) / (a * sin(val));
            double l = b * sin(val) + c * cos(val);
            double h = b * cos(val);
            double res = l * h - b * sin(val) * b * cos(val) / 2 - b * cos(val) * c * cos(val) / 2;
            return v <= res;
        }

        double h = b * cos(val);

        double l = b * sin(val) + a * cos(val);

        double d1 = h * b * sin(val) / 2;
        double d2 = a * sin(val) * a * cos(val) / 2;
        double d3 = (l - a / cos(val)) * (h - a * sin(val)) / 2;

        double res = l * h - d1 - d2 - d3;
        return v <= res;
    };

    double ok = 1e-8;
    double ng = M_PI / 2 - 1e-8;
    for(int i = 0; i < 100; ++i){
        double mid = (ok + ng) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    printf("%.20lf\n", ok * 180 / M_PI);
}



Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#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 n;
vector<pair<pair<int,int>,int> >edg;
int main() {
	read(n);
	int p=1,m=n;n=min(524288,n);
	while((1<<(p-1))<n)
		p++;
//	cout<<p<<endl;
	for(int i=1;i<p-1;++i)
		edg.push_back(make_pair(make_pair(i,i+1),0)),
		edg.push_back(make_pair(make_pair(i,i+1),1<<(i-1)));
	edg.push_back(make_pair(make_pair(p-1,p),0));
	int tmp=n;
	n-=(1<<(p-2));
//	cout<<tmp<<" "<<n<<" "<<p<<endl;
	int q=1;
	for(int i=0;i<p-1;++i,q<<=1)
		if(n>>i&1)
			edg.push_back(make_pair(make_pair(i+1,p),tmp-q)),tmp-=q;
	if(m>(1<<19)) {
		tmp=m;
		m-=(1<<19);
		int qi=1;
//		cout<<m<<" "<<oi<<" "<<qi<<endl;
		for(int i=0;i<p-1;++i,qi<<=1)
			if(m>>i&1)
				edg.push_back(make_pair(make_pair(i+1,p),tmp-qi)),tmp-=qi;
	}
	printf("%d %d\n",p,edg.size());
	for(int i=0;i<edg.size();++i)
		printf("%d %d %d\n",edg[i].first.first,edg[i].first.second,edg[i].second);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline void upmin(T &x,T y) { y<x?x=y:0; }
template<typename T>inline void upmax(T &x,T y) { x<y?x=y:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=2010;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int siz[N],fa[N];
int f0[N][N],f1[N][N],f2[N][N];
int F0[N],F1[N],F2[N];
int main()
{
	int n=gi(),i,j,k,t,ans=0,s,fac;
	const int mod=1e9+7,inv2=(mod+1)>>1;
	for (i=2;i<=n;i++) fa[i]=gi();
	for (i=1;i<=n;i++) siz[i]=1,f0[i][1]=1;
	for (k=n;k>1;k--) {
		t=fa[k];
		for (i=0;i<=siz[k]+siz[t];i++) F0[i]=F1[i]=F2[i]=0;
		for (i=1;i<=siz[t];i++)
			for (j=1;j<=siz[k];j++) {
				s=((LL)f0[k][j]+f1[k][j]+f2[k][j])%mod;
				
				F2[i+j]=(F2[i+j]+1LL*f2[t][i]*s)%mod;
				F2[i+j-1]=(F2[i+j-1]+1LL*f1[t][i]*f1[k][j]%mod*inv2+1LL*f1[t][i]*f0[k][j])%mod;

				F1[i+j]=(F1[i+j]+1LL*f1[t][i]*s)%mod;
				F1[i+j-1]=(F1[i+j-1]+1LL*f0[t][i]*(f1[k][j]+2LL*f0[k][j]))%mod;

				F0[i+j]=(F0[i+j]+1LL*f0[t][i]*s)%mod;
			}
		for (i=siz[t]+=siz[k];~i;i--) f0[t][i]=F0[i],f1[t][i]=F1[i],f2[t][i]=F2[i];
	}
	for (i=fac=1;i<=n;i++) {
		fac=1LL*fac*i%mod;
		ans=(ans+((n^i)&1?-1:1)*fac*((LL)f0[1][i]+f1[1][i]+f2[1][i]))%mod;
	}
	cout<<(ans+mod)%mod<<endl;
	return 0;
}


Measured memory_bytes: 47488
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    HashMap<String,String> map = new HashMap<String,String>();

    for(int i = 0; i < n; i++) {
      String str = sc.next();
      map.put(str,str);
    }
    System.out.println(map.size());

    sc.close();
  }
}

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

using namespace std;

int main () {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (a < c) swap(a, c);
  if (a < b) swap(a, b);
  cout << (1 << k)*a + b + c << "\n";
}

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

long mod = 1000000007;
long dp[101][8] = {};
int H, W;
vector<vector<int>> v;  // 横棒のパターン
int bit[8] = {};

void addBit() {
  int l = W - 1;
  for (int i = 1; i < l; i++) {
    if (bit[i - 1] == 1 && bit[i] == 1) return;
  }
  vector<int> tmp(l);
  for (int i = 0; i < l; i++) {
    tmp[i] = bit[i];
  }
  v.push_back(tmp);
}

void makeBit(int k) {
  if (k == W - 1) {
    addBit();
    return;
  }
  makeBit(k + 1);
  bit[k] = 1;
  makeBit(k + 1);
  bit[k] = 0;
}

void swap(long a[], vector<int> b, long c[]) {
  for (int i = 0; i < W - 1; i++) {
    if (b[i] == 1) {
      c[i] = a[i + 1];
      c[i + 1] = a[i];
    } 
  }
}

void disp(long a[]) {
  for (int i = 0; i < W; i++) {
    cout << a[i] << " ";
  }
  cout << "\n";
}
int main() {
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  int K;
  cin >> H >> W >> K;
  
  if (W == 1) {
    if (K == 1) cout << "1\n";
    else cout << "0\n";
    return 0;
  }
 
  dp[0][0] = 1;
  makeBit(0);
  // for (int i = 0; i < v.size(); i++) {
  //   for(int j = 0; j < W - 1; j++) {
  //     cout << v[i][j] << " ";
  //   }
  //   cout << "\n";
  // }
  int l = v.size();
  for (int i = 1; i <= H; i++) {
    for (int j = 0; j < l; j++) {
      long* c = new long[W]();
      for (int k = 0; k < W; k++) {
        c[k] = dp[i - 1][k];
      }
      //memcpy(c, dp[i - 1], sizeof(dp[i - 1]));
      //disp(c);
      //disp(dp[i - 1]);
      swap(dp[i - 1], v[j], c);
      //disp(c);
      for (int k = 0; k < W; k++) {
        dp[i][k] += c[k];
        dp[i][k] %= mod;
      }
    }
  }
  cout << dp[H][K - 1] << "\n";
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
using namespace std;
string s;
bool mark[300];
vector <char> vec;
int main(){
	cin>>s;
	int n=s.size();
	rep(i,0,n) mark[(int)s[i]]=true;
	rep(i,(int)'a',(int)'z'){
		if(!mark[i]){
			cout<<s<<char (i);
			return 0;
		}
	}
	int t=n;
	for(int i=n-1;i>=0;i--){
		t--;
		rep(j,0,(int)vec.size()){
			if(vec[j]>s[i]){
				rep(k,0,t){
					cout<<s[k];
				}
				cout<<vec[j];
				return 0;
			}
		}
		vec.push_back(s[i]);
		sort(vec.begin(),vec.end());
	}
	cout<<-1;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

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

    //reverse(s.begin(), s.end());

    ll num (1);
    ll dec (0);
    for (auto i: s)
    {
        dec += (i-48);    
    }

    ll num2 = atoi(s.c_str());

    if( num2 % dec == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

// FIXME:　クラス名をMainに修正してからコミットすること。
class Main {

    // エントリポイント
    public static void main(String args[]) {
        doLogic();
    }

    // 定数
    private static final int TOP = 0;
    private static final int NORTH = 1;
    private static final int EAST = 2;
    private static final int SOUTH = 3;
    private static final int WEST = 4;

    // フィールド
    private static int sum = 1;
    private static int[] dice = new int[5]; // TOP, NORTH, EAST, SOUTH, WEST を保持

    /**
     * サイコロに対するコマンドを実行する。
     *
     * @param command コマンド
     */
    private static void doCommand(String command) {
        int tmp = 0;
        if ("Right".equals(command)) {
            tmp = dice[4];
            for (int j = 3; j >= 1; j--) {
                dice[j + 1] = dice[j];
            }
            dice[1] = tmp;

        } else if ("Left".equals(command)) {
            tmp = dice[1];
            for (int j = 1; j <= 3; j++) {
                dice[j] = dice[j + 1];
            }
            dice[4] = tmp;

        } else if ("North".equals(command)) {
            dice[NORTH] = dice[TOP];
            dice[TOP] = dice[SOUTH];
            dice[SOUTH] = 7 - dice[NORTH];

        } else if ("South".equals(command)) {
            dice[SOUTH] = dice[TOP];
            dice[TOP] = dice[NORTH];
            dice[NORTH] = 7 - dice[SOUTH];

        } else if ("East".equals(command)) {
            dice[EAST] = dice[TOP];
            dice[TOP] = dice[WEST];
            dice[WEST] = 7 - dice[EAST];

        } else if ("West".equals(command)) {
            dice[WEST] = dice[TOP];
            dice[TOP] = dice[EAST];
            dice[EAST] = 7 - dice[WEST];
        }
    }

    /**
     * 標準入力を1行読む（例外処理を切り出し）
     *
     * @param reader 入力ストリーム
     * @return 1行分のデータ
     */
    private static String readLine(BufferedReader reader) {
        String line = null;
        try {
            line = reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException();
        }
        return line;
    }

    /**
     * メインロジック
     *
     */
    private static void doLogic() {

        // 標準入力のストリームを作成する
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String input = null;
        while (true) {
            input = readLine(reader);
            int loop = Integer.parseInt(input);

            // 終了判定を行う
            if (loop == 0) {
                break;
            }

            // 初期化する
            sum = 1;
            dice[0] = 1;
            dice[1] = 5;
            dice[2] = 3;
            dice[3] = 2;
            dice[4] = 4;

            // 指定された数だけコマンドを実行する
            for (int i = 0; i < loop; i++) {
                String command = readLine(reader);
                doCommand(command);
                sum += dice[0];
            }
            System.out.println(sum);

        }
    }
}

Measured memory_bytes: 21820
#include <stdio.h>

int main (void){

	int H[1000];
	int W[1000];
	int i,j,k;
	int lim=0;
	while(1){
		scanf("%d %d",&H[lim],&W[lim]);
		if(H[lim]==0 && W[lim]==0){
			break;
		}
		lim++;
	}
	for(k=0;k<lim;k++){
	for(i=0;i<H[k];i++){
		for(j=0;j<W[k];j++){
			printf("#");
		}
		printf("\n");
	}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N,A,B; cin >> N >> A >> B;
    string s; cin >> s;

    int all = 0;
    int abr = 0;

    for(int i=0; i<N; i++){
        if(s[i] == 'a'){
            if(all < A+B){
                cout << "Yes" << endl;
                all++;
            }
            else cout << "No" << endl;
            
        }
        else if(s[i] == 'b'){
            if(all < A+B && abr < B){
                all++; abr++;
                cout << "Yes" << endl;
            }
            else cout << "No" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

ll MOD=998244353;

ll add(ll x, ll y)
{
    x += y;
    if (x >= MOD)
        return x - MOD;
    return x;
}
ll sub(ll x, ll y)
{
    x -= y;
    if (x < 0)
        return x + MOD;
    return x;
}
ll mult(ll x, ll y)
{
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p)
{
    if (p == 0)
        return 1;
    if (p & 1)
        return mult(x, bin_pow(x, p - 1));
    return bin_pow(mult(x, x), p / 2);
}
int dp[3010][3010];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    for (int i = a; i <= c; i++)
    {
        for (int j = b; j <= d; j++)
        {
           
            if(i == a){
                dp[i][j]=bin_pow(a , j-b);
            }
            else if(j == b){
                dp[i][j]=bin_pow(b, i-a);
            }
            else{
            /*    if(i==3 && j==2){
                    cerr<<dp[i-1][j]*j<<" "<<dp[i][j-1]*i<<endl;
                }*/
                dp[i][j]=(dp[i-1][j]*(j) + dp[i][j-1]*(i)+MOD) - dp[i-1][j-1]*(i-1)*(j-1)%MOD;
            }
            dp[i][j]%=MOD;
        }
        
    }
   /* for (int i = a; i <=c ; i++)
    {
        for(int j=b;j<=d;j++){
            cerr<<dp[i][j]<<" ";
        }
        cerr<<endl;
    }*/
    
    cout<<dp[c][d]<<endl;
    
    
    return 0;
}

Measured memory_bytes: 74056
/********************************************//**
 ****** Author: Shivam Kejriwal *****************
 ****** Handle: techno_phyle    *****************
 ***********************************************/

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;

#define mod 1000000007
#define N 100010
#define M 100010
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto it:a) cout << it << " "; cout << endl
#define adbp(a) for(auto it:a) cout << it.first << " " << it.second << endl
#define pb push_back
//greater<pair<int,int> , greater<int>>
const ll INF = 1e18L + 5;
//int dp[N][3];

int recurse_graph(int i , const vector<vector<int>> &v ,vector<int> &dp){
    if(dp[i]!=-1) return dp[i];

    int res =0;
    for(int j=0;j<v[i].size();j++)
        res = max(res , recurse_graph(v[i][j] , v ,  dp) + 1);
    return dp[i] = res;
}
int main(){
	fastIO;
    /*#ifndef ONLINE_JUDGE
        freopen("../input.txt", "r", stdin);
        freopen("../output.txt","w",stdout);
    #endif	*/
    int n,m;
    cin >> n >> m;
    vector<vector<int>> v(n+1);
    for(int i=1;i<=m;i++){
        int x ,y;
        cin >> x >> y;
        v[x].push_back(y);
    }
    vector<int> dp(n+1,-1);

    int ans =0;
    for(int i=1;i<=n;i++){
        ans = max(ans , recurse_graph(i , v , dp));
    }
    cout << ans << endl;
	return 0;

}

Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int t = sc.nextInt();

        int g = x - t;
        if (g < 0) {
            g = 0;
        }

        System.out.println(g);
    }

}

Measured memory_bytes: 21204
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228

ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n;
	cin >> n;
	vector<int> crd;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		crd.push_back(a[i]);
	}
	sort(crd.begin(), crd.end());
	crd.erase(unique(crd.begin(), crd.end()), crd.end());
	if (crd.size() > 3) {
		cout << "No\n";
		return 0;
	}
	for (int fir : crd) {
		for (int sec : crd) {
			for (int thi : crd) {
				vector<int> v;
				map<int, int> cnt;
				for (int i = 0; i < n; ++i) {
					++cnt[a[i]];
					if (i % 3 == 0) --cnt[fir], v.push_back(fir);
					if (i % 3 == 1) --cnt[sec], v.push_back(sec);
					if (i % 3 == 2) --cnt[thi], v.push_back(thi);
				}
				bool ok = 1;
				for (int i = 0; i < n; ++i) {
					if ((v[i] ^ v[(i + 1) % n] ^ v[(i + 2) % n]) != 0) {
						ok = 0;
					}
				}
				for (auto p : cnt) {
					if (p.second) {
						ok = 0;
						break;
					}
				}
				if (ok) {
					cout << "Yes\n";
					return 0;
				}
			}
		}
	}
	cout << "No\n";
    return 0;
} // kek ;


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define ll long long
#define N 1234567
using namespace std;
int main(void)
{
    int k;
    string s;
    cin>>k>>s;
    if(s.size() <= k)
    {
        cout<<s<<endl;
    }
    else
    {
        for(int i=0;i<k;i++) cout<<s[i];
        cout<<"...\n";
    }
    //main();
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
map<string,int> a;
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		a[s]++;
	}
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		a[s]--;
	}
	int maxx=0;
	for (map<string, int>::iterator i=a.begin();i!=a.end();i++)
	{
		if (i->second>maxx) maxx=i->second;
	}
	printf("%d\n",maxx);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main(void)
{
    long long N, M;
    cin >> N >> M;
    long long minN, maxN;
    for (long long i = 0; i < M; i++)
    {
        long long L, R;
        cin >> L >> R;
        if (i == 0)
        {
            minN = L;
            maxN = R;
        }
        else
        {
            minN = max(minN, L);
            maxN = min(maxN, R);
        }
    }
    long long ans;
    ans = max(maxN - minN + 1, 0LL);
    cout << ans << endl;

    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define mp(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    string s[n];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        string tmp[n];
        for (int r = 0; r < n; r++) {
            tmp[r] = s[r];
            if ((i >> r) & 1) {
                for (int c = 0; c < m; c++) {
                    tmp[r][c] = 'X';
                }
            }
        }

        for (int j = 0; j < (1 << m); j++) {
            string ttmp[n]; for (int i = 0; i < n; i++) ttmp[i] = tmp[i];
            for (int c = 0; c < m; c++) {
                if ((j >> c) & 1) {
                    for (int r = 0; r < n; r++) {
                        ttmp[r][c] = 'X';
                    }
                }
            }
            int tot = 0;
            for (int r = 0; r < n; r++) {
                for (int c = 0; c < m; c++) {
                    if (ttmp[r][c] == '#') tot++;
                }
            }
            ans += tot == k;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pli = std::pair<long long, int> ;

using namespace std;

const long long MOD = 1000000007;

void warshallFloyd(int** graph, int n) noexcept {
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			for (int k = 0; k < n; ++k) {
				graph[j][k] = min(graph[j][k], graph[j][i] + graph[i][k]);
			}
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int h, w;
	cin >> h >> w;
	int** graph;
	graph = new int*[h*w];
	rep(i, h*w) {
		graph[i] = new int[h*w];
		rep(j, h*w) {
			graph[i][j] = MOD;
		}
	}

	char** map;
	map = new char*[h];
	rep(i, h) {
		map[i] = new char[w];
		rep(j, w) {
			cin >> map[i][j];
		}
	}

	rep(i, h) {
		rep(j, w) {
			if (map[i][j] == '.') {
				graph[i*w + j][i*w + j] = 0;
				if (i != 0) {
					if (map[i - 1][j] == '.') {
						graph[i*w + j][(i - 1)*w + j] = 1;
						graph[(i - 1)*w + j][i*w + j] = 1;
					}
				}
				if (j != w - 1) {
					if (map[i][j + 1] == '.') {
						graph[i*w + j][i*w + j + 1] = 1;
						graph[i*w + j + 1][i*w + j] = 1;
					}
				}
			}
		}
	}

	warshallFloyd(graph, h*w);

	int ans = 0;
	rep(i, h*w) {
		rep(j, h*w) {
			if (graph[i][j] != MOD) ans = max(ans, graph[i][j]);
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include <stdio.h>
#include<algorithm>
#include<string.h>
#include<cmath>
#include <vector>
using namespace std;
string x;
int n;
int comp(int t)
{
    bool a[30]={0},b[30]={0};
    for(int i=0;i<=t;i++)
        a[x[i]-97]=1;
    for(int i=t+1;i<n;i++)
        b[x[i]-97]=1;
    int sum=0;
    for(int i=0;i<26;i++)
        if(a[i]==1&&b[i]==1)sum++;
    return sum;
}
int main()
{
    scanf("%d",&n);
    cin>>x;
    int mmax=0;
    for(int i=0;i<n;i++)
    {
        mmax=max(mmax,comp(i));
    }
    printf("%d",mmax);
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pii;
#define MAX_V 100010
struct edge{
	int to,cost;
};
vector<vector<edge> >G(MAX_V);
int V,E,s;
void dijkstra(){
	vi d(MAX_V);
	rep(i,MAX_V)d[i]=inf;
	d[s]=0;
	priority_queue<pii>q;
	q.push(pii(0,s));
	while(!q.empty()){
		pii p=q.top();
		q.pop();
		int pos=p.second,cost=-p.first;
		if(cost>d[pos])continue;
		rep(i,G[pos].size()){
			edge e=G[pos][i];
			int to=e.to;
			int nowcost=cost+e.cost;
			if(nowcost<d[to]){
				d[to]=nowcost;
				q.push(pii(-d[to],to));
			}
		}
	}
	rep(i,V)if(d[i]==inf)cout<<"INF"<<endl;
	else cout<<d[i]<<endl;
}
int main(){
	cin>>V>>E>>s;
	while(E--){
		int a,b,c;
		cin>>a>>b>>c;
		edge t={b,c};
		G[a].pb(t);
	}
	dijkstra();
}

Measured memory_bytes: 12360
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[][] nums = new long[10][10];
        for (int i = 1; i <= n; i++) {
            String s = String.valueOf(i);
            int head = s.charAt(0) - '0';
            int tail = s.charAt(s.length() - 1) - '0';
            nums[head][tail]++;
        }
        long ans = 0;
        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                ans += nums[i][j] * nums[j][i];
            }
        }
        System.out.println(ans);
    }

}


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


int main()
{
	auto& in = cin;

	int N;
	in >> N;
	long long sum = 0;
	vector<long long> A(N);
	for (int i = 0; i < N; ++i) {
		in >> A[i];
		sum += A[i];
	}

	long long mod = 1000000007;
	long long result = 0;
	for (int i = 0; i < N - 1; ++i) {
		sum -= A[i];
		result += (A[i] * (sum % mod)) % mod;
		result %= mod;
	}
	cout << result % mod;

	return 0;
}


Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
ll x;
vector<P1>edge;
vector<P>G[1005];
bool used[1005][1005];
struct uf{
	int par[1005],ran[1005];
	void init(){ for(int i=0;i<1005;i++) par[i] = i; }
	int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
	void unite(int x,int y){
		x = find(x); y = find(y); if(x==y) return;
		if(ran[x] < ran[y]) par[x] = y;
		else{
			par[y] = x;
			if(ran[x] == ran[y]) ran[x]++;
		}
	}
	bool same(int x,int y){ return find(x)==find(y); }
}uf;
int mx[1005];
void dfs(int v,int u){
	for(int i=0;i<G[v].size();i++){
		if(G[v][i].fi == u) continue;
		mx[G[v][i].fi] = max(mx[G[v][i].fi],max(mx[v],G[v][i].sc));
		dfs(G[v][i].fi,v);
	}
}
int main(){
	cin>>n>>m;
	if(n <= 2){
		puts("0"); return 0;
	}
	cin>>x;
	for(int i=0;i<m;i++){
		int u,v,w;
		cin>>u>>v>>w;
		edge.pb(mp(w,mp(u,v)));
	}
	uf.init();
	SORT(edge);
	ll cs = 0;
	for(int i=0;i<m;i++){
		int to = edge[i].sc.fi,to2 = edge[i].sc.sc;
		if(!uf.same(to,to2)){
			uf.unite(to,to2);
			cs += edge[i].fi;
			G[to].pb(mp(to2,edge[i].fi)); used[to][to2] = 1;
			G[to2].pb(mp(to,edge[i].fi)); used[to2][to] = 1;
		}
	}
	if(cs > x){
		puts("0"); return 0;
	}
	else if(cs == x){
		uf.init();
		int cnt = 0;
		for(int i=0;i<m;){
			int j = i;
			while(j<m && edge[i].fi == edge[j].fi) j++;
			//[i,j)
			for(int k=i;k<j;k++){
				int to = edge[k].sc.fi,to2 = edge[k].sc.sc;
				if(!uf.same(to,to2)){
					cnt++;
				}
			}
			for(int k=i;k<j;k++){
				int to = edge[k].sc.fi,to2 = edge[k].sc.sc;
				uf.unite(to,to2);
			}
			i = j;
		}
		ll ans = 1;
		int zan = m-cnt;
		for(int i=0;i<zan;i++) ans = ans*2ll%mod;
		ll ans2 = 1;
		for(int i=0;i<cnt;i++){
			ans2 = ans2*2ll%mod;
		}
		ans2 = (ans2+mod-2)%mod;
		cout<<ans*ans2%mod<<endl;
		return 0;
	}
	else{
		ll ans = 2;
		int cnt = 0;
		for(int i=0;i<m;i++){
			int to = edge[i].sc.fi,to2 = edge[i].sc.sc;
			if(used[to][to2]) continue;
			memset(mx,-1,sizeof(mx));
			dfs(to,-1);
			int dif = edge[i].fi - mx[to2];
			assert(dif >= 0);
			if(dif < x-cs) continue;
			else if(dif > x-cs){
				ans = ans*2ll%mod;
			}
			else{
				cnt++;
			}
		}
		ll ans2 = 1;
		for(int i=0;i<cnt;i++) ans2 = ans2*2ll%mod;
		ans2 = (ans2+mod-1)%mod;
		cout<<ans*ans2%mod<<endl;
		return 0;
	}
}

Measured memory_bytes: 1408
# 昔解いてた

n = gets.to_i

a = 0
b = n
ans = 999999999999
while n > a * a
  a += 1
  next if n % a > 0
  b = n / a
  val = [a.to_s.size, b.to_s.size].max
  ans = [ans, val].min
end

puts ans


Measured memory_bytes: 1916
#include <iostream>
#include <set>
#include <vector>
using namespace std;
const int MAX_N = 100010;
int p[MAX_N];
int par[MAX_N], _rank[MAX_N];
void init(int n) {
    for (int i=0;i<n;i++) {
        par[i] = i;
        _rank[i] = 0;
    }
}
int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (_rank[x] < _rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (_rank[x] == _rank[y])_rank[x]++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int main () {
    int n, m, x, y;
    cin >> n >> m;
    init(n);
    for (int i=0;i<n;i++) {
        cin >> p[i];
        p[i]--;
    }
    for (int i=0;i<m;i++) {
        cin >> x >> y;
        unite(--x, --y);
    }
    vector<set<int> > sets(n);
    for (int i=0;i<n;i++) {
        int root = find(i);
        sets[root].insert(i);
    }
    int cnt = 0;
    for (int i=0;i<n;i++) {
        int root = find(i);
        if (sets[root].count(p[i]) == 0) {
            cnt++;
        }
    }
    cout << (n - cnt) << endl;
}


Measured memory_bytes: 10752
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto k = readln.chomp.to!int;
  long sum;
  foreach (int i; 1..k+1) {
    foreach (int j; 1..k+1) {
      auto t = gcd(i, j);
      foreach (int l; 1..k+1) {
        sum += gcd(t, l);
      }
    }
  }
  sum.writeln;
}


Measured memory_bytes: 2732
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define F0R(i,b) FOR(i,0,b)
using namespace std;

const int maxn = 1010;

const char ans[5][7][8] = {
	{
		{"add"},
		{"a.c"},
		{"bbc"},
	},
	{
		{"fhdd"},
		{"fhbb"},
		{"eegc"},
		{"aagc"},
	},
	{
		{"ddjgg"},
		{"aaj.c"},
		{".fbbc"},
		{"hfi.."},
		{"h.iee"},
	},
	{
		{"ii..ak"},
		{"b...ak"},
		{"b.hh.c"},
		{".jjddc"},
		{"..glee"},
		{"ffgl.."},
	},
	{
		{"j...fnn"},
		{"j.kkf.."},
		{".c..bbd"},
		{".c.mm.d"},
		{"iie..a."},
		{"..e..ag"},
		{"llhh..g"},
	}
};

int n;
char ret[maxn][maxn];

int main() {
	scanf("%d", &n);
	if (n < 3) printf("-1");
	else if (n == 3) {
		F0R(i,n)
			printf("%s\n", ans[0][i]);
	}
	else {
		F0R(i,n)
			F0R(j,n)
				ret[i][j] = '.';
		int _ = 0;
		for (; _+8 <= n; _+=4) {
			FOR(i,_,_+4)
				FOR(j,_,_+4)
					ret[i][j] = ans[1][i-_][j-_];
		}
		FOR(i,_,n)
			FOR(j,_,n)
				ret[i][j] = ans[(n-_-4)+1][i-_][j-_];
		F0R(i,n)
			printf("%s\n", ret[i]);
	}
}


Measured memory_bytes: 2176
n, k = map(int, input().split())
p = list(map(int, input().split()))
p_ex = []
for p_one in p:
    p_ex.append(p_one / 2 + 0.5)

sum_ex = 0

for i in range(k):
    sum_ex += p_ex[i]

sum_ex_prev = sum_ex
for i in range(n - k):
    sum_ex_tmp = sum_ex_prev
    sum_ex_tmp -= p_ex[i]
    sum_ex_tmp += p_ex[i + k]
    sum_ex = max(sum_ex, sum_ex_tmp)
    sum_ex_prev = sum_ex_tmp

print(sum_ex)

Measured memory_bytes: 24816
#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 Int = int64_t;
using P = pair<Int, Int>;
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
#define debug2(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << 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; }

Int N, K;

void make_group(const vector<Int> &P, vector<vector<Int>> &G)
{
    vector<Int> used(N, 0);
    for(Int i = 0; i < N; i++)
    {
        Int s = i;
        if(used[s]) continue;
        vector<Int> tmp;
        while (s < N)
        {
            if (used[s]) break;
            used[s] = 1;
            tmp.push_back(s);
            s = P[s];
        }
        G.push_back(tmp);
    }
}

void solve()
{
    cin >> N >> K;

    vector<Int> P(N), C(N);
    for(Int i = 0; i < N; i++)
    {
        cin >> P[i];
        P[i]--;
    }

    for(Int i = 0; i < N; i++) cin >> C[i];

    vector<vector<Int>> G;
    make_group(P, G);

    Int ans = *max_element(C.begin(), C.end());

    for(const vector<Int> &p : G)
    {
        Int value = 0;
        Int n = (Int)p.size();
        for(Int i = 0; i < n; i++) value += C[p[i]];

        if(value > 0)
        {
            Int k = K % n + n;
            for(int i = 0; i < n; i++)
            {
                Int sum = value * (K / n - 1);
                ans = max(ans, sum);
                for (int j = 1; j <= k; j++)
                {
                    sum += C[p[(i + j) % n]];
                    ans = max(ans, sum);
                }
            }
        }
        else
        {
            Int k = min(n, K);
            for(int i = 0; i < n; i++)
            {
                Int sum = 0; 
                for(int j = 1; j <= k; j++)
                {
                    sum += C[p[(i + j) % n]];
                    ans = max(ans, sum);
                }
            }
        }
    }
    
    cout << ans << endl;
}

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


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

using namespace std;

using ll = long long;

constexpr ll INF = 1e17;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector< vector<ll> > dpL(2, vector<ll>(n + 1, -INF));
    dpL[false][0] = 0;
    for (int i = 0; i + 1 < n; i += 2) {
        dpL[false][i + 2] = max(dpL[false][i + 2], dpL[false][i] + a[i]);
        dpL[true][i + 2] = max(dpL[true][i + 2], max(dpL[false][i], dpL[true][i]) + a[i + 1]);
    }

    if (n % 2 == 0) {
        cout << max(dpL[false][n], dpL[true][n]) << "\n";
        return 0;
    }

    vector< vector<ll> > dpR(2, vector<ll>(n + 1, -INF));
    dpR[false][n - 1] = 0;
    for (int i = n - 1; i >= 2; --i) {
        dpR[false][i - 2] = max(dpR[false][i - 2], dpR[false][i] + a[i]);
        dpR[true][i - 2] = max(dpR[true][i - 2], max(dpR[false][i], dpR[true][i]) + a[i - 1]);        
    }

    ll ans = -INF;
    for (int i = 0; i < n; i += 2) {
        ans = max(ans, max(dpL[false][i], dpL[true][i]) + max(dpR[false][i], dpR[true][i]));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 12552
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();

        int cntFour = 0;
        int cntTwo = 0;

        for (int i=0; i<n; i++) {
            if (arr[i]%4==0) {
                cntFour++;
            } else if (arr[i]%2==0) {
                cntTwo++;
            }
        }

        if (n/2<=cntFour || n/2<=(cntTwo/2+cntFour)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}

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

long long n,ans[505][505],gap,cont;

int main(){

	cin>>n;
	
	cont=1;
	
	for(int i=0;(1ll<<i)<=n;i++){
		
		gap=(1ll<<i);
		
		for(int j=0;j<gap;j++){
			for(int z=j+1;z<gap;z++){
				if((j+gap)<n && (z+gap)<n){
					ans[j+gap][z+gap]=ans[j][z];
				}
			}
		}
		
		for(int j=0;j<gap;j++){
			for(int z=0;z<gap;z++){
				if((z+gap)<n)
				ans[j][z+gap]=cont;
			}
		}
		
		cont++;
	}
	
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++)cout<<ans[i][j]<<" ";
		cout<<"\n";
	}

return 0;
}


Measured memory_bytes: 2432
#include<iostream>

using namespace std;

typedef long long ll;

int main() {
	int K, A, B;
	cin >> K >> A >> B;
	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			cout << "OK\n";
			return 0;
		}
	}
	cout << "NG\n";
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] vote = new String[N];
		int i = 0;
		while(i < N) {
			vote[i] = sc.next();

			i++;
		}

		Arrays.sort(vote);
		int maxCounter = 0;
		int[] a = new int[N];
		String[] b = new String[N];
		int j = 0;

		a[0] = 1;
		b[0] = vote[0];

		for(i = 1; i < N; i++) {
			if(vote[i].equals(b[j])) {
				a[j]++;
			}else {
				if(maxCounter < a[j]) {
					maxCounter = a[j];
				}
				j++;
				a[j] = 1;
				b[j] = vote[i];
			}
		}
		if(maxCounter < a[j]) {
			maxCounter = a[j];
		}

		for(i = 0; i<N; i++) {
			if(a[i] == maxCounter) {
				System.out.println(b[i]);
			}
		}

	}

}


Measured memory_bytes: 79452
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
int main(void){

  int a;
  string s;
  cin >> a >> s;

  if(a >= 3200)
    cout << s << endl;
  else
    cout << "red" << endl;

  return 0;
}

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

int main() {
  int num_of_cards, rank;
  char A;
  bool cards[4][13];
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      cards[i][j] = false;
    }
  }
  cin >> num_of_cards;
  for (int i = 0; i < num_of_cards; i++) {
    cin >> A >> rank;
    switch (A) {
      case 'S':
        cards[0][rank - 1] = true;
        break;
      case 'H':
        cards[1][rank - 1] = true;
        break;
      case 'C':
        cards[2][rank - 1] = true;
        break;
      case 'D':
        cards[3][rank - 1] = true;
        break;
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 13; j++) {
      if (!cards[i][j]) {
        switch (i) {
          case 0:
            cout << "S " << j + 1 << endl;
            break;
          case 1:
            cout << "H " << j + 1 << endl;
            break;
          case 2:
            cout << "C " << j + 1 << endl;
            break;
          case 3:
            cout << "D " << j + 1 << endl;
            break;
        }
      }
    }
  }
}

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

int main() {
  long N, M;
  cin >> N >> M;
  vector<long> steps(N + 1, -1);
  vector<int> broken(M);
  steps[0] = 1;
  for (int i = 0; i < M; i++) {
    cin >> broken[i];
  }
  for (int i : broken) {
    steps[i] = 0;
  }
  if (steps[1] != 0) {
    steps[1] = 1;
  }
  if (N > 1) {
    for (int i = 2; i < N + 1; i++) {
      if (steps[i] != 0) {
        steps[i] = (steps[i - 2] + steps[i - 1]) % 1000000007;
      }
    }
  }
  cout << steps[N] % 1000000007 << endl;
  
  return 0;
}

Measured memory_bytes: 1408
# coding: utf-8
# Here your code !

def BubbleSort(A, N):
    count = 0
    flag = 1
    while flag:
        flag = 0
        for i in range(1, N):
            if int(A[N - i][1]) < int(A[N - i - 1][1]):
                A[N - i], A[N - i - 1] = A[N - i - 1], A[N - i]
                flag = 1
    return A


def SelectionSort(C, N):
    for i in range(N):
        minj = i

        for j in range(i, N):
            if int(C[j][1]) < int(C[minj][1]):
                minj = j
        if i != minj:
            C[i], C[minj] = C[minj], C[i]
    return C


if __name__ == '__main__':
    n = int(input())
    data = input().split()
    selection = data[:]
    data = BubbleSort(data, n)
#    print(" ".join(BubbleSort(data, n)))
    print(" ".join(data))
    print("Stable")
    selection = SelectionSort(selection, n)
    print(" ".join(selection))
    if data == selection:
        print("Stable")
    else:
        print("Not stable")

Measured memory_bytes: 7812
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

template<const long long mod = 1000000007>
struct mint{ //modint
    long long x;
    mint(long long x = 0): x((x %= mod) < 0 ? x + mod : x) {}
    friend istream& operator >> (istream &s, mint& m){ return s >> m.x; }
    friend ostream& operator << (ostream &s, mint m){ return s << m.x; }
    inline mint& operator += (mint a){ if((x += a.x) >= mod)x -= mod; return *this; }
    inline mint& operator -= (mint a){ if((x += mod - a.x) >= mod)x -= mod; return *this; }
    inline mint& operator *= (mint a){ (x *= a.x) %= mod; return *this; }
    inline mint& operator /= (mint a){ return (*this) *= a.inv(); }
    inline mint operator + (mint a){ mint res(*this); return res += a; }
    inline mint operator - (mint a){ mint res(*this); return res -= a; }
    inline mint operator * (mint a){ mint res(*this); return res *= a; }
    inline mint operator / (mint a){ mint res(*this); return res /= a; }
    inline void takemod(){ x = ((x % mod) + mod) % mod; }
    inline mint inv(){
        long long a = x, b = mod, u = 1, v = 0, t;
        while(b){
            t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    inline mint pow(long long p){
        mint res(1), tmp(x);
        for(; p; p >>= 1){ if(p & 1)res *= tmp; tmp *= tmp; }
        return res;
    }
};

int main(){

    int N, M;
    cin >> N >> M;

    vector<bool> a(N * M, 0);
    vector<bool> b(N * M, 0);
    rep(i, N){
        int x; cin >> x;
        a[x - 1] = 1;
    }
    rep(i, M){
        int x; cin >> x;
        b[x - 1] = 1;
    }

    long long vert = 0, side = 0;
    mint<> ans(1);
    for(int i = N * M - 1; i >= 0; i--){
        if(a[i] and b[i]){
            vert++;
            side++;
        }
        if(a[i] and !b[i]){
            ans *= mint<>(side);
            vert++;
        }
        if(!a[i] and b[i]){
            ans *= mint<>(vert);
            side++;
        }
        if(!a[i] and !b[i]){
            ans *= mint<>(vert * side - (N * M - 1 - i));
        }
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 512
def main():
    R, C, K = map( int, input().split())
    V = [[0]*C for _ in range(R)]
    for _ in range(K):
        r, c, v = map( int, input().split())
        V[r-1][c-1] = v
    dp0 = [[0]*(C+1) for _ in range(R+1)]
    dp1 = [[0]*(C+1) for _ in range(R+1)]
    dp2 = [[0]*(C+1) for _ in range(R+1)]
    dp3 = [[0]*(C+1) for _ in range(R+1)]
    for r in range(1,R+1):
        m = 0
        for c in range(1,C+1):
            m = max(m,dp0[r-1][c], dp1[r-1][c], dp2[r-1][c], dp3[r-1][c])
            dp0[r][c] = max(m, dp0[r][c-1])
            dp1[r][c] = max(dp1[r][c-1], dp0[r][c]+V[r-1][c-1])
            dp2[r][c] = max(dp2[r][c-1], dp1[r][c-1]+V[r-1][c-1])
            dp3[r][c] = max(dp3[r][c-1], dp2[r][c-1]+V[r-1][c-1])
    # print(dp0)
    # print(dp1)
    # print(dp2)
    # print(dp3)
    print( max( max(dp0[R]), max(dp1[R]), max(dp2[R]), max(dp3[R])))
if __name__ == '__main__':
    main()


Measured memory_bytes: 424744
#include <iostream>
#include <vector>

int main() {
    long long x, quo_11, quo_6, quo_5,rem_11,rem_6,rem_5;
    
    std::cin >> x;
    if (x > 11)
    {
        quo_11 = x / 11;
        rem_11 = x % 11;
        if (rem_11 > 6)
        {
            std::cout << quo_11 * 2 + 2 << std::endl;
        }
        else if (rem_11 == 0)
        {
            std::cout << quo_11 * 2 << std::endl;
        }
        else
        {
            std::cout << quo_11 * 2 + 1 << std::endl;
        }
    }else if (x > 6)
    {
        std::cout << "2" << std::endl;
    }else
    {
        std::cout << "1" << std::endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int a;
	string s;
	int ans;

	cin >> a >> s;

	if(a >= 3200) printf("%s",s.c_str());
	else printf("red");

	//printf("%d\n", ans);


	return 0;
}



Measured memory_bytes: 256