akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;

const int prime_max = 55555;
int NP,prime[100000],divp[prime_max];
map<int,int> M;

void cprime() {
	if(NP) return;
	for(int i=2;i<prime_max;i++) if(divp[i]==0) {
		//M[i]=NP;
		prime[NP++]=i;
		for(ll j=1LL*i*i;j>=i&&j<prime_max;j+=i) if(divp[j]==0) divp[j]=i;
	}
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cprime();
	
	cin>>N;
	FOR(i,NP) {
		if(N && prime[i]%5==1) {
			N--;
			cout<<prime[i]<<" ";
		}
	}
	cout<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;



int main(){
	int N;
	cin>>N;
	vector<int> vec;
	
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		vec.push_back(a);
	}
	
	long long min_cost = 99999999;
	for(int i=-100;i<=100;i++){
		long long cost=0;
		for(int j=0;j<N;j++){
			cost+=(vec[j]-i)*(vec[j]-i);		
		}
		if(cost<min_cost)min_cost=cost;
	}
	cout<<min_cost<<endl;
	
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int H, W;

vector<string> A;
vvi visited;
queue<vector<int>> que;

void bfs(int sh, int sw) {
    visited = vvi(H, vi(W, -1));
    que.push({sh, sw});
    visited[sh][sw] = 0;

    while (!que.empty()) {
        vi v = que.front();
        que.pop();
        int h = v[0];
        int w = v[1];

        for (vi nv : vvi{{h - 1, w}, {h + 1, w}, {h, w - 1}, {h, w + 1}}) {
            int nh = nv[0];
            int nw = nv[1];

            if (nh < 0 || H <= nh) continue;
            if (nw < 0 || W <= nw) continue;
            if (visited[nh][nw] != -1) continue;
            if (A[nh][nw] != '.') continue;

            visited[nh][nw] = visited[h][w] + 1;
            que.push(nv);
        }
    }
}

int main() {
    cin >> H >> W;

    A = vector<string>(H);
    int count = 0;
    for (int i = 0; i < H; i++) {
        cin >> A[i];
        for (int j = 0; j < W; j++) {
            if (A[i][j] == '.') count++;
        }
    }

    bfs(0, 0);
    if (visited[H - 1][W - 1] == -1)
        cout << -1 << endl;
    else
        cout << count - visited[H - 1][W - 1] - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
//void chmin(ll &a,ll b){if(a>b) a = b ;}

int main(){
	ll n,m ;
	cin >> n >> m ;
	map<ll,ll> cnt ;
	ll ans = 0 ;
	ll sum = 0 ;
	cnt[0]++ ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		sum = (sum+a)%m ;
		ans += cnt[sum] ;
		cnt[sum]++ ;
	}
	cout << ans << endl ;
}


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


int main() {
	int n, a[30], mx[30], ans = 1;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	mx[0] = a[0];
	for (int i = 1; i < n; i++)
		mx[i] = max(a[i], mx[i - 1]);
	for (int i = 1; i < n; i++)
		if (a[i] >= mx[i - 1])
			ans++;
	cout << ans;
}







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

int N;
int A[5][105];
int p[5][105];

int max(int a, int b)
{
	return a>=b?a:b;
}
int main()
{
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	
	int N;
	scanf("%d",&N);
	
	memset(A,0,sizeof(A));
	
	for(int i = 1; i <= 2; i++)
	{
		for(int j = 2; j <= N + 1; j++)
			scanf("%d",&A[i][j]);
	}
	memset(p,0,sizeof(p));
	for(int i = 1; i <= 2; i++)
	{
		for(int j = 2; j <= N + 1; j++)
			p[i][j] = max(p[i-1][j],p[i][j - 1]) + A[i][j];
	}
	printf("%d\n",p[2][N+1]);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int A, B, N;
int maxA, corB;

int main() {
    cin >> N;
    cin >> maxA >> corB;
    while (--N) {
        cin >> A >> B;
        if (A > maxA) {
            maxA = A;
            corB = B;
        }
    }
    cout << maxA + corB << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
x1 = sum(a) - 2 * sum([a[i] for i in range(N) if i % 2 == 1])
ans = [0] * N
ans[0] = x1
for i in range(N - 1):
    ans[i + 1] = 2 * a[i] - ans[i]
print(*ans)

Measured memory_bytes: 14092
#include<bits/stdc++.h>
using namespace std;
int main(){
	int maxi = 0,s=0;
	int n;
	char c;
	cin >> n;
	while(n--){
		cin >> c;
		if(c == 'I')
			s++;
		else
			s--;
		maxi = max(maxi,s);
	}
	cout<<maxi;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=1;i<n;i++)
using namespace std;
int main(){
  long long n,p,a,b;
  while(cin>>n,n){
    long long s=1;
    if(n==1)s--;
    for(int i=2;i*i<n;i++)if(n%i==0)s+=i+n/i;
    if(n<s)cout<<"abundant number"<<endl;
    else if(n>s)cout<<"deficient number"<<endl;
    else cout<<"perfect number"<<endl;
  }
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
long long n,a[200005],l[200005],r[200005],ans;
pair<long long,long long>p[200005];
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	int cc=0;
	for(int i=1;i<=n;i++)
	{
		while(cc&&p[cc-1].first>a[i])r[p[--cc].second]=i;
		p[cc++]=make_pair(a[i],i);
	}
	for(int i=0;i<cc;i++)r[p[i].second]=n+1;
	cc=0;
	for(int i=n;i>=1;i--)
	{
		while(cc&&p[cc-1].first>a[i])l[p[--cc].second]=i;
		p[cc++]=make_pair(a[i],i);
	}
	for(int i=0;i<cc;i++)l[p[i].second]=0;
	ans=0;
	for(int i=1;i<=n;i++)ans+=(i-l[i])*(r[i]-i)*a[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8064
n = gets.chomp.to_i

taro = 0
hanako = 0

n.times do
  c_t, c_h = gets.chomp.split

  if c_t == c_h
    taro += 1
    hanako += 1
  else
    c_t > c_h ? taro += 3 : hanako += 3
  end
end

puts "#{taro} #{hanako}"



Measured memory_bytes: 6864
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = j;i <= k;++i)
#define repp(i,j,k) for(int i = j;i >= k;--i)
#define rept(i,x) for(int i = linkk[x];i;i = e[i].n)
#define P pair<int,int>
#define Pil pair<int,ll>
#define Pli pair<ll,int>
#define Pll pair<ll,ll>
#define pb push_back 
#define pc putchar
#define mp make_pair
#define file(k) memset(k,0,sizeof(k))
#define ll long long
int rd()
{
    int sum = 0;char c = getchar();bool flag = true;
    while(c < '0' || c > '9') {if(c == '-') flag = false;c = getchar();}
    while(c >= '0' && c <= '9') sum = sum * 10 + c - 48,c = getchar();
    if(flag) return sum;
    else return -sum;
}
const int p = 1e9+7;
int n;
int a[201000],b[201000];
int fac[101000],inv[101000];
int det = 2001;
int f[4010][4010];
int C(int i,int j)
{
    int now = 1ll*fac[i]*inv[j]%p;
    now = 1ll*now*inv[i-j]%p;
    return now;
}
int Pow(int a,int x)
{
    int now = 1;
    while(x)
    {
        if(x&1) now = 1ll*now*a%p;
        a = 1ll*a*a%p;
        x >>= 1;
    }
    return now;
}
int main()
{
    n = rd();
    rep(i,1,n) a[i] = rd(),b[i] = rd();
    fac[0] = 1;
    rep(i,1,10000) fac[i] = 1ll*fac[i-1]*i%p,inv[i] = Pow(fac[i],p-2);
    rep(i,1,n) f[det-a[i]][det-b[i]] += 1;
    int ans = 0;
    rep(i,1,4001) rep(j,1,4001) (f[i][j] += (f[i][j-1]+f[i-1][j])%p)%=p;
  //  rep(i,1,n) printf("#%d %d %d\n",det-a[i],det-b[i],f[det-a[i]][det-b[i]]);
    rep(i,1,n) (ans += f[a[i]+det][b[i]+det])%=p;
    rep(i,1,n) ans = ((ans - C(2*a[i]+2*b[i],2*a[i]))%p+p)%p;
    ans = 1ll*ans*Pow(2,p-2)%p;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 65280
N=int(input())
a=list(map(int,input().split()))

o = 0
f = 0
t = 0
for i in a:
  if i % 2 == 1:
    o += 1
  if i % 4 == 0:
    f += 1
  if i % 4 == 2:
    t += 1
if f >o-1:
  print('Yes')
elif f == o-1 and t==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 15020
#include<stdio.h>
#include<cstdlib>
#include<math.h>

void insertionSort(int *, int, int);
void shellSort(int *, int);

double logn(int, double);

int cnt;

int main(){
    int i,N,*A;
    scanf("%d",&N);
    A = (int *)malloc(sizeof(int) * N);
    for (i = 0; i < N; i++) {
        scanf("%d",&A[i]);
    }
    
    shellSort(A, N);
    //insertionSort(A, N, 1);
    printf("%d\n",cnt);
    for (i = 0; i < N; i++) {
        printf("%d\n",A[i]);
    }
    
    free(A);
    return 0;
}

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

void shellSort(int *A, int n){
    cnt = 0;
    int i;
    int *G;
    int m = (int)logn(3,2*n+1); // n > (3^m - 1) / 2
    
    G = (int *)malloc(sizeof(int) * m);
    printf("%d\n",m);
    for (int i = 0; i < m; i++) {
        G[i] = ((int)pow(3, m-i) - 1) / 2;
        printf("%d",G[i]);
        if(i == m - 1){
            printf("\n");
            break;
        }
        printf(" ");
    }
    
    for (i = 0; i < m; i++) {
        insertionSort(A, n, G[i]);
    }
    
    free(G);
}

// calculate log_base(x)
double logn(int base, double x) {
    return log(x) / log((double)base);
}









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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int N;

int main() {
   cin >> N;
   for (int i = 0; i < N; i++) {
      int a[10];
      for (int j = 0; j < 10; j++) {
         cin >> a[j];
      }

      bool flag = false;
      for (int mask = 0; mask < (1<<10); mask++) {
         vector<int> b, c;
         for (int j = 0; j < 10; j++) {
            if ( (mask >> j) & 1 ) {
               b.push_back(a[j]);
            } else {
               c.push_back(a[j]);
            }
         }
         bool f = true;
         for (int k = 1; k < b.size(); k++) {
            if (b[k-1] > b[k]) f = false;
         }
         for (int k = 1; k < c.size(); k++) {
            if (c[k-1] > c[k]) f = false;
         }
         if (f) {
            flag = true;
         } 
      }

      if (flag) {
         puts("YES");
      } else {
         puts("NO");
      }
   }

   return 0;
}


Measured memory_bytes: 3132
import std.stdio, std.conv, std.string, std.range, std.typecons, std.format;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.mutation;

void main()
{
    int[] input = readln().split.to!(int[]);
    double T = input[0];
    double X = input[1];
    writeln(T/X);
}


Measured memory_bytes: 256
S = str(input())
N = len(S) + 1
a = [-1] * N


def chmax(a, b):
    if a < b:
        a = b
    return a


for i in range(N - 1):
    if (i == N - 2 and S[i] == ">"):
        a[i + 1] = 0
    elif (i == 0 and S[i] == "<"):
        a[i] = 0
    elif (S[i] == ">" and S[i + 1] == "<"):
        a[i + 1] = 0

for i in range(N - 1):
    if a[i] != -1 and S[i] == "<":
        a[i + 1] = a[i] + 1

for i in reversed(range(1, N)):
    if a[i] != -1 and S[i - 1] == ">":
        a[i - 1] = chmax(a[i - 1], a[i] + 1)

print(sum(a))



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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

struct dsu {
  int cc;
  vector<int> p, sz;
  dsu(int n = 0) : cc(n), p(n, -1), sz(n, 1) {}
  int root(int v) const {
    while (p[v] != -1) v = p[v];
    return v;
  }
  bool unite(int u, int v) {
    u = root(u), v = root(v);
    if (u == v) return false;
    --cc;
    if (sz[u] < sz[v]) swap(u, v);
    p[v] = u;
    sz[u] += sz[v];
    return true;
  }
  bool same(int u, int v) const { return root(u) == root(v); }
  int size(int v) const { return sz[root(v)]; }
};

template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  vector<int> d(m), e(m), f(m);
  for (int j = 0; j < m; ++j) {
    cin >> d[j] >> e[j] >> f[j];
  }
  vector vx{-inf<int>, 0, inf<int>};
  vector vy{-inf<int>, 0, inf<int>};
  vx.insert(end(vx), begin(a), end(a));
  vx.insert(end(vx), begin(b), end(b));
  vy.insert(end(vy), begin(c), end(c));
  vx.insert(end(vx), begin(d), end(d));
  vy.insert(end(vy), begin(e), end(e));
  vy.insert(end(vy), begin(f), end(f));
  sort(begin(vx), end(vx));
  vx.erase(unique(begin(vx), end(vx)), end(vx));
  sort(begin(vy), end(vy));
  vy.erase(unique(begin(vy), end(vy)), end(vy));
  for (auto&& el : a) el = lower_bound(begin(vx), end(vx), el) - begin(vx);
  for (auto&& el : b) el = lower_bound(begin(vx), end(vx), el) - begin(vx);
  for (auto&& el : c) el = lower_bound(begin(vy), end(vy), el) - begin(vy);
  for (auto&& el : d) el = lower_bound(begin(vx), end(vx), el) - begin(vx);
  for (auto&& el : e) el = lower_bound(begin(vy), end(vy), el) - begin(vy);
  for (auto&& el : f) el = lower_bound(begin(vy), end(vy), el) - begin(vy);
  int h = size(vx) - 1;
  int w = size(vy) - 1;
  auto $ = [&](int i, int j) {
    return i * w + j;
  };
  vector ho(h + 1, vector<bool>(w));
  vector ve(w + 1, vector<bool>(h));
  for (int i = 0; i < n; ++i) {
    for (int x = a[i]; x < b[i]; ++x) {
      ve[c[i]][x] = true;
    }
  }
  for (int j = 0; j < m; ++j) {
    for (int y = e[j]; y < f[j]; ++y) {
      ho[d[j]][y] = true;
    }
  }
  dsu ds(h * w);
  for (int x = 0; x < h; ++x) {
    for (int y = 0; y < w; ++y) {
      if (x and not ho[x][y]) {
        ds.unite($(x, y), $(x - 1, y));
      }
      if (y and not ve[y][x]) {
        ds.unite($(x, y), $(x, y - 1));
      }
    }
  }
  int ox = lower_bound(begin(vx), end(vx), 0) - begin(vx);
  int oy = lower_bound(begin(vy), end(vy), 0) - begin(vy);
  if (ds.same(0, $(ox, oy))) {
    cout << "INF\n";
    exit(0);
  }
  long long res = 0;
  for (int x = 0; x < h; ++x) {
    for (int y = 0; y < w; ++y) {
      if (ds.same($(x, y), $(ox, oy))) {
        res += (long long)(vx[x + 1] - vx[x]) * (vy[y + 1] - vy[y]);
      }
    }
  }
  cout << res << '\n';
}


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

int N;
int F[100005];
const int M = 100005;
int main() {
  cin >> N;
  for(int i=0;i<N;i++){
    int a; cin >> a;
    F[a]++;
  }
  int cnt = 0;
  for(int i=0;i<M;i++){    
    if( F[i] & 1 ) F[i] = 1;
    else if( F[i] ){
      F[i] = 2;
      cnt++;
    }
  }
  int res = 0;
  for(int i=0;i<M;i++)
    if( F[i] ) res++;
  if( cnt & 1 ) res--;
  cout << res << endl;
}


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

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


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




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


const int MOD = 1000000007;
const long double PI = (acos(-1));
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

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


void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % MOD;
       inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
   }
}


int n;
int a[200005];
bool ok[200005];
vector<int> ans;
void Input() {

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

        cin >> a[i];
    }
}



void Solve() {


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

        if(k == n-1) {

            ans.push_back(a[n]);
            break;
        }
        if(a[i] == idx) {

            ans.push_back(idx);
            idx++;

        }
        else k++;

    }


    if(ans.size() == 0) {

        cout << -1 << endl;
        return;
    }
    vector<int> :: iterator it;
    idx = 1;
    for(it = ans.begin(); it != ans.end(); it++) {

        if(*it != idx) {

            cout << -1 << endl;
            return;
        }
        else idx++;
    }

    cout << k << endl;


}

int main() {

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


  return 0;

}



Measured memory_bytes: 2168
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
  int k,s; cin>>k>>s;
  int count=0;
  int i,j,l;

for(i=0;i<k+1;i++){
  for(j=0;j<k+1;j++){
    if(s-i-j<=k and s-i-j>=0) count++;
  }
}
cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    // dp, ApplePen
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        --A[i];
    }
    ll ans = 0;
    ll temp = 0;
    map<int, int> mp;
    vector<int> cum(N+1);
    queue<int> que;
    rep(i, N) cum[i+1] = (cum[i] + A[i]) % K;
    rep(i, N+1) {
        ans += mp[cum[i]];
        mp[cum[i]]++;
        que.push(cum[i]);
        if (sz(que) == K) {
            mp[que.front()]--;
            que.pop();
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 15100
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int a,b,c=1;
    cin>>a>>b;
    for(int i=0;i<b;i++){
        c=c*2;
    }
    a=(a-b)*100+b*1900;
    a=a*c;
    cout<<a<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>
#define REP(i,m,n) for(int i = (int) (m);i < (int) (n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int n;
bool J = false;


int main() {
	cin >> n;
	REP(i, 1, 10) {
		REP(j, 1, 10) {
			if (n == i * j) {
				J = true;
			}
		}
	}
	if (J) cout << "Yes" << endl;
	else cout << "No" << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n;
 cin >> n;
 int a;
  a = n / 100;
 int b;
  b = (n - 100 * a) / 10;
 cout << n - 99 * a - 9 * b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    int N, p;
    cin>>N;
    int Minim=2000000, count=0;
    rep(i, N){
        cin>>p;
        Minim=min(p, Minim);
        if(Minim>=p) count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		while(sc.hasNext()){
			int n = sc.nextInt();
			for(int a=1;a<=n;a++){
				int[][] map = new int[8][8];
				String s = "";
				for(int i=0;i<8;i++){
					s = sc.next();
					for(int j=0;j<8;j++){
						if(s.codePointAt(j)==49)map[i][j]=1;
					}
				}
				
				ArrayDeque<Integer> px = new ArrayDeque<Integer>();
				ArrayDeque<Integer> py = new ArrayDeque<Integer>();
				px.push(sc.nextInt()-1);
				py.push(sc.nextInt()-1);
				
				int x, y;
				while(true){
					int k = px.size();
					if(k==0)break;
					for(int i=0;i<k;i++){
						x = px.pop();
						y = py.pop(); 
						map[y][x]=0;
						
						for(int j=1;j<4;j++){
							if(x+j==8)break;
							if(map[y][x+j]==1){
								py.push(y);
								px.push(x+j);
							}
						}
						
						for(int j=1;j<4;j++){
							if(x-j==-1)break;
							if(map[y][x-j]==1){
								py.push(y);
								px.push(x-j);
							}
						}
						
						for(int j=1;j<4;j++){
							if(y+j==8)break;
							if(map[y+j][x]==1){
								py.push(y+j);
								px.push(x);
							}
						}
						
						for(int j=1;j<4;j++){
							if(y-j==-1)break;
							if(map[y-j][x]==1){
								py.push(y-j);
								px.push(x);
							}
						}
						
					}
				}
				System.out.println("Data " + a + ":");
				for(int i=0;i<8;i++){
					for(int j=0;j<8;j++){
						System.out.print(map[i][j]);
					}
					System.out.println();
				}
			}
		}
	
	}	
}

Measured memory_bytes: 17268
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int, int> P;
void move(int x, int y, int& nx, int& ny, int r){
  int dx[6] = {1, 0, -1, -1, 0, 1};
  int dy[6] = {1, 1, 0, -1, -1, 0};
  nx = x + dx[r];
  ny = y + dy[r];
}

int main(){
  int N;
  cin>>N;
  cin.ignore();
  while(N--){
    string s, t, tmp;
    getline(cin, s);
    getline(cin, t);
    getline(cin, tmp);
    set<P> p_set;
    int x = 0, y = 0;
    p_set.insert(P(x, y));
    REP(i, s.size()){
      move(x, y, x, y, s[i] - 'a');
      //printf("(%d %d) ", x, y);
      p_set.insert(P(x, y));
    }
    bool ans = false;
    REP(d, 6){
      vector<P> p_vect;
      x = 0, y = 0;
      p_vect.push_back(P(x, y));
      REP(i, t.size()){
        move(x, y, x, y, (t[i] - 'a' + d) % 6);
        p_vect.push_back(P(x, y));
      }
      REP(i, p_vect.size()){
        int bx = p_vect[i].first, by = p_vect[i].second;
        set<P> p_set2;
        REP(j, p_vect.size()){
          p_set2.insert(P(p_vect[j].first - bx, p_vect[j].second - by));
        }
        if(p_set == p_set2) ans = true;
      }
    }
    if(ans) cout<<"true"<<endl;
    else cout<<"false"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
import sys
def input():
    return sys.stdin.readline()[:-1]
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]

p = [A[0][0]] + [A[i][1] for i in range(n)]
m = [[0 for i in range(n+1)] for j in range(n+1)]

for l in range(2,n+1):
    for i in range(1,n-l+1+1):
        j = i + l - 1
        for k in range(i,j):
            x = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]
            if not 0<m[i][j]<=x:
                m[i][j] = x
print(m[1][n])


Measured memory_bytes: 5664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    bool my = false;
    rep(i,n){
        cin >> a[i];
        a[i] %= 2;
        if(a[i]==1) my = true;
    }
    cout << (my?"first":"second") << endl;
    return 0;
}


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

using ll=long long;

int main(){
    int N, M; cin >> N >> M;
    vector<int> H(N);
    for(auto &x: H) cin >> x;
    vector<vector<int>> road(N);
    for(int i=0; i<M; i++){
        int A, B; cin >> A >> B;
        A--, B--;
        road[A].push_back(B);
        road[B].push_back(A);
    }
    int res=0;
    for(int i=0; i<N; i++){
        bool ok=true;
        if(road[i].size() == 0) res++;
        else{
            for(auto x: road[i]){
                if(H[x] >= H[i]) ok=false;
            }
            if(ok) res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8800
# Dinic's algorithm
from collections import deque
class Dinic:
    def __init__(self, N):
        self.N = N
        self.G = [[] for i in range(N)]

    def add_edge(self, fr, to, cap):
        forward = [to, cap, None]
        forward[2] = backward = [fr, 0, forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)

    def add_multi_edge(self, v1, v2, cap1, cap2):
        edge1 = [v2, cap1, None]
        edge1[2] = edge2 = [v1, cap2, edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)

    def bfs(self, s, t):
        self.level = level = [None]*self.N
        deq = deque([s])
        level[s] = 0
        G = self.G
        while deq:
            v = deq.popleft()
            lv = level[v] + 1
            for w, cap, _ in G[v]:
                if cap and level[w] is None:
                    level[w] = lv
                    deq.append(w)
        return level[t] is not None

    def dfs(self, v, t, f):
        if v == t:
            return f
        level = self.level
        for e in self.it[v]:
            w, cap, rev = e
            if cap and level[v] < level[w]:
                d = self.dfs(w, t, min(f, cap))
                if d:
                    e[1] -= d
                    rev[1] += d
                    return d
        return 0

    def flow(self, s, t):
        flow = 0
        INF = 10**9 + 7
        G = self.G
        while self.bfs(s, t):
            *self.it, = map(iter, self.G)
            f = INF
            while f:
                f = self.dfs(s, t, INF)
                flow += f
        return flow

n = int(input())
rl = [list(map(int, input().split())) for _ in range(n)]
bl = [list(map(int, input().split())) for _ in range(n)]

dinic = Dinic(2*n+10)
s = 2*n
e = 2*n + 1
for i in range(n):
    dinic.add_edge(s,i,1)
    dinic.add_edge(n+i,e,1)

for i in range(n):
    for j in range(n):
        r = rl[i]
        b = bl[j]
        if r[0]<b[0] and r[1]<b[1]:
            dinic.add_edge(i,n+j,1)

print(dinic.flow(s,e))

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e18;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}


using Weight=int;
struct Edge{
  int src,dst;
  Weight weight;
  Edge():src(0),dst(0),weight(0){}
  Edge(int s,int d,Weight w=0):src(s),dst(d),weight(w){}
};

using Edges=vector<Edge>;
using Graph=vector<Edges>;

vector<int> Dij(Graph&g,int s){
    using state = pair<int,int>;
    priority_queue<state,vector<state>,greater<state>> pq;
    vector<int> dis(g.size(),INF);
    dis[s]=0;
    pq.push(state(0,s));
    while(!pq.empty()){
      int d=pq.top().first;
      int v=pq.top().second;
      pq.pop();
      if(dis[v]<d)continue;
      rep(i,g[v].size()){
        Edge &e=g[v][i];
        if(dis[e.dst]>dis[v]+e.weight){
          dis[e.dst]=dis[v]+e.weight;
          pq.push(state(dis[e.dst],e.dst));
        }
      }
    }
    return dis;
}

signed main(){
  int n,m,s,t;
  cin>>n>>m>>s>>t;
  s--;t--;
  Graph yen(n);
  Graph snu(n);
  rep(i,m){
    int u,v,a,b;
    cin>>u>>v>>a>>b;
    u--;v--;
    yen[u].emplace_back(u,v,a);
    yen[v].emplace_back(v,u,a);
    snu[u].emplace_back(u,v,b);
    snu[v].emplace_back(v,u,b);
  }

  vector<int> cosyen=Dij(yen,s);
  vector<int> cossnu=Dij(snu,t);
  vector<int> ans(n+1,INF);

  for(int i=n-1;i>=0;i--){
    ans[i]=min(ans[i+1],cosyen[i]+cossnu[i]);
  }
  int tmp=1e15;
  rep(i,n){
    cout<<tmp-ans[i]<<endl;
  }


  return 0;
}


Measured memory_bytes: 21832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    double n;
    cin >> n;
    cout << n * 2 * 3.141592 << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3752
#include <stdio.h>
#include <stdbool.h>

int main(void)
{   
    int n, x, y, z;
    while(true){
        scanf("%d", &n);
        if(n == 0){
            break;
        }
        for(int i = 0; i < n; ++i){
            scanf ("%d%d%d", &x, &y, &z);
            int sum2 = x + y;
            int sum3 = x + y + z;
            if(x == 100 || y == 100 || z == 100){
                printf("A\n");
            }else if(sum2 >= 180){
                printf("A\n");
            }else if(sum3 >= 240){
                printf("A\n");
            }else if(sum3 >= 210){
                printf("B\n");
            }else if(sum3 >= 150 && (x >= 80 || y >= 80)){
                printf("B\n");
            }else{
                printf("C\n");
            }
        }
    }
    return 0;        
}

Measured memory_bytes: 1012
#include <iostream>
#include <string>
#include <stack>

int main ()
{
  std::string input;
  std::stack<char> cube;
  int result = 0;
  std::cin >> input;
  for (char ch : input) {
    if (cube.empty()) {
      cube.push(ch);
      continue;
    }
    char t = cube.top();
    if (t != ch) {
      cube.pop();
      result += 2;
    } else {
      cube.push(ch);
    }
  }
  std::cout << result << '\n';
  return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
int A[100010];

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

	cin >> N;
	rep(i, 0, N)cin >> A[i];

	int s = 0;
	int res = 0;
	int ans = INF;
	rep(i, 0, N)
	{
		if (i == 0)
		{
			if (A[i] <= 0)
			{
				res += 1 - A[i];
				s = 1;
			}
			else s = A[i];
		}
		else
		{
			if (i % 2 == 0)
			{
				res += max(0LL, 1 - (s + A[i]));
				s = max(1LL, s + A[i]);
			}
			else
			{
				res += max(0LL, (s + A[i]) + 1);
				s = min(-1LL, s + A[i]);
			}
		}
	}

	chmin(ans, res);

	s = 0;
	res = 0;
	rep(i, 0, N)
	{
		if (i == 0)
		{
			if (A[i] >= 0)
			{
				res += A[i] + 1;
				s = -1;
			}
			else s = A[i];
		}
		else
		{
			if (i % 2 == 1)
			{
				res += max(0LL, 1 - (s + A[i]));
				s = max(1LL, s + A[i]);
			}
			else
			{
				res += max(0LL, (s + A[i]) + 1);
				s = min(-1LL, s + A[i]);
			}
		}
	}

	chmin(ans, res);

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main(){ 
  int time[30]; bool table[30];
  int N; cin>> N;
  for(int i = 0; i < 30; i++){ time[i] = 0; table[i] = false;}
  time[0] = 1;//高橋くん自身
   
 for(int i = 0; i < N; i++){ int d; cin >> d; time[d]++;}
  
  int ans = 0; vector<int> vec;
  
  if( time[0] >= 2 || time[12] >= 2){ //時刻０か１２に2人以上いる場合は０;
    cout << 0 << endl; return 0;}
    
  if( time[0] == 1){ table[0] = true;} if( time[12] == 1){ table[12] = true;}
  
  for(int j = 1; j < 12; j++){ // 1 ~ 11 への場合分けは解説PDF準拠
    if( time[j] >= 3){ cout << 0 << endl; return 0;} 
    if( time[j] == 1){ vec.push_back(j); } //可変成分(1人しかいない）をvecに格納
    if( time[j] == 2){ table[j] = true; table[24-j] = true;}
    //ちょうど２人いる場合は左右で固定（tableに記録）
   
  }
  
  //以下は時刻０、１２に1人以下しかおらず、かつ全ての時刻について３人以上いることはない。
  
  int n = (int) vec.size();
  
  for(int i = 0; i < ( 1 << n); i++){
    //高々2^11通りをbit演算
    for(int j = 0; j < n; j++){
      if( i & ( 1 << j)){ vec[j] = 24 - vec[j];}}
    
    vector<int> clock;
    for(int k = 0; k < 30; k++){ 
      if( table[k]){ clock.push_back(k);}}
    
    for(int k = 0; k < n; k++){
      clock.push_back(vec[k]);} 
    
    sort(clock.begin(),clock.end());
    
    int diff0 = abs(clock.front() - clock.back());
   
    int res = min( diff0, 24 - diff0);
    for(int k = 1; k < (int) clock.size() ; k++){
      int diff = abs(clock[k] - clock[k-1]);
     
      res = min( res, min( diff, 24 - diff));}
    
    ans = max( res, ans); 
    
     for(int j = 0; j < n; j++){
      if( i & ( 1 << j)){ vec[j] = 24 - vec[j];}}//復元
  }
  
  cout << ans << endl; return 0;}
    
      
      
      
    
  
  
  

  
  

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

int H,W,K,tmp[11];
string s[11];

int calcMin(int bit) {
  int ret = __builtin_popcount(bit);
  vector<int> cnt(1+__builtin_popcount(bit),0);
  rep(x,W) {
    int ptr = 0;
    memset(tmp,0,sizeof tmp);
    rep(y,H) {
      if( s[y][x] == '1' ) {
	++tmp[ptr];
	if( tmp[ptr] > K ) return INT_MAX;
      }
      if( (1<<y) & bit ) ++ptr;
    }
    bool over = false;
    rep(i,(int)cnt.size()) {
      if( cnt[i] + tmp[i] > K ) { over = true; break; }
    }
    if( over ) {
      rep(i,(int)cnt.size()) cnt[i] = 0;
      ++ret;
    }
      rep(i,(int)cnt.size()) cnt[i] += tmp[i];
  }
  return ret;
}

void solve() {
  int mini = INT_MAX;
  rep(i,(1<<(H-1))) {
    mini = min(mini,calcMin(i));
  }
  cout << mini << endl;
}

int main() {
  cin >> H >> W >> K;
  rep(i,H) cin >> s[i];
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,data[4]={0};
	scanf("%d",&n);
	char s[3];
	while(n--){
		scanf("%s",s);
      	getchar();
		if(s[0]=='A'){
			data[0]+=1;
		}
		else if(s[0]=='W'){
			data[1]+=1;
		}
		else if(s[0]=='T'){
			data[2]+=1;
		}
		else{
			data[3]+=1;
		}
	}
	printf("AC x %d\n",data[0]);
	printf("WA x %d\n",data[1]);
	printf("TLE x %d\n",data[2]);
	printf("RE x %d",data[3]);
	
	
	
	return 0;
}

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

using namespace std;

int main(void)
{
	int n;
	cin >> n;

	vector<int> mon;

	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		mon.push_back(x);
	}

	vector<int> mi(n);
	mi[0] = mon[0];
	for (int i = 1; i < n; i++)
	{
		mi[i] = (min(mi[i - 1], mon[i]));
	}

	vector<int> ma(n);
	ma[n - 1] = mon[n - 1];
	for (int i = n - 2; i >= 0; i--)
	{
		ma[i] = max(ma[i + 1], mon[i]);
	}

	int best = -1000000000;

	for (int i = 1; i < n; i++)
	{
		int ans = ma[i] - mi[i - 1];
		if (ans > best)
			best = ans;
	}

	cout << best << endl;

	return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
typedef pair<int,int> P;
class uft {//union-find tree
public:
    int parent[200010];
    int root(int x);
    bool same(int x,int y);
    void unite(int x,int y);
};
int uft::root(int x){
    if(parent[x]==x){
        return x;
    }
    return parent[x] = root(parent[x]);
}
bool uft::same(int x,int y){
    if(root(x)==root(y)){
        return true;
    }else{
        return false;
    }
}
void uft::unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x == y) return;
    parent[x] = y;
}
int main(){
    int N,K,L;
    cin>>N>>K>>L;
    uft u;
    for(int i=0;i<N;i++){
        u.parent[i]=i;
    }
    uft v;
    for(int i=0;i<N;i++){
        v.parent[i]=i;
    }
    for(int i=0;i<K;i++){
        int p,q;
        cin>>p>>q;
        p--; q--;
        u.unite(p,q);
    }
    for(int i=0;i<L;i++){
        int p,q;
        cin>>p>>q;
        p--; q--;
        v.unite(p,q);
    }
    map< P,int > mp;
    for(int i=0;i<N;i++){
        mp[P(u.root(i),v.root(i))]++;
    }
    for(int i=0;i<N;i++){
        cout<<mp[P(u.root(i),v.root(i) )]<<endl;
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 13568
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include <array>
using namespace std;

struct Vec{
	int num;
	int index;
	Vec(int _num,int _index){
		num = _num;
		index = _index;
	}
	bool operator<( const Vec& right ) const {
		return num < right.num;
	}
};

int main(){
	int n;
	vector<Vec> x;
	cin >> n;
	for(int i=0;i<n;i++){
		int tmp;
		cin >> tmp;
		x.push_back(Vec{tmp,i});
	}
	vector<bool> d(n);
	stable_sort(x.begin(), x.end());
	for(int i=0;i<n;i++){
		if(i < (n/2)){
			d[x[i].index] =true; 
		}else{
			d[x[i].index] =false; 
		}
	}
	for(int i=0;i<n;i++){
		if(d[i]){
			cout << x[n/2].num << endl;
		}else{
			cout << x[n/2-1].num << endl;
		}
	}
}

Measured memory_bytes: 3924
D,G=gets.split.map(&:to_i)
P,C=D.times.map{gets.split.map(&:to_i)}.transpose

dp=Array.new(D+1){Array.new(P.inject(:+)+1)}
D.times do |i|
  dp[i][0] = 0
  p, c = 100*(i+1), C[i]
  0.upto(dp[i].size) do |ac|
    next unless dp[i][ac]
    0.upto(P[i]) do |try|
      nex = ac + try
      break unless nex < dp[i+1].size
      dp[i+1][nex] = 0 unless dp[i+1][nex]
      dp[i+1][nex] = [dp[i+1][nex], dp[i][ac] + p*try].max
      dp[i+1][nex] = [dp[i+1][nex], dp[i][ac] + p*try + c].max if try == P[i]
    end
  end
end
dp[D].each.with_index do |s, i|
  next if s<G
  p i
  exit
end


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,x;
  cin >> a >> b >> c;
  x=a;
  a=b;
  b=x;
  x=a;
  a=c;
  c=x;
  cout << a << " " << b << " " << c ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N, Steps, x;
	cin >> N;
	vector<int> vec(N);

	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}

	sort(vec.begin(), vec.end());	//小さい順に並び替え
	reverse(vec.begin(), vec.end());//大きい順に並び替え

	Steps = 1;
	x = vec.at(0);
	for (int i = 1; i < N; i++) {
		if (x > vec.at(i)) {
			Steps++;
			x = vec.at(i);
		}
	}
	cout << Steps << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	n%=12;
	rep(i,n){
		if(i%2==0)a=a-b;
		else b=a+b;
		//cout<<i<<" "<<a<<" "<<b<<endl;
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#define MX 100005
using namespace std;
typedef pair<int,int> PA;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
	return x*f;
}
int n,m;
int a[MX],fa[MX],bl[MX],vis[MX];
priority_queue<PA> que[MX];
priority_queue<int> q;
int zbb(int k){return fa[k]==k?k:fa[k]=zbb(fa[k]);}
int main(){
	//freopen("a.in","r",stdin);
	n=read();m=read();
	for(int i=0;i<n;i++)
		a[i]=read();
	
	for(int i=0;i<n;i++) fa[i]=i;
	
	int x,y,r1,r2;
	for(int i=1;i<=m;i++)
	{
		x=read();y=read();
		r1=zbb(x);r2=zbb(y);
		if(r1!=r2)
			fa[r2]=r1;
	}
	
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		r1=zbb(i);
		if(!vis[r1])
		{
			vis[r1]=1;
			cnt++;
			bl[r1]=cnt;
		}
		que[bl[r1]].push(make_pair(-a[i],i));
	}
	
	if(cnt==1)
	{
		printf("0\n");
		return 0;
	}
	if(n<cnt*2-2)
	{
		printf("Impossible\n");
		return 0;
	}
	
	long long ans=0;
	for(int i=1;i<=cnt;i++)
	{
		ans-=que[i].top().first;
		que[i].pop();
	}
	
	for(int i=1;i<=cnt;i++)
		while(!que[i].empty())
		{
			q.push(que[i].top().first);
			que[i].pop();
		}
	
	for(int i=1;i<=cnt-2;i++)
	{
		ans-=q.top();q.pop();
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  ll n; cin >> n;
  ll ans = n * (n-1) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
#include <set>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll n, k;

int main(){
  cin >> n >> k;
  if (k % 2 == 0) {
    cout << ll(pow((n / ( k / 2 ) - n / k), 3) + pow(n / k, 3)) << endl;
  } else {
    cout << ll(pow(n / k, 3)) << endl;
  }
  return 0;
}


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

int main()
{
	string S,T;
	cin >> S >> T;
	vector<int> start(26,-1);
	vector<int> goal(26,-1);
	for(int i=0; i<S.size(); i++){
		int a = S[i] - 'a';
		int b = T[i] - 'a';
		
		if(start[a] != -1 || goal[b] != -1){
			if(start[a] != b || goal[b] != a){
				cout << "No" << endl;
				return 0;
			}
		}else{
			start[a] = b;
			goal[b] =a;
		}
	}
	
	cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 776
#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 a, b, k;
  cin >> a >> b >> k;
  vector<int> vec;
  for(int i = min(a,b); i >= 1; i--) {
    if(a%i == 0 && b%i == 0) vec.push_back(i);
  }
  cout << vec.at(k-1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,a[100],i,max=0,min=1000000001;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        max=(max<a[i])?a[i]:max;
        min=(min>a[i])?a[i]:min;
    }
    printf("%d\n",max-min);
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader bf = 
            new BufferedReader(new InputStreamReader(System.in));
        String[] str = bf.readLine().split(" ");
        int N = Integer.parseInt(str[0]),
            K = Integer.parseInt(str[1]),
            max = 0;
        String[] S = bf.readLine().split("");            
        ArrayList<Integer> data = new ArrayList<>();
        int value = Integer.parseInt(S[0]);
        if(value == 0){
            data.add(0);
        }
        for(int i = 0; i < N; value = 1-value){
            int count = 0;
            while(i < N && Integer.parseInt(S[i]) == value){
                count++;
                i++;
            }            
            data.add(count);
        }
        if(value == 1){
            data.add(0);
        }
        int size = data.size(),
            sum = 0;
        for(int i = 0; i < 2*K+1 && i < size; i++){
            sum += data.get(i);
        }
        max = sum;
        for(int i = 3; i+2*K-1 < size; i += 2){
            sum += -data.get(i-3) - data.get(i-2) + data.get(i+2*(K-1))+data.get(i+2*K-1);
            if(max < sum){
                max = sum;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 33228
#include <stdio.h>
#include <queue>
using namespace std;
char field[2000][2000];
int dx[] = {1,1,1,0,0,-1,-1,-1};
int dy[] = {1,0,-1,1,-1,1,0,-1};
int x,y,d,ans;
queue<int> str[3];
int main()
{
    int h,w;
    scanf("%d%d",&h,&w);
    ans = 0;
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w + 1; j++)
        {
            scanf("%c",&field[i][j]);
        }
    }
    for(int i = 0; i < h + 1; i++)
    {
        for(int j = 1; j < w + 1; j++)
        {
            if(field[i][j] == '.')
            {
                str[0].push(i);
                str[1].push(j);
                str[2].push(0);
            }
        }
    }
    while(str[0].size())
    {
        x = str[0].front();str[0].pop();
        y = str[1].front();str[1].pop();
        d = str[2].front();str[2].pop();
        if(ans < d)ans = d;
        for(int i = 0; i < 8; i++)
        {
            if(0 <= x + dx[i]&&x + dx[i] < h&&0 <= y + dy[i]&&y + dy[i] < w)
            {
                field[x + dx[i]][y + dy[i]]--;
                if(field[x + dx[i]][y + dy[i]] == '0')
                {
                    str[0].push(x + dx[i]);
                    str[1].push(y + dy[i]);
                    str[2].push(d + 1);
                }
            }
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 3132