akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            int n = ReadInt();
            var restaurants = from elem in Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split()).Select((l, index) => new { Line = l, Index = index })
                              let line = elem.Line
                              select new { S = line[0], P = int.Parse(line[1]), Index = elem.Index } into r
                              orderby r.S, r.P descending
                              select r;

            foreach (var r in restaurants)
            {
                Console.WriteLine(r.Index + 1);
            }
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 13908
import sys
# import numpy as np

def I():
	return int(sys.stdin.readline().rstrip())

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def main():
	N = I()
	activity = []
	for i in range(N):
		activity.append(LI())
	
	# dp = np.zeros((N, 3), dtype=int)
	dp = [[0, 0, 0] for _ in range(N)]
	dp[0][0] = activity[0][0]
	dp[0][1] = activity[0][1]
	dp[0][2] = activity[0][2]
	for i in range(1, N):
		dp[i][0] = max(dp[i-1][1] + activity[i][0], dp[i-1][2] + activity[i][0])
		dp[i][1] = max(dp[i-1][0] + activity[i][1], dp[i-1][2] + activity[i][1])
		dp[i][2] = max(dp[i-1][0] + activity[i][2], dp[i-1][1] + activity[i][2])
	print(max(dp[-1]))

if __name__ == "__main__":
	main()

Measured memory_bytes: 72412
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<ceil(log2(double(n)))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	LL n,sum=0;
	scanf("%lld",&n);
	for(LL i=1;i*i<=n;i++){			
		if(n%(i)==0){
		LL m1=i;
		LL m2=n/(i);
		m1--;m2--;	
		if(m1)		
		if((m1+1)*(n%m1)==n){
		sum+=m1;
		}
		if(m2)
		if((m2+1)*(n%m2)==n){
		sum+=m2;
		}
		}		
	}
	printf("%lld\n",sum);
	return 0;
}

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

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


	string str;
	cin>>str;

	char a = str[2];
	char b = str[3];

	char c = str[4];
	char d = str[5];

	if(a == b && c == d)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

  /* クイックソートを行う */
void QSort(long x[ ], long left, long right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }
    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

  /* 配列の要素を交換する */
void Swap(long x[ ], int i, int j)
{
    long temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int main(){
  int n,i;
  long a[200000],x[200000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
    x[i]=a[i];
  }
  QSort(a, 0, n - 1);
  for(i=0;i<n;i++){
    if(x[i]<a[n/2]) printf("%d\n",a[n/2]);
    else printf("%d\n",a[n/2-1]);
  }
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
int main(){
    long N;cin>>N;long a[N][2];for(int i;i<N;i++)cin>>a[i][0]>>a[i][1];
    long b=0;for(int i=N-1;i>=0;i--){long p=a[i][0],q=a[i][1];b=(p+b+q-1)/q*q-p;}
    cout<<b<<endl;
}


Measured memory_bytes: 1792
/*

Coded and Decoded by : Yash Kapoor

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

// s.find_by_order(index);
// s.order_of_key(value);

#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll, ll>
#define vl vector<ll>
#define sl set<ll>
#define vll vector<pll>
#define ml map<ll, ll>
#define mll map<pll, ll>
#define all(a) a.begin(), a.end()
#define x first
#define y second
#define sz(x) (ll) x.size()
#define dl '\n'
#define why (ll)1000000007
//#define why         (ll)998244353
#define lp(i, a, b) for (ll i = a; i < b; ++i)
#define lpr(i, a, b) for (ll i = a; i >= b; i--)
#define lpd(i, x) for (auto i : x)
#define ios                                                                                                            \
  ios_base::sync_with_stdio(false);                                                                                    \
  cin.tie(0);                                                                                                          \
  cout.tie(0);

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base, ll power, ll mod)
{
  ll result = 1;
  while (power) {
    if (power % 2)
      result = (result * base) % mod;
    base = (base * base) % mod;
    power /= 2;
  }
  return result;
}

ll inverse(ll base, ll mod) { return fast_power(base, mod - 2, mod); }
int test = 1;
void solve() 
{
  ll n; cin >> n;
  if( n >= 30 )
    cout << "Yes" ;
else cout << "No";
}

int main()
{
  // #ifndef ONLINE_JUDGE 
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt", "w", stdout);
  // #endif
  ios 
  ll t = 1;
  //cin >> t;
  while (t--) 
  {
    //cout << "Case #" << test++ << ": ";
    solve();
  }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;
ll dp[200005][4];

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n)cin >> a[i];
  int k = 1+n%2;
  rep(i,n+1)rep(j,k+1)dp[i][j]=-LINF;
  dp[0][0]=0;
  for(int i=1;i<=n;i++){
    rep(j,k+1){
      if(j>0)chmax(dp[i][j],dp[i-1][j-1]);
      ll now = dp[i-1][j];
      if((i+j)%2==1)now+=a[i-1];
      chmax(dp[i][j],now);
    }
  }
  cout << dp[n][k] << endl;
}

Measured memory_bytes: 10348
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	int t=1;
	//cin>>t;
	while(t--)
	{
	    string s;
	    cin>>s;
	    int n=s.size();
	    for(int i=0,j=n-1;i<j;i++,j--)
	    {
	        if(s[i]!=s[j]) {cout<<"No";return 0;}
	    }
	    for(int i=0,j=(n-1)/2-1;i<j;i++,j--)
	    {
	        if(s[i]!=s[j]) {cout<<"No";return 0;}
	    }
	    for(int i=(n+3)/2-1,j=n-1;i<j;i++,j--)
	    {
	        if(s[i]!=s[j]) {cout<<"No";return 0;}
	    }
	    cout<<"Yes";
	    return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;


int main(void){
    int n; cin >> n;
    vector<int> a(n), b(n);
    vector<pair<int, int>> ab(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        ab[i] = make_pair(b[i], a[i]);
    }
    sort(ab.begin(), ab.end());

    int now = 0;
    bool ok = true;
    for (int i = 0; i < n; i++)
    {
        now += ab[i].second;
        if(now > ab[i].first){
            ok = false;
            break;
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>
using namespace std;
const double inf = 1e9;

struct info{
  int t;
  int c;
  double d;
  info(int t, int c, double d):t(t),c(c),d(d){}
};

namespace std{
  bool operator < (const info& a, const info& b){
    return b.d < a.d;
  }
}

int main(){
  while(1){
    int n,m,p,a,b;
    cin >>n>>m>>p>>a>>b;
    if(n==0) break;
    a--; b--;

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

    vector<vector<int> > road(m, vector<int>(m, -1));
    for(int i=0; i<p; i++){
      int x,y,z;
      cin >> x >> y >> z;
      x--; y--;
      road[x][y] = road[y][x] = z;
    }

    vector<vector<vector<info> > > adj(1<<n, vector<vector<info> >(m));
    for(int i=0; i<(1<<n); i++){
      for(int j=0; j<n; j++){
        if(((1<<j)&i)==0) continue;
        for(int k=0; k<m; k++){
          for(int l=0; l<m; l++){
            if(road[k][l]==-1) continue;
            adj[i][k].push_back(info(i&~(1<<j), l, (double)road[k][l]/t[j]));
          }
        }
      }
    }

    priority_queue<info> pq;
    pq.push(info((1<<n)-1, a, 0));
    vector<vector<double> > mincost(1<<n, vector<double>(m, inf));
    while(!pq.empty()){
      int tic = pq.top().t;
      int city = pq.top().c;
      double cost = pq.top().d;
      pq.pop();
      if(cost > mincost[tic][city]) continue;

      for(int i=0; i<(int)adj[tic][city].size(); i++){
        int ntic = adj[tic][city][i].t;
        int ncity = adj[tic][city][i].c;
        double ncost = adj[tic][city][i].d;
        if(cost+ncost < mincost[ntic][ncity]){
          mincost[ntic][ncity] = cost+ncost;
          pq.push( info(ntic, ncity, cost+ncost) );
        }
      }
    }

    double ans = inf;
    for(int i=0; i<(1<<n); i++){
      ans = min(ans, mincost[i][b]);
    }
    if(ans==inf){
      cout << "Impossible" << endl;
    }else{
      cout << fixed;
      cout << setprecision(5);
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 24488
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,k,*d = map(int,read().split())


suki = [1]*10
for i in d: suki[i]=0

def check(i):
    while i:
        r = i%10
        if suki[r]==0: return False
        i//=10
    return True    

ans = 10**7
for i in range(10**6,0,-1):
    if i < n: break
    if check(i): ans = i

    
print(ans)













Measured memory_bytes: 43356
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a) (a).begin(), (a).end()

const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T &r, T &l)
{
    T tmp = r;
    r = l;
    l = tmp;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
    return is;
}

int main()
{
    ll n,m;
    cin >> n >> m;
    vector<ll> p(m);
    vector<string> s(m);
    vector<pair<ll,string>> ps(m);

    for (ll i = 0; i < m; i++)
    {
        cin >> p[i] >> s[i];
        ps[i] = make_pair(p[i],s[i]);
    }

    vector<ll> c(n,0);
    vector<bool> ac(n,false);

    ll ans=0;
    for (ll i = 0; i < m; i++){
        if (s[i]=="AC"){
            ac[ p[i]-1 ] = true;
        }else{
            if (ac[ p[i]-1 ] ==false ){
                c[ p[i]-1 ]++;
            }
        }
    }
    
    for (ll i = 0; i < n; i++)
    {
        if (ac[i]==true)ans+=c[ i ];
    }

    ll ans2=0;
    for (ll i = 0; i < n; i++)
    {
        if (ac[i]==true)ans2++;
    }


        cout<< ans2<<" " << ans << endl;
    

}


Measured memory_bytes: 8832
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int getNum(const vector<int>& a, const vector<int>& to)
{
    set<int> s;
    for(int j : to)
        s.insert(a[j]);

    int ans = -1;
    if(s.empty() || *s.begin() != -1){
        ans = 0;
        for(int b : s){
            if(ans == b)
                ++ ans;
            else
                break;
        }
    }
    return ans;
}

int main()
{
    int n;
    cin >> n;
    vector<int> from(n);
    vector<vector<int> > to(n);
    for(int i=0; i<n; ++i){
        int p;
        cin >> p;
        -- p;
        from[i] = p;
        to[p].push_back(i);
    }

    queue<int> q;
    for(int i=0; i<n; ++i){
        if(to[i].empty())
            q.push(i);
    }
    vector<int> a(n, -1);
    while(!q.empty()){
        int i = q.front();
        q.pop();
        a[i] = getNum(a, to[i]);
        if(a[i] != -1)
            q.push(from[i]);
    }

    int initPos = 0;
    while(a[initPos] != -1)
        ++ initPos;
    for(int initVal=0; initVal<50; ++initVal){
        int i = initPos;
        a[i] = initVal;
        do{
            i = from[i];
            a[i] = getNum(a, to[i]);
        }while(i != initPos);

        if(a[i] == initVal){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 11776
use std::collections::HashMap;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let a: Vec<usize> = s.trim().split(" ").map(|x| x.parse().unwrap()).collect();
    let mut h: HashMap<usize, usize> = HashMap::new();
    for e in &a {
        let x = match h.get(e) {Some(x) => *x, None => 0};
        h.insert(*e, x + 1);
    }
    let mut z = 0;
    for (k, v) in &h {
        if k != v {z += if v > k {*v - *k} else {*v}};
    }

    println!("{:?}", z);
}



Measured memory_bytes: 14588
while True:
    n, x = map(int, input().split(" "))
    if n == x == 0:
        break
    cnt = 0
    for i in range(1, n-1):
        if i < x:
            for j in range(i+1, n):
                if i + j < x:
                    for k in range(j+1, n+1):
                        if i + j + k == x:
                            cnt += 1

    print(cnt)



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

int main()
{
	string s, s1, s2, s3;
	cin >> s;

	s1 = s.substr(0, 5);
	s2 = s.substr(6, 7);
	s3 = s.substr(14, 5);

	/*
	cout << s1 << endl;
	cout << s2 << endl;
	cout << s3 << endl;
	*/

	cout << s1 << " " << s2 << " " << s3 << endl;

	return 0;
}	


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

int main(int argc, char const *argv[])
{
    int h, w;
    while(1){
        cin >> h >> w;
        if(h==0 && w==0) break;
        rep(i, h){
            rep(j, w) {
                if((i+j)%2 == 0) cout << '#';
                if((i+j)%2 != 0) cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < n; i++) 
 
int main()
{
  int  rem = 0;
  int K;
  cin >> K;
  vector<bool> app(K);
  
  int cnt = 0;
  while(1)
  {
    cnt++;
    rem = (rem * 10 + 7) % K;
    
    if(rem == 0) break;
    else if(app[rem-1])
    {
      cnt = -1;
      break;
    }
    else app[rem-1] = true; 
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dpi3[100001][101];
ll knapsnacki3(vector<ll>& w,vector<ll>& v,ll n,ll mw){
	ll i,j;
	for(i=0;i<=n;i++) dpi3[0][i]=0;
	for(i=1;i<=100000;i++) dpi3[i][n]=mw+1;
	for(i=1;i<=100000;i++){
		for(j=n-1;j>=0;j--){
			dpi3[i][j] = dpi3[i][j+1];
			if(i-v[j]>=0) dpi3[i][j] = min(dpi3[i][j],w[j]+dpi3[i-v[j]][j+1]);
		}
	}
	ll ans = 0;
	for(i=0;i<=100000;i++) if(dpi3[i][0]>0&&dpi3[i][0]<=mw) ans = max(ans,i);
	return ans;
}
int main() {
  ll n; 
    cin >> n;
    ll W;
    cin >> W;
    vector<ll> weight(n), value(n);
    for (ll i = 0; i < n; ++i)
    	cin >> weight[i] >> value[i];
    cout << knapsnacki3(weight, value, n, W);
}

Measured memory_bytes: 79104
# -*- coding: utf-8 -*-
from sys import stdin

a,b,k = [int(x) for x in stdin.readline().rstrip().split()]

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -=  1
        b += a//2
        a //= 2
    elif i % 2 == 1:
        if b % 2 == 1:
            b -=  1
        a += b//2
        b //= 2
print("{} {}".format(a,b))


Measured memory_bytes: 3060
#include <cstdio>
int N, M, A, B, C, T, a[55], b[55], d[55][55], dt[55][55], d2[55][55];
int main() {
	while (scanf("%d%d%d%d%d%d", &N, &M, &A, &B, &C, &T), N) {
		for (int i = 0; i < N; i++) scanf("%d", &a[i]);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				d[i][j] = 0;
				if (j - i == -1) d[i][j] = A;
				if (j - i == 0) d[i][j] = B;
				if (j - i == 1) d[i][j] = C;
				dt[j][i] = d[i][j];
			}
		}
		while(T >= 1) {
			if (T & 1) {
				for (int j = 0; j < N; j++) {
					for (int k = 0; k < N; k++) {
						b[j] += a[k] * d[j][k];
					}
				}
				for (int j = 0; j < N; j++) {
					a[j] = b[j] % M;
					b[j] = 0;
				}
			}
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < N; k++) {
					for (int l = 0; l < N; l++) {
						d2[j][k] += d[j][l] * dt[k][l];
					}
				}
			}
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < N; k++) {
					d[j][k] = d2[j][k] % M;
					dt[k][j] = d[j][k];
					d2[j][k] = 0;
				}
			}
			T >>= 1;
		}
		for (int i = 0; i < N; i++) {
			if (i) printf(" ");
			printf("%d", a[i]);
		}
		printf("\n");
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(0, c - (a - b)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
typedef long long ll;
const int MAXN = 200000;
int A[MAXN + 5];
int adj[MAXN + 5], fir[MAXN + 5];
bool tag[MAXN + 5];
int nxt[MAXN + 5][65];
ll dis[MAXN + 5][65];
int main() {
	int N; ll K;
	scanf("%d%lld", &N, &K);
	for(int i=1;i<=MAXN;i++)
		adj[i] = -1;
	for(int i=0;i<N;i++) {
		int x; scanf("%d", &x); A[i] = x;
		if( adj[x] == -1 ) fir[x] = i;
		else nxt[adj[x]][0] = i;
		adj[x] = i;
	}/*
	if( N == 1 ) {
		if( K & 1 ) printf("%d\n", A[0]);
		return 0;
	}*/
	for(int i=1;i<=MAXN;i++)
		if( adj[i] != -1 )
			nxt[adj[i]][0] = fir[i], tag[adj[i]] = true;
	for(int i=0;i<N;i++) {
		if( nxt[i][0] <= i )
			dis[i][0]++;
		if( nxt[i][0] + 1 == N )
			dis[i][0]++;
		nxt[i][0] = (nxt[i][0] + 1) % N;
	}
	for(int i=1;i<=60;i++)
		for(int j=0;j<N;j++) {
			nxt[j][i] = nxt[nxt[j][i-1]][i-1];
			dis[j][i] = dis[j][i-1] + dis[nxt[j][i-1]][i-1];
		}
	int pos = 0;
	for(int i=60;i>=0;i--)
		if( K - 1 > dis[pos][i] )
			K -= dis[pos][i], pos = nxt[pos][i];
	for(int i=0;i<N;i++)
		nxt[i][0] = (nxt[i][0] + N - 1) % N;
	while( true ) {
		if( nxt[pos][0] <= pos ) {
			if( K == 1 ) break;
			else K--;
		}
		pos = nxt[pos][0] + 1;
		if( pos == N ) {
			if( K == 1 ) break;
			else K--, pos = 0;
		}
	}
	while( pos < N ) {
		if( nxt[pos][0] <= pos ) {
			printf("%d ", A[pos]);
			pos++;
		}
		else pos = nxt[pos][0] + 1;
	}
}

Measured memory_bytes: 156416
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>

#define INF 2000000000

using namespace std;

int main() {
	int n;
	int sum = 0;
	int mini = INF;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 10 != 0)
			mini = min(a, mini);
		sum += a;
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
	}
	else {
		if (mini == INF) cout << 0 << endl;
		else cout << sum - mini << endl;
	}
	return 0;
}

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

//create arrays outside of main()
//int a[300000] = {};

int main()
{
    int a, b;
    cin >> a >> b;
  
    bool palin = true;
    int counter = 0;

    for (int i = a; i <= b; i++)
    {
        palin = true;
        string str = to_string(i);

        for (int i = 0; i < str.length(); i++)
        {
            if (str[i] != str[str.length() - i - 1])
            {
                palin = false;
            }
        }

        if (palin == true)
        {
            counter += 1;
        }
    }

    cout << counter;

    return 0;
}

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

int main() {
    int N, M;
    cin >> N;
    string s[110], t[110];
    for (int i=0; i<N; i++) cin >> s[i];
    cin >> M;
    for (int i=0; i<M; i++) cin >> t[i];
    int max_score=0;
    for (int i=0; i<N; i++){
        int count=0;
        for (int j=0; j<N; j++) if (s[i]==s[j]) count++;
        for (int j=0; j<M; j++) if (s[i]==t[j]) count--;
        max_score=max(count, max_score);
    }
    cout << max_score << endl;
}


Measured memory_bytes: 256
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
main=print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve(n:k:ps)=(/2).fromIntegral.(+k).V.maximum.(V.zipWith(-)=<<V.drop k).V.scanl'(+)0.V.fromList$ps

Measured memory_bytes: 10184
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

int n,m,c[1000];
int s;
signed main(){
    cin>>n>>m;
    r(i,n){
        int k;
        cin>>k;
        while(k--){
            int a;
            cin>>a;
            c[a]++;
        }
    }
    r(i,1000)if(c[i]==n)s++;
    cout<<s<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
   public static void main(String args[]) {
	   Scanner sc = new Scanner(System.in);
	   String st1 = sc.nextLine();
	   String st2 = sc.nextLine();
	   if(st1.charAt(0)==st2.charAt(2) && st1.charAt(1)==st2.charAt(1) && st1.charAt(2)==st2.charAt(0)) {
		   System.out.println("YES");
	   }
	   else {
		   System.out.println("NO");
	   }
   }
}


Measured memory_bytes: 22740
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN int(3*1e5)
int len,tot[2],res[2],ans;
char s[MAXN+5];
int main()
{
    scanf("%d%s",&len,s);
    for(int i=0;i<len;i++)
        tot[s[i]=='E']++;
    ans=1e9;
    for(int i=0;i<len;i++)
    {
        int F=0;
        F+=res[0];
        F+=tot[1]-res[1]-int(s[i]=='E');
        res[s[i]=='E']++;
        ans=min(ans,F);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 512
// failed to generate code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

#define MAX_N 200001

long long par[MAX_N]; // 親
long long rankuf[MAX_N]; // 木の深さ
// n要素で初期化
void init(long long n) {
	for (long long i = 0; i < n; i++) {
		par[i] = i;
		rankuf[i] = 0;
	}
}
// 木の根を求める
long long find(long long x) {
	if (par[x] == x) {
		return x;
	} else {
		return par[x] = find(par[x]);
	}
}
// xとyの属する集合を併合
void unite(long long x, long long y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (rankuf[x] < rankuf[y]) {
		par[x] = y;
	} else {
		par[y] = x;
		if (rankuf[x] == rankuf[y]) rankuf[x]++;
	}
}
// xとyが同じ集合に属するか否か
bool same(long long x, long long y) {
	return find(x) == find(y);
}

// init(V); // Union-Findの初期化

map<ll, ll> m;

int main(){	
	ll N, M, K;
	cin >> N >> M >> K;
	vector<ll> A(M), B(M);
	init(N);
	rep(i, M) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
		m[A[i]]++;
		m[B[i]]++;
		unite(A[i], B[i]);
	}
	vector<ll> C(K), D(K);
	rep(i, K) {
		cin >> C[i] >> D[i];
		C[i]--; D[i]--;
		if (same(C[i], D[i])) {
			m[C[i]]++;
			m[D[i]]++;
		}
	}

	map<ll, ll> t;
	rep(i, N) {
		t[find(i)]++;
	}

	// rep(i, N) {
	// 	cout << par[find(i)] << endl;
	// }

	rep(i, N-1) {
		cout << t[find(i)]-m[i]-1 << " ";
	}
	cout << t[find(N-1)]-m[N-1]-1 << endl;
}


Measured memory_bytes: 17664
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long k,a,b;
  cin>>k>>a>>b;
  if((a+2)>b || k<(a+1))
  {
    cout<<k+1<<endl;
  }
  else
  {
    long long ans=b;
    k-=(a+1);
    long long n=k/2;
    ans+=n*(b-a)+(k%2);
    cout<<ans<<endl;
  }
  return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,X;
  int ans=0;
  cin >> A >> B >> C >> X;
  for(int i=0;i<=A;i++) {
    for(int j=0;j<=B;j++) {
      for(int l=0;l<=C;l++) {
	int sum=500*i+100*j+50*l;
	if(sum==X) ans++;
      }
    }
  }
  cout << ans << endl;
}

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

vector<pair<int,int>> dir = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h, w, k;
	cin >> h >> w >> k;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	--x1; --y1; --x2; --y2;
	vector<string> grid(h);
	for (int i = 0; i < h; ++i)
		cin >> grid[i];
	auto valid = [&](const pair<int, int>& p){ return p.first >= 0 && p.first < h && p.second >= 0 && p.second < w; };
	
	vector<vector<int>> dist(h, vector<int>(w, 1e9));
	auto bfs = [&](){
		queue<pair<int, int>> q;
		vector<vector<bool>> vis(h, vector<bool>(w));
		q.emplace(x1, y1);
		dist[x1][y1] = 0;
		vis[x1][y1] = 1;
		while (!q.empty()){
			auto u = q.front(); q.pop();
			for (int j = 0; j < 4; ++j){
				for (int i = 1; i <= k; ++i){
					int nr = u.first + i * dir[j].first;
					int nc = u.second + i * dir[j].second;
					if (!valid({nr, nc})) continue;
					if (grid[nr][nc] == '@' || dist[nr][nc] <= dist[u.first][u.second]) break;
					if (vis[nr][nc]) continue;
					dist[nr][nc] = dist[u.first][u.second] + 1;
					vis[nr][nc] = 1;
					q.emplace(nr, nc);
				}
			}
		}
		return (dist[x2][y2] >= (int) 1e9 ? -1 : dist[x2][y2]);
	};
	cout << bfs() << '\n';
}


Measured memory_bytes: 12156
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	string S;
	cin >> N >> S;
	int bsum = 0;
	REP(i, 2 * N) {
		if (i % 2==0) {
			if (S[i] == 'B')S[i] = 'W';
			else S[i] = 'B';
		}
		if (S[i] == 'B')bsum++;
	}
	if (bsum != N) {
		cout << 0 << endl;
     	return 0;
	}
	int cnt = 0;
	int ans = 1;
	REP(i, 2 * N) {
		if (S[i] == 'B') {
			ans *= cnt;
			ans %= mod;
			cnt--;
		}
		else {
			cnt++;
		}
	}
	eFOR(i, 1, N) {
		ans *= i;
		ans %= mod;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 720
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  	 int n;
  	 cin >> n;
  	 vector<int> v;
  	 for(int i = 1; i <= n; i++){
	   v.push_back(i);	 
	}
	do{
	 for(int i = 0; i < n; i++){
	  if (i == n - 1) cout << v[i];
	  else cout << v[i] << " ";	 
	 }
	cout << endl;
   }while(next_permutation(all(v)));
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3188
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n: u32,
        s: Chars,
    }

    solve(n, &s);
}

fn solve(n: u32, s: &[char]) {
    let a = 'A' as u32;

    for &ch in s {
        let b = ((ch as u32) - a + n) % 26 + a;
        print!("{}", std::char::from_u32(b).unwrap());
    }
    println!("");
}


Measured memory_bytes: 2140
/**
  @file a.cpp
  @title
  @url https://atcoder.jp/contests/abc134/tasks/abc134_a
**/

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

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

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

  cout << 3 * r * r << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    N, W_MAX = (int(i) for i in input().split())
    W = []
    V = []
    for _ in range(N):
        w, v = (int(i) for i in input().split())
        W.append(w)
        V.append(v)
    V_SUM = sum(V)
    INF = (1 << 60)
    dp = [INF] * (V_SUM + 1)
    dp[0] = 0
    for i in range(N):
        for j in range(V[i], V_SUM + 1)[::-1]:
            dp[j] = min(dp[j], dp[j - V[i]] + W[i])
    print(max(j for j in range(V_SUM+1) if dp[j] <= W_MAX))


if __name__ == '__main__':
    main()


Measured memory_bytes: 40048
#include <cstdio>
#include <cmath>
#include <queue>
#include <map>
#include <string>
#include <utility>

using namespace std;

#define N (3)
#define N2 (N*N)

struct Puzzle {
    int f[N2];
    int space;
    string path;

    bool operator < ( const Puzzle &p ) const {
	for ( int i = 0; i < N2; i++ ) {
	    if ( f[i] == p.f[i] ) continue;
	    return ( f[i] < p.f[i] );
	}
	return false;		// ????????????????????´???????????\????????????
    }
};

// x, y?????????????????£??????
static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

bool isTarget( Puzzle p ) {
    for ( int i = 0; i < N2; i++ ) {
	if ( p.f[i] != ( i + 1 ) ) return false;
    }
    return true;
}

string bfs( Puzzle s ) {
    queue<Puzzle> Q;
    map<Puzzle, bool> V;
    Puzzle u, v;
    s.path = "";
    Q.push( s );
    V[s] = true;
    
    while ( !Q.empty() ) {
	u = Q.front(); Q.pop();
	if ( isTarget( u ) ) return u.path;
	int sx = u.space / N;
	int sy = u.space % N;
	
	for ( int r = 0; r < 4; r++ ) {
	    int tx = sx + dx[r];
	    int ty = sy + dy[r];

	    if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
	    v = u;
	    swap( v.f[u.space], v.f[tx * N + ty] );
	    v.space = tx * N + ty;
	    if ( !V[v] ) {
		V[v] = true;
		v.path += dir[r];
		Q.push( v );
	    }
	}
    }

    return "unsolvable";
}

int main()
{
    Puzzle in;
    
    for ( int i = 0; i < N2; i++ ) {
	scanf("%d", &in.f[i]);
	if ( in.f[i] == 0 ) {
	    in.f[i] = N2;
	    in.space = i;
	}
    }
    string ans = bfs( in );

    printf("%d\n", (int)ans.size());

    return 0;
}

Measured memory_bytes: 28536
N=int(input())

from itertools import combinations
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

d=make_divisors(N)

if math.sqrt(N)**2 ==N:
    d.append(int(math.sqrt(N)))

dist=float('inf')
for i in d:
    j = N//i
    if i * j ==N:
        dist = min(dist,i+j-2)

print(dist)
    

Measured memory_bytes: 40612
#include <stdio.h>
 
int main(void)
{
    int xs[2], ys[2], eqs[2];
    float x, y;
 
    while (~scanf("%d %d %d %d %d %d", xs, ys, eqs, xs + 1, ys + 1, eqs + 1)){
        x = 1.*(eqs[0] * ys[1] - eqs[1] * ys[0]) / (xs[0] * ys[1] - xs[1] * ys[0]);
        y = 1.*(eqs[1] * xs[0] - eqs[0] * xs[1]) / (xs[0] * ys[1] - xs[1] * ys[0]);
 
        if (x == 0.0) x = 0.0;
        //if (y == 0.0) y = 0.0;

        printf("%.3f %.3f\n", x, y);
    }
 
    return (0);
}

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

int main(){
    long long int X;
    cin >> X;

    bool found = false;

    for(int i = 0; i <= 130; i++){
        for(int j = 0; j <= 130; j++){
            if(pow(i,5)-pow(j,5) == X){
                cout << i << " " << j;
                found = true;
                break;
            }else if(pow(i,5)+pow(j,5) == X){
                cout << i << " " << -j;
                found = true;
                break;
            }
        }
        if(found)break;

    }
    
}

Measured memory_bytes: 4060
num = 0
s = input()
k = int(input())
pre = ""
out = ""
for _ in range(k):
  inp = input()
  if inp[0] == "1":
    num += 1
    num %= 2
  else:
    if (inp[2] == "1" and num == 0) or (inp[2] == "2" and num == 1):
      pre = pre + inp[4]
    else:
      out = out + inp[4]
if num:
      print(out[::-1] + s[::-1] + pre)
else:
  print(pre[::-1] + s + out)

Measured memory_bytes: 4468
import sys
input = sys.stdin.buffer.readline

def main():
    n=int(input())
    a=list(map(int,input().split()))
    #print(a)
    
    if n<4:
        print(max(a))
        sys.exit()

    if n%2:
        #dp[位置][個数]
        dp=[[0,0,0]for i in range(n-2)]
        dp[0]=a[:3]
        for i in range(2,n-1,2):
            dp[i][0]=dp[i-2][0]+a[i]
            dp[i][1]=max(dp[i-2][0],dp[i-2][1])+a[i+1]
            dp[i][2]=max(dp[i-2][0],dp[i-2][1],dp[i-2][2])+a[i+2]
        #print(dp)
        print(max(dp[-1]))

    else:
        #dp[位置][個数]
        dp=[[0,0]for i in range(n-1)]
        dp[0]=a[:2]
        for i in range(2,n-1,2):
            dp[i][0]=dp[i-2][0]+a[i]
            dp[i][1]=max(dp[i-2][0],dp[i-2][1])+a[i+1]
        #print(dp)
        print(max(dp[-1]))
main()

Measured memory_bytes: 52148
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
 
using namespace std;

int main(){
	int q=1;
	//cin>>q;
	while(q--){
		ll a,b,n,x;
		cin>>a>>b>>n;
		x=min(n,b);

		if(x==b)
			x--;

		cout<<((a*x)/b)<<endl;
	}   	
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

const double PI = 2 * acos(0);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<double, double> pdd;
typedef pair<double, pdd> pddd;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

bool comp[55555];

int main() {
    for(int i = 3; i * i < 55555; i++) {
        for(int j = i*i; j < 55555; j += i) {
            comp[j] = true;
        }
    }
    vector<int> ret;
    int n;
    scanf("%d", &n);
    int curr = 11;
    while(ret.size() < n) {
        if(!comp[curr]) ret.push_back(curr);
        curr += 10;
    }
    for(int i = 0; i < n; i++) {
        printf("%d", ret[i]);
        if(i == n-1) printf("\n");
        else printf(" ");
    }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    double w = Integer.parseInt(sc.next());
    double h = Integer.parseInt(sc.next());
    double x = Integer.parseInt(sc.next());
    double y = Integer.parseInt(sc.next());
    int ans;
    int cnt = 0;

	Double s = w*h*0.5d;

    if (w%2 == 0 && h%2 == 0 && x == w/2 && y == h/2) {
      ans = 1;
    } else {
      ans = 0;
    }
    
    System.out.println(s + " " + ans);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;


int main(void) {
    ll N;
    cin >> N;
    ll dp[111][4][4][4]={};
    ll i, j, k, l, m;
    
    for(j=0; j<4; j++) {
        for(k=0; k<4; k++) {
            for(l=0; l<4; l++) {
                if(j==0 && k==1 && l==2) continue;
                if(j==0 && k==2 && l==1) continue;
                if(j==2 && k==0 && l==1) continue;
                
                dp[3][j][k][l]=1;
            }
        }
    }
    
    for(i=3; i<N; i++) {
        for(j=0; j<4; j++) {
            for(k=0; k<4; k++) {
                for(l=0; l<4; l++) {
                    for(m=0; m<4; m++) {
                        if(j==0 && k==1 && l==2) continue;
                        if(j==0 && k==2 && l==1) continue;
                        if(j==2 && k==0 && l==1) continue;
                        
                        if(j==0 && k==2 && m==1) continue;
                        
                        if(j==0 && l==2 && m==1) continue;
                        
                        else moC(dp[i+1][k][l][m], +, dp[i][j][k][l]);
                    }
                    
                }
            }
        }
    }
    
    ll ans=0;
    for(j=0; j<4; j++) {
        for(k=0; k<4; k++) {
            for(l=0; l<4; l++) {
                if(j==0 && k==1 && l==2) continue;
                if(j==0 && k==2 && l==1) continue;
                if(j==2 && k==0 && l==1) continue;
                
                moC(ans, +, dp[N][j][k][l]);
            }
        }
    }
    
    pt(ans);
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vpi;
typedef vector<pair<long long, long long> > vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#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 FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    
    rep(i,N){
        int a;
        cin >> a;
        if(a%2 == 0){
            if(a%3 != 0 && a%5 != 0 ){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;


}

Measured memory_bytes: 256
from sys import stdin
input = stdin.readline

A, B, C, K = map(int, input().split())

ans = 0

if K > 0:
    ans += min(K, A)
    K -= min(A, K)

if K > 0:
    K -= min(B, K)

if K > 0:
    ans -= min(K, C)
    K -= min(C, K)

print(ans)


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

int main() {
    string S;
    cin >> S;
    int n = 0;
    for (char & c : S) {
        if (c == '+'){
            ++n;
        }else{
            --n;
        }
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector




signed solve()
{
    int n;
    cin>>n;
    int arr[n+10];
    int sum = 0;
    forn(i,1,n){cin>>arr[i];if(i%2)sum+=2*(arr[i]); else sum-=2*arr[i];}
    int ans[n+10];
   // cout<<sum;
    ans[1] = sum/2;
    forn(i,2,n)
    {
        ans[i] = 2*arr[i-1] - ans[i-1];
    }
    
    
    forn(i,1,n)cout<<ans[i]<<" ";
}


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



    return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 2944
n,ma,mb = map(int,input().split())
x = []
amax = 0
bmax = 0
for i in range(n):
    x1,y1,z1=[int(i) for i in input().split()]
    x.append([x1,y1,z1])
    amax += x1
    bmax += y1
inf = float("inf")
dp = [[inf] * (amax+1) for i in range(bmax+1)]
dp[0][0] = 0
aru = {(0,0)}
for i in x:
  a = i[0]
  b = i[1]
  c = i[2]
  aru2 = list(aru)
  aru2 = sorted(aru2,key=lambda x:-x[0])
  for j in aru2:
    dp[j[1]+b][j[0]+a] = min(dp[j[1]+b][j[0]+a],dp[j[1]][j[0]]+c)
    aru.add((j[0]+a,j[1]+b))
ans = inf
mam = ma+0
mbm = mb + 0
while (amax >= ma and bmax >= mb):
  suu = dp[mb][ma]
  ans = min(ans,suu)
  mb += mbm
  ma += mam
if ans == inf:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 7036
#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: 2700