akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353
#define MAX 100000

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

using namespace std;

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; }

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

	ll A, B;
	cin >> A >> B;

	ll K = (A + B) / 2;

	if ((A + B) % 2 == 1) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << K << endl;
	}



	return 0;
}



Measured memory_bytes: 888
MOD = 10 ** 9 + 7
K = int(input())
M = len(input())
N = M + K

pow25 = [1] * (N + 1)
fac = [1] * (N + 1)
inv = [1] * (N + 1)
for x in range(1, N + 1):
    fac[x] = fac[x - 1] * x % MOD
    pow25[x] = pow25[x - 1] * 25 % MOD
inv[N] = pow(fac[N], MOD-2, MOD)
for x in range(N - 1, -1, -1):
    inv[x] = inv[x + 1] * (x + 1) % MOD

def binom(n, k):
    return fac[n] * inv[n - k] % MOD * inv[k] % MOD

ans = 0
for k in range(M, N + 1):
    ans += binom(N, k) * pow25[N - k] % MOD
    ans %= MOD
print(ans)


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

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

	int N;
	int i,j;
	int tmp;
	int answer;
	int counter=0;
	double ave;
	string S,T;
	vector<int> given;

	cin >> S >> T;

	cout << T << S << endl;

	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
//
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long blue = n/(a+b)*a;
		long rem = n%(a+b);
		blue += Math.min(a,rem );
		System.out.println(blue);
		
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		}
		//----------------------------------------
		//メソッド置き場
		
		//----------------------------------------
	}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
using ll = long long;

inline bool bit(ll x, int b) { return (x >> b) & 1; }

constexpr int SZ = 100000;
constexpr int prs = 10;
ll pre[1 << prs][SZ + 1];

int main() {
  int N;
  cin >> N;
  vector<int> V(N + 1), W(N + 1);
  REP(i, N) cin >> V[i + 1] >> W[i + 1];
  FOR(i, 1, min(N + 1, 1 << prs)) {
    if (i != 1) copy(pre[i / 2], pre[i / 2] + SZ + 1, pre[i]);
    for (int j = SZ; j >= W[i]; --j)
      pre[i][j] = max(pre[i][j], pre[i][j - W[i]] + V[i]);
    REP(j, SZ) pre[i][j + 1] = max(pre[i][j + 1], pre[i][j]);
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int v, L;
    cin >> v >> L;
    if (v < (1 << prs)) {
      cout << pre[v][L] << "\n";
    } else {
      int lvl = 32 - __builtin_clz(v) - prs;
      ll ans = 0;
      REP(b, 1 << lvl) {
        int w = 0;
        ll va = 0;
        REP(i, lvl) {
          if ((b >> i) & 1) {
            w += W[v >> i];
            va += V[v >> i];
          }
          if (w > L) break;
        }
        if (w <= L) ans = max(ans, pre[v >> lvl][L - w] + va);
      }
      cout << ans << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 804380
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int hikaku(const void *n1,const void *n2)
{
    return *(int*)n1-*(int*)n2;
}

int main()
{
    double a,b,h,m;
    scanf("%lf %lf %lf %lf",&a,&b,&h,&m);

    double th,tm,t;
    tm=2*m*atan(1)/15;
    m=m+60*h;
    th=m*atan(1)/90;
    t=(th-tm);
    if(t<0)
    {
        t=-t;
    }
    if(t>4*atan(1))
    {
        t=8*atan(1)-t;
    }

    double ans;
    ans=a*a+b*b-2*a*b*cos(t);
    ans=sqrt(ans);

    printf("%.30f\n",ans);

    return 0;
}

Measured memory_bytes: 2600
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<queue>
#include<vector>
#define LL long long
#define ULL unsigned long long
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define itn int
#define pritnf printf
#define mp make_pair
#define pb push_back
using namespace std;

int A,B,C;
int cnt[10];

int main(){
	cin>>A>>B>>C;
	cnt[A]++,cnt[B]++,cnt[C]++;
	if (cnt[5]==2&&cnt[7]==1){
		printf("YES");
	}
	else printf("NO");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
typedef double db;
const int M=1100,O=2e5+10;
const db PI=acos(-1.0);
int dx[128],dy[128],cnt,x,y,K,n,m,len,N,r[M],l;
char s[O];
struct cp{
    db r,i;
    cp(db a=0,db b=0):r(a),i(b){}
}a[M][M],b[M][M],c[M];
inline cp operator +(cp a,cp b){return cp(a.r+b.r,a.i+b.i);}
inline cp operator -(cp a,cp b){return cp(a.r-b.r,a.i-b.i);}
inline cp operator *(cp a,cp b){return cp(a.r*b.r-a.i*b.i,a.r*b.i+a.i*b.r);}
inline cp operator /(cp a,db b){return cp(a.r/b,a.i/b);}
void DFT(cp *a,int k){
    rep(i,0,N-1){
        r[i]=(i&1)?r[i^1]|(1<<l-1):r[i>>1]>>1;
        if(i<r[i]) swap(a[i],a[r[i]]);
    }
    for(int mid=1;mid<N;mid<<=1){
        cp wn(cos(PI/mid),k*sin(PI/mid));
        for(int R=mid<<1,j=0;j<N;j+=R){
            cp w(1,0),*l=a+j,*r=a+j+mid,x,y;
            for(int k=0;k<mid;++k,++l,++r,w=w*wn)
                x=*l,y=(*r)*w,*l=x+y,*r=x-y;
        }
    }
    if(k==-1) rep(i,0,N-1) a[i]=a[i]/N;
}
void DFT_2(cp a[M][M],int k){
    rep(i,0,N-1) DFT(a[i],k);
    //rep(i,0,N-1){rep(j,0,N-1) printf("%.8lf %.8lf ",a[i][j].r,a[i][j].i);puts("");}
    rep(i,0,N-1){
        rep(j,0,N-1) c[j]=a[j][i];DFT(c,k);
        rep(j,0,N-1) a[j][i]=c[j];
    }
}
void conv(){
    for(N=1,l=0;N<m;N<<=1,l++);
    DFT_2(b,1);
    DFT_2(a,1);
    //rep(i,0,N-1){rep(j,0,N-1) printf("%.8lf %.8lf ",a[i][j].r,a[i][j].i);puts("");}
    
    //rep(i,0,N-1){rep(j,0,N-1) printf("%.8lf %.8lf ",b[i][j].r,b[i][j].i);puts("");}
    rep(i,0,N-1) rep(j,0,N-1) a[i][j]=a[i][j]*b[i][j];
    //rep(i,0,N-1){rep(j,0,N-1) printf("%.8lf %.8lf ",a[i][j].r,a[i][j].i);puts("");}
    DFT_2(a,-1);
}
int main(){
    scanf("%d%d%d%d",&n,&m,&K,&len);
    rep(i,0,n-1){
        scanf("%s",s);
        rep(j,0,n-1) b[i][j].r=s[j]=='X';
    }
    scanf("%s",s+1);
    dx['U']=-1;dx['D']=1;dy['R']=1;dy['L']=-1;
    rep(i,1,len){
        x+=dx[s[i]];y+=dy[s[i]];
        a[x][y].r++;
    }
    conv();
    //rep(i,0,m-1){rep(j,0,m-1) printf("%d ",(int)a[i][j].r);puts("");}
    rep(i,0,m-1) rep(j,0,m-1) if(a[i][j].r+0.5>=K) ++cnt;
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 41648
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {-1, 0};
const int dx[] = {0, -1};
const int MAX_N = 80;
vector<vector<string>> memo(MAX_N, vector<string>(MAX_N));
int h, w;
bool IsNumber(char ch)
{
    if(ch >= 'A' && ch <= 'Z') return false;
    else return true;
};
string Cal(string s, string t)
{
    if(s.size() > t.size()) return s;
    else if(s.size() == t.size()) return max(s, t);
    else return t;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> w >> h, h | w)
    {
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                char ch;
                cin >> ch;
                memo[i][j] = ch;
            }
        }
        string ans = "";
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                if(!(IsNumber(memo[i][j][0]))) continue;
                string ms = "";
                for(int k = 0; k < 2; k++)
                {
                    int ny = i + dy[k];
                    int nx = j + dx[k];
                    if(ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
                    if(!(IsNumber(memo[ny][nx][0]))) continue;
                    if(memo[ny][nx][0] == '0' && memo[ny][nx].size() <= 1) continue;
                    ms = Cal(memo[ny][nx], ms);
                }
                memo[i][j] = ms + memo[i][j];
                ans = Cal(memo[i][j], ans);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3384
#include<iostream>
using namespace std;
int main(){
  int n;
  int i;
  int card[4][13]={{}};
  cin >> n;
  char a;
  int b;
  for(i=0;i<n;i++) {
    cin >> a >> b;
    switch(a){
    case 'S':
      card[0][b-1]=1;
      break;
    case 'H':
      card[1][b-1]=1;
      break;
    case 'C':
      card[2][b-1]=1;
      break;
    case 'D':
      card[3][b-1]=1;
      break;
    }
  }
  for(i=0;i<52;i++) {
    switch(i/13){
    case 0:
      if(card[0][i%13]==0) cout << "S " << i+1 << endl;
      break;
    case 1:
      if(card[1][i%13]==0) cout << "H " << i%13+1 << endl;
      break;
    case 2:
      if(card[2][i%13]==0) cout << "C " << i%13+1 << endl;
      break;
    case 3:
      if(card[3][i%13]==0) cout << "D " << i%13+1 << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int uf_par[112345], uf_rnk[112345];

void uf_init(int size)
{
    REP(i, size)
    {
        uf_par[i] = i;
        uf_rnk[i] = 0;
    }
}

int uf_find(int x)
{
    if (uf_par[x] == x)
        return x;
    else
        return uf_par[x] = uf_find(uf_par[x]);
}

void uf_unite(int x, int y)
{
    x = uf_find(x);
    y = uf_find(y);
    if (x == y)
        return;

    if (uf_rnk[x] < uf_rnk[y])
    {
        uf_par[x] = y;
    }
    else
    {
        uf_par[y] = x;
        if (uf_rnk[x] == uf_rnk[y])
            uf_rnk[x]++;
    }
}

bool uf_same(int x, int y)
{
    return uf_find(x) == uf_find(y);
}

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

    int n, m, p[112345];

    cin >> n >> m;
    REP(i, n)
    cin >> p[i];

    uf_init(n + 1);

    REP(i, m)
    {
        int x, y;
        cin >> x >> y;
        uf_unite(x, y);
    }

    int res = 0;
    REP(i, n)
    {
        res += uf_same(p[i], i + 1);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;

int main()  {
    fastio;
    int n ,  x , t;
    cin>>n>>x>>t;
    cout<<t*( (n-1)/x + 1)<<'\n';
    return 0;
    
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	vector<int>AA(N);
	rep(i, N) {
		AA[i] = A[i];
	}
	sort(A);
	vector<vector<int>>B;
	do {
		B.push_back(A);
	} while (next_permutation(A.begin(), A.end()));
	int it = 0;
	rep(i, B.size()) {
		if (B[i] == AA) {
			it = i;
		}
	}
	if (0 <= it - 1) {
		rep(i, N) {
			cout << B[it - 1][i];
			if (i != N - 1) {
				cout << ' ';
			}
			else {
				cout << endl;
			}
		}
	}
	rep(i, N) {
		cout << B[it][i];
		if (i != N - 1) {
			cout << ' ';
		}
		else {
			cout << endl;
		}
	}
	if (it + 1<B.size()) {
		rep(i, N) {
			cout << B[it + 1][i];
			if (i != N - 1) {
				cout << ' ';
			}
			else {
				cout << endl;
			}
		}
	}
}




Measured memory_bytes: 28320
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
    ll x,ans=0;
    cin>>x;
    ans+=1000*(x/500);
    x-=500*(x/500);
    ans+=5*(x/5);
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

void solve() {
  int d, g; cin >> d >> g;
  g /= 100;
  Graph G(d, vi(2));
  rep(i,d) rep(j,2) cin >> G[i][j];
  rep(i,d) G[i][1] /= 100;

  int ans = 1000;
  rep(tmp,(1<<d)) {
    bitset<10> s(tmp);
    int num = 0;
    int score = 0;

    rep(i,d) {
      if (s[i]) {
        num += G[i][0];
        score += (i+1) * G[i][0] + G[i][1];
      }
    }

    for (int i=d-1; i>=0; --i) {
      if (score >= g) break;
      if (!s[i]) {
        int lack = ((g-score) - 1) / (i+1) + 1;
        num += min(lack, G[i][0]);
        score += (i+1) * min(lack, G[i][0]);
      }
    }

    ans = min(ans, num);
  }

  cout << ans << endl;
  return;
}

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


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

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

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

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

    int mx = 0;
    for (int i = 0; i < n; i++)
        mx = max(mx, ans[i]);

    cout << mx << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a==4||a==6||a==9||a==11) a=2;
    else if(a==2) a=3;
    else a=1;
    if(b==4||b==6||b==9||b==11) b=2;
    else if(b==2) b=3;
    else b=1;
    if(a==b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 384
n,m,c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
for i in range(n):
    a = list(map(int, input().split()))
    ab = [aa*bb for aa,bb in zip(a,b)]
    if (sum(ab) + c) > 0:count+=1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long a, long long b){
    long long s = b - a;
    long long B = 0;
    for (int i = 0; i < s; i++) {
        B += i + 1;
    }
    std::cout << B - b << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long b;
    long long a;
    scanf("%lld",&a);
    scanf("%lld",&b);
    solve(a, b);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  //a = b * q + r
  //(k < b <= n)
  //(k <= r < b) (0 <= q <= n / b, a <= n)
  int a, b, q;
  long long ans = 0;
  for (int b = k+1; b <= n; b++){
    //max_q = n / b
    // (b-k) * (n /b +1 - 1)
    // b * max_q + r <= n, k <= r
    q = n / b;
    ans += (long long)(b - k) * q + max(0, (n - b*q - k + 1));
  }
  // a != 0, q == 0 && r == 0 not suitable
  if (k == 0){
    ans -= n;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
    int n,k,i,x,count;
    scanf("%d %d",&n,&k);
    for(i=0; i<n; i++){
        scanf("%d",&x);
        if(x<k-x){
            count+=2*x;
        }else{
            count+=(2*k-2*x);
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
fun main(args : Array<String> )  {
  val (h, w) = readLine()!!.split(" ").map { x -> x.toInt() }
  val strs = (1..h).map {
    val s = readLine()!!
    s
  }
  strs.zip(strs).map{ x ->
    x.toList()
  }.flatten()
  .map{ x ->
    println(x)
  }
}

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

int main(){
  while(1){
    int d, w, h;
    scanf("%d %d %d", &d, &w, &h);
    if(d==0 && w==0 && h==0)
      break;
    int n;
    scanf("%d", &n);
    
    int max = (int)fmax((double)d, fmax((double)w, (double)h));
    double a = sqrt(d*d+w*w+h*h-max*max) / 2;

    int i;
    for(i=0;i<n;i++){
      int b;
      scanf("%d", &b);
      //printf("a:%lf b:%d", a, b);
      if((double)b <= a)
	printf("NA\n");
      else
	printf("OK\n");
    }
  }
  return 0;
}

Measured memory_bytes: 2720
x,y=map(int,input().split())
A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
C=[2]
belong=[1,3,1,2,1,2,1,1,2,1,2,1]
print('Yes' if belong[x-1]==belong[y-1] else 'No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int a[10],b[10],c[10];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<=n;i++){
        c[i]=i;
    }
    int x=1,y=1,p=1;
    while(next_permutation(c+1,c+1+n)){
        int tag=0;p++;
        for(int i=1;i<=n;i++){
            if(a[i]!=c[i]){
                tag=1;
                break;
            }
        }
        if(!tag) x=p;
        tag=0;
        for(int i=1;i<=n;i++){
            if(b[i]!=c[i]){
                tag=1;
                break;
            }
        }
        if(!tag) y=p;
    }
    cout<<abs(x-y)<<endl;
}

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

using namespace std;


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

    int w[N+1];
    int v[N+1];
    int sum = 0;
    for(int i=1; i<=N; i++){
        cin >> w[i] >> v[i];
        sum += v[i];
    }


    long long int  dp[sum+1];
    memset(dp, 1000000005, sizeof(dp));
    dp[0] = 0;

    for(int i=1; i<=N; i++){
        for(int j=sum; j>=v[i]; j--){
            dp[j] = min(dp[j], w[i] + dp[j - v[i]]);
        }
    }

    int ans = INT32_MIN;
    for(int i=1; i<=sum; i++){
        if(dp[i] <= W && ans <= i){
            ans = i;
        }
    }

    cout << ans << "\n";


    return 0; 
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a[105],b[105];
int main()
{
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    int p=-200,k=200;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        p=max(p,a[i]);
    }
    for(int i=0;i<m;i++)
    {
        cin>>b[i];
        k=min(b[i],k);
    }
    int flag=1;
    for(int i=x+1;i<=y;i++)
    {
        if(p<i&&k>=i)
        {
            flag=0;break;
        }
    }
    if(flag) printf("War\n");
    else printf("No War\n");
}


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

int main(){
string s,t;
cin >> s >> t;
bool can = true;
for (int i = 0;i < s.size();i++){
    if(t[i]!=s[i]) can = false;
}
if(can) cout << "Yes" << endl;
else cout << "No" << endl;

}



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

#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int;  // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    pair<ll, ll> a = make_pair(i, 0);
    while ((n % i) == 0) {
      n /= i;
      a.second += 1;
    }
    p.push_back(a);
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) {
    u += MOD;
  }
  return u;
}
// 順列
ll permutation(const ll n, const ll m) {
  ll result = 1;
  for (ll i = n; i > n - m; i--) {
    result = (result * i) % MOD;
  }
  return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
  if (x == 0) return 1;
  ll res = repeat_square(n, x / 2);
  res = res * res % MOD;
  if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
  ll p = permutation(n, m);
  ll div = 1;
  for (ll i = 2; i <= m; i++) {
    div = (div * i) % MOD;
  }
  return (p * modinv(div)) % MOD;
}

// アルファベットの取得
string get_alphabet(ll n) {
  n--;
  return string(1, 'a' + (n % 26));
}

// int main() {
//   int N;
//   ll K;
//   cin >> N >> K;
//   vector<ll> x(100001, 0);

//   rep(i, N) {
//     int a, b;
//     cin >> a >> b;
//     x[a] += b;
//   }

//   int ans = 0;
//   rep(i, 1, x.size()) {
//     cout << K << ", " << x[i] << endl;
//     if (K <= x[i]) {
//       ans = i;
//       break;
//     }

//     K -= x[i];
//   }
//   cout << ans << endl;
//   return 0;
// }


int main() {
  int N;
  ll K;
  cin >> N >> K;
  map<int, ll> n;

  rep(i, N) {
    int a, b;
    cin >> a >> b;
    n[a] += b;
  }

  int ans = 0;
  for(auto itr: n) {
    if (K <= itr.second) {
      ans = itr.first;
      break;
    }

    K -= itr.second;
  }

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

Measured memory_bytes: 7584
from collections import deque

N, Q = map(int, input().split())
names = []
tasks = []

for i in range(N):
    name, task = input().split()
    names.append(name)
    tasks.append(int(task))

names_q = deque(names)
task_q = deque(tasks)

time = 0
while(len(task_q) > 0):
    name = names_q.popleft()
    task = task_q.popleft()
    if task <= Q:
        time += task
        print(name, time)
    else:
        time += Q
        task -= Q
        names_q.append(name)
        task_q.append(task)


Measured memory_bytes: 10680
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort()
ans = 0
t = 1
for i in range(1,n):
    if a[i]!=a[i-1]:
        if t%2 == 1:
            ans += 1
        t = 1
    else :
        t += 1
if t%2 == 1:
    ans += 1
print(ans)


Measured memory_bytes: 7448
#include<iostream>
#include<string>
using namespace std;
 
int main() {
	string a, b, c; cin >> a >> b >> c;
 
	a[0] -= 32;
	b[0] -= 32;
	c[0] -= 32;
 
	cout << a[0] << b[0] << c[0];
	return 0;
}

Measured memory_bytes: 256
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
#n = int(input())
#n, x, t = map(int, sys.stdin.readline().split())
n = input()
#p = list(map(int, sys.stdin.readline().split()))

a = 0

for i in range(len(n)):
    a += int(n[i])

if a % 9 == 0:
    print("Yes")
else:
    print("No")
    






Measured memory_bytes: 10144
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def main():
    N = ii()
    ans = 'No'
    c = 0
    for _ in range(N):
        a, b = mis()
        if a == b:
            c += 1
            if c >= 3:
                ans = 'Yes'
        else:
            c = 0
    print(ans)






main()



Measured memory_bytes: 9996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <list>

using namespace std;

int main() {
    int r, g, b;
    cin >> r >> g >> b;

    int a = r * 100 + g * 10 + b;


    std::cout << (a % 4 == 0 ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
import math
def modpow(a,b,MOD):
    if b == 0:
        return 1
    if b%2:
        return a*modpow(a**2%MOD,b//2,MOD)%MOD
    else:
        return modpow(a**2%MOD,b//2,MOD)
def modinv(a,MOD):
    return modpow(a,MOD-2,MOD)
def modcomb(n,r,MOD):
    return math.factorial(n)%MOD*modinv(math.factorial(r),MOD)%MOD*modinv(math.factorial(n-r),MOD)%MOD

MOD=10**9+7
n,k=map(int,input().split())
for i in range(1,k+1):
    if n-k+1<i:print(0)
    else:print((modcomb(n-k+1,i,MOD)*modcomb(k-1,k-i,MOD))%MOD)

Measured memory_bytes: 3316
#include<iostream>
#include<list>
#include<algorithm>
#include<vector>
#include<math.h>
#include<iterator>
#include<ctype.h>
using namespace std;
int main() 
{
	int n, k, i, sum=0;
	cin>>n>>k;
	vector<int>a(n);
	for(i=0;i<n;i++) 
	cin>>a[i];
	sort(a.begin(),a.end()) ;
	for(i=0;i<k;i++) 
	sum+=a[i];
	cout<<sum<<endl;
  return 0;
} 


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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

using Graph = vector<vector<int>>;
using mint = modint<(int)1e9+7>;

int subtree_size(const Graph& G, int v, int p, vector<int> &S){
  for(auto v_ : G[v]){
    if(v_ == p) continue;
    S[v] += subtree_size(G,v_,v,S);
  }
  ++S[v];
  return S[v];
}

template<typename T>
T power(T x, long long k){
  T ret{1};
  while(k > 0){
    if(k&1) ret *= x;
    x *= x;
    k /= 2;
  }
  return ret;
}

mint dfs(const Graph& G, int v, int p, const vector<int> &S, int s){
  mint ret(0);
  int sum = 0;
  vector<int> T;
  for(auto v_ : G[v]){
    if(v_ == p) continue;
    sum += S[v_];
    T.push_back(S[v_]);
  }
  sum += s;
  T.push_back(s);
  mint one(1);
  ret += one/2;
  for(auto t : T){
    int s_ = sum - t;
    ret -= (one-power(one/2,t))*power(one/2,s_+1);
  }
  ret -= power(one/2,sum+1);
  for(auto v_ : G[v]){
    if(v_ == p) continue;
    int s_ = sum - S[v_] + 1;
    ret += dfs(G,v_,v,S,s_);
  }
  return ret;
}

int main(){
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for(int i = 1; i < N; ++i){
    int a, b;
    cin >> a >> b;
    --a,--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> S(N);
  subtree_size(G,0,-1,S);
  mint ans = dfs(G,0,-1,S,0);
  cout << ans << endl;
}


Measured memory_bytes: 36480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main(){
  int N,C;
  cin>>N;
  int X[200010]={0};
  ll Y[200010]={0};
  rep(i,N){
    cin>>C;
    if(X[C]&&(X[C]!=i)) Y[i-1]=X[C];
    X[C]=i+1;
  }
  for(int i=2;i<200010;i++){
    if(Y[i]==0) Y[i]=Y[i-1];
    else if(Y[i]==1) Y[i]=(Y[i-1]+1)%1000000007;
    else Y[i]=(Y[i-1]+Y[Y[i]-2]+1)%1000000007;
  }
  cout<<Y[200000]+1<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
char G[305][305];
int output[305][305];
int main() {
	int m;
	vector<int> a(2);
	scanf("%d%d%d", &a[0], &a[1], &m);
	vector<vector<int>> C;
	for (int i = 0; i < a[0]; ++i) {
		scanf("%s", G[i]);
		for (int j = 0; j < a[1]; ++j)
			if (G[i][j] == '#') {
				C.push_back({i + 1, j + 1});
			}
	}
	assert(C.size() == m);
	vector<vector<pair<int, int>>> ans(m);
	function<void(vector<int>, vector<pair<int, int>>)> solve = [&](vector<int> ids, vector<pair<int, int>> range) {
		if (range.size() == 2) {
			assert(ids.size() == 1);
			ans[ids[0]] = range;
			return;
		}
		map<int, vector<int>> xs;
		for (int i : ids) {
			xs[C[i][range.size()]].push_back(i);
		}
		int lastx = xs.rbegin()->first;
		int las = 0;
		for (auto& x : xs) {
			pair<int, int> v = {las + 1, x.first == lastx ? a[range.size()] : x.first};
			auto nrange = range;
			nrange.push_back(v);
			solve(x.second, nrange);
			las = x.first;
		}
	};
	vector<int> ids(m);
	iota(ids.begin(), ids.end(), 0);
	solve(ids, {});
	int v = 1;
	for (auto& x : ans) {
		for (int i = x[0].first - 1; i < x[0].second; ++i)
			for (int j = x[1].first - 1; j < x[1].second; ++j)
				output[i][j] = v;
		++v;
	}
	for (int i = 0; i < a[0]; ++i) {
		for (int j = 0; j < a[1]; ++j)
			printf("%d ", output[i][j]);
		printf("\n");
	}
}


Measured memory_bytes: 12976
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
//ll MOD = 1000000007;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int M,D;
int main(){
	cin>>M>>D;
	int ans=0;
	for(int i=22;i<=D;i++){
		int x=i/10;
		int y=i%10;
		if(y>=2&&x*y<=M)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

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

  vector<int> A(N + 1);
  vector<int> diff(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  A[N] = A[0] + K;
  for (int i = 0; i < N; i++) {
      diff[i] = A[i + 1] - A[i];
  }
  double max = *max_element(diff.begin(), diff.end());
  cout << K - int(max) << endl;
}


Measured memory_bytes: 1792
#coding: utf-8

n = int(input())
for i in range(n):
    R = int(input())
    if i == 0:
        minR = R
    elif i == 1:
        maxP = R - minR
    if i >= 1:
        maxP = max(maxP, R - minR)
    minR = min(minR, R)
print(maxP)


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

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

Measured memory_bytes: 256
n = STDIN.gets.to_i
array = STDIN.gets.split.map(&:to_i)
puts array.join(' ')

for i in 1..(n-1) do
  v = array[i]
  j=i-1
  while (j>=0 && array[j] > v) do
    array[j+1] = array[j]
    j-=1
  end
  array[j+1] = v
  puts array.join(' ')
end

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

int64_t myadd(int64_t a, int64_t b) {
  int64_t a_ = a % 1000000007;
  int64_t b_ = b % 1000000007;
  return ( a_ + b_ ) % 1000000007;
}

int64_t myprod(int64_t a, int64_t b) {
  int64_t a_ = a % 1000000007;
  int64_t b_ = b % 1000000007;
  return ( a_ * b_ ) % 1000000007;
}

int64_t myfact(int64_t n) {
  if ( n == 1 ) {
    return 1;
  }
  return myprod(n, myfact(n-1));
}

int main() {
  //input
  int64_t N;
  string S;
  cin >> N >> S;
  //calc
  int64_t answer;  
  if ( S.at(0) == 'W' ) {
    answer = 0;
  }
  else {
    vector<int64_t> r_index(0);
    int64_t l = 0;
    int64_t r = 0;
    vector<int64_t> l_count(2*N);
    vector<int64_t> r_count(2*N);
    bool is_left = true;
    char pre_c = '_';
    char c;
    rep(i,2*N) {
      c = S.at(i);
      if ( c == pre_c ) {
        is_left = !is_left;
      }
      l_count.at(i) = l;
      r_count.at(i) = r;
      if ( is_left ) {
        l++;
      }
      else {
        r_index.push_back(i);
        r++;
      }
  //    cout << "(" << l << "," << r << ")" << endl;
      pre_c = c;
    }
    if ( l == r ) {
      int64_t base = 1;
      for(auto i : r_index) {
        base = myprod(base, l_count.at(i) - r_count.at(i));
      }
      answer = myprod(base, myfact(N));
    }
    else {
      answer = 0;
    }
  }
  //output
  cout << answer << endl;
}

Measured memory_bytes: 6008
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

ll n;
string a;
vector<string> ans;
string c = "abcdefghijklm";
void func(ll cnt, string s){
    if(cnt<n){
        ll MAX = 0;
        for(ll i = 0; i < s.length(); i++){
            char b = s[i];
            ll d = b-97;
            MAX = max(MAX, d);
        }
        for(ll i = 0; i <= MAX+1; i++){
            string t = s + c[i];
            func(cnt+1, t);
        }
    }
    else if(cnt==n)
        ans.push_back(s);
}

int main(void) {
    cin >> n;
    a = 'a';
    func(1, a);
    sort(ans.begin(), ans.end());
    for(ll i = 0; i < ans.size(); i++)
        cout << ans[i] << endl;
    return 0;
}


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

int main() {
    int K, N;
    cin >> K >> N;
    vector<int> v(N);
    rep(i,N) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    int maxi = 0;
    rep(i,N-1) {
        if (v[i + 1]  - v[i] > maxi) {
            maxi = v[i + 1]  - v[i];
        }
    }
    if (v[0] + K - v[N-1] > maxi) {
        maxi = v[0] + K - v[N-1];
    }
    cout << K - maxi << endl;
    return 0;
}


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

int main() {

	int N;
	int a[110];
	int tmp;

	cin >> N;
	for (int i = 1; i <= N; i++) {

		cin >> a[i];
		
	}

	for (int i = 1; i < N; i++) {

		for (int j = i + 1; j <= N; j++) {

			if (a[i] < a[j]) {

				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;

			}

		}

	}

	cout << a[1] - a[N] << endl;
	
	return 0;
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int h, w; cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  vector<pair<int, int>> black;
  for(int i=0;i<h;++i) {
    for(int j=0;j<w;++j) {
      char tmp; cin >> tmp;
      a[i][j] = (tmp == '#') ? 1 : 0;
    }
  }

  vector<vector<int>> d(h, vector<int>(w, INT_MAX));

  for(int i=0;i<h;++i) {
    int dist = 0;
    for(int j=0;j<w;++j) {
      if(j == 0) while(j < w && a[i][j] == 0) j++;
      if(j == w) break;
      if(a[i][j] == 0) {
        dist++;
        d[i][j] = min(d[i][j], dist);
        
      } else {
        dist = 0;
      }
    }
    for(int j=w-1;j>=0;--j) {
      if(j == w-1) while(j >= 0 && a[i][j] == 0) --j;
      if(j == -1) break;
      if(a[i][j] == 0) {
        dist++;
        d[i][j] = min(d[i][j], dist);
        
      } else {
        dist = 0;
      }
    }
  }

  for(int j=0;j<w;++j) {
    int dist = 0;
    for(int i=0;i<h;++i) {
      if(i == 0) while(i < h && a[i][j] == 0) i++;
      if(i == h) break;
      if(a[i][j] == 0) {
        dist++;
        d[i][j] = min(d[i][j], dist);
      } else {
        dist = 0;
      }
    }
    for(int i=h-1;i>=0;--i) {
      if(i == h-1) while(i >= 0 && a[i][j] == 0) --i;
      if(i == -1) break;
      if(a[i][j] == 0) {
        dist++;
        d[i][j] = min(d[i][j], dist);
        
      } else {
        dist = 0;
      }
    }
  }

  for(int i=0;i<h;++i) {
    for(int j=0;j<w-1;++j) {
      if(a[i][j] == 0 && d[i][j] != INT_MAX) d[i][j+1] = min(d[i][j+1], d[i][j]+1);
    }
    for(int j=w-1;j>=1;--j) {
      if(a[i][j] == 0 && d[i][j] != INT_MAX) d[i][j-1] = min(d[i][j-1], d[i][j]+1);
    }
  }

  for(int j=0;j<w;++j) {
    for(int i=0;i<h-1;++i) {
      if(a[i][j] == 0 && d[i][j] != INT_MAX) d[i+1][j] = min(d[i+1][j], d[i][j]+1);
    }
    for(int i=h-1;i>=1;--i) {
      if(a[i][j] == 0 && d[i][j] != INT_MAX) d[i-1][j] = min(d[i-1][j], d[i][j]+1);
    }
  }
/* 
  for(int i=0;i<h;++i) {
    printv(a[i]);
  }

  for(int i=0;i<h;++i) {
    printv(d[i]);
  } */

  int ma = 0;
  for(int i=0;i<h;++i) {
    for(int j=0;j<w;++j) {
      if(a[i][j] == 0) {
        ma = max(ma, d[i][j]);
      }
    }
  }
  cout << ma << endl;



}


Measured memory_bytes: 8256
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main(void){
	string a;
	unsigned int n,x;
	cin>>n;
	while(n--){
		cin>>a;
		sort(a.begin(),a.end());
		x=atoi(a.c_str());
		reverse(a.begin(),a.end());
		cout<<atoi(a.c_str())-x<<"\n";
	}
} 

Measured memory_bytes: 1220
def gcd(_a, _b):
    if _b == 0:
        return _a
    return gcd(_b, _a % _b)


if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

    if max(A) < K:
        print("IMPOSSIBLE")
    elif K in A:
        print("POSSIBLE")
    else:
        tmp = -1
        min_value = min(A)
        for i in range(0, N):
            tmp = gcd(min_value, A[i])
            if tmp == 1:
                break
        if tmp == 1:
            print("POSSIBLE")
        elif K % tmp == 0:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")


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

int main() {
  int N, K;
  cin >> N >> K;
  int64_t H[N];
  int64_t ans = 0;
  for(int i=0; i<N; i++) {
      cin >> H[i];
  }
  sort(H, H + N, greater<int64_t>());
  if(N <= K) ans = 0;
  else{
      for(int i=K; i<N; i++) {
          ans += H[i];
      }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int k, a, b;
	cin >> k >> a >> b;

	if( a % k == 0 || b % k == 0 ) cout << "OK" << endl;
	else if( (a / k + 1) * k <= b ) cout << "OK" << endl; 
	else cout << "NG" << endl;
	
	return 0;
}


Measured memory_bytes: 3636