akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	scanf("%d", &n);
	vector<int>v;
	for (int i = 0; i < n; i++)
	{
		int z;
		scanf("%d", &z);
		z--;
		v.push_back(z);
	}
	int now = 0, c = 0;
	for (;;)
	{
		if (now == 1)
		{
			printf("%d\n", c);
			break;
		}
		c++;
		now = v[now];
		if (c > n + n)
		{
			printf("-1\n");
			break;
		}
	}
}

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

ll a[5];

int main()
{
	ios::sync_with_stdio(false);
	int cnt = 0;
	for(int i = 0; i < 3; i++){
		cin >> a[i];
		if(a[i] % 2 == 0) cnt++;
	}
	if(cnt != 0) { cout << '0' << endl; return 0;}
	sort(a, a + 3);
	cout << a[0] * a[1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

typedef long long int ll;

const int N = 1e3 + 10;
const int M = 1e4 + 10;

struct block {
  int w, s, v;
  block(int a, int b, int c) {
    w = a, s = b, v = c;
  }
  bool operator<(const block &o) const {
    return s - o.w < o.s - w;
  }
};

int n;
vector<block> a;
ll dp[M + M];

void solve() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int w, s, v; cin >> w >> s >> v;
    a.emplace_back(w, s, v);
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n; ++i) {
    block& cur = a[i];
    for(int weight = cur.s; weight >= 0; --weight) {
      dp[weight + cur.w] = max(dp[weight + cur.w], dp[weight] + cur.v);
    }
  }
  ll ans = 0;
  for(int i = 0; i < M + M; ++i) ans = max(ans, dp[i]);
  cout << ans << endl;
}

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


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

using namespace std;

#define ALL(x) x.begin(), x.end()

typedef long long int lld;
typedef pair<int, int> pii;

const int maxw = 100005;
lld dp[maxw];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;

	int n, w;
	cin >> n >> w;

	vector<pair<lld, lld>> vec(n);

	for (int i = 0; i < n; i++) {
		cin >> vec[i].first >> vec[i].second;
	}

	for (int i = 0; i < n; i++) {
		for (int j = w; j >= vec[i].first; j--) {
			if (dp[j - vec[i].first])
				dp[j] = max(dp[j], dp[j - vec[i].first] + vec[i].second);
				
		}

		dp[vec[i].first] = max(dp[vec[i].first], vec[i].second);
	}

	cout << *max_element(dp, dp + w + 1) << endl;



	

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

struct UnionFind {
  vector<int> parent;
  UnionFind (int n) : parent(n, -1) {}
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (parent[y] < parent[x]) swap(x, y);
    if (parent[x] == parent[y]) --parent[x];
    parent[y] = x;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  cin>>n>>m;
  UnionFind uf(n);
  int cnt = n;
  REP(i,m) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    if (uf.merge(a,b)) --cnt;
  }
  cout<<cnt-1<<endl;
  return 0;
}


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

using namespace std;

int cnt(int x) {
    int rv = 0;
    while (x) {
        rv ++;
        x /= 10;
    }
    return rv;
}

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

    int n;
    cin >> n;

    vector< int> v(n + 1);
    for (int i = 1; i <= n; i ++) cin >> v[i];

    for (int i = 1; i <= n; i ++) {
        if (v[i] > v[i - 1]) {
            v[i] --;
        }
        if (v[i] < v[i - 1]) return cout << "No\n", 0;
    }
    cout << "Yes\n";
}


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

int* marge(int* array1, int length1, int* array2, int length2)
{
  int length_new = length1 + length2;
  int* array_new = new int[length_new];
  for (int i=0, j=0, k=0; k<length_new; k++)
  {
    if (i < length1 && j < length2)
    {
      if (array1[i] < array2[j])
      {
        array_new[k] = array1[i];
        i++;
      }
      else
      {
        array_new[k] = array2[j];
        j++;
      }
    }
    else if ( i >= length1 )
    {
      array_new[k] = array2[j];
      j++;
    }
    else
    {
      array_new[k] = array1[i];
      i++;
    }
  }
  return array_new;
}

int max_diff(int* array, int length)
{
  int max = array[0];
  for (int i = 1; i < length; i++)
  {
    int diff = array[i] - array[i-1];
    if (max < diff)
    {
      max = diff;
    }
  }
  return max;
}

int main(void)
{
  int n, m;
  while (true)
  {
    cin >> n >> m;
    if ( n == 0 && m == 0 ) break;
    
    int* up_line = new int[n];
    for (int i = 0; i < n; i++)
    {
      cin >> up_line[i];
    }

    int* down_line = new int[m];
    for (int j = 0; j < m; j++)
    {
      cin >> down_line[j];
    }

    int* marge_line = marge(up_line, n, down_line, m);

    delete[] up_line;
    delete[] down_line;

    int max = max_diff(marge_line, n+m);

    cout << max << endl;

    delete[] marge_line;
  }
  return 0;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
typedef pair< int , int> P;
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){
  if(checkyear%4==0){
    if(checkyear%100!=0||checkyear%400==0)
    return true;
  }
  return false;
}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const P& firstElof, const P& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
int a=0,b=0;
string s= "IMPOSSIBLE";
std::cin >> x>>y;
if((x+y)%2==0)std::cout << (x+y)/2 << '\n';
else std::cout << s << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;
struct UF
{
  vector<int> par;
  vector<int> sz;
  vector<int> rank;
  UF(int n):par(n),sz(n),rank(n){
    for(int i = 0; i < n; i++){
      par[i] = i;sz[i] = 1;rank[i] = 0;
    }
  }
  int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  void merge(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if(rank[x] < rank[y]){
      par[x] = y;
      sz[y] += sz[x];
    }
    else{
      par[y] = x;
      sz[x] += sz[y];
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int n){return sz[find(n)];}
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  vector<pair<ll,ll>>E(m);
  for(auto &a:E){
    cin>>a.F>>a.S;
    a.F--;a.S--;
  }
  ll ans = 0;
  for(int i=0;i<m;i++){
    UF uni(n+10);
    for(int j=0;j<m;j++){
      if(i == j)continue;
      uni.merge(E[j].F,E[j].S);
    }
    // cout<<uni.size(0)<<endl;
    ans += (uni.size(0) != n);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
total = 0
def cmb(n, r, mod):
    if (r<0 or r>n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**5
g1 = [1,1]
g2 = [1,1]
inverse = [0,1]

for i in range(2, N + 1):
    g1.append((g1[-1]*i) % mod)
    inverse.append((-inverse[mod%i] * (mod//i)) % mod)
    g2.append((g2[-1]*inverse[-1]) % mod)

for i in range(n-k+1):
    total += cmb(n-i-1,k-1,mod)*(a[n-i-1]-a[i])
    total %= mod
print(total)

Measured memory_bytes: 21136
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<functional>
#include<map>
using namespace std;
int main()
{
	string a;
	map<char, int >b,c;
	int q = 0;
	cin >> a;
	for (int i = 0; i < 3; i++)
	{
		b[a[i]]++;
		if (b[a[i]] == 3) { cout << "Yes" << endl; q++; break; }
	}
	if(q==0)
	for (int i = 1; i < 4; i++)
	{
		c[a[i]]++;
		if (c[a[i]] == 3) { cout << "Yes" << endl; q++; break; }
	}
	if (q == 0)cout << "No" << endl;
	//system("pause");
	return 0;
}

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

template<typename T>
class PriorityQueue{
private:
	vector<T> d;
public:
	void push(T t){
        int k = d.size();
		d.push_back(t);
        while(k && d[(k - 1) / 2] < d[k]){
            swap(d[(k - 1) / 2], d[k]);
            k = (k - 1) / 2;
        }
	}
    T top(){
        // assert(d.size() > 0);
        return d[0];
    }
    void pop(){
        // assert(d.size() > 0);
        d[0] = d.back();
        d.pop_back();
        maxHeapify(0);
    }
	void maxHeapify(int k){
		int l = 2 * k + 1;
		int r = 2 * k + 2;
		T largest;
		if(l < d.size() && d[l] > d[k]) largest = l;
		else largest = k;

		if(r < d.size() && d[r] > d[largest]) largest = r;

		if(largest != k){
			swap(d[k], d[largest]);
			maxHeapify(largest);
		}
	}
	void buildMaxHeap(){
		for(int i = d.size() / 2; i >= 0; i--){
			maxHeapify(i);
		}
	}
	void printHeap(){
		for(int i = 0; i < d.size(); i++){
			cout << " " << d[i];
		}
		cout << endl;
	}
};

signed main(){
    PriorityQueue<int> pq;
    while(1){
        string s;
        cin >> s;
        if(s == "end") break;
        if(s == "insert"){
            int a;
            cin >> a;
            pq.push(a);
        }else{
            cout << pq.top() << endl;
            pq.pop();
        }
        // pq.printHeap();
    }
}

Measured memory_bytes: 11316
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <utility>
#define INF 9999999999
using namespace std;
typedef long long int ll;

int main() {
	int N;
	cin >> N;
	if (N <= 999) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int n, m;
    vector<int> odd, a, b;
     
    int main() {
        cin >> n >> m;
        for (int i = 0; i < m; i++) {
            int cur;
            cin >> cur;
            if (cur % 2 == 0) {
                a.push_back(cur);
            } else {
                odd.push_back(cur);
            }
        }
     
        if (odd.size() > 2) {
            cout << "Impossible\n";
            return 0;
        }
        if (!odd.empty()) {
            a.insert(a.begin(), odd.back());
            odd.pop_back();
        }
        if (!odd.empty()) {
            a.push_back(odd.back());
            odd.pop_back();
        }
     
        for (int i = 0; i < m; i++) {
            if (i == 0) {
                if (m == 1) {
                    b.push_back(1);
                    if (a[i] - 1 > 0) {
                        b.push_back(a[i] - 1);
                    }
                } else {
                    if (a[i] % 2 == 0) {
                        b.push_back(1);
                        b.push_back(a[i]);
                    } else {
                        b.push_back(a[i] + 1);
                    }
                }
            } else if (i + 1 < m) {
                b.push_back(a[i]);
            } else {
                if (a[i] - 1 > 0) {
                    b.push_back(a[i] - 1);
                }
            }
        }
     
        for (int i = 0; i < m; i++) {
            cout << a[i];
            if (i + 1 < m) {
                cout << ' ';
            }
        }
        cout << '\n' << b.size() << endl;
        for (int i = 0; i < b.size(); i++) {
            cout << b[i];
            if (i + 1 < b.size()) {
                cout << ' ';
            }
        }
        cout << endl;
        return 0;
    }

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

int main(){
    double pai=3.141592653589;
    char w;
    for(;;){
        scanf("%c",&w);
        if(w=='\n'){
            break;
        }else if(isupper(w)){
            w=tolower(w);
            printf("%c",w);
        }else if(islower(w)){
            w=toupper(w);
            printf("%c",w);
        }else{
            printf("%c",w);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 3148
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)



int main() {
	int n, t;
	cin >> n >> t;

	int ci, ti;
	int ans=10000;
	REP(i, n) {
		cin >> ci >> ti;
		if (ti <= t) {
			if (ci < ans) {
				ans = ci;
			}
		}
	}
	if (ans == 10000) {
		ANS("TLE")
	}
	else {
		ANS(ans);
	}
	

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a[3];
    int sum=0;
    for(int i=0; i<3; i++){
        scanf("%d", &a[i]);
        sum += a[i];
    }

    if(sum>21){
        printf("bust");
    }else{
        printf("win");
    }
    
}

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

int main()
{
  int n;
  cin >> n;
  
  int a;
  bool flag = false;
  for (int i = 0; i < n; i ++)
  {
    cin >> a;
    if (a % 2 == 0)
    {
      if (!((a % 3 == 0) || (a % 5 == 0)) )
      {
        flag = true;
        break;
      }
    }
  }
        
  if(flag)
    cout << "DENIED" << endl;
  else
    cout << "APPROVED" << endl;
  
  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

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


int main(){
    int i;
    
    int N, T;
    int c,t;
    cin >> N >> T;
    vector<pair<int,int>> ct;
    
    for(i=0;i<N;i++){
        cin >> c >> t;
        if(t<=T) ct.push_back(pair<int,int>(c,t));
    }
    sort(ct.begin(), ct.end());
    if(ct.size()==0) cout << "TLE" << endl;
    else cout << ct[0].first << endl;
    
    
    return 0;
}


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

ll digit(ll n)
{
  ll k = 0;
  while(n != 0)
  {
    n /= 10;
    k++;
  }
  return k;
}  

//nの10^iの位の数を出力する関数
ll pla(ll n,ll i)
{
  ll x = pow(10,i + 1),y = pow(10,i);
  return n % x / y;
}

int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll> D(K);
  rep(i,K)
  {
    cin>>D.at(i);
  }
  for(ll i=N;;i++)
  {
    ll keta=digit(i);
    bool a=true;
    rep(j,keta)
    {
      rep(l,K)
      {
        if(pla(i,j)==D.at(l))
        {
          a=false;
        }
      }
    }
    if(a)
    {
      cout<<i<<endl;
      break;
    }
  }  
  return 0;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	int ans;

	if (A == B) {
		ans = A + B;
	}

	else {
		if (A > B) {
			ans = A + A - 1;
		}
		if (A < B) {
			ans = B + B - 1;
		}
    }

 	cout << ans << endl;

	return 0;
}

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

int main()
{
    char s[101];
    cin >> s;
    int num_set[23];
    for (int i=0; i<23; i++){
        num_set[i]=0;
    }
    int len = strlen(s);
    for (int i=0; i<len; i++){
        num_set[int(s[i]-97)]++;
    }
    int flag=0;
    for (int i=0; i<23; i++){
        if (num_set[i]%2!=0){
            flag=1;
            break;
        }
    }
    if(flag==0){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
    return 0;
}

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

using namespace std;

int main(void){
	int n;

	cin >> n;

	int prev = 0;
	if (n > 2){
		for (int i = 0; i <= n; i++){
			if (i * i <= n)
				prev = i * i;
			else {
				cout << prev << endl;
				break;
			}
		}
	}
	else
		cout << 1 << endl;

	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int n;
	cin >> n;
	cout << (n + 1) / 2;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    long long n, select;
    cin >> n >> select;
    long long MOD = 1e9+7;
    long long ans = 0;
    for(long long i=select;i<=n+1;i++){
        ans += ((n*(n+1))/2)-(((n-i)*(n-i+1))/2)-(((i-1)*i)/2)+1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

#define mp make_pair
typedef long long ll;
typedef pair<int,int>pii;
const int N = 2e5;
pii arr[N+100];
map<pii,ll>m;

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int t = i;
		int s = t%10,lst;
		while(t)
		{
			lst = t%10;
			t/=10;
		}
		m[mp(lst,s)]++;
		arr[i] = mp(lst,s);
	}
	ll ans = 0;
	for(int i=1;i<=n;i++){
		int t1 = arr[i].first,t2 = arr[i].second;
		ans += m[mp(t2,t1)];
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 1792
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    ans = 0
    for i in range(N)[::-1]:
        if A[i+1] >= B[i]:
            ans += B[i]
            A[i+1] -= B[i]
            B[i] = 0
        else:
            ans += A[i+1]
            B[i] -= A[i+1]
            A[i+1] = 0
            if A[i] >= B[i]:
                ans += B[i]
                A[i] -= B[i]
                B[i] = 0
            else:
                ans += A[i]
                B[i] -= A[i]
                A[i] = 0
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 81892
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<>());

    cout << (s < t ? "Yes" : "No")<< "\n";
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    ll n, k;
    cin >> n >> k;
    vector<pll> dt(n);
    rep(i, n){
        cin >> dt[i].second >> dt[i].first;
    }
    sort(dt.rbegin(), dt.rend());

    set<ll> s;
    stack<ll> st;

    ll ans = 0;
    rep(i, k){
        if(s.count(dt[i].second)) st.push(dt[i].first);
        s.insert(dt[i].second);
        ans += dt[i].first;
    }

    ll sum = ans;
    ans += s.size()*s.size();
    for(int i = k; i < n; ++i){
        if(st.empty()) break;
        if(s.count(dt[i].second)) continue;
        s.insert(dt[i].second);
        sum -= st.top(); st.pop();
        sum += dt[i].first;
        chmax(ans, sum+(ll)(s.size()*s.size()));
    }
    ppp(ans);


    return 0;
}


Measured memory_bytes: 4992
#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>;

const string ok = "POSSIBLE";
const string ng = "IMPOSSIBLE";

int main() {
    int n, m;
    cin >> n >> m;
    vector<set<int>> ship(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        ship.at(a).insert(b);
        ship.at(b).insert(a);
    }

    for (int i : ship.at(0)) {
        if (ship.at(i).count(n-1)) {
            cout << ok << endl;
            return 0;
        }
    }

    cout << ng << endl;
    return 0;
}

Measured memory_bytes: 31328
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

cnt = 0
b_tmp = 0
for i in range(n):
    if a[i] >= b[i]:
        cnt += b[i]
    else:
        cnt += a[i]
        b_tmp = b[i] - a[i]
        if a[i+1] >= b_tmp:
            cnt += b_tmp
            a[i+1] -= b_tmp
        else:
            cnt += a[i+1]
            a[i+1] = 0

print(cnt)


Measured memory_bytes: 18624
class BinarySearchTree:
    def __init__(self):
        self.root = None

    def insert(self, x):
        node = self.Node(x)
        if self.root is None:
            self.root = node
        else:
            here = self.root
            #
            temp = None
            while here is not None:
                temp = here
                if x < here.node:
                    here = here.left
                elif x > here.node:
                    here = here.right
            if x < temp.node:
                temp.left = node
            elif x > temp.node:
                temp.right = node

    def inorder(self, answer, address = "root"):
        if address is "root":
            address = self.root
        elif address is None:
            return
        self.inorder(answer, address.left)
        answer.append(address.node)
        self.inorder(answer, address.right)

    def preorder(self, answer, address = "root"):
        if address is "root":
            address = self.root
        elif address is None:
            return
        answer.append(address.node)
        self.preorder(answer, address.left)
        self.preorder(answer, address.right)

    class Node:
        def __init__(self, x):
            self.node = x
            self.left = None
            self.right = None

query = int(input())
bt = BinarySearchTree()
for _ in range(query):
    command = input()
    if command[0] == "i":
        bt.insert(int(command.split(" ")[1]))
    else:
        a = []
        bt.inorder(a)
        print(" ", end = "")
        print(*a)
        a = []
        bt.preorder(a)
        print(" ", end = "")
        print(*a)

Measured memory_bytes: 113116
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if((i+j)%2 == 0) printf("#");
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2620
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int H,W;
  scanf("%d %d",&H,&W);
  char s[H][W];
  char tmp;
  int ans=1;
  for (int i=0;i<H;i++){
      scanf("%s",s[i]);
  }
/*  for (int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout<<s[i][j];
    }
    cout<<"\n";
  } */

  for (int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(s[i][j]=='#'){
        if(s[i+1][j]=='#'){

        }else if(s[i-1][j]=='#'){

        }else if(s[i][j+1]=='#'){

        }else if(s[i][j-1]=='#'){

        }else{
          ans=0;
        }
      }
    }
  }
  if(ans==1){
    cout<<"Yes";
  }else{
    cout<<"No";
  }

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define MAXN 55
char o[MAXN], e[MAXN];
int main() {
	scanf("%s\n%s", o, e);
	for(int i = 0; ; i++) {
		if(o[i] != '\0')
			printf("%c", o[i]);
		if(e[i] != '\0')
			printf("%c", e[i]);
		if(o[i] == '\0' && e[i] == '\0')
			break;
	}
	return 0;
} 

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

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


int main()
{
    int N, L, Q;
    cin >> N;
    vector<int> x(N);
    REP(i, N) cin >> x[i];
    cin >> L;
    cin >> Q;
    vector<int> a(Q), b(Q);
    REP(i, Q){
        cin >> a[i] >> b[i];
        --a[i], --b[i];
        if(a[i] > b[i]) swap(a[i], b[i]);
    }

    // dp[k][i]: ホテル i から 2^k 以内に到達可能な最も右のホテル番号
    vector<vector<int>> dp(20, vector<int>(N));
    // initialize
    REP(i, N){
        dp[0][i] = upper_bound(x.begin(), x.end(), x[i]+L)-x.begin() - 1;
    }

    REP(k, 19){
        REP(i, N){
            dp[k+1][i] = dp[k][dp[k][i]];
        }
    }

    REP(i, Q){
        int ans = 0; 
        for(int k = 19; k >= 0; --k){
            if(dp[k][a[i]] < b[i]){
                a[i] = dp[k][a[i]];
                ans += (1<<k);
            }
        }
        cout << ++ans << endl;
    }

    return 0;
}

Measured memory_bytes: 9848
import java.util.Scanner;  
class Main 
{
  public static void main(String[] args) 
  {
    Scanner input=new Scanner(System.in);
    int a500=input.nextInt();
    int a100=input.nextInt();
    int a50=input.nextInt();
    int money=input.nextInt();
    int count=0;
    //case1
    int temp=0;
    for(int i=1;i<=a50;i++)
    {
      temp=temp+50;
      if(temp==money)
      {
        count++;
        break;
      }
    }
    //case2
    temp=0;
    for(int i=1;i<=a100;i++)
    {
      temp=temp+100;
      if(temp==money)
      {
        count++;
        break;
      }
    }
    //case3
    temp=0;
    for(int i=1;i<=a500;i++)
    {
      temp=temp+500;
      if(temp==money)
      {
        count++;
        break;
      }
    }
    //listing50
    temp=0;
    int[] list50=new int[a50];
    for(int i=0;i<a50;i++)
    {
     temp=temp+50;
     list50[i]=temp;
    }
    //listing100
    temp=0;
    int[] list100=new int[a100];
    for(int i=0;i<a100;i++)
    {
     temp=temp+100;
     list100[i]=temp;
    }
    //listing500
    temp=0;
    int[] list500=new int[a500];
    for(int i=0;i<a500;i++)
    {
     temp=temp+500;
     list500[i]=temp;
    }
    //case4  50_100
    temp=0;
    for(int i=0;i<a50;i++)
    {
      for(int k=0;k<a100;k++)
      {
      temp=list50[i]+list100[k];
      if(temp==money)
      {
        count++;
      }
      }
    }
    //case5  50_500
    temp=0;
    for(int i=0;i<a50;i++)
    {
      for(int k=0;k<a500;k++)
      {
      temp=list50[i]+list500[k];
      if(temp==money)
      {
        count++;
      }
      }
    }
    //case6  100_500
    temp=0;
    for(int i=0;i<a100;i++)
    {
      for(int k=0;k<a500;k++)
      {
      temp=list100[i]+list500[k];
      if(temp==money)
      {
        count++;
      }
      }
    }
    //case7  50_100_500
    temp=0;
    for(int i=0;i<a50;i++)
    {
      for(int k=0;k<a100;k++)
      {
        for(int l=0;l<a500;l++)
        {
         temp=list50[i]+list100[k]+list500[l];
         if(temp==money)
          {
            count++;
          }
        }
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21460
import java.util.*
import java.math.*

private val readString: ()->String = {readLine()!!}
private val readInt: ()->Int = { readLine()!!.toInt() }
private val readLong: ()->Long = { readLine()!!.toLong() }
private val readListInt: ()->List<Int> = { readLine()!!.split(' ').map(String::toInt) }
private val readListLong: ()->List<Long> = { readLine()!!.split(' ').map(String::toLong) }
private val errPrint: (String)->Unit = { msg -> System.err.println(msg) }


fun solveD(N: Long, K: Long): Long {
    val MOD = (1e9+7).toLong()

    var cnt = 0L
    for (k in K..N+1) {
        var from = (0 + (k - 1)) * k / 2
        var to = (N - k + 1 + N) * k / 2
        cnt += (to - from + 1)
        cnt %= MOD
    }

    return cnt
}


fun main(args: Array<String>) {
    val (N, K) = readListLong()

    val ans = solveD(N, K)

    println(ans)
}


Measured memory_bytes: 36552
#include <iostream>
#include <algorithm>
#include <cstring>

#define maxx 1000000000

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k, s;
    cin >> n >> k >> s;
    for (int i = 0; i < k; i++) {
        cout << s << " ";
    }
    for (int i = k; i < n; i++) {
        if (s == maxx) cout << s - 1 << " ";
        else cout << s + 1 << " ";
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 1280
h,w,k=map(int,input().split())
C=[]
ans=0
for i in range(h):
  C.append(input())
for i in range(2**h):
  for j in range(2**w):
    counts=0
    for l in range(h):
      for m in range(w):
        if C[l][m]=="#" and ((i>>l)&1) and ((j>>m)&1):
          counts+=1
    if counts==k:
      ans +=1
print(ans)

Measured memory_bytes: 68568
#include<iostream>
int main() {
	int pasta[3];
	int juise[2];
	int min1=10000000, min2=1000000;
	for (int i = 0; i < 3; ++i){
		std::cin >> pasta[i];
		if (pasta[i] < min1)min1 = pasta[i];
	}
	for (int i = 0; i < 2; ++i) { 
		std::cin >> juise[i]; if (juise[i] < min2)min2 = juise[i]; }
	std::cout << min1 + min2-50 << std::endl;
	return 0;
}

Measured memory_bytes: 3080
import math
from math import pi
A, B, H, M = map(int, input().split())

theta1 = 2 * pi / 12  # 短針の1時間あたりの角度
theta2 = theta1 / 60  # 短針の1分あたりの角度
theta3 = 2 * pi / 60
angle_H = H * theta1 + M * theta2
angle_M = M * theta3
angle = angle_H - angle_M
l = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(angle))
print(l)

Measured memory_bytes: 9500
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
//using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
bool solve(void){
	//逆順にたどることで貪欲が可能になります。私って天才?
	int n,m,sta,gol,i,j,k;cin>>n>>m>>sta>>gol;
	if(n==0){return false;}
	vector<string>magic(n,"~");// ~ is weakest
	magic[gol]="#";
	vector<tuple<int,int,string>>road(m);
	for(i=0;i<m;i++){
		int x,y;cin>>x>>y;
		string lab;cin>>lab;
		road[i]=mt(x,y,lab);
	}
	for(i=0;i<n*10;i++){
		for(j=0;j<m;j++){
			int x,y;string lab;
			tie(x,y,lab)=road[j];
			if(magic[y].back()=='~'){continue;}
			mineq(magic[x],lab+magic[y]);
		}
	}
	string ansA=magic[sta];
	for(i=0;i<n*10;i++){
		for(j=0;j<m;j++){
			int x,y;string lab;
			tie(x,y,lab)=road[j];
			if(magic[y].back()=='~'){continue;}
			mineq(magic[x],lab+magic[y]);
		}
	}
	string ansB=magic[sta];
	if(ansA.back()=='~'||ansB<ansA){cout<<"NO"<<endl;}
	else{ansA.pob();cout<<ansA<<endl;}
	return true;
}

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



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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

const int N = 410;
int arr[N];
ll sum[N];
int n;
ll memo[N][N];
ll dp(int i, int j) {
  ll &res = memo[i][j];
  if (res != -1) return res;
  if (i >= j) return res = 0;
  res = LLONG_MAX / 2;
  for (int k = i; k < j; k++){
    res = min(res, dp(i, k) + dp(k+1, j) + (sum[j] - sum[i] + arr[i]));
  }
  return res;
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> arr[i];
    sum[0] = arr[0];
    for (int i = 1; i < n; i++) {
      sum[i] = sum[i-1] + arr[i];
    }
    memset(memo, -1, sizeof memo);
    cout << dp(0, n-1) << endl;
}


Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    vi v(2020,0);
    int n;
    cin >> n;
    rep(i,n){
        int x;
        cin >> x;
        v[x] = i+1;
    }
    int m;
    cin >> m;
    rep(i,m){
        int a;
        cin >> a;
        rep(j,2020)if(v[j] == a){
            if(j < 2019 && v[j+1] == 0){
                v[j] = 0;
                v[j+1] = a;
                break;
            }
        }
    }
    loop(i,1,n+1){
        rep(j,2020)if(v[j] == i){
            cout << j << endl;
        }
    }
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 3e5 + 10;
int divs(int n){
	int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            // If divisors are equal, 
            // count only one 
            if (n / i == i) 
                cnt++; 
  
            else // Otherwise count both 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1;i <= n;i++){
    	int r = n - i;
    	int a = divs(r);
    	// cout << r << " " << a << "\n";
    	ans += a;
    }
    cout << ans << "\n";
    return 0;
}
 

Measured memory_bytes: 3696
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  b = a < 6 ? 0 : a < 13 ? b / 2 : b;
  cout << b;
}
#endif


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int N;
    int temp,i;
    int count;
    cin >> N;
    count = 0;
    for(i=1;i<=N;i++){
        cin >> temp;
        if( temp != i){
            count++;
        }
    }
    if( count > 2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

    return 0;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  void solve() {
    string s;
    cin >> s;
    int l = s.length();
    bool ans = isPa(s) & isPa(s.substr(0, l / 2)) & isPa(s.substr((l + 1) / 2));
    if (ans) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  bool isPa(string t) {
    DBG(t)
    bool ret = true;
    for (int i = 0; i < t.size(); ++i) {
      ret &= (t[i] == t[t.size() - 1 - i]);
    }
    return ret;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);

  Problem::Solver sol;
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>

using namespace std;


int main() {
	map<int, int> mp;
	int n, m,tmp=0;
	string str[5000], str2[5000];
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> str[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> str2[i];
	}
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			tmp = 0;
			for (int k = 0; k < m; k++) {
				for (int s = 0; s < m; s++) {
					if (str[i+k][j+s] == str2[k][s]) { tmp++; }
				}
			}
			if (tmp == m * m) { cout << "Yes"; return 0; }
		}
	}
	cout << "No";
}

Measured memory_bytes: 384
d = int(input())
c = list(map(int,input().split()))
ans = []
pen = [0]*26
for i in range(d):
    s = list(map(int,input().split()))
    for i in range(26):
        pen[i] += c[i]
        s[i] += pen[i]
    ans += [s.index(max(s))+1]
for i in ans:
    print(i)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	string s;
	cin >> s;
	string res = s.substr(0, SZ(s) - 8);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		String input = s.nextLine();

		Pattern pattern = Pattern.compile("(.+)\\1");
		Matcher matcher;

		StringBuilder sb = new StringBuilder(input);

		while(true) {
			sb.deleteCharAt(sb.length()-1);
			String test = sb.toString();
			matcher = pattern.matcher(test);
			if(matcher.matches()) {
				System.out.println(test.length());
				break;
			}
		}

	}

}


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

int main () {

    int N;
    cin >> N;

    int A[N+1], B[N];
    for (int i = 0; i < N + 1; i++) {
        scanf("%d", &A[i]);
    }
    for (int i = 0; i < N; i++) {
        scanf("%d", &B[i]);
    }

    long long ans = 0;
    for (int i = 0; i < N; i++) {

        int defeatable = min(A[i], B[i]);
        ans += defeatable;
        A[i] -= defeatable;
        B[i] -= defeatable;

        int next_defeatable = min(A[i+1], B[i]);

        ans += next_defeatable;
        A[i+1] -= next_defeatable;
        B[i] -= next_defeatable;
    }
    printf("%lld\n", ans);

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<long long>a(n);
  long long l1 = 0,l2 = 0;
  for(int i = 0;i < n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  for(int i = n-1;i >= 1;i--){
    if(a[i] == a[i-1]){
      if(l1 == 0){
        l1 = a[i];
        i--;
      }
      else{
        l2 = a[i];
        cout << l1*l2 << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
const int MAXN = 100005;
const int mod = 998244353;

bool query(lint x){
	printf("? %lld\n", x);
	fflush(stdout);
	char str[10]; cin >> str;
	return *str == 'Y';
}

int main(){
	if(query(1e10)){
		lint cur = 9;
		for(int i=1; ; i++){
			if(query(cur) == 1){
				printf("! %lld\n", (cur + 1) / 10);
				return 0;
			}
			cur = cur * 10 + 9;
		}
	}
	lint pwr = 1;
	for(int i=0; ; i++){
		if(!query(pwr)){
			lint s, e;
			s = pwr / 10;
			e = pwr - 1;
			while(s != e){
				lint m = (s + e) / 2;
				if(query(1000000 * m + 696969) == 0){
					s = m + 1;
				}
				else e = m;
				
			}
			printf("! %lld\n", s);
			return 0;
		}
		pwr *= 10;
	}
}


Measured memory_bytes: 596
def ordinary(n, numbers):
    i = 0
    ret = 0
    while i + 3 <= n:
        cmp = numbers[i+1]
        if sorted(numbers[i:i+3])[1] == cmp: ret += 1
        i += 1
    return ret
  
n = int(input())
numbers = [ int(i) for i in input().split(' ') ]
print(ordinary(n, numbers))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int M=2005;
int n,x,sum;
bitset<M*M>dp;
void in(){scanf("%d",&n);}
void ac()
{
	dp[0]=1;
	for(int i=1;i<=n;++i)scanf("%d",&x),dp|=dp<<x,sum+=x;
	for(int i=sum+1>>1;i<=sum;++i)if(dp[i])printf("%d",i),exit(0);
}
int main(){in();ac();}

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

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

    int arr,c[n+5]={0};

    for(int i=0;i<(n-1);i++){
        cin>>arr;
        c[arr-1]++;
    }

    for(int i=0;i<n;i++){
        cout<<c[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 4420
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;

            for (; (line = Console.ReadLine()) != "";)
            {
                string[] sArr = line.Split(' ');
                int h = int.Parse(sArr[0]);
                int w = int.Parse(sArr[1]);

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

                string r1 = new string('#', w);
                string r2 = "#" + new string('.', w - 2) + "#";
                Console.WriteLine(r1);
                for (int i = 1; i < h - 1; i++)
                {
                    Console.WriteLine(r2);
                }
                Console.WriteLine(r1);

                Console.WriteLine();
            }

            Console.ReadLine();
        }
    }
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using namespace std;

#define int long long
#define deb(x) cout << #x << " " << x << endl;
#define pb push_back
#define pp pop_back
#define F first
#define S second
#define all(x) x.begin(),x.end()

#define MOD 1000000007
#define MAX 50000

typedef long double ld;
const int N = 1e5 + 10;
const long double Pie = acos(-1);

map<int, bool> perfectSquares;


signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		
	int k;
	string str;
	
	cin >> k >> str;
	
	int len = str.size();
	
	if (len <= k)
		cout << str;
	else
	{
		string sub;
		sub = str.substr(0, k);
		sub += "...";
		
		cout << sub;
	}
	
	return 0;
}


Measured memory_bytes: 3596