akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

int n,m;
ll dp[2020][2020];
ll sum[2020][2020];
int S[2020],T[2020];


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    REP(i,n) cin>>S[i];
    REP(i,m) cin>>T[i];
    REP(i,2020) sum[i][0]=sum[0][i]=1;
    ll ret = 1;
    REP(x,n) REP(y,m){
        if(S[x]==T[y]){
            dp[x+1][y+1]=(sum[x][y])%MOD;
            ret += dp[x+1][y+1];
        }
        sum[x+1][y+1] = (sum[x][y+1]+sum[x+1][y]+MOD-sum[x][y]+dp[x+1][y+1])%MOD;
    }
    cout<<ret%MOD<<endl;
}

Measured memory_bytes: 63744
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#define my_max zhi5968
typedef long long ll;
using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	if(a+b==15)
		cout<<"+"<<endl;
	else if(a*b==15)
		cout<<"*"<<endl;
	else
		cout<<"x"<<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 rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n;
ll a[100000];

// 偶数番目の要素をtと同符号に、奇数番目を異符号に調整する
ll calc(ll t) {
	ll res = 0, sum = 0;
	for (int i = 0; i < n; ++i, t=-t) {
		sum += a[i];
		if (sum*t>0) continue;
		res += abs(sum-t);
		sum += t*abs(sum-t);
	}
	return res;
}

int main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	
	ll ans = min(calc(1), calc(-1));
	cout << ans << ln;
}

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

using namespace std;

#define all(a) a.begin(), a.end()
#define pi acos(-1)
#define eps 1e-6
#define inf 1e14

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy[8] = {-1, 0, 1, -1, 1, 0, 1, -1};
const int maxn = 2 * 1e5;
const int mod = 1e9 + 7;
const int maxa = 2 * 1e5;

int mul(int a, int b) { return a * 1LL * b % mod;}
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b;}
int sub(int a, int b) { return a >= b ? a - b : a - b + mod;}
int pow(int a, int k)
{
    int res = 1;
    while (k)
    {
        if (k % 2) res = mul(res, a);
        a = mul(a, a);
        k /= 2;
    }

    return res;
}

int inv(int a)
{
    return pow(a, mod - 2);
}

int dp[maxn], n, h[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> h[i];

    for (int i = 1; i < n; ++i)
    {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        if (i > 1)
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    
    cout << dp[n - 1];
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define maxn 200005
#define LL long long
using namespace std;

int n,k;
int mAp[maxn];
char s[maxn];
int w[3];
int nxt(int x){ return (x+1)%3; }

int main(){
	scanf("%d%d%d%d%d",&n,&k,&w[0],&w[2],&w[1]);
	mAp['r']=0,mAp['p']=1,mAp['s']=2;
	scanf("%s",s);
	for(int i=0;i<n;i++) s[i]=mAp[s[i]];
	int ans = 0;
	for(int i=0;i<k;i++){
		int tot = 0;
		for(int j=i;j<n;j+=k){
			tot++;
			if((j+k>=n) || (s[j] ^ s[j+k])) ans += w[nxt(s[j])] * ((tot + 1) / 2) , tot = 0;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read()
{
    char ch=getchar();
    ll 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 gcd(int x,int y)
{
    int z=x%y;
    while(z)
    {
        x=y;
        y=z;
        z=x%y;
    }
    return y;
}
int main()
{
    ll ans=0;
    int n,i,j,k,t;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
        	t=gcd(i,j);
        	for(k=1;k<=n;k++)
                ans+=gcd(t,k);
		}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define LL long long
#define MAXN 100000
#define INF 1000000000
int n,a,b,ans,p[MAXN+5];
int main()
{
	scanf("%d%d",&n,&a);
	for(int i=1;i<=n;i++){
		scanf("%d",&b);
		ans+=(b>=a);
	}
	printf("%d ",ans);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){

    int N,a,b,i,k;
    int c,v,w,x,y,z;
    
    k=0;

    scanf("%d%d%d",&N,&a,&b);

    for(i=1;i<=N;i++){
        v=(int)(i/10000)*10000;
        w=(int)((i-v)/1000)*1000;
        x=(int)((i-v-w)/100)*100;
        y=(int)((i-v-w-x)/10)*10;
        z=i-v-w-x-y;
        c=v/10000+w/1000+x/100+y/10+z;

        if(c>=a && c<=b){
            k+=i;
        }

    }

    printf("%d\n",k);
    return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


A, B = MI()
print((A + B) % 24)

Measured memory_bytes: 38512
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll N,K,S;cin>>N>>K>>S;

    if(S==1e9){
        REP(i,K)cout<<S<<" ";
        REP(i,N-K)cout<<1<<" ";
        cout<<"\n";
    }
    else{
        REP(i,K)cout<<S<<" ";
        REP(i,N-K)cout<<S+1<<" ";
        cout<<"\n";
    }
}

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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"
#define MOD 1000000000+7
#define forit(v) for(auto it = v.begin(); it != v.end(); ++it)

using namespace std;

int f(int m) {
  int tmp = 0;
  while (m >= 10) {
    tmp += m % 10;
    m /= 10;
  }
  tmp += m % 10;
  return tmp;
}

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

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  // flag = true;

  int n, a, b; cin >> n >> a >> b;

  for (int i = 1; i <= n; ++i) {
    int m = f(i);
    if (a <= m && m <= b) num += i;
  }

  cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  string Mae;
  string Ato;
  int Q;
  cin>>S>>Q;
  int flag=1;
  for(int i=0;i<Q;i++){
    int T;
    cin>>T;
    if(T==1){
      flag=flag*(-1);
    }
    else{
      int F;
      char C;
      cin>>F>>C;
      if(F==1){
        if(flag==1){
          Mae=C+Mae;
        }
        else{
          Ato=Ato+C;
        }
      }
      else{
        if(flag==1){
          Ato=Ato+C;
        }
        else{
          Mae=C+Mae;
        }
      }
    }
  }
  S=Mae+S+Ato;
  if(flag==1){
    cout<<S<<endl;
  }
  else{
    reverse(S.begin(),S.end());
    cout<<S<<endl;
  }
}
        
    


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

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

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

ll n,m,k,d;
bool Solve(vector<vector<char>> v){
  int pos = m,h = 0;
  while(h < d){
    if(v[h][pos] == 1){
      ++pos;
      ++h;
    }
    else{
      if(pos > 0 && v[h][pos-1] == 1){
        --pos;
      }
      ++h;
    }
  }
  if(pos == k) return true;
  return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin >> n && n){
    cin >> m >> k >> d;
    --m,--k;
    vector<vector<char>> v(d,vector<char>(n,0));
    rep(i,d){
      rep(j,n-1){
        cin >> v[i][j];
        v[i][j] -= '0';
      }
    }
    auto copy = v;
    if(Solve(v)){
      cout << 0 << endl;
    }
    else{
      bool flag = false;
      rep(i,d){
        rep(j,n-1){
          if(v[i][j] == 0){
            v = copy;
            if(j == 0){
              if(v[i][1] == 0){
                v[i][j] = 1;
              }
            }
            else if(j == n-2){
              if(v[i][j-1] == 0){
                v[i][j] = 1;
              }
            }
            else if(v[i][j-1] == 0 && v[i][j+1] == 0){
              v[i][j] = 1;
            }
            if(Solve(v)){
              flag = true;
              cout << i+1 << ' ' << j+1 << endl;
              break;
            }
          }
        }
        if(flag){
          break;
        }
      }
      if(!flag){
        cout << 1 << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3156
#include<iostream>
using namespace std;
int main()
{
long long int a,b,c,d;
  cin>>a>>b>>c>>d;
  long long int ans1,ans2,ans3,ans4;
  ans1=a*c;
  ans2=a*d;
  ans3=b*c;
  ans4=b*d;
  cout<<max(ans1,max(ans2,max(ans3,ans4)));
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n, ans;
VI p, q;

int main()
{
    cin>>n;
    p.resize(n); q.resize(n, 0);
    REP(i, n) {
        cin>>p[i];
        if (i != 0) {
            q[i] = min(q[i-1], p[i]);
            if (p[i] <= q[i]) {
                ans++;
            }
        } else {
            q[0] = p[0];
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int n,m,a,b;
long long lst;
const long long md=1e9+7;
long long p[200010];
long long qmul(long long x,int p)
{
	if(p==0)return 1LL;
	if(p==1)return x;
	long long res=qmul(x,p/2);
	res=res*res%md;
	if(p&1)res=res*x%md;
	return res;
}
long long C(int x,int y)
{
	if(x<y)return 0LL;
	return p[x]*qmul(p[x-y]*p[y]%md,md-2)%md;
}
long long gtans(int x,int y)
{
	return C(x+y-2,y-1);
}
int main()
{
	scanf("%d%d%d%d",&n,&m,&a,&b);
	p[0]=1LL;
	for(int i=1;i<=n+m-2;i++)p[i]=p[i-1]*i%md;
	long long ans=gtans(n,m);
	a=n+1-a;
	while(a<=n && b>0)
	{
		ans=ans+md-gtans(a,b)*gtans(n+1-a,m+1-b)%md;
		if(ans>=md)ans-=md;
		a++;
		b--;
	}
	printf("%lld",ans);
	return 0;
}

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

#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;
inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}
inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}



void solve(){
    int r;cin>>r;
    cout<<2*pi*r<<endl;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<bool> S(N);
  for (int i = 0; i < N; i++) {
    char s;
    cin >> s;
    S[i] = s == 'o';
  }
  for (int t = 0; t < (1 << 2); t++) {
    vector<bool> T(N);
    T[0] = (t & 1) == 1;
    T[1] = ((t >> 1) & 1) == 1;
    for (int i = 2; i < N; i++) {
      T[i] = S[i - 1] ^ T[i - 1] ^ T[i - 2];
    }
    if (S[N - 1] == (T[N - 2] ^ T[N - 1] ^ T[0]) &&
        S[0] == (T[N - 1] ^ T[0] ^ T[1])) {
      for (int i = 0; i < N; i++) {
        cout << (T[i] ? 'S' : 'W');
      }
      cout << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n , m , k;
    cin >> n >> m >> k;
    ll a[n+10],b[m+10];
    vector<ll>va,vb;
    ll suma = 0 , sumb = 0;
    for(int i=0; i<n; i++){cin >> a[i];
    suma += a[i];
    va.push_back(suma);

    }
    for(int i=0; i<m; i++){cin >> b[i];
    sumb += b[i];
    vb.push_back(sumb);
    }
    ll mx=0 ;

    ll x = upper_bound(vb.begin(), vb.end(), k) - vb.begin();
    mx = max(mx,x);
     for(int i=0; i<n; i++)
     {
         if(va[i]<=k)
         {
             ll xx = i+1;
             ll yy = upper_bound(vb.begin(), vb.end(), k-va[i]) - vb.begin();

             mx = max(mx,xx+yy);
         }
         else break;
     }
      ll y = upper_bound(va.begin(), va.end(), k) - va.begin();
      mx = max(y,mx);
       for(int i=0; i<m; i++)
     {
         if(vb[i]<=k)
         {
             ll xx = i+1;
             ll yy = upper_bound(va.begin(), va.end(), k-vb[i]) - va.begin();

             mx = max(mx,xx+yy);
         }
         else break;
     }


      cout << mx << endl;


}


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

int main(){
  int route[4];
  for (int i=0;i<4;i++) cin >> route[i];
  const int dx = route[2] - route[0];
  const int dy = route[3] - route[1];
  cout << string(dx, 'R') << string(dy, 'U');
  cout << string(dx, 'L') << string(dy, 'D');
  cout << 'D' << string(dx+1, 'R') << string(dy+1, 'U') << 'L';
  cout << 'U' << string(dx+1, 'L') << string(dy+1, 'D') << 'R';
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n; cin>>n;
	vector<string> s(n);
	REP(i,n) cin>>s[i];
	sort(s.begin(),s.end());
	vector<pair<ll,string>> l;
	REP(i,n){
		if(i==0){
			l.push_back(make_pair(1,s[i]));
		}else{
			if(l[l.size()-1].second==s[i])l[l.size()-1].first++;
			else l.push_back(make_pair(1,s[i]));
		}
	}
	sort(l.begin(),l.end());
	ll max=l[l.size()-1].first;
	REP(i,l.size()){
		if(l[i].first==max)cout<<l[i].second<<endl;
	}
	return 0;
}


Measured memory_bytes: 18292
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
#define MOD 1000000007

int main()
{

    int N;
    cin >> N;
    vector<ll> A(N);
    ll ans = 0;
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }

    for (int i = 0; i < 60; ++i)
    {
        ll one = 0;
        for (int j = 0; j < N; ++j)
        {
            if (A[j] >> i & 1)
                one++;
        }
        ll now = one * (N - one) % MOD; // N-one = 0の個数

        for (int j = 0; j < i; ++j)
        {
            now = now * 2 % MOD;
        }
        ans += now;
        ans %= MOD;
    }

    cout << ans;

    return 0;
}

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

public class Main {


	static int MOD=(int)1e9+7;
	
	static int n;
	static int[][] matMult(int [][]A,int [][]B)
	{
		int [][]C=new int [n][n];
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
			{
				long ans=0;
				for(int k=0;k<n;k++)
					ans=(ans+A[i][k]*1L*B[k][j])%MOD;
				C[i][j]=(int) ans;
			}
		return C;
	}
	static int[][] pow(int [][]A,long e)
	{
		int [][]ans=new int [n][n];
		for(int i=0;i<n;i++)
			ans[i][i]=1;
		while(e>0)
		{
			if((e&1)==1)
				ans=matMult(ans, A);
			e>>=1;
			A=matMult(A,A);
				
		}
		return ans;
	}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		 n=sc.nextInt();
	
		long k=sc.nextLong();
		int [][]B=new int [n][n];
		for(int x=0;x<n;x++)
			for(int y=0;y<n;y++)
		{
			int z=sc.nextInt();
			B[x][y]=z;
			
		}
		int [][]ans=pow(B,k);
		
		int total=0;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				total+=ans[i][j];
				if(total>=MOD)
					total-=MOD;
				
				
			}
			
		}
		out.println(total);
		out.close();
	}
	
	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(System.in));

		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
	}

}

Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,k;
    cin>>n>>k;
    if((n-1)*(n-2)/2<k){
        cout<<-1<<endl;
        return 0;
    }
    int a=(n-1)*(n-2)/2-k;
    cout<<n-1+a<<endl;
    for(int i=1;i<=n-1;i++){
        cout<<i<<" "<<n<<endl;
    }
    for(int i=1;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(a==0)return 0;
            cout<<i<<" "<<j<<endl;
            a--;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

typedef unsigned long long ull;

char buf1[101], buf2[101], buf3[101];
int l1, l2, l3;
void rev(char b[], int n) {
	int i,t;
	for(i = 0; i < (n+1)/2; i ++) {
		t=b[i];b[i]=b[n-i-1];b[n-i-1]=t;
	}
}
int main() {
	int tn,ti,c,i,x;
	scanf("%d",&tn);
	for(ti=0;ti<tn;ti++){
		scanf("%s%s",&buf1,&buf2);
		l1 = strlen(buf1); l2 = strlen(buf2);
		rev(buf1, l1); rev(buf2, l2);
		for(i=l1;i<100;i++)buf1[i]='0';
		for(i=l2;i<100;i++)buf2[i]='0';
		c=0,l3=0;
		for(i=0;i<100;i++){
			x=buf1[i]-'0'+buf2[i]-'0'+c;
			if(x>=10)x-=10,c=1;
			else c=0;
			if(x)l3=i;
			buf3[i]=x+'0';
		}
		l3++;
		buf3[l3]=0;
		rev(buf3, l3);
		if(l3>80)
			puts("overflow");
		else
			puts(buf3);
	}
	return 0;
}

Measured memory_bytes: 584
import java.util.Scanner;

/**
 * Main
 */
public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int N = s.nextInt();
        float[] x = new float[N];
        float[] y = new float[N];

        for (int i = 0; i < N; i++) {
            x[i] = s.nextInt();
            y[i] = s.nextInt();
        }

        double[][] z = new double[N][N];

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

        double sum = 0;
        for (int i = 0; i < N-1; i++) {
            for (int j = i+1; j < N; j++) {
                z[i][j] = Math.sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
                sum += z[i][j];
            }
        }

        System.out.println(sum*2/N);
        s.close();

    }
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
using ld =  double;
const ld eps = 1e-9;
const int COMB_MAX = 11;
int per[5][5];
ld dp[101][COMB_MAX + 1][101][5][11];

int A, B;
ld solve(vector<int>&nodes, int now, int combo,int score, int preuse,int preacc) {
	if (dp[now][combo][score][preuse][preacc] > -eps) {
		return dp[now][combo][score][preuse][preacc];
	}else if (now == nodes.size()) {
		if (score == 100) {
			int a;
			a = 1;
			a++;
		}
		dp[now][combo][score][preuse][preacc] = score >= 100;
	}
	else {

		ld ans = 0;
		if (nodes[now] == 0) {
			dp[now][combo][score][preuse][preacc] = solve(nodes, now + 1, combo, score, 4, 10);
		}
		else if (score >= 100) {
			dp[now][combo][score][preuse][preacc] = 1.0l;
		}
		else {
			for (int nextuse = 0; nextuse < 5; ++nextuse) {
				int nextscore(score);
				int nextcombo(combo);
				int kot = nextuse == 4 ? 0 : nextuse % 2+1;
				if (kot&&nodes[now] == kot) {
					nextcombo++;
					nextscore += A + B*min(combo, 10);
				}
				else {
					nextcombo = 0;
				}
				if (nextcombo > COMB_MAX) {
					nextcombo = min(nextcombo, COMB_MAX);
				}
				nextscore = min(nextscore, 100);
				int nextacc = nextuse == 4 ? 10 : max(0, ((per[preuse][nextuse] - 10) * 10 + preacc*10) / 10);
				assert(nextacc <= 10);
				ld nans = 0;
				{
					if (nextacc) {
						nans += (ld(nextacc) / 10)*solve(nodes, now + 1, nextcombo, nextscore, nextuse, nextacc);
					}
					nans += (1.0l-ld(nextacc) / 10)*solve(nodes, now + 1, 0, score, nextuse, nextacc);
				}
				ans = max(ans, nans);
			}
			dp[now][combo][score][preuse][preacc] = ans;
		}
		
	}
	return dp[now][combo][score][preuse][preacc];

}

int main() {
	cout << setprecision(10) << fixed;
	while (1) {
		for (int i = 0; i < 101; i++) {
			for (int j = 0; j <=COMB_MAX ; ++j) {
				for (int k = 0; k < 101; ++k) {
					for (int l = 0; l < 5; ++l) {
						for (int m = 0; m < 11; ++m) {
							dp[i][j][k][l][m] = -1;
						}
					}
				}
			}
		}
		for (int i = 0; i < 2; ++i) {
			for (int j = 0; j < 2; ++j) {
				int from = j * 2 + i;
				for (int k = 0; k < 2; ++k) {
					for (int l = 0; l < 2; ++l) {
						int to = l * 2 + k;
						cin >> per[from][to];
						if (per[from][to] < -0.5)return 0;
					}
				}
			}
		}
		for (int i = 0; i < 5; ++i) {
			per[i][4] = 10;
			per[4][i] = 10;
		}
		int L; cin >> L;
		vector<int>nodes(L);
		for (int i = 0; i < L; ++i) {
			cin >> nodes[i];
		} cin >> A >> B;
		A /= 100;
		B /= 100;
		ld ans = solve(nodes, 0, 0, 0, 4, 10);
		cout << ans << endl;
	}
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int k;
  cin >> k;
  cout << k * k / 4;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    string s;
    cin>>s;
    if(s[2]==s[3] and s[4]==s[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import sys
f = sys.stdin


lines = [list(map(int,line.split(','))) for line in f]

for i in range(1, len(lines) // 2 + 1):
    for j in range(len(lines[i])):
        lines[i][j] += max(lines[i - 1][max(j - 1,0):min(j + 1,len(lines[i -1]) )])

for i in range(len(lines) // 2 + 1, len(lines)):
    for j in range(len(lines[i])):
        lines[i][j] += max(lines[i - 1][j:j +2])

print(lines[-1][0])

Measured memory_bytes: 6756
#include <iostream>
#include <algorithm>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl


int main() {
    ll h, w;
    string shape;
    while(1){
        cin >> h >> w;

        if(h == 0 && w == 0){
            break;
        }
        

        for(int i = 0;i < h;i++){
            shape = "";
            for(int j = 0;j < w;j++){
                shape += "#";
            }
            cout << shape << endl;
        }
        cout << "" << endl;
    }

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  a--,b--,c--,d--;
  string s;
  cin >> s;
  if(c<d){
    repp(i,a,d){
      if(s[i]=='#'&&s[i+1]=='#'){
        CNO;
        return 0;
      }
    }
    CYES;
    return 0;
  }else{
    repp(i,a,d){
      if(s[i]=='#'&&s[i+1]=='#'){
        CNO;
        return 0;
      }
    }
    repp(i,b,d+1){
      if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
        CYES;
        return 0;
      }
    }
    CNO;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 640
<?php 
    $s = explode(' ', trim(fgets(STDIN)));
	if($s[0]%3 == 0 || $s[1]%3 == 0 || ($s[0]+$s[1])%3 == 0){
    	echo "Possible";
    }else{
    	echo "Impossible";
    }
?>

Measured memory_bytes: 4604
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	string[] str = ["dream", "dreamer", "erase", "eraser"];
	long pos = S.length, lastPos = pos;
	bool isWrong;
	while (pos != 0)
	{
		foreach (e; str)
		{
			auto len = e.length;
			if (pos-len >= 0 && S[pos-len..pos] == e)
			{
				pos -= len;
				break;
			}
		}
		if (pos == lastPos)
		{
			isWrong = true;
			break;
		}
		lastPos = pos;
	}
	writeln(isWrong ? "NO" : "YES");
	stdout.flush();
	//readln();
}

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

def main():
    N = int(input())
    P = list(map(int, input().split()))
    P = [0] + P
    X = list(map(int, input().split()))

    Y = [0] * N
    children = [None] * N

    for i in range(N - 1, 0, -1):
        parent = P[i] - 1
        if children[parent] is None:
            children[parent] = []
        children[parent].append(i)


    for i in range(N - 1, -1, -1):
        if not children[i] is None:
            dp = []
            j_max = len(children[i])
            for j in range(j_max + 1):
                dp.append([0] * 5050)
            dp[0][0] = 1
            x_sum, y_sum = 0, 0
            for j in range(j_max):
                c = children[i][j]
                xc, yc = X[c], Y[c]
                x_sum += xc
                y_sum += yc
                for k in range(X[i] + 1):
                    if xc <= k and dp[j][k - xc] == 1:
                        dp[j + 1][k] = 1
                    if yc <= k and dp[j][k - yc] == 1:
                        dp[j + 1][k] = 1
            f = False
            for k in range(X[i], -1, -1):
                if dp[j_max][k] == 1:
                    Y[i] = x_sum + y_sum - k
                    f = True
                    break
            if not f:
                print('IMPOSSIBLE')
                return

    print('POSSIBLE')


if __name__ == '__main__':
    main()



Measured memory_bytes: 42612
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    auto S = sread();
    long K = lread();
    bool[string] visited;
    PQueue!(string) Q;
    long cnt;
    foreach (l; 1 .. min(5, S.length) + 1)
        foreach (i; 0 .. S.length - l + 1)
        {
            dprint(i, l, S[i .. i + l]);
            Q.insert(S[i .. i + l]);
        }

    while (true)
    {

        auto s = Q.front;
        Q.removeFront();
        if (s in visited)
            continue;
        visited[s] = true;
        dprint(s);
        cnt++;
        if (cnt == K)
        {
            writeln(s);
            return;
        }
    }
}


Measured memory_bytes: 4432
#include<bits/stdc++.h>
using namespace std;
/*int arr[100005]={0};
int dp[100005]={0};
bool is_completed[100005]={0};
int dynamic(int a)
{
    if(a<2)
        return dp[a];
    else if(is_completed[a]==true)
    {
        return dp[a];
    }
    else
    {
        is_completed[a]=true;
        dp[a]=min(dynamic(a-1)+abs(arr[a]-arr[a-1]),dynamic(a-2)+abs(arr[a]-arr[a-2]));
        return dp[a];
    }
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    is_completed[0]=is_completed[1]=true;
    cout<<dynamic(n-1);
}*/
long long dp[100001];
int arr1[105];
int arr2[105];
int main()
{
    int n,w;
    long long c;
    cin>>n>>w;
    for(int i=0;i<n;i++)
    {
        cin>>arr1[i]>>arr2[i];
    }
    for(int i=0;i<=w;i++)
    {
        dp[i]=0;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=w;j>=0;j--)
        {
            if(i==0)
            {
                if(j>=arr1[0])
                {
                    dp[j]=arr2[0];
                }
            }
            else if(j-arr1[i]<0)
            {
                dp[j]=dp[j];
            }
            else
            {
                dp[j]=max(dp[j],arr2[i]+dp[j-arr1[i]]);
            }
        }
    }
    //for(int i=0;i<n;i++)
    //{
       /* for(int j=0;j<=w;j++)
        {
            cout<<dp[j]<<" ";
        }
        cout<<"\n";
    //}*/
    cout<<dp[w];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    long long N;
    cin>>N;
    long long A,T;
    T=1000000000000000;
    for(int i=0;i<5;i++){
        cin>>A;
        if(A<T){
            T=A;
        }
    }
    
    if(N%T==0){
        T=N/T;
    }else{
        T=N/T+1;
    }
    
    long long ans;
    ans=T+4;
    
    cout<<ans<<endl;
    return 0;
    
}

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

int main(){

  
  ll n,a,b;
  while(cin>>n>>a>>b){
  
  ll c=a+b;
  ll l=n/c;
  ll d=n%c;
  ll ans=0;
  if(d<a){
    ans=a*l+d;
  }else{
    ans=a*l+a;
  }

  cout<<ans<<endl;

   }
  
}

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

int main(){

  int n;
  cin >> n;

  int allst[26];
  int stlis[26];

  for (int i = 0 ; i < 26 ; i++){
    allst[i] = 50;
    stlis[i] = 0;
  }
  
  string S;

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

    cin >> S;

    for (int j = 0 ; j < S.size() ; j++){

      stlis[S.at(j) - 'a'] += 1;

    }

    for (int j = 0 ; j < 26 ; j++){

      allst[j] = min(allst[j] , stlis[j]);
      stlis[j] = 0;

    }

  }

  string ans = "";

  for (int i = 0 ; i < 26 ; i++){
    for (int j = 0 ; j < allst[i] ; j++){
      ans += 'a' + i;
    }
  }

  cout << ans << endl;
      
  return 0;

}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
if sum(a)%((1+n)*n//2):
  print("NO")
  exit()
kai = sum(a)//((1+n)*n//2)
b = []
b.append(a[0]-a[-1]-kai)
for i in range(n-1):
  b.append(a[i+1]-a[i]-kai)
for i in b:
  if i>0:
    print("NO")
    exit()
ss = 0
for i in b:
  if (-i)%n !=0:
    print("NO")
    exit()
  ss += (-i)//n
if ss == kai:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 63644
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int main(){
  int n,k,q;cin>>n>>k>>q;
  int a[n];
  vector<pii> vv;
  for(int i=0;i<n;i++){
    cin>>a[i];
    vv.push_back(make_pair(a[i],i));
  }
  sort(vv.begin(),vv.end());
  int ans=1000000000;
  set<int> st;
  st.insert(-1);
  st.insert(n);
  for(int i=0;i<n;i++){
    int ps=vv[i].second;
    vector<int> v;
    for(auto itr=st.begin();;){
      vector<int> w;
      int now1=*itr;
      itr++;
      int now2=*itr;
      now2--;
      if(now2-now1>=k){
        for(int j=now1+1;j<=now2;j++){
          w.push_back(a[j]);
        }
        sort(w.begin(),w.end());
        for(int j=0;j<now2-now1-k+1;j++){
          v.push_back(w[j]);
        }
      }
      if(itr==st.end())break;
    }
    if(v.size()<q)break;
    sort(v.begin(),v.end());
    ans=min(ans,v[q-1]-v[0]);
    st.insert(ps);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>

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

using namespace std;

int main(){
	string n;
	int ans;
	
	ans = 0;
	cin >> n;
	REP(i,n.length()){
		ans += n[i]-'0';
	}
	if (ans<=1) ans = 10;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int a, b;
	char str[101][101];
	char change[101];
	char kekka[350] = { "\0" };
	int i, j,k;

	scanf("%d %d", &a, &b);
	for (i = 0; i < a; i++)
	{
		scanf("%s", &str[i]);
	}
	
	for (i=0;i<a-1;i++)
	{
		j = 0;
			for (k =i+1; k < a; k++)
			{
				while (str[i][j] == str[k][j])  j++;
				if ((int)str[i][j]>(int)str[k][j])
				{
					strcpy(change, str[i]);
					strcpy(str[i], str[k]);
					strcpy(str[k], change);
				}
				j = 0;
			}
	}
	
	for (i = 0; i < a; i++)
	{
		printf("%s", str[i]);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
class Main{
    public static void main(String[] args){
		int n; //件数
		int b; //棟
		int f; //階
		int r; //番目
		int v; //人数
		int[][][] canpus=new int[5][4][11];
		Scanner sc=new Scanner(System.in);
		for(int i=1;i<5;i++){
			for(int j=1;j<4;j++){
				for(int k=1;k<11;k++){
					canpus[i][j][k]=0;
				}
			}
		}
		n=sc.nextInt();
		for(int i=0;i<n;i++){
			b=sc.nextInt();
			f=sc.nextInt();
			r=sc.nextInt();
			v=sc.nextInt();
			canpus[b][f][r]+=v;
		}
		for(int i=1;i<5;i++){
			for(int j=1;j<4;j++){
				for(int k=1;k<11;k++){
					System.out.print(" "+canpus[i][j][k]);
				}
				System.out.println("");
			}
			if(i!=4)System.out.println("####################");
		}
    }
}



Measured memory_bytes: 30104
import math
def isprime(n):
  if n == 2:
    return True
  elif n % 2 == 0:
    return False
  else:
    for i in range(3,math.ceil(math.sqrt(n))+1,2):
      if n % i == 0:
        return False
    return True

x = int(input())
ans = 0
if x == 2:
  ans = 2
else:
  if x % 2 == 0:
    st = x+1
  else:
    st = x
  for i in range(st,100001):
    if isprime(i) == True:
      ans = i
      break
  if ans == 0:
    ans = 100003
print(ans)

Measured memory_bytes: 9132
#include <stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

void show(int a[])
{
//	for (int i = 0; i < 10; i++)
//		printf("%d ", a[i]);
//	printf("\n");
}

void quicksort(int a[], int left, int right)
{

	int p;	//中央値
	int L = left, R = right;		//ループ中で変化するleft、right
	int temp;
	p = a[(left + right) / 2];

	while (1)
	{
		while (a[L] < p) L++; while (a[R] > p)
			R--;
		
		if (L >= R)
			break;

		temp = a[R];
		a[R] = a[L];
		a[L] = temp;

		L++;
		R--;
	}

	show(a);

	if (left < L - 1) quicksort(a, left, L - 1); if (right > R + 1)
		quicksort(a, R + 1, right); 
	
}

int main(void)
{
	int a,b,c[100010],i,d[100010],x=0;
	scanf("%d %d",&a,&b);
	for(i=0;i<b;i++){
		scanf("%d",&c[i]);
	}
	quicksort(c,0,b-1);
	for(i=0;i<b-1;i++){
		d[i]=c[b-i-1]-c[b-i-2];
	}
	quicksort(d,0,b-2);
	for(i=0;i<b-a;i++){
		x=x+d[i];
	}
	printf("%d\n",x);
}


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

namespace abc174_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = CIn.ReadInt();
            var n = 0;
            for(var i = 1; i <= K; i++)
            {
                n = 10 * (n % K) + 7;
                if(n % K == 0)
                {
                    Console.WriteLine(i);
                    return;
                }               
            }
            Console.WriteLine("-1");
        }
    }
    class CIn
    {
        private static readonly Queue<string> fieldBuffer = new Queue<string>();

        public static string Read()
        {
            if (fieldBuffer.Count == 0)
            {
                foreach (var field in Console.ReadLine().Split())
                {
                    fieldBuffer.Enqueue(field);
                }
            }

            return fieldBuffer.Dequeue();
        }

        public static int ReadInt() => int.Parse(Read());
        public static long ReadLong() => long.Parse(Read());
        public static double ReadDouble() => double.Parse(Read());

        public static string[] ReadStringArray(long n)
        {
            var array = new string[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = Read();
            }

            return array;
        }

        public static int[] ReadIntArray(long n)
        {
            var array = new int[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadInt();
            }

            return array;
        }

        public static long[] ReadLongArray(long n)
        {
            var array = new long[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadLong();
            }

            return array;
        }
        public static double[] ReadDoubleArray(long n)
        {
            var array = new double[n];

            for (var i = 0; i < n; i++)
            {
                array[i] = ReadDouble();
            }

            return array;
        }
    }

}


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


int main(){

  while(1){
    string s;
    getline(cin,s);
    //    cout << s << endl;
    if(s == ".") break;
    stack<string> st;
    bool ok = true;
    for(int i=0; i<s.size(); i++){
      string si = s.substr(i,1);
    
      if(si == "(" or si == "["){
	st.push( s.substr(i,1) );
	continue;
      }
      else if(si == ")"){
	if(st.size() > 0 and st.top() == "("){
	  st.pop();
	  continue;
	}
	else{
	  ok = false;
	}
      }
      else if(si == "]"){
	if(st.size() > 0 and st.top() == "["){
	  st.pop();
	  continue;
	}
	else{
	  ok = false;
	}
      }
    }
    if(ok and st.empty())
      cout << "yes" << endl;
    else
      cout << "no" << endl;
    
  }
}

Measured memory_bytes: 1192
#include <algorithm>
#include <cstdio>
using std::scanf;
using std::printf;

const int kMaxN = 1000;
const int kMaxWi = 10000;

int BinarySearch(int A[], int n, int key) {
  int left = 0, right = n, mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (A[mid] == key) { return mid; }
    if (key < A[mid]) { right = mid; }
    if (A[mid] < key) { left = mid + 1; }
  }
  return -1;
}

// w[i]?????????????????????????????????cycle???????????????????????????remain????????£?????????????¨????
// ????????????cycle?????????
int MakeCycle(int w[], int i, int n, int sorted[], int remain[], int cycle[]) {
  int j = 0;
  cycle[0] = -1; //?????????while?????????????????????
  while(w[i] != cycle[0]) {
    cycle[j] = w[i];
    ++j;
    remain[i] = 0;
    i = BinarySearch(sorted, n, w[i]);
  }
  return j;
}

int CompareCosts(int cycle[], int cycle_n, int cycle_min, int w_min) {
  if (cycle_n == 1) {
    return 0;
  } else if (cycle_n == 2) {
    return cycle[0] + cycle[1];
  } else {
    int cycle_sum, i, cost1, cost2;
    cycle_sum = 0;
    for (i = 0; i < cycle_n; ++i) { cycle_sum += cycle[i]; }
    cost1 = cycle_sum + (cycle_n - 2) * cycle_min;
    cost2 = cycle_sum + cycle_min + (cycle_n + 1) * w_min;
    return std::min(cost1, cost2);
  }
}

int main() {
  int n, i, j, cycle_n, cycle_min, w_min, cnt;
  scanf("%d", &n);
  int w[n], sorted[n], remain[n], cycle[n];
  for (i = 0; i < n; ++i) { scanf("%d", &w[i]); }
  w_min = kMaxWi;
  for (i = 0; i < n; ++i) { w_min = std::min(w_min, w[i]); }
  for (i = 0; i < n; ++i) { sorted[i] = w[i]; }
  std::sort(sorted, sorted + n);
  for (i = 0; i < n; ++i) { remain[i] = 1; }
  cnt = 0;
  for (i = 0; i < n; ++i) {
    if (remain[i]) {
      cycle_n = MakeCycle(w, i, n, sorted, remain, cycle);
      cycle_min = kMaxWi;
      for (j = 0; j < cycle_n; ++j) { cycle_min = std::min(cycle_min, cycle[j]); }
      cnt += CompareCosts(cycle, cycle_n, cycle_min, w_min);
    }
  }
  printf("%d\n", cnt);
  return 0;
}

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

using namespace std;

int const size = 3006;
int arr[size];
long long int dp[2][size][size];

long long int solve(int turn, int left, int right){
	if(left>right) return 0;
	if(dp[turn][left][right] != -1) return dp[turn][left][right];
	long long int ans = 0;
	if(turn == 0){
		ans = max(arr[left] + solve(1, left+1, right), arr[right]+solve(1, left, right-1));
	} else ans = min(solve(0, left+1, right) - arr[left], solve(0, left, right-1)- arr[right]);
	dp[turn][left][right] = ans;
	return ans;
}

int main(){
	int n;
	scanf("%d",&n);
	for(int x=0;x<n;x++) scanf("%d",&arr[x]);
	for(int x=0;x<size;x++){
		for(int i=0;i<size;i++) for(int j=0;j<2;j++) dp[j][x][i] = -1;
	}
	cout<<solve(0,0,n-1);
	return 0;
}

Measured memory_bytes: 141696
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,-1,0,0};
const int dy[]={0,0,1,-1};
int n,m;
int a,b;
int c,d;
char e[1010][1010];
int need[1010][1010];
vector<int> vv[700010];
int bbfs[700010];
int now=0;
void bdfs(){
	queue<int> q;
	bbfs[need[a][b]]=0;
	q.push(need[a][b]);
	while(!q.empty()){
		int p=q.front();
		q.pop();
		for(int i=0;i<vv[p].size();i++){
			if(bbfs[p]+1<bbfs[vv[p][i]]){
				bbfs[vv[p][i]]=bbfs[p]+1;
				q.push(vv[p][i]);
			}
		}
	}
}
void bfs(int x,int y){
	now++;
	queue<pair<int,int> > q;
	q.push(make_pair(x,y));
	need[x][y]=now;
	while(!q.empty()){
		pair<int,int> p=q.front();
		q.pop();
		for(int i=0;i<4;i++){
			int ax=dx[i]+p.first;
			int ay=dy[i]+p.second;
			if(ax>=0&&ax<n&&ay>=0&&ay<m&&e[ax][ay]!='#'&&!need[ax][ay]){
				need[ax][ay]=now;
				q.push(make_pair(ax,ay));
			}
		}
	}
}
int main(){
	cin>>n>>m>>a>>b>>c>>d;
	a--,b--,c--,d--;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>e[i][j];
//			e[i][j]='.';
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(e[i][j]=='.'&&!need[i][j]){
				bfs(i,j);
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(e[i][j]!='.')continue;
			for(int ii=-2;ii<=2;ii++){
				for(int jj=-2;jj<=2;jj++){
					int ax=i+ii,ay=j+jj;
					if(ax>=0&&ax<n&&ay>=0&ay<m&&e[ax][ay]=='.'&&need[i][j]!=need[ax][ay]){
						vv[need[i][j]].push_back(need[ax][ay]);
						vv[need[ax][ay]].push_back(need[i][j]);
					}
				} 
			}
		}
	}
	set<int> s; 
	for(int i=1;i<=now;i++){
		s.clear();
		bbfs[i]=1e9;
		for(int j=0;j<vv[i].size();j++)s.insert(vv[i][j]);
		vv[i].clear();
		for(set<int> ::iterator it=s.begin();it!=s.end();it++)vv[i].push_back(*it);
		/*
		cout<<i<<endl;
		for(int j=0;j<vv[i].size();j++){
			cout<<vv[i][j]<<" ";
		}
		cout<<endl;
		*/
	}
	bdfs();
	if(bbfs[need[c][d]]==1e9)cout<<-1<<endl;
	else cout<<bbfs[need[c][d]]<<endl;
	return 0;
}

Measured memory_bytes: 47004