akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main()
{
	int n;
	int y, m, d;
	cin >> n;
	int diff = 1;
	for (int i = 1; i < 1000; i++)
	{
		if (i % 3 == 0)
		{
			diff += 10 * 20;
		}
		else
		{
			diff += 5 * 19 + 5 * 20;
		}
	}
	for (int i = 0; i < n; i++)
	{
		cin >> y >> m >> d;
		int sum = 0;
		for (int j = 1; j < y; j++)
		{
			if (j % 3 == 0)
			{
				sum += 10 * 20;
			}
			else
			{
				sum += 5 * 19 + 5 * 20;
			}
		}

		if (y % 3 == 0)
		{
			sum += ((m-1) * 20);
		}
		else
		{
			for (int j = 1; j < m; j++)
			{
				if (j % 2 == 0)
				{
					sum += 19;
				}
				else
				{
					sum += 20;
				}
			}
		}
		sum += d;
		cout << diff - sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args)throws IOException{
        int m, f, r;

        InputStreamReader isr =new InputStreamReader(System.in);
   		BufferedReader br =new BufferedReader(isr);
    	String buf = br.readLine();
        StringTokenizer st = new StringTokenizer(buf," ");
        m = Integer.parseInt(st.nextToken());
        f = Integer.parseInt(st.nextToken());
        r = Integer.parseInt(st.nextToken());
        
        while(true) {
            if (m == -1 && f == -1 && r==-1) break;
            else if (m == -1 || f == -1) {
                System.out.println("F");
            }
            else if (m + f >= 80) {
                System.out.println("A");
            }
            else if (m + f < 80 && m + f >= 65) {
                System.out.println("B");
            }
            else if (m + f < 65 && m + f >= 50) {
                System.out.println("C");
            }
            else if (m + f < 50 && m + f >= 30) {
                if (r >= 50) System.out.println("C");
                else System.out.println("D");
            }
            else System.out.println("F");
            
            buf = br.readLine();
            st = new StringTokenizer(buf," ");
            m = Integer.parseInt(st.nextToken());
            f = Integer.parseInt(st.nextToken());
            r = Integer.parseInt(st.nextToken());
        }
    }
}

Measured memory_bytes: 24212
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long double sum=0;
    for(int i=0;i<n;i++){
        long double c;
        cin>>c;
        sum+=(1/c);
    }
    cout<<fixed<<setprecision(7)<<1/sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 1000000007
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,m;
    cin >> n >> m;
    cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2;
    return 0;
}


Measured memory_bytes: 256
lis=[0]*((10**5)+10)
N=int(input().strip())
a=list(map(int, input().split()))
for i in range(N):
    lis[a[i]-1]+=1
    lis[a[i]]+=1
    lis[a[i]+1]+=1
lis.sort(reverse=True)
print(lis[0])

Measured memory_bytes: 14732
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <cstdio>
using namespace std;
int main(){
	int x,h;
	while(1){
		cin>>x;
		cin>>h;
		if(x==0 && h==0) break;
		double s=(double)(x*x)+(double)x*(sqrt((double)(x*x)+4.0*(double)(h*h)));
		printf("%.6lf\n",s);
	}
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
long n,a,res;
map<long , bool>mp;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a;
        if(!mp[a])res++,mp[a]=true;
        else mp[a]=false,--res;
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
# define LL          long long
# define pr          pair
# define mkp         make_pair
# define lowbit(x)   ((x)&(-x))
# define PI          acos(-1.0)
# define INF         0x3f3f3f3f3f3f3f3f
# define eps         1e-8
# define MOD         1000000007
# define MX          500

int n;
char s[MX];

int check(int x)
{
    int all=s[0]-'0';
    if (x&(1<<0)) all+=s[1]-'0';
    else all-=s[1]-'0';
    if (x&(1<<1)) all+=s[2]-'0';
    else all-=s[2]-'0';
    if (x&(1<<2)) all+=s[3]-'0';
    else all-=s[3]-'0';
    return all==7;
}

void prt(int x)
{
    for (int i=0;i<4;i++)
    {
        printf("%c",s[i]);
        if (i==3) break;
        if (x&(1<<i)) putchar('+');
        else putchar('-');
    }
    printf("=7");
}

int main()
{
    scanf("%s",s);
    for (int i=0;i<8;i++)
    {
        if (check(i))
        {
            prt(i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
int main() {
	int h, w, ans = 0, i, j, x[33][2], y[33][2], flag, p[33], t;
	char c[555][555];
	cin >> h >> w;
	for (i = 0; i < h; i++)
		cin >> c[i];
	for (i = 0; i < 26; i++)
		x[i][0] = -1;
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (c[i][j] != '.') {
				if (x[c[i][j] - 'A'][0] == -1) {
					x[c[i][j] - 'A'][0] = j;
					y[c[i][j] - 'A'][0] = i;
				}
				else {
					x[c[i][j] - 'A'][1] = j;
					y[c[i][j] - 'A'][1] = i;
				}
			}
		}
	}
	for (i = 0; i < 26; i++) {
		if (x[i][0] == -1)
			p[i] = 1;
		else
			p[i] = 0;
	}
	while (1) {
		flag = 0;
		for (i = 0; i < 26; i++) {
			if (p[i] == 0 && c[y[i][0]][x[i][1]] == '.') {
				t = 1;
				for (j = min(x[i][0], x[i][1]) + 1; j < max(x[i][0], x[i][1]); j++)
					if (c[y[i][0]][j] != '.')
						t = 0;
				for (j = min(y[i][0], y[i][1]) + 1; j < max(y[i][0], y[i][1]); j++)
					if (c[j][x[i][1]] != '.')
						t = 0;
				if (t == 1) {
					ans += 2;
					flag = 1;
					c[y[i][0]][x[i][0]] = '.';
					c[y[i][1]][x[i][1]] = '.';
					p[i]++;
				}
			}
			if (p[i] == 0 && c[y[i][1]][x[i][0]] == '.') {
				t = 1;
				for (j = min(x[i][0], x[i][1]) + 1; j < max(x[i][0], x[i][1]); j++)
					if (c[y[i][1]][j] != '.')
						t = 0;
				for (j = min(y[i][0], y[i][1]) + 1; j < max(y[i][0], y[i][1]); j++)
					if (c[j][x[i][0]] != '.')
						t = 0;
				if (t == 1) {
					ans += 2;
					flag = 1;
					c[y[i][0]][x[i][0]] = '.';
					c[y[i][1]][x[i][1]] = '.';
					p[i]++;
				}
			}
			if (p[i] == 0 && x[i][0] == x[i][1]) {
				t = 1;
				for (j = min(y[i][0], y[i][1]) + 1; j < max(y[i][0], y[i][1]); j++)
					if (c[j][x[i][0]] != '.')
						t = 0;
				if (t == 1 && abs(y[i][0] - y[i][1]) > 1) {
					ans += 2;
					flag = 1;
					c[y[i][0]][x[i][0]] = '.';
					c[y[i][1]][x[i][1]] = '.';
					p[i]++;
				}
			}
			if (p[i] == 0 && y[i][0] == y[i][1]) {
				t = 1;
				for (j = min(x[i][0], x[i][1]) + 1; j < max(x[i][0], x[i][1]); j++)
					if (c[y[i][0]][j] != '.')
						t = 0;
				if (t == 1&&abs(x[i][0]-x[i][1])>1) {
					ans += 2;
					flag = 1;
					c[y[i][0]][x[i][0]] = '.';
					c[y[i][1]][x[i][1]] = '.';
					p[i]++;
				}
			}
		}
		if (flag == 0)
			break;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3392
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.nextLine();
		if(str.indexOf("A") != -1 && str.lastIndexOf("Z") != -1){
			System.out.println((str.substring((str.indexOf("A")),str.lastIndexOf("Z")+1)).length());
		}
	}
}

Measured memory_bytes: 25676
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using vvll = vector<vector<long long>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define rreps(i,n) for(int i = (int)(n); i > 0; i--)
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define call(x) (x).cbegin(), (x).cend()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
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 (b<a) {a=b; return 1;} return 0;}
const int INF = INT_MAX;
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};


void solve(int N, int M, vi &A, vpii &CB){
    sort(all(A));
    sort(rall(CB));
    int i = 0;
    bool flag = false;
    for(auto cb : CB) {
        rep(b, cb.second) {
            if (!(chmax(A[i], cb.first))) {
                flag = true;
                break;
            }
            i++;
            if (i >= N) {
                flag = true;
                break;
            }
        }
        if (flag) break;
    }
    sort(rall(A));
    ll ans = 0;
    rep(i, N) ans += A[i];
    cout << ans << endl;
}

int main(){
    int N;
    cin >> N;
    int M;
    cin >> M;
    vi A(N);
    for(int i = 0 ; i < N ; i++){
        cin >> A[i];
    }
    vpii CB(M);
    for(int i = 0 ; i < M ; i++){
        int b, c;
        cin >> b >> c;
        CB[i] = make_pair(c, b);
    }
    solve(N, M, A, CB);
    return 0;
}


Measured memory_bytes: 1408
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, K = in.nextInt
  val snukes = Array.fill(N)(false)

  (1 to K).foreach { k =>
    (1 to in.nextInt).foreach(_ => snukes(in.nextInt - 1) = true)
  }
  println(snukes.count(!_))
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100010


const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];



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

	REP(i,S.size()){
		if(S[i]=='?')S[i]='D';
	}

	cout << S << endl;
	
	return 0;
}
 



Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N, M;
    cin >> N >> M;
    priority_queue<i32, Vec<i32>> q;
    for (i32 i = 0; i < N; i++) {
        i32 A; cin >> A;
        q.push(A);
    }
    for (i32 i = 0; i < M; i++) {
        i32 max_v = q.top();
        q.pop();
        q.push(max_v / 2);
    }
    i64 sum = 0;
    while (!q.empty()) {
        sum += q.top();
        q.pop();
    }
    cout << sum << endl;
}


Measured memory_bytes: 3800
#include <stdio.h>
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int dp[60][60][110][2][2];
int check[60][60][110][2][2];
//dp[n][m][x][c][p];
//デッキのn,m枚目を次に使い、スタックにx枚積んであり、
//手番がcで、直前がパス(p?である:でない)
int a[60],b[60];

int calc(int n,int m,int x,int c){
	int ttt=0;
	int b0=0,b1=0;
	for(int i=0;i<x;i++){
		if(i%2==c){
			if(a[--n]==-1)b1=1;
			else if(!b0)ttt+=a[n];
		}else{
			if(b[--m]==-1)b0=1;
			else if(!b1)ttt-=b[m];
		}
	}
//	printf("%d %d %d %d %d\n",n,m,x,c,ttt);
	return ttt;
}


int N,M;
int f(int n,int m,int x,int c,int p){
	if(check[n][m][x][c][p]++)return dp[n][m][x][c][p];
	int temp;
	if(c==0){
		temp=-1e9;
		//テイク
		if(n<N)temp=max(temp,f(n+1,m,x+1,c^1,0));
		//パス
		//スタックの解消
		int ttt=calc(n,m,x,1);
		if(p)temp=max(temp,ttt);
		else temp=max(temp,ttt+f(n,m,0,c^1,!x));
	}else{
		temp=1e9;
		//テイク
		if(m<M)temp=min(temp,f(n,m+1,x+1,c^1,0));
		//パス
		//スタックの解消
		int ttt=calc(n,m,x,0);
		if(p)temp=min(temp,ttt);
		else temp=min(temp,ttt+f(n,m,0,c^1,!x));
	}
	return dp[n][m][x][c][p]=temp;
}

int main(){
	scanf("%d%d",&N,&M);
	for(int i=0;i<N;i++)scanf("%d",a+i);
	for(int i=0;i<M;i++)scanf("%d",b+i);	
	printf("%d\n",f(0,0,0,0,0));
}


Measured memory_bytes: 11056
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N;
    cin >> N;
    ll now = 0;

    ll t = 1;
    while(now < N){
        now += t;
        if(now >= N) break;
        t++;
        // if(now < N){
        //     now += t;
        // }else if(now > N){
        //     now -= t;
        // }
    }

    pr(t);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int i, j, n, ret = 0, d[50];

    scanf("%d", &n);
    for (i = 0; i < n; ++i){
        scanf("%d", &d[i]);
    }
    for (i = 0; i < n-1; ++i){
        for (j = i+1; j < n; ++j){
            ret += d[i] * d[j];
        }
    }
    printf("%d\n", ret);
    return 0;
}

Measured memory_bytes: 128
class UnionFind{
  treeset: {parent?:number, size:number}[];
  constructor(size){
      this.treeset=new Array(size);
      for(let i=0;i<size;i++){
        this.treeset[i]={size:1};
      }
  }
  union(x:number, y:number){
      const rootX=this.find(x);
      const rootY=this.find(y);
      if(rootX!=null && rootX==rootY){
          return;
      }else{
          const sizeX=this.size(x);
          const sizeY=this.size(y);
          if(sizeX>sizeY){
              this.treeset[rootY].parent = rootX;
              this.treeset[rootX].size += this.treeset[rootY].size;
          }else{
              this.treeset[rootX].parent = rootY;
              this.treeset[rootY].size += this.treeset[rootX].size;
          }
      }
  }
  //x should be root
  size(x:number){
      return this.treeset[x].size;
  }
  print(){
    for(let i=0;i<this.treeset.length;i++)
      console.log("i:%d parent:%d size:%d", i, this.treeset[i].parent, this.treeset[i].size);
      console.log();
    }
  find(x:number):number{
      let parent = this.treeset[x].parent;
      if(parent==null){
          return x;
      }else{
        const root = this.find(parent);
        this.treeset[x].parent=root;
        return root;
      }
  }
}
function encode(i,j,W){
  return i*W+j;
}
function decode(code,W){
  const j=code%W;
  const i=(code-j)/W;
  return [i,j];
}
function Main(raw: string) {
  const lines = raw.split("\n");
  const [firstLine, ...rest] = lines;
  const HW = firstLine.split(" ");
  const H = parseInt(HW[0], 10);
  const W = parseInt(HW[1], 10);
  const S = rest;

  //Test
  // const uf=new UnionFind(H*W);
  // uf.union(0,1);
  // uf.print();

  // Union Find
  const uf=new UnionFind(H*W);
  for(let i=0;i<H;i++)
    for(let j=0;j<W-1;j++){
      if(S[i][j]!=S[i][j+1]){
        uf.union(encode(i,j,W), encode(i,j+1,W));
      }
    }
  for(let i=0;i<H-1;i++)
    for(let j=0;j<W;j++){
      if(S[i][j]!=S[i+1][j]){
        uf.union(encode(i,j,W), encode(i+1,j,W));
      }
    }
  const collect = new Array(H*W);
  for(let i=0;i<H*W;i++){
    collect[i]={b:0, w:0};
  }
  for(let i=0;i<H;i++)
    for(let j=0;j<W;j++){
      if(S[i][j]=='#'){
        const root=uf.find(encode(i,j,W));
        const {b, w} = collect[root];
        collect[root] = {b:b+1, w};
      }else{
        const root=uf.find(encode(i,j,W));
        const {b, w} = collect[root];
        collect[root] = {b, w:w+1};
      }
    }
  const ans=collect.map(({b=0,w=0})=>
    b*w
  ).reduce((x,y)=>x+y,0);
  // 出力
  console.log("%d", ans);
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 60512
S = input()
if S == 'SUN':
	print(7)
elif S == 'MON':
	print(6)
elif S == 'TUE':
	print(5)
elif S == 'WED':
	print(4)
elif S == 'THU':
	print(3)
elif S == 'FRI':
	print(2)
elif S == 'SAT':
	print(1)
else:
  print(-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
   SPEED;
   int a,b,c,k;
   cin>>a>>b>>c>>k;
   if(a>=k)
   {
       cout<<k;
   }
   else if(a+b>=k)
   {
       cout<<a;
   }
   else
   {
       k-=(a+b);
       cout<<a-k;
   }
}

Measured memory_bytes: 3640
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
using namespace std;
typedef long long LL;
LL gi () {
    LL ret=0; char ch=getchar();
    while((ch<'0' || ch>'9') && ch!='-') ch=getchar();
    char c=ch=='-'?getchar():ch;
    while(c>='0' && c<='9') ret=ret*10+c-'0',c=getchar();
    return ch=='-'?-ret:ret;
}
const int N = 2000000 + 10;
const int mo = 1e9 + 7;
int n,x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6;
LL fac[N],ifc[N];
LL ksm (LL a,LL b) {
    LL ret = 1;
    while(b) {
        if(b&1) ret = ret * a %mo;
        a = a * a %mo; b >>= 1;
    }
    return ret;
}
LL calc (int x,int y) {
    return (fac[x+y+2] * ifc[x+1] %mo * ifc[y+1] %mo - 1) %mo;
}
LL calc1 (int i,int j) {
    return (calc(i-x1,j-y1) - calc(i-x1,j-y2-1) - calc(i-x2-1,j-y1) + calc(i-x2-1,j-y2-1)) %mo;
}
LL calc2 (int i,int j) {
    return (calc(x6-i,y6-j) - calc(x6-i,y5-j-1) - calc(x5-i-1,y6-j) + calc(x5-i-1,y5-j-1)) %mo;
}
int main () {
    x1 = gi(); x2 = gi(); x3 = gi(); x4 = gi(); x5 = gi(); x6 = gi();
    y1 = gi(); y2 = gi(); y3 = gi(); y4 = gi(); y5 = gi(); y6 = gi();
    fac[0] = 1;
    for(int i=1;i<N;i+=1) fac[i] = fac[i-1] * i %mo;
    ifc[N-1] = ksm(fac[N-1],mo-2);
    for(int i=N-2;i>=0;i-=1) ifc[i] = ifc[i+1] * (i+1) %mo;
    LL ans = 0;
    for(int x=x3;x<=x4;x+=1) {
        ans = (ans + (-x-y3) * calc1(x,y3-1) %mo * calc2(x,y3) %mo) %mo;
        ans = (ans + (x+y4+1) * calc1(x,y4) %mo * calc2(x,y4+1) %mo) %mo;
    }
    for(int y=y3;y<=y4;y+=1) {
        ans = (ans + (-y-x3) * calc1(x3-1,y) %mo * calc2(x3,y) %mo) %mo;
        ans = (ans + (y+x4+1) * calc1(x4,y) %mo * calc2(x4+1,y) %mo) %mo;
    }
    cout << (ans+mo) %mo;
    return 0;
}


Measured memory_bytes: 31488
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll h,w,n;
    std::cin >> h>>w>>n;
    map<pair<ll,ll>,ll> m;
    for (int i = 0; i < n; i++) {
        ll a,b;
        std::cin >> a>>b;
        for (int j = -1; j < 2; j++) {
            for (int k = -1; k < 2; k++) {
                if(2<= a+j && a+j <= h-1 && 2<= b+k && b+k <= w-1){
                    m[{a+j,b+k}]++;
                }
            }
        }
    }
    ll count[10];
    Fill(count,0);
    for (auto e : m) {
        count[e.second]++;
    }
    count[0] = (h-2)*(w-2)-m.size();
    for (int i = 0; i < 10; i++) {
        std::cout << count[i] << std::endl;
    }
    
}


Measured memory_bytes: 56448
julia -En,s=`tr '
' ,`1";A=3n;f(b,n)=n<b?n:f(b,n÷b)+n%b;g(b)=A>b>1&&f(b,n)==s?b:A;A=g(n+1);for b=1:isqrt(n);A=g(b);A=g((n-s)÷b+1);end;A>2n?-1:A"

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

int main() {
    ll m, g, a[10], b[10], dp[2005]{};
    while(cin >> m, m){
        for(int i=0;i<m;i++){
            cin >> a[i] >> b[i];
        }
        fill(dp, dp+1005, 0);
        dp[0] = 1;
        for(int j=0;j<m;j++){
            for(int i=1000;i>=0;i--){
                for(int k=1;k<=b[j];k++){
                    dp[i+a[j]*k] += dp[i];
                }
            }
        }
        cin >> g;
        for(int i=0;i<g;i++){
            int n;
            cin >> n;
            cout << dp[n] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>

int main(void) {
	int i,j,H,W;

	do{
		scanf("%d %d",&H,&W);

		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				if(i==1||j==1||j==W||i==H){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		if(H!=0&&W!=0){
			printf("\n");
		}
	}while(H!=0&&W!=0);
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<int> a(n),b(1000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0){
            b[a[i]]++;b[a[i]+1]++;
        }
        else{b[a[i]-1]++;b[a[i]]++;b[a[i]+1]++;}
    }
    sort(b.begin(),b.end());
    cout<<b[b.size()-1]<<endl;
    return 0;
}

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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n,m;
  cin >> n >> m;

  vector<ll> aVec(n);
  for(int i=0;i<n;i++){
    cin >> aVec[i];
  }
  sort(aVec.begin(),aVec.end());

  ll b,c;
  priority_queue<pair<ll,ll>> d;
  for(int i=0;i<m;i++){
    cin >> b >> c;
    d.push(make_pair(c,b));
  }  
  
  ll total = 0;
  int i = 0;
  pair<ll,ll> currentD = d.top();
  while(i<n){
    if(!d.empty() && currentD.first>aVec[i]){
      currentD.second--;
      total += currentD.first;
      if(currentD.second == 0){
        d.pop();
        currentD = d.top();
      }
    }
    else{
      total += aVec[i];
    }
    i++;
  }

  cout << total << endl;
  return 0;
}



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

int main() {
    int cnt[2] = {};
    for(int i=0; i<3; ++i) {
        int a;
        cin >> a;
        if(a == 5) {
            cnt[0]++;
        } else if(a == 7) {
            cnt[1]++;
        }
    }
    if(cnt[0] == 2 && cnt[1] == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long f[1000],n;
int main()
{
    cin>>n;
    f[0]=2;
    f[1]=1;
    for(int i=2;i<=n*2;i++)
    {
        f[i]=f[i-1]+f[i-2];
    }
    cout<<f[n];
    return 0;
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    ll dp[100001];
    for(int i=0;i<100001;i++)
        dp[i]=10000000000;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=min(n-1,i+k);j++){
            dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
        }
    }
    cout<<dp[n-1];
}



Measured memory_bytes: 1408
#!/usr/bin/env python3

import sys
import heapq

def main():
    input = sys.stdin.readline
    n = int(input())
    adjs = [[] for i in range(n)]
    for i in range(n - 1):
        a, b, c = map(int, input().split())
        adjs[a - 1].append((b - 1, c))
        adjs[b - 1].append((a - 1, c))
    q, k = map(int, input().split())

    # Dijkstra
    dist = [None] * n
    dist[k - 1] = 0
    hq = [(0, k - 1)]
    queued = [False] * n
    queued[k - 1] = True
    while hq:
        d, j = heapq.heappop(hq)
        dist[j] = d
        for j2, d2 in adjs[j]:
            if queued[j2]:
                continue
            heapq.heappush(hq, (d + d2, j2))
            queued[j2] = True

    # For each query
    for i in range(q):
        x, y = map(int, input().split())
        print(dist[x - 1] + dist[y - 1])

if __name__ == "__main__":
    main()


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

typedef unsigned long long ull;

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

int main(){
    int n;
    while(cin >> n, n){
        int ans = 100000;
        rep(i, 26){
            rep(j, 21){
                rep(k, 11){
                    int cost = i*380 + j*550 + k*850 - (i/5)*5*0.2*380 - (j/4)*4*0.15*550 - (k/3)*3*0.12*850;
                    int weight = i*200 + j*300 + k*500;
                    if(weight == n) ans = min(ans, cost);
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <limits.h>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

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


Measured memory_bytes: 19228
def main():
    n = int(input())
    x = list(map(int, input().split()))
    l = int(input())
    q = int(input())
    ab = [list(map(lambda x:int(x)-1, input().split())) for _ in [0]*q]
    doubling = [[] for _ in [0]*n]
    j = 0
    for i in range(n):
        while j < n:
            if x[j]-x[i] > l:
                doubling[i].append(j-1)
                break
            else:
                j += 1
    for i in range(n-1, -1, -1):
        if not doubling[i]:
            doubling[i].append(n-1)
        else:
            break
    for _ in range(16):
        for i in range(n):
            doubling[i].append(doubling[doubling[i][-1]][-1])
    for a, b in ab:
        if a > b:
            a, b = b, a
        ans = 0
        j = 16
        while j >= 0:
            if doubling[a][j] >= b:
                j -= 1
            else:
                a = doubling[a][j]
                ans += 2**j
        if a == b:
            print(ans)
        else:
            print(ans+1)


main()

Measured memory_bytes: 64964
#include <iostream>
#define INF 2000000000
using namespace std;
 
struct Card{
    char s;
    int n;
};
 
Card L[50002],R[50002];
 
void merge(Card a[],int l,int m,int r){
    int n1=m-l;
    int n2=r-m;
    for(int i=0;i<n1;i++)
        L[i]=a[l+i];
    for(int i=0;i<n2;i++)
        R[i]=a[m+i];
    L[n1].n=INF;
    R[n2].n=INF;
    int i=0,j=0;
    for(int k=l;k<r;k++){
        if(L[i].n<=R[j].n)
            a[k]=L[i++];
        else
            a[k]=R[j++];
    }
}
 
void mergesort(Card a[],int l,int r){
    if(l+1<r){
        int m=(l+r)/2;
        mergesort(a,l,m);
        mergesort(a,m,r);
        merge(a,l,m,r);
    }
}
 
int partition(Card a[],int p,int r){
    Card x=a[r],tmp;
    int i=p-1;
    for(int j=p;j<r;j++){
        if(a[j].n<=x.n){
            i++;
            swap(a[i],a[j]);
        }
    }
    i++;
    swap(a[i],a[r]);
    return i;
}
 
void quicksort(Card a[],int l,int r){
    if(l>=r)
        return ;
    int m=partition(a,l,r);
    quicksort(a,l,m-1);
    quicksort(a,m+1,r);
}
 
int main(){
    int n;
    Card a[100000],b[100000];
    cin>>n;
    for(int i=0;i<n;i++){
        char s[3];
        int x;
        cin>>s>>x;
        a[i].s=b[i].s=s[0];
        a[i].n=b[i].n=x;
    }
    mergesort(a,0,n);
    quicksort(b,0,n-1);
    bool f=true;
    for(int i=0;i<n;i++)
        if(a[i].s!=b[i].s){
            f=false;
            break;
        }
    cout<<(f?"Stable":"Not stable")<<endl;
    for(int i=0;i<n;i++)
        cout<<b[i].s<<' '<<b[i].n<<endl;
    return 0;
}


Measured memory_bytes: 5420
def insert(z):
    global root
    y = NIL
    x = root
    #print(x)
    while x != NIL:
        y = x
        if z < x:
            x = TL[x]
        else:
            x = TR[x]
    TP[z] = y

    if y == NIL:
        root = z
    elif z < y:
        TL[y] = z
    else:
        TR[y] = z


def inorder(u):
    if u == NIL:
        return
    inorder(TL[u])
    print(' ', end='')
    print(u, end='')
    inorder(TR[u])


def preorder(v):
    if v == NIL:
        return
    print(' ', end='')
    print(v, end='')
    preorder(TL[v])
    preorder(TR[v])


TR = {}
TL = {}
TP = {}
NIL = None
root = NIL
m = int(input())
data = [input().split() for _ in range(m)]
#print(data)
for i in data:
    if i[0][0] == 'i':
        TR[int(i[1])] = TL[int(i[1])] = NIL
        insert(int(i[1]))
    elif i[0][0] == 'f':
        if int(i[1]) in TR:
            print('yes')
        else:
            print('no')
    else:
        inorder(root)
        print()
        preorder(root)
        print()


Measured memory_bytes: 250940
using System;

namespace abc124_a
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力
            string[] input = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(input[0]);
            int b = Convert.ToInt32(input[1]);
            int max = 0;


            //ボタン処理
            for (int i = 0; i < 2; i++)
            {
                if (a >= b)
                {
                    max += a;
                    a--;
                }
                else
                {
                    max += b;
                    b--;
                }
            }
            //出力
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 11220
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
if m == 0:
    print(1)
    exit()
uf = UnionFind(n)
ans = 0
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
    ans = max(ans, uf.size(a-1))
print(ans)

Measured memory_bytes: 78164
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	string S, T, U;
	int A, B;
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;

	if(S==U) cout << A-1 << " " << B << endl;
	else cout << A << " " << B-1 << endl;

	return 0;
}


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

using namespace std;

bool e[21][21];

void solve()
{
	int n, m;
	cin >> m >> n;
	vector<int> in(m + 1);
	for (int i = 0; i < n; ++i)
	{
		int x, y;
		cin >> x >> y;
		e[y][x] = true;
		in[y]++;
	}
	for (int i = 0; i < m; ++i)
	{
		for (int j = 1; j <= m; ++j)
		{
			if (i != m - 1 && j == 2)
			{
				continue;
			}
			if (in[j] == 0)
			{
				cout << j << endl;
				in[j] = -1;
				for (int k = 1; k <= m; ++k)
				{
					if (e[k][j])
					{
						in[k]--;
					}
				}
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1192
//31
#include<iostream>

#define BY(I,J) ((I)/3*3+(J)/3)
#define BX(I,J) ((I)%3*3+(J)%3)

using namespace std;

int main(){
  int n;
  cin>>n;
  while(n--){
    int g[9][9];
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	cin>>g[i][j];
      }
    }
    bool dup[9][9]={{}};
    for(int i=0;i<9;i++){
      int cn[10]={};
      for(int j=0;j<9;j++){
	cn[g[i][j]]++;
      }
      for(int j=0;j<9;j++){
	dup[i][j]|=cn[g[i][j]]>1;
      }
    }
    for(int i=0;i<9;i++){
      int cn[10]={};
      for(int j=0;j<9;j++){
	cn[g[j][i]]++;
      }
      for(int j=0;j<9;j++){
	dup[j][i]|=cn[g[j][i]]>1;
      }
    }
    for(int i=0;i<9;i++){
      int cn[10]={};
      for(int j=0;j<9;j++){
	cn[g[BY(i,j)][BX(i,j)]]++;
      }
      for(int j=0;j<9;j++){
	dup[BY(i,j)][BX(i,j)]|=cn[g[BY(i,j)][BX(i,j)]]>1;
      }
    }
    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	cout<<((dup[i][j])?'*':' ')<<g[i][j];
      }
      cout<<endl;
    }
    if(n){
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
x=int(input())

 
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

while True:
  ans=is_prime(x)
  if ans==True:
    print(x)
    break
  x=x+1

Measured memory_bytes: 9172
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

int main() {

	int M;
	cin >> M;
	cout << 48 - M << endl;

	return 0;
}

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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pii pair<int, int>
#define pb emplace_back
#define pf emplace_front
#define mp make_pair
#define ld long double
#define all(x) (x).begin(), (x).end()

const int maxn = 309;
int n;
int c[maxn];

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    cout << "? ";
    for (int i = 0; i < n; i++)
        cout << i + 1 << " ";
    cout << endl;
    string s;
    cin >> s;
    bool t = (s[0] == 'R');
    int left = 0;
    int right = n;
    while (right - left > 1)
    {
        int j = (left + right) / 2;
        cout << "? ";
        for (int e = 0; e < n; e++)
            cout << j + e + 1 << " ";
        cout << endl;
        cin >> s;
        bool u = (s[0] == 'R');
        if (u != t)
            right = j;
        else
            left = j;
    }
    int y = right;
    set<int> r;
    set<int> b;
    for (int i = 0; i < 2 * n; i++)
    {
        if (i >= y && i - y < n - 1)
            continue;
        cout << "? ";
        cout << i + 1 << " ";
        for (int e = 0; e < n - 1; e++)
            cout << y + e + 1 << " ";
        cout << endl;
        cin >> s;
        if (s[0] == 'R')
            r.insert(i);
        else
            b.insert(i);
    }
    for (int i = 0; i < n - 1; i++)
    {
        cout << "? " << y + i + 1 << " ";
        auto w = r.begin();
        for (int e = 0; e < n / 2; e++)
        {
            cout << (*w) + 1 << " ";
            w++;
        }
        w = b.begin();
        for (int e = 0; e < n / 2; e++)
        {
            cout << (*w) + 1 << " ";
            w++;
        }
        cout << endl;
        cin >> s;
        if (s[0] == 'R')
            r.insert(y + i);
        else
            b.insert(y + i);
    }
    cout << "! ";
    for (int i = 0; i < 2 * n; i++)
    {
        if (r.find(i) == r.end())
            cout << "B";
        else
            cout << "R";
    }
    cout << endl;
}


Measured memory_bytes: 724
#include<stdio.h>
int main(void)
{
	int a,b,c,x,y,z;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b){
		x=b;
	}
	else{
		x=a;
	}
	if(x<c){
		y=c;
	}
	else{
		y=x;
	}
	z=a+b+c;
	if(z-y==y){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
long long a[1000010];
int main()
{
    int n;
    int x=1,ans=0;//x表示一个数出现的次数，赋值1
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0; i<n; i++)
    {
        if(a[i]==a[i-1])
            x=(x+1)%2;
        else
        {
            ans+=x;
            x=1;
        }
    }
    if(x%2)
        ans++;
    printf("%d",ans-1);

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int power[111][111];
int dp[111][3333];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	for(int i=1;i<=110;i++)
	{
		power[i][0]=1;
		for(int j=1;j<=100;j++) power[i][j]=mult(power[i][j-1],i);
	}
	int tot = mult(n, mult((k*(k+1))/2, power[k+1][n-1]));
	dp[n][0] = min(k+1, n); //add(power[k+1][n], (k==n?MOD-power[k+1][n-1]:0));
	dp[n][1] = (k==n?1:0); //(k==n?power[k+1][n-1]:0);
	if(k==n) tot = add(tot, MOD - power[k+1][n-1]);
	for(int i=n;i>=2;i--)
	{
		for(int j=0;j<3333;j++)
		{
			int v=dp[i][j];
			if(v==0) continue;
			for(int z=0;z<=k;z++)
			{
				if(z>i-1) dp[i-1][j] = add(dp[i-1][j], v);
				else 
				{
					dp[i-1][j+(z+j)/(i-1)] = add(dp[i-1][j+(z+j)/(i-1)], v);
					tot = add(tot, MOD - mult(power[k+1][i-2], mult(v, (z+j)/(i-1))));
				}
			}
		}
	}
	cout<<tot<<'\n';
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R;
    cin >> R;
    if (R < 1200)
    {
        cout << "ABC" << endl;
    }
    else if (R < 2800)
    {
        cout << "ARC" << endl;
    }
    else
    {
        cout << "AGC" << endl;
    }
    return 0;
}

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

int main(){
	int n,m;
	ll count;

	cin >> n >> m;
	if(n == 1 and m == 1)count = 1;
	else if(n == 1)count = m - 2;	
	else if(m == 1)count = n - 2;
	else count = ll(n - 2) * ll(m - 2);
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b) = get!(i32, i32);
    println!("{}", (a + b + 1) / 2);
}

Measured memory_bytes: 2080
#D
N, K = map(int,input().split())
A = list(map(int,input().split()))

now = 0
visited = [0]
visited_set = set([0])

for i in range(K):
    now = A[now] - 1
    if now in visited_set:
        break
    visited.append(now)
    visited_set.add(now)
if len(visited) == N:
    print(visited[K-1]+1)
else:    
    ind = visited.index(now)
    roop = visited[ind:]
    print(roop[(K-ind)%len(roop)]+1)

Measured memory_bytes: 35276
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int counter = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'o')
            ++counter;
    }
    cout << 700 + 100*counter << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

s = 0 # 累積和
ans1 = 0
# plus-minus-plus...
for i in range(n):
    s += a[i]
    if i%2==0:
        if s>0: continue
        else: 
            ans1 += abs(s-1)
            s = 1
    else: 
        if s<0: continue
        else: 
            ans1 += abs(s-(-1))
            s = -1

s = 0
ans2 = 0
# minus-plus...
for i in range(n):
    s += a[i]
    if i%2==1:
        if s>0: continue
        else: 
            ans2 += abs(s-1)
            s = 1
    else: 
        if s<0: continue
        else: 
            ans2 += abs(s-(-1))
            s = -1
            
print(min(ans1, ans2))

Measured memory_bytes: 14468