akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<bits/stdc++.h>
#include<unordered_map>
#define ll long long
using namespace std;
int main(){
 
  ll n;
  cin>>n;
  string res;
  while(n>0)
  {
      ll index = (n - 1) % 26;
		res = char(index + 'a') + res;
		n = (n - 1) / 26;
  }
  cout<<res<<endl;
   return 0;
    
}


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

int n;
int A[20];


int solve(int i, int m){
  if (m == 0) {
    return 1;
  }
  if (i >= n) {
    return 0;
  }
  int res = solve(i+1, m) || solve(i+1, m - A[i]);

}

int main(int argc, char const *argv[]) {
  int m;
  int q;

  cin >> n;
  for(int i = 0; i < n; i++) cin >> A[i];
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> m;
    if (solve(0, m)) {
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

bool check(string s) {
    stack<char> stk;
    stk.push('#');
    for (auto c : s) {
        if (c == '(' || c == '[') {
            stk.push(c);
        } else if (c == ')' || c == ']') {
            if ((stk.top() == '(' && c == ')') || (stk.top() == '[' && c == ']')) {
                stk.pop();
            } else {
                return false;
            }
        }
    }
    return stk.size() == 1;
}

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

    string s;
    while (getline(cin, s), s[0] != '.') {
        cout << (check(s) ? "yes" : "no") << endl;
    }
}

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

using namespace std;

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

    string s, t;
    cin >> s >> t;

    int n = s.size(), m = t.size();

    int dp[n+1][m+1];

    for(int i = 0; i <= n; i++)
    {
        dp[i][0] = 0;
    }
    for(int j = 0; j <= m; j++)
    {
        dp[0][j] = 0;
    }

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            if(s[i-1] == t[j-1])
            {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else
            {
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
            }
        }
    }

    int res = dp[n][m];
    char c[res];
    int i = n,j=m;

    int ind = res-1;
    while(dp[i][j] != 0)
    {
        if(s[i-1] == t[j-1])
        {
            i--,j--;
            c[ind] = s[i];
            ind--;
        }
        else if(dp[i][j-1] == dp[i][j])
        {
            j--;
        }
        else
        {
            i--;
        }
    }

    for(auto e : c)
    {
        cout << e;
    }

}


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

int gcd(int a, int b){
  if(a == 0) return b;
  else return gcd(b%a, a);
}

int32_t main(){
  DESYNC;
  int n, k;
  cin >> n >> k;
  int v[n+1];
  for(int i=1; i<=n; i++) cin >> v[i];
  int p[n+1];
  p[0] = 0;
  for(int i=1; i<=n; i++){
    p[i] = p[i-1] + v[i];
  }
  map<int,int> m;
  m[p[0] - 0]++;
  int ans = 0;
  for(int i = 1; i<=n; i++){
    if(i - k >= 0){
      int x = p[i-k] - (i-k);
      x %= k;
      m[x]--;
    }
    int val = p[i] - i;
    val %= k;
    //cout << i << "= " << val << endl;
    //cout << "ans bef = " << ans << endl;
    ans += m[val];
    //cout << "ans after = " << ans << endl;
    m[val]++;
  }
  cout << ans << endl;
}




Measured memory_bytes: 15924
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int pos_x = 0, pos_y = 0;
  int n;
  int t[100000], x[100000], y[100000];
  int i;
  int dist,time;
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d %d %d", &t[i], &x[i], &y[i]);
  for (i = 0; i < n; i++)
  {
    dist = i == 0 ? x[i] + y[i] : abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    time = i == 0 ? t[i] : t[i] - t[i - 1];
    if(time < dist){
      printf("No\n");
      return 0;
    }
    else if(!((dist % 2 == 0 && time % 2 == 0) || (dist % 2 != 0 && time % 2 != 0))){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
using namespace std;

typedef long long ll;
const int N=1e5+5;
const ll p=1000000007;

ll a[101000],b[101000],c[101000],x[101000],y[100100];
int main()
{
    int A,B,M;
    scanf("%d%d%d",&A,&B,&M);
    ll ans1=0x3f3f3f3f,ans2=0x3f3f3f3f;
    for(int i=1; i<=A; i++)
        scanf("%lld",&a[i]),ans1=min(ans1,a[i]);
    for(int i=1; i<=B; i++)
        scanf("%lld",&b[i]),ans2=min(ans2,b[i]);;
    ll ans=ans1+ans2;
    for(int i=1;i<=M;i++)
    {
        ll x,y,c;
        scanf("%lld%lld%lld",&x,&y,&c);
        ans=min(ans,a[x]+b[y]-c);
    }
    cout<<ans<<endl;
}


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

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

	int roop = 0;
	int result = 0;
	if (s.size() % 2 == 1) {
		roop = (s.size() - 1) / 2;
	} else {
		roop = s.size() / 2;
	}
	for (int i = 0; i < roop; i++) {
		if (s[i] == s[(s.size() - i - 1)]) {

		} else {
			result++;
		}
	}
	cout << result << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)


ll N, M, Q;
int ans;
vector<int> a, b, c, d;


void dfs(vector<int> A)
{
    if (A.size() == N+1) {
        int now = 0;
        rep(i,Q) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                now += d[i];
            }
            ans = max(ans, now);
        }
        return;
    }

    A.push_back(A.back());
    while (A.back() <= M) {
        dfs(A);
        A.back()++;
    }
}


int main()
{
    cin >> N >> M >> Q;
    a = b = c = d = vector<int>(Q);
    rep(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3192
import java.util.*;

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

        System.out.println(GoldenApple(N, D));
    }
    public static int GoldenApple(int N, int D) {
        return ((N - 1) / (2 * D + 1)) + 1;
    }
}


Measured memory_bytes: 21076
#include<stdio.h>
int main (void){
  int N,i,CHECK = 0;
  scanf("%d",&N);
  for(i=0;i<3;i++){
    if(N%10 == 7)
      CHECK = 1;
    N = N/10;
  }
  if(CHECK == 1)
    printf("Yes");
  else
    printf("No");
}


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

int main(){
  string str;
  while(cin >> str){
    vector<char> v;
    int ci, cj, co;
    int lv = 0;
    for(int i=0; i<str.size(); ++i) v.push_back(str[i]);
    ci = 0;
    cj = 0;
    co = 0;
    for(int i=0; i<v.size(); ++i){
      if(v[i] == 'J'){
	++cj;
      }else if(cj>0){
	for(;i<v.size(); ++i){
	  if(v[i] == 'O'){
	    ++co;
	  }else if(co>0){
	    for(;i<v.size(); ++i){
	      if(v[i] == 'I'){
		++ci;
	      }
	      if(v[i] != 'I' || i == v.size()-1){
		if(co <= cj && co <= ci && co > lv)lv = co;
		co = 0;
		ci = 0;
		cj = 0;
		//cout << "cj:co:ci:i = " <<cj<<":"<<co<<":"<<ci<<":"<<i<< endl;
 		//--i;
		break;
	      }
	    }
	  }
	  if(v[i]!='O'){
	    co = 0;
	    cj = 0;
	    ci = 0;
	    i -=1;
	    break;
	  }
	}
      }
    }
    //cout << "-----------------------------"<< endl;
    cout << lv << endl;
  }
}
  



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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

template <typename F>
inline constexpr decltype(auto) fix(F&& f) noexcept {
    return [=](auto g) {
        return [=](auto&&... args) {
            return f(g(g), std::forward<decltype(args)>(args)...);
        };
    }([=](auto g) {
        return [=](auto&&... args) {
            return f(g(g), std::forward<decltype(args)>(args)...);
        };
    });
}

void solve() {
    int Q;
    cin >> Q;
    unordered_map<ll, ll> dp;
    while (Q--) {
        ll N, A, B, C, D;
        cin >> N >> A >> B >> C >> D;
        dp.clear();

        auto dfs = [&](auto&& dfs, ll x) -> ll {
            if (dp.find(x) != dp.end()) {
                return dp[x];
            }

            if (x == 0) {
                dp[x] = 0;
                return dp[x];
            }

            if (x == 1) {
                dp[x] = D;
                return dp[x];
            }

            ll res = L_INF;

            ll r2 = x % 2;
            ll r3 = x % 3;
            ll r5 = x % 5;

            // goto 0
            if (x < L_INF / D) {
                res = dfs(0) + x * D;
            }

            // 2
            res = min(res, dfs(x / 2) + A + r2 * D);
            res = min(res, dfs((x + 1) / 2) + A + r2 * D);

            // 3
            res = min(res, dfs(x / 3) + B + r3 * D);
            res = min(res, dfs((x + 2) / 3) + B + (3 - r3) * D);

            // 5
            res = min(res, dfs(x / 5) + C + r5 * D);
            res = min(res, dfs((x + 4) / 5) + C + (5 - r5) * D);

            dp[x] = res;
            return res;
        };

        ll res = fix(dfs)(N);
        cout << res << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 4032
#include<iostream>
using namespace std;
int N;string s;
int nxt[30300][10];
main()
{
	cin>>N>>s;
	for(int i=0;i<10;i++)nxt[N][i]=-1;
	for(int i=N;i--;)
	{
		for(int j=0;j<10;j++)nxt[i][j]=nxt[i+1][j];
		nxt[i][s[i]-'0']=i;
	}
	int cnt=0;
	for(int x=0;x<10;x++)for(int y=0;y<10;y++)for(int z=0;z<10;z++)
	{
		int id=0;
		id=nxt[id][x];
		if(id<0)continue;
		id++;
		id=nxt[id][y];
		if(id<0)continue;
		id++;
		id=nxt[id][z];
		if(id<0)continue;
		cnt++;
	}
	cout<<cnt<<endl;
}


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

int main(){
    int a[9];
    for(int i=0;i<9;i++){
        cin>>a[i];
    }
    
    if(a[0]+a[4]==a[1]+a[3] && a[1]+a[5]==a[2]+a[4] && a[3]+a[7]==a[4]+a[6] && a[4]+a[8]== a[5]+a[7])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
}


Measured memory_bytes: 256
/*
This code By @1353055672(Ligen)
[Warning]You're not excepted to understand this code!
RP++
*/
#pragma GCC optimize(3)
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#define ll long long
#define ull unsigned long long
#define mn 1000020
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register ll a=b;a<=c;a++)
#define FORD(a,b,c) for (register ll a=b;a>=c;a--)
using namespace std;
inline ll read(){
    ll 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;
}
inline void writeln(ll a){
    if(a==0){puts("0");return;}
    char c1[120];
    int h=0;
    while(a)c1[++h]=a%10+'0',a/=10;
    FORD(i,h,1)putchar(c1[i]);putchar('\n');
    return;
}
inline ll Max(ll a,ll b){return (a>b)?a:b;}
inline ll Min(ll a,ll b){return (a<b)?a:b;}
inline ll Abs(ll x){return (x<0)?-x:x;}
inline void Swap(ll &x,ll &y){ll t=x;x=y;y=t;}
struct node{
	int a,b,c,d;
}an[250020];
int a[520][520];
int main(){
	int n=read(),m=read(),ans=0;
	FOR(i,1,n)FOR(j,1,m){
		a[i][j]+=read();
		if(i<n&&a[i][j]&1){
			a[i+1][j]++;an[++ans]=(node){i,j,i+1,j};
		}else if(i==n&&j<m&&a[i][j]&1){
			a[i][j+1]++;an[++ans]=(node){i,j,i,j+1};
		}
	}
	writeln(ans);
	FOR(i,1,ans)printf("%d %d %d %d\n",an[i].a,an[i].b,an[i].c,an[i].d);
	return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<algorithm>
#include<vector>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <cmath>
#include <unordered_set>
#include <sstream>
#define Endl endl
#define inf 0x3f3f3f3f
 
using namespace std;
typedef long long  ll;
 
const double pi=acos(-1);
ll GCD(ll a,ll b){return b==0?a:GCD(b,a%b);}

int main(){
 
    
    string s;cin>>s;
    if(s=="ABC") cout<<"ARC";
    else cout<<"ABC"<<Endl;
    
  
    
    return 0;
    
}


Measured memory_bytes: 3100
N = gets.to_i
A = gets.split.map(&:to_i)

counter = Hash.new(0)
max_dist = 0

A.each do |a|
  max_dist = a if max_dist < a
  counter[a] += 1
end

i = 0
j = max_dist

while i <= j
  if i != j
    counter[j] -= 2
  else
    counter[j] -= 1
  end

  if counter[j + 1] > 0
    counter[j + 1] = 0
  end

  i += 1
  j -= 1
end

if counter.values.all? { |x| x == 0 }
  puts 'Possible'
else
  puts 'Impossible'
end


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

/*高速化*/
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* define */
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))
#define REV(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REV(V)
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define Rep(i,n) for(int i = 1;i <= (int)(n);++i)
#define REP(i,n,m) for(int i = (int)(n);i < (int)(m);++i)
#define Mod(n,m) n % m
#define Mod7(n) Mod(n,7)
#define Mod9(n) Mod(n,9)

/* 最大値と最小値に置き換える */
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}


/* 型定義 */
typedef vector<long long> vi;
typedef long long ll;
using Graph = vector<vi>;


/* 定数 */
const double PI = 3.141592;
const double e = 2.6;
const long long Inf = 1LL << 60;
const long long mInf = -Inf;

//bool isAGCT(char s)
//{
//    if(s == 'A' or s == 'C' or s == 'G' or s == 'T')
//        return true;
//    return false;
//}

void calc()
{
    int N;
    cin >> N;
    int _min = 1 << 20;
    int res = 0;
    rep(i,N)
    {
        int tmp;
        cin >> tmp;
        if(tmp <= _min)
        {
            res++;
            _min = tmp;
        }
    }
    cout << res << '\n';
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    calc();
}


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

int N;
ll tmin,tmax;
vector<P> G[5];

int main(){
  cin>>N>>tmin>>tmax;
  
  for(int i=0;i<N;i++){
    int type;
    ll x,y;
    cin>>type>>x>>y;
    type--;
    G[type].push_back( P(x,y) );
  }
  for(int i=0;i<5;i++)G[i].push_back( P(0,0) );
  
  for(int i=0;i<3;i++){
    int target=i;
    for(int j=i+1;j<5;j++){
      if( G[target].size() > G[j].size() ){
        target=j;
      }
    }
    if(i!=target){
      vector<P> tmp;
      tmp=G[i];
      G[i]=G[target];
      G[target]=tmp;
    }
  }

  ll Asize= G[0].size() * G[1].size()  * G[2].size();
  //  if(Asize>500000)return 0;
  ll Bsize= G[3].size() * G[4].size();
  
  vector<P> A ( Asize );
  vector<P> B ( Bsize );

  int cc;
  cc=0;
  for(int i=0;i<(int)G[0].size();i++){
    P X=G[0][i];
    for(int j=0;j<(int)G[1].size();j++){
      P Y=G[1][j];
      for(int k=0;k<(int)G[2].size();k++){
        P Z=G[2][k]; 
        A[cc++]=P( X.first+Y.first+Z.first , X.second+Y.second+Z.second );
      }
    }
  }
  cc=0;
  for(int i=0;i<(int)G[3].size();i++){
    P X=G[3][i];
    for(int j=0;j<(int)G[4].size();j++){
      P Y=G[4][j];
      B[cc++]=P( X.first+Y.first , X.second+Y.second );
    }
  }
  
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());

  int l=B.size() ,r= B.size();
  
  map<ll,int> count;
  set<ll> st;
  for(int i=0;i<(int)A.size();i++){
    ll x=A[i].first;
    ll y=A[i].second;
    
    while(l-1>=0 && x + B[l-1].first >= tmin ){
      ll key=B[l-1].second;
      st.insert(key);
      count[ key ]++;
      l--;
    }
    
    while(r>l && x + B[r-1].first > tmax ){
      ll key=B[r-1].second;
      count[ key ]--;
      if( count[ key ] == 0 )  st.erase( key );
      r--;
    }

    if( st.lower_bound(tmin-y) != st.upper_bound(tmax-y) ){
      cout<<"Yes"<<endl;
      return 0;
    }
  }

  cout<<"No"<<endl;
  return 0;
}
           

Measured memory_bytes: 20148
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct node{
	int t,id;
}c[100005];
bool cmp(node a,node b){return a.t<b.t;}
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>c[i].t,c[i].id=i;
	sort(c+1,c+n+1,cmp);
	for(int i=1;i<=n;i++)
		cout<<c[i].id<<" ";
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,i,j,k,N,count=0;
    cin >>a>> b>>c>>N;
    for(i=0;i<=a;i++){
        for(j=0;j<=b;j++){
            for(k=0;k<=c;k++){
                if(N==i*500+j*100+k*50)
                count++;
            }
        }
    }
    cout << count <<endl;
}


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

int main()
{
	int X,Y,Z,K;
	cin >> X >> Y >> Z >> K;
	vector<ll> A(X),B(Y),C(Z);
	for(int i(0);i<X;++i) cin >> A[i];
	for(int i(0);i<Y;++i) cin >> B[i];
	for(int i(0);i<Z;++i) cin >> C[i];
	sort(A.begin(),A.end(),greater<ll>());
	sort(B.begin(),B.end(),greater<ll>());
	sort(C.begin(),C.end(),greater<ll>());

	priority_queue<pair<ll, vector<int>>> Q;
	set<vector<int>> memo;
	vector<int> idx{0, 0, 0};
	memo.insert(idx);
	Q.push(make_pair(A[0]+B[0]+C[0], idx));

	for(int i(0);i<K;++i){
		auto t = Q.top(); Q.pop();
		cout << t.first << endl;

		int x(t.second[0]), y(t.second[1]), z(t.second[2]);
		if(x < X - 1){
			ll s = A[x+1] + B[y] + C[z];
			vector<int> v{x+1, y, z};
			auto p = make_pair(s,v);
			if (memo.count(v) == 0) memo.insert(v), Q.push(p);
		}
		if(y < Y - 1){
			ll s = A[x] + B[y+1] + C[z];
			vector<int> v{x, y+1, z};
			auto p = make_pair(s,v);
			if (memo.count(v) == 0) memo.insert(v), Q.push(p);
		}
		if(z < Z - 1){
			ll s = A[x] + B[y] + C[z+1];
			vector<int> v{x, y, z+1};
			auto p = make_pair(s,v);
			if (memo.count(v) == 0) memo.insert(v), Q.push(p);
		}
	}
	return 0;
}

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

int main() {
    int N, result,
    Alice = 0,
    Bob = 0;
    cin >> N;
    vector<int> a(N);

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

    int j, temp;
    for (i = 0; i < N; i++) {
        for (j = 0; j < N - 1; j++) {
            if (a.at(j) < a.at(j + 1)) {
                temp = a.at(j);
                a.at(j) = a.at(j + 1);
                a.at(j + 1) = temp;
            }
        }
    }

    for (i = 0; i < N; i += 2) {
        Alice += a.at(i);
    }
    for (i = 1; i < N; i += 2) {
        Bob += a.at(i);
    }

    result = Alice - Bob;

    cout << result << endl;
 }


Measured memory_bytes: 256
N,M=map(int, input().split())
vs=set()
def dfs(v,path,pvs):
    lp=l=N+1
    for u in d[v]:
        if u in pvs:
            for i, c in enumerate(path):
                if c == u:
                    break
            nlp = path[i+1:]+[u]
            nl = len(nlp)
            if nl < l:
                lp, l = nlp, nl
        if u in vs:
            continue
        vs.add(u)
        nl, nlp = dfs(u,path+[u],pvs|{u})
        if nl < l:
            lp, l = nlp, nl
    return l,lp
d = [set() for _ in range(N+1)]
for _ in range(M):
    a,b=map(int,input().split())
    d[a].add(b)
for i in range(N):
    v=i+1
    l,lp=dfs(i+1,[v],{v})
    if l<=N:
        print("\n".join(str(x) for x in[l]+lp))
        break
else:
    print(-1)

Measured memory_bytes: 60272
#include <iostream>
#include <cstdlib>
using namespace std;
char shcd[4] = {'S', 'H', 'C', 'D'};
struct Card {
    char picture;
    int number;
    bool have;
};

int main()
{
    Card mycard[4][13];
    int num;
    char a;
    int b;

    for(int i =0; i < 4; i++)
        for(int j = 0; j < 13; j++)
        {
            mycard[i][j].picture = shcd[i];
            mycard[i][j].number = j + 1;
            mycard[i][j].have = false;
        }

    cin >> num;
    for(int i = 0; i < num; i++)
    {
        cin >> a;
        cin >> b;
        switch(a)
        {
            case 'S':
                mycard[0][b-1].have = true;
                break;
            case 'H':
                mycard[1][b-1].have = true;
                break;
            case 'C':
                mycard[2][b-1].have = true;
                break;
            case 'D':
                mycard[3][b-1].have = true;
                break;
            default:
                cout << "error!!" << endl;
                exit(EXIT_FAILURE);
        }
    }
    for(int i =0; i < 4; i++)
        for(int j = 0; j < 13; j++)
        {
            if(mycard[i][j].have == false)
            {
                cout << mycard[i][j].picture;
                cout << " ";
                cout << mycard[i][j].number;
                cout << endl;
            }
        }

    return EXIT_SUCCESS;
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>


using namespace std;
#define INF 1000000005
int main()
{
int n,m;
std::cin >> n >> m;
long long int max = 1;
for(int i = (m / n); i >= 1; i--){
    if(m % i == 0 && i * n <= m){
        max = i;
        break;
    }
}
std::cout << max << std::endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
map<string,int> pre;
int main()
{
    int n;
    cin>>n;
    int cur=0;
    for(int i=0;i<n;i++)
    {
        string s;
        int t;
        cin>>s>>t;
        cur+=t;
        pre[s]=cur;
    }
    string x;
    cin>>x;
    cout<<cur-pre[x]<<'\n';
}

Measured memory_bytes: 256
s = input()

if s[0] == s[1] and s[1] == s[2] and s[2] == s[3]:
    print("No")
else:
    if s[0] == s[1] and s[2] == s[3]:
        print("Yes")
    elif s[0] == s[2] and s[1] == s[3]:
        print("Yes")
    elif s[0] == s[3] and s[1] == s[2]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <array>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <random>
#include <bitset>
#include <cassert>
#include <tuple>
#include <list>
#include <iterator>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef long double ld;

template<class htpe, class cmp>
using heap = priority_queue<htpe, vector<htpe>, cmp>;

template<class htpe>
using min_heap = heap<htpe, greater<htpe> >;

template<class htpe>
using max_heap = heap<htpe, less<htpe> >;

#define mp make_pair
#define pb push_back
#define mt make_tuple
#define ff first
#define ss second

#define forn(i, n) for (int i = 0; i < ((int)(n)); ++i)
#define forrn(i, s, n) for (int i = (int)(s); i < ((int)(n)); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define PYMOD(a, m) ((((a) % (m)) + (m)) % (m))

const int INF = 1791791791;
const ll INFLL = 1791791791791791791ll;

const int maxn = 179;
int a[2][maxn];
int dp[2][maxn];


int main() {
    // Code here:

    int n;
    cin >> n;
    forn(i, 2)
        forn(j, n)
            cin >> a[i][j];
    dp[0][0] = a[0][0];

    forn(i, 2) {
        forrn(j, i == 0, n) {
            dp[i][j] = -INF;
            if (i > 0) dp[i][j] = max(dp[i][j], dp[i - 1][j] + a[i][j]);
            if (j > 0) dp[i][j] = max(dp[i][j], dp[i][j - 1] + a[i][j]);
        }
    }

    cout << dp[1][n - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
cost0 = 0
costN = 0

for i in range(x, 0, -1):
    for j in range(len(a)):
        if a[j] == i:
            cost0 += 1

for i in range(x, n+1):
    for j in range(len(a)):
        if a[j] == i:
            costN += 1

if cost0 <= costN:
    print(cost0)

else:
    print(costN)

Measured memory_bytes: 3064
(N,M) = (int(i)for i in input().split(" "))
S = input()
l = [[0,0]]
ch = '0'
count = 0
for s in S:
	if s==ch:
		count += 1
	else:
		if s == '0':
			l[-1].append(count)
		else:
			l.append([count])
		ch = s
		count += 1
if len(l[-1]) == 1:
	l[-1].append(count)
elif l[-1][1] != count:
	l.append([count, count])

left = 0
right = M
if len(l) <= M:
	right = len(l) - 1

max_ans = 0
while right < len(l):
	ans = l[right][1] - l[left][0]
	if ans > max_ans:
		max_ans = ans
	right += 1
	left += 1

print(max_ans)

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

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

ll num[ten52];
ll num2[ten52];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3,range;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    a=a1=a2=a3=a4=a5=a6=0;
    //float f,g,h;
    string s,s1;
    //priority_queue<long long int> pq;
    //vector<pair<ll,ll>> vint;
    //map<pair<ll,ll>,ll> mp;
    //list<int> li;
    //map<string,int>::iterator iter;
    //set<int> sint;
    char now,pre,c;
    cin>>n;
    cin>>s;
    num[0]=(s[0]=='#');
    for(i=1;i<=n;i++)
    {
        num[i]=num[i-1]+(s[i]=='#');
    }
    for(i=n-1;i>=0;i--)
    {
        num2[i]=num2[i+1]+(s[i]=='.');
    }
    a=num2[0];
    for(i=0;i<=n;i++)
    {
        a=min(a,num[i]+num2[i+1]);
    }
    cout<<a;
    return 0;
}
/*.#..####.
011123455
433211111*/


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define li long
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pli pair<li,li>
#define pll pair<ll,ll>
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
#define tc int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define inf INT_MAX
#define ninf INT_MIN
#define W(x) cout<<x<<endl
#define WW(x,y) cout<<x<<' '<<y<<endl;
#define in(x) cin>>x
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll power(ll x,ll y){
    ll res = 1;
    
    while(y>0){
        if(y&1)res = (res*x);
        y>>=1;
        x = (x*x);
    }
    return res;
}

ll power(ll x,ll y,ll p){
    ll res = 1;
    x%=p;
    while(y>0){
        if(y&1)res = (res*x)%p;
        y>>=1;
        x = (x*x)%p;
    }
    return res;
}

ll x;
int main(){
	fastio();
	cin>>x;
	ll ans1,ans2;
	for(ll i = -1000; i<=1000; i++){
		for(ll j = -1000; j<=1000; j++){
			if(power(i,5)-power(j,5) == x){
				ans1 = i,ans2 = j;
				break;
			}
		}
	}
	cout<<ans1<<' '<<ans2<<"\n";
}

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

int main()
{
  string N;
  int tmp=0;
  string result;

  cin >> N;
  for(int i=0;i<N.length();i++){
    int a = N[i] - '0';
    tmp += a;
  }
  if(tmp%9==0){
    result = "Yes";
  }else{
    result ="No";
  }
  
  cout << result << endl;
}

Measured memory_bytes: 3708
#include <stdio.h>

main(){
	int N,M;
	scanf("%d %d",&N,&M);

	int y[100001];
	int i,j,k;
	for(i=1;i<=N;i++)
		y[i]=2*N;

	int a,b;

	for(i=0;i<M;i++){
		scanf("%d %d",&a,&b);
		if(b<y[a])
			y[a]=b;
	}
	for(i=1;i<N;i++){
		if(y[i]==2*N)continue;
		for(k=i+1;k<y[i];k++){
			if(y[k]<=y[i]){//ganni
				y[i]=2*N;
				break;
			}
			else{	//and
				y[k]=y[i];
				y[i]=2*N;
				break;
			}
		}
	}
	int rt=0;
	for(i=1;i<N;i++)
		if(y[i]!=2*N)
			rt++;
	printf("%d\n",rt);

	return 0;
}

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

using namespace std;

int main() {
	int n;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		int h, m, s;
		int h2, m2, s2;
		char c;
		vector<int> mm(100000, 0);
		for (int i = 0; i < n; i++) {
			cin >> h >> c >> m >> c >> s >> h2 >> c >> m2 >> c >> s2;
			//cout << h << ' ' << m << ' ' << s << ' ' << h2 << ' ' << m2 << ' ' << s2 << endl;
			int a = h * 3600 + m * 60 + s;
			int b = h2 * 3600 + m2 * 60 + s2;
			//cout << a << ' ' << b << endl;
			mm[a]++;
			mm[b]--;
		}
		int MAX = mm[0];
		for (int i = 1; i < 100000; i++) {
			mm[i] += mm[i - 1];
			MAX = max(MAX, mm[i]);
		}
		cout << MAX << endl;
	}
	return 0;
}

Measured memory_bytes: 3408
#include <stdio.h>

void sort(int *A, int l, int r){
	if(r - l != 1){
		int h = (r + l)/2, d = r - l;
		sort(A, l, h);
		sort(A, h, r);
		int i = l, j = h, k, B[d];
		for(k = 0; k < d; k++){
			if(j == r){
				B[k] = A[i];
				i++;
			}
			else if(A[i] > A[j] || i == h){
				B[k] = A[j];
				j++;
			}
			else{
				B[k] = A[i];
				i++;
			}
		}
		for(k = 0; k < d; k++){
			A[l + k] = B[k];
		}
	}
}

int main(){
	int N, i;
	scanf("%d", &N);
	int A[N];
	for(i = 0; i < N; i++){
		scanf("%d", &(A[i]));
	}
	sort(&(A[0]), 0, N);
	int a, n = 0;
	for(i = 0; i < N; i++){
		if(a != A[i]){
			a = A[i];
			n++;
		}
	}
	if((N-n)%2 == 0){
		printf("%d\n", n);
	}
	else{
		printf("%d\n", n-1);
	}
	return 0;
}

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

vector<int>to[200005];
vector<int>ans;
void dfs(int v,int p=-1){
    for(int u:to[v]){
        if(u==p)continue;
        ans[u]+=ans[v];
        dfs(u,v);
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(n);
    rep(i,q){
        int p,x;
        cin>>p>>x;
        --p;
        ans[p]+=x;
    }
    dfs(0);
    rep(i,n){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 23552
#include <stdio.h>
#define MAX 100005
#define NIL -1

struct Node {
  int p, l, r;
};

struct Node T[MAX];
int n, D[MAX];

void print(int u) {
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", D[u]);

  if (T[u].p == NIL) printf("root, ");
  else if (T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for (int i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if (T[u].r != NIL) rec(T[u].r, p);
  if (T[u].l != NIL) rec(T[u].l, p + 1);
}

int main() {
  int d, v, c, l, r;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }

  for (int i = 0; i < n; i++) {
    scanf("%d %d", &v, &d);
    for (int j = 0; j < d; j++) {
      scanf("%d", &c);
      if (j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }

  for (int i = 0; i < n; i++) {
    if (T[i].p == NIL) r = i;
  }

  rec(r, 0);

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

  return 0;
}



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

int main(){
   int x,y;
   while(1){
       cin>>x>>y;
       if(x==0 && y==0)break;
       if(x>y) swap(x,y);
       cout<<x<<" "<<y<<endl;
   }
   return 0;
}


Measured memory_bytes: 3080
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val xs = IntArray(n)
    val ys = IntArray(n)

    val points = (0 until n).map {
        val (x, y) = readLine()!!.split(' ').map { it.toInt() }
        xs[it] = x
        ys[it] = y
        x to y
    }

    xs.sort()
    ys.sort()

    var ans = 1L * (xs.last() - xs.first()) * (ys.last() - ys.first())

    for (xi in 0 until n) {
        for (xj in xi + 1 until n) {
            for (yi in 0 until n) {
                for (yj in yi + 1 until n) {
                    val xl = xs[xi]
                    val xr = xs[xj]
                    val yb = ys[yi]
                    val yt = ys[yj]

                    val cnt = (0 until n).count { points[it].first in xl..xr && points[it].second in yb..yt }
                    if (cnt >= k) {
                        ans = Math.min(1L * (xr - xl) * (yt - yb), ans)
                    }
                }
            }
        }
    }

    println(ans)
}

Measured memory_bytes: 52552
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char []s = sc.next().toCharArray();
		char []t = sc.next().toCharArray();
		
		int count  = 0;
		for(int i = 0; i < 3 ; i++) {
			if(s[i] == t[i])
				count++;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 21332
import sys
input = sys.stdin.readline
N = int(input())
B = [int(x) for x in input().split()]

A = []
for i in range(N) :
    if i == 0 :
        Ai = B[0]
    elif i == N-1 :
        Ai = B[i-1]
    else :
        Ai = min(B[i-1], B[i])
    A.append(Ai)

print(sum(A))


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const int N = 1e5 + 5;

int id[N];
int sz[N];

void pre(){

	for(int i= 0 ; i<N ; i++) id[i] = i , sz[i] = 1;
}

int root(int i){

	while(i != id[i])	id[i] = id[id[i]] , i = id[i];
	return i;
}

void uni(int a, int b){
	int ra = root(a);
	int rb = root(b);
	if(ra == rb)	return;
	if(sz[ra] < sz[rb]) swap(ra,rb);
	id[rb] = ra , sz[ra] += sz[rb];
}

vi g[N];
int f[N];
int32_t main(){
	fast;
	pre();
	
	int n,m,k;
	cin >> n >> m >> k;
	
	for(int i=1 ; i<=m ; i++){
		int x,y;
		cin >> x >> y;
		f[x]++;
		f[y]++;
		uni(x,y);
	}
	
	for(int i=1 ; i<=k ; i++){
		int x,y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	
	for(int i=1 ; i<=n ; i++){
		int rt = root(i);
		int ans = sz[rt] - f[i] - 1;
		for(int u : g[i]){
			if(root(u) == rt){
				ans--;
			}
		}
		cout << ans << " ";
	}
}


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

int main() {
  int n, s = 1;
  cin >> n;
  vector<pair<int,int>> x(n);
  rep(i, n){
    int a, b;
    cin >> a >> b;
    x[i] = make_pair(a, b);
  }
  sort(x.begin(), x.end());
  vector<int> tmp = {x[0].first + x[0].second};
  rep(i, n-1){
    if(x[i+1].first + x[i+1].second <= tmp[tmp.size()-1]) tmp.push_back(x[i+1].first + x[i+1].second);
    else if(x[i+1].first - x[i+1].second >= tmp[tmp.size()-1]){
      ++s;
      tmp.push_back(x[i+1].first + x[i+1].second);
    }
  }
  cout << s << endl;
}

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

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES" : "NO");

		static void Main(string[] args)
		{
			var a = RIs;
			if (a[0] == 1 || a[1] == 1)
			{
				char[][] map = (new char[100][]).Select(x => new char[100]).ToArray();
				for (int i = 0;i < 100;i++)
				{
					for(int j = 0;j < 100;j++)
					{
						map[i][j] = (a[0] == 1) ? '.' : '#';
					}
				}
				char cc = (a[0] == 1) ? '#' : '.';
				int count = 0;
				int f = (a[0] == 1) ? a[1] : a[0];
				for (int i = 0;i < 100;i += 2)
				{
					for(int j = 0;j < 100;j+= 2)
					{
						map[i][j] = cc;
						count++;
						if(count == f)
						{
							output(map);
							return;
						}
					}
				}
			}
			else
			{
				char[][] map = (new char[100][]).Select(x => new char[100]).ToArray();
				{
					for (int i = 0; i < 50; i++)
					{
						for (int j = 0; j < 100; j++)
						{
							map[i][j] = '.';
						}
					}
					char cc ='#';
					int count = 0;
					int f =a[1]-1;
					for (int i = 0; i < 100; i += 2)
					{
						for (int j = 0; j < 100; j += 2)
						{
							map[i][j] = cc;
							count++;
							if (count == f)
							{
								goto NEXT;
							}
						}
					}
				}
				NEXT:
				{
					for (int i = 50; i < 100; i++)
					{
						for (int j = 0; j < 100; j++)
						{
							map[i][j] = '#';
						}
					}
					char cc = '.';
					int count = 0;
					int f = a[0] - 1;
					for (int i = 51; i < 100; i += 2)
					{
						for (int j = 0; j < 100; j += 2)
						{
							map[i][j] = cc;
							count++;
							if (count == f)
							{
								output(map);
								return;
							}
						}
					}
				}
			}
		}

		static void output(char[][] str)
		{
			Out("100 100");
			for(int i = 0;i < str.Length;i++)
			{
				Out(new String(str[i]));
			}
		}
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 

int main(){
  int N;
  cin >> N;
  vec<char> color(N);
  rep(i,N){
    cin >> color.at(i);
  }
  
  int Exists_Y = 0;
  rep(i,N){
    if (color.at(i) == 'Y'){
      Exists_Y = 1;
    }
  }
  
  if (Exists_Y == 1){
    cout << "Four";
  }else{
    cout << "Three";
  }
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    long double n,a,p=1,l=1;
    cin>>n;
    while(n--)
    {
        cin>>a;
        p*=a;
        if(a==0)
            l=5;
        if(p>1.0e18)
        {
            l=0;
        }
    }
    if(l==5)
        cout<<"0";
    else if(l==1)
        cout<<fixed<<setprecision(0)<<p;
    else
        cout<<"-1";




}


Measured memory_bytes: 3792
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

#define MOD 1000000007
using namespace std;
long long mod(const long long &a) {
	if (a >= 0)return a % 1000000007;
	return 1000000007 - (-a) % 1000000007;
}
int mod(const int &a) {
	if (a >= 0)return a % 1000000007;
	return 1000000007 - (-a) % 1000000007;
}

int n, m,l;
string s;

int main() {
	cin >> n>>m;
	vector<int> a(m);
	for (int i = 0; i < m; i++)
	{
		cin >> a[i];
	}
	vector<int> dp(n + 2);
	dp[0] = 1;
	int iter = 0;
	if (m > 0) {
		if (a[0] != 1) {
			dp[1] = 1;
		}
		else {
			dp[1] = 0;iter++;
		}
	}
	else {
		dp[1] = 1;
	}
	for (int i = 2; i <= n; i++)
	{
		if (iter<m&&i == a[iter]) {
			dp[i] = 0;
			iter++;
			continue;
		}
		dp[i] = mod(dp[i - 1] + dp[i - 2]);
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int a, b, i, count, flag = 0;

	while (1) {
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) break;
		count = 0;
		if (flag)printf("\n");
		flag = 1;
		for (i = a; i <= b; i++) {
			if ((i % 400 == 0) || (i % 4 == 0 && i % 100 != 0)) {
				printf("%d\n", i);
				count++;
			}
		}
		
		if (count == 0) printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 616
while True:
    n,m =map(int, input().split())
    if n==0 and m==0:
        break
    a=[]
    length=0
    for i in range(0,n):
        d,p= map(int,input().split())
        length+= d
        a.append([p,d])

    a.sort()
    a.reverse()
    if length <= m:
        print(0)
    else:
        zankin=m
        flag=0
        while True:
            if zankin<= a[0][1]:
                a[0][1]-=zankin

                break
            else:
                zankin-=a[0][1]
                a.pop(0)
        ans=0
        for i in range(0,len(a)):
            ans+= a[i][0]*a[i][1]
        print(ans)


Measured memory_bytes: 6800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.1415926535

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int itr = 1;
    int ans = 0;
    rep(i, n) {
        if (a[i] == itr)
            itr++;
        else
            ans++;
    }
    if (itr == 1)
        cout << -1 << endl;
    else
        cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long in;
int main()
{
    in n,k;
    cin>>n>>k;
    vector<vector<in>> dp(n+1,vector<in>(k+1));
    in w[n];
    in p[n];
    for(in i=0;i<n;i++)
    {
        cin>>w[i]>>p[i];
    }
    for(in i=1;i<=n;i++)
    {
        for(in j=1;j<=k;j++)
        {
            if(j-w[i-1]>=0)
            {
                dp[i][j]=max(dp[i-1][j-w[i-1]]+p[i-1],dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][k];
}

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

int main() {
	
	ll n; cin >> n;
	vector<ll> a(n);
	vector<ll> num(n + 1, 0);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		num[a[i]]++;
	}
	ll sum = 0;
	for (ll i = 0; i <= n; i++) {
		if (2 <= num[i]) {
			sum += num[i] * (num[i] - 1) / 2;
		}
	}
	for (ll i = 0; i < n; i++) {
		ll ans;
		ans = sum;
		ans -= num[a[i]] * (num[a[i]] - 1) / 2;
		ans += (num[a[i]] - 1) * (num[a[i]] - 2) / 2;
		cout << ans << endl;
	}	
	return 0;
}

Measured memory_bytes: 5760
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;

int n,m,w,h;
int g[10][10];
ll k;
string s;

int main() {
	cin >> h >> w;
	REP(i,10)REP(j, 10){
		cin >> g[i][j];
	}
	REP(k,10)REP(i,10)REP(j,10)
			g[i][j] = min(g[i][k] + g[k][j], g[i][j]);

	 ll ans = 0;
	REP(i,h)REP(j,w){
		int a;
		cin >> a;
		if(a!=-1)ans += g[a][1];
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
NT = list(map(int,input().split()))
t = list(map(int,input().split()))

o = 0
for i in range(NT[0] - 1):
    # お湯が一度止まる
    if t[i+1] - t[i] >= NT[1]:
        o += NT[1]
    else:
        o += t[i+1] - t[i]

print(o + NT[1])

Measured memory_bytes: 25196
#include<stdio.h>
#include<cctype>
using namespace std;

int main(){
  char s;
  while (1){
    scanf("%c", &s);
    if (s == '\n') break;
    if (islower(s)) printf("%c", toupper(s));
    else if (isupper(s)) printf("%c", tolower(s));
    else printf("%c", s);
  }
  printf("\n");  
  
  return 0;
}


Measured memory_bytes: 2692
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)

using namespace std;

int code(char c) {
	if (c == '<')return 1;
	else return -1;
}

void foreach_permutation(int n, std::function<void(int*)> f) {
	int indexes[10];
	for (int i = 0; i < n; i++) indexes[i] = i;
	do {
		f(indexes);
	} while (std::next_permutation(indexes, indexes + n));
}

double dis(pair<int, int> a, pair<int, int> b) {
	return sqrt(pow(a.first - b.first, 2) + pow(a.second - b.second, 2));

}



int main() {
	int N;
	vector<pair<int, int>> A;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		A.push_back(make_pair(x, y));
	}


	double ans = 0;
	int M = 1;
	for (int i = 1; i <= N; i++) {
		M *= i;
	}
	int num =M/N ;

	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			ans += sqrt((pow(A[i].first - A[j].first, 2) + pow(A[i].second - A[j].second, 2)) * num *num*4);
		}

	}

	ans /= M;
	printf("%.6lf", ans);
	return 0;
}


Measured memory_bytes: 256