akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 11;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

ll dp[100001];

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


	fread(cn, 1, cm, stdin);
	int N = getint(), W = getint();

	rep(i, N) {
		int w = getint();
		int v = getint();
		ll* nanika = dp + w;
		rep (j, W - w + 1) {
			chmax(dp[j], nanika[j] + v);
		}
	}

	printf("%lld", dp[0]);

	Would you please return 0;
}

Measured memory_bytes: 896
N = int(input())
A = [int(a) for a in input().split()]
maxi = max(A)
mini = min(A)
maxiidx = A.index(maxi)
miniidx = A.index(mini)
print(2 * N - 1)
if maxi >= abs(mini):
    for i in range(N):
        print(maxiidx + 1, i + 1)
    for i in range(1, N):
        print(i, i + 1)
else:
    for i in range(N):
        print(miniidx + 1, i + 1)
    for i in reversed(range(1, N)):
        print(i + 1, i)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>

#define N 10010

struct Edge{
	int y;
	int z;
	int w;
	Edge(){}
	Edge(int y,int z,int w):y(y),z(z),w(w){}
	bool operator <(const Edge&_x)const{
		return this->z>_x.z || (this->z==_x.z && this->w>_x.w);
	}
};
#define Node Edge

std::vector<Edge> v[N];

void Dijkstra(int&);

int main(){
	while(true){
		int n,m;
		scanf("%d%d",&n,&m);
		if(!(n||m))
			break;
		for(int i=1;i<=n;i++)
			v[i].clear();
		while(m--){
			int x,y,z,w;
			scanf("%d%d%d%d",&x,&y,&z,&w);
			v[x].push_back(Edge(y,z,w));
			v[y].push_back(Edge(x,z,w));
		}
		int ans=0;
		Dijkstra(ans);
		printf("%d\n",ans);
	}
	return 0;
}

void Dijkstra(int &ans){
	std::priority_queue<Node> q;
	q.push(Node(1,0,0));
	bool vis[N]={};
	while(q.size()){
		int x=q.top().y,z=q.top().z,w=q.top().w;
		q.pop();
		if(vis[x])
			continue;
		vis[x]=true;
		ans+=w;
		for(auto p:v[x])
			q.push(Node(p.y,z+p.z,p.w));
	}
}


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

using namespace std;

int main() {
	int k,n;
	cin >> k >> n;
	int a[200001];
	for(int i=0;i<n;i++)cin >> a[i];
	int m,ans;
	ans=a[n-1]-a[0];
	for(int i=0;i<n-1;i++){
		int s=(k-a[i+1])+a[i];
		ans=min(ans,s);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import itertools

N = int(input())
inlst = []

for _ in range(2):
    inlst.append(list(map(int, input().split())))

lst = list(range(1, N + 1))
per = list(itertools.permutations(lst))

ab = []
for i, v in enumerate(inlst):
    ab.append(per.index(tuple(v)) + 1)

a, b = ab
print(abs(a - b))

Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)

// http://drken1215.hatenablog.com/entry/2019/03/15/205900
// など

ll calc(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return -a; // 最後2 * b * (q - 1) + bとしたい
    ll q = a / b;
    ll ret = 2 * b * q;
    ret += calc(b, a % b);
    return ret;
}
int main() {
    ll n, x; cin >> n >> x;
    out(n + calc(n - x, x));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  vector<ll> h(n);
  rep(i,n)cin>>h[i];
  int ans=0;
  rep(i,n) {
    while(h[i]>0) {
      ans++;
      h[i]--;
      repeat(j,i+1,n) {
        if(h[j]==0)
          break;
        h[j]--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    reverse(a.begin(), a.end());

    rep(i, n) {
        if (i != 0)
            cout << " ";
        cout << a[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3048
import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		//A
		/*
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b < a)
			System.out.println(a-1);
		else
			System.out.println(a);
			*/
		//B
		/*
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		for(int i = 0 ; i < k ; i++){
			int max = a;
			int max_index = 0;
			if(max < b){
				max = b;
				max_index = 1;
			}
			if(max < c){
				max = c;
				max_index = 2;
			}
			switch(max_index){
				case 0: a*=2;
				case 1: b*=2;
				case 2: c*=2;
			}
		}
		System.out.println(a+b+c);
		*/
		//C
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] s = new String[h];
		for(int i = 0 ; i < h ; i++){
			s[i] = sc.next();
		}
		boolean successflag = true;
		for(int i = 0 ; i < h ; i++){
			for(int j =0 ; j < w ; j++){
				boolean flag = false;
				if (s[i].charAt(j) == '#') {
					if (i > 0) {//上
						if (s[i - 1].charAt(j) == '#')
							flag = true;
					}
					if (i < h - 1) {//下
						if (s[i + 1].charAt(j) == '#')
							flag = true;
					}
					if (j > 0) {
						if (s[i].charAt(j - 1) == '#')
							flag = true;
					}
					if (j < w - 1) {
						if (s[i].charAt(j + 1) == '#')
							flag = true;
					}
					if (!flag)
						successflag = false;
				}
			}
		}
		if(successflag)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))
 
using namespace std;
 
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 vector<int> vi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-12;
const double PI = acos(-1.0);
 
int main() {
	int n;
	string s;
	cin >> n >> s;
	int r[n+10],g[n+10],b[n+10];
	rep(i,n+10) r[i] = g[i] = b[i] = 0;
	for(int i = 1; i <= n; i++){
		r[i] = r[i-1];
		g[i] = g[i-1];
		b[i] = b[i-1];
		switch(s[i-1]) {
			case 'R': r[i]++; break;
			case 'G': g[i]++; break;
			case 'B': b[i]++; break;
		}
		//cout << r[i] << " " << g[i] << " " << b[i] << endl;
	}
	ll cnt = 0;
	for(int j = 2; j < n; j++){
		for(int k = j+1; k <= n; k++){
			if(s[j-1]!=s[k-1]){
				char c;
				if((s[j-1]=='G'&&s[k-1]=='B')||(s[j-1]=='B'&&s[k-1]=='G')) c = 'R';
				if((s[j-1]=='R'&&s[k-1]=='B')||(s[j-1]=='B'&&s[k-1]=='R')) c = 'G';
				if((s[j-1]=='R'&&s[k-1]=='G')||(s[j-1]=='G'&&s[k-1]=='R')) c = 'B';
				int ng = 2*j-k;
				switch(c) {
					case 'R':
						cnt += r[j];
						if(0<ng&&ng<j&&s[ng-1]=='R') cnt--;
						break;
					case 'G':
						cnt += g[j];
						if(0<ng&&ng<j&&s[ng-1]=='G') cnt--;
						break;
					case 'B':
						cnt += b[j];
						if(0<ng&&ng<j&&s[ng-1]=='B') cnt--;
						break;
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

int main(){

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

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

    int h,w;
    cin >> h >> w;

    vector<vector<int>> s(h, vector<int>(w));
    for(int i = 0;i < h;i++){
        string l;
        cin >> l;
        for(int k = 0; k < w; k++){
            if(l[k] == '.')
                s[i][k] = 0;
            else
                s[i][k] = 1;
        }
    }

    vector<vector<int>> n(h, vector<int>(w, 0));

    for(int i = 0;i < h;i++){
        for(int k = 0; k < w; k++){
            if(s[i][k])
                for(int l = 0; l < 4; l++){
                    int y = i + dy[l];
                    int x = k + dx[l];
                    if(y < 0 || x < 0 || y == h || x == w)
                        continue;
                    n[y][x]++;
                }
        }
    }

    for(int i = 0;i < h;i++){
        for(int k = 0; k < w; k++){
            if(s[i][k] && n[i][k] == 0){
                cout << "No" << endl;
                exit(0);
            }
        }
    }
    cout << "Yes" << endl;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char c[105][105];
int main()
{
int w,h;
    cin>>w>>h;
for(int i=0;i<w;i++)
    cin>>c[i];
for(int i=0;i<h+2;i++)
     cout<<'#';
    cout<<endl;

for(int i=0;i<w;i++)
     cout<<'#'<<c[i]<<'#'<<endl;
for(int i=0;i<h+2;i++)
     cout<<'#';
     cout<<endl;
}


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

using namespace std;

#define MOD 1000000007
#define HALF ((MOD + 1) / 2)

int n;
vector<int> v[200005];
int dp[200005];
long long ans;

long long po(long long b, int p) {
	long long re = 1;
	while (p) {
		if (p % 2)
			re = re * b % MOD;
		b = b * b % MOD;
		p /= 2;
	}
	return re;
}

void dfs(int a, int b) {
	dp[a] = 1;
	vector<int> tv;
	for (int i : v[a])
		if (i != b) {
			dfs(i, a);
			dp[a] += dp[i];
			tv.push_back(dp[i]);
		}
	tv.push_back(n - dp[a]);
	long long tmp = 1;
	tmp = (tmp + MOD - po(HALF, n - 1)) % MOD;
	for (int i : tv)
		tmp = (tmp + MOD - po(HALF, n - 1 - i) * (1 + MOD - po(HALF, i)) % MOD) % MOD;
	ans = (ans + HALF * tmp) % MOD;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int ta, tb;
		scanf("%d%d", &ta, &tb);
		v[ta].push_back(tb);
		v[tb].push_back(ta);
	}
	dfs(1, 0);
	printf("%lld\n", ans);
}


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

long long int N;
long long int A[200000 + 7];
map <long long int,long long int> m;
long long int ans;


//
//
//
int main(){
    
    cin >> N;
    for(int i = 1;i < N+1;i++){
        cin >> A[i];
        m[A[i]]++;
    }

    // どれも抜かれていない時の解を出す
    for(int i = 1;i < N+1;i++){
        ans += m[i] * (m[i] - 1) / 2;
    }

    //
    // 3 3 3 3 3 2 2 2
    // 0 3 10 = 13  
    // 9 9 9 9 9 11 11 11
    //
    // 13 - (10 - 6)
    //

    long long int t = 0;
    for(int i = 1;i < N+1;i++){
        t = 
            ans - (
            m[A[i]] * (m[A[i]] - 1) / 2
            - (m[A[i]] - 1) * (m[A[i]] - 2) / 2
            );
        
        if(m[A[i]] == 2){
            t = 
                ans - 1;
        }
        if(m[A[i]] == 1){
            t = 
                ans;
        }
        
        cout << t << endl;
    }


}

Measured memory_bytes: 16640
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		String[] strs = str.split("");
		int num = Integer.parseInt(str);
		int sum = 0;
		for(int i = 0; i < strs.length; i++) {
			sum += Integer.parseInt(strs[i]);
		}
		System.out.println(num%sum==0 ? "Yes" : "No");
	}
}

Measured memory_bytes: 23252
// Copyright 2015 KanatoNagayama
#include <iostream>
#include <vector>
using std :: cout;
using std :: cin;
using std :: endl;
using std :: vector;
int main() {
  vector<int> v(10000);
  int i = 0;
  while(true) {
    cin >> v[i];
    if(v[i] == 0)
      break;
    i++;  
  }
  for (int k = 0; k < i; k++) {
  cout << "Case " << k + 1 << ": " <<  v[k] << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d",&n);
	int array[10000];
	int i;
	int min=0,max=0;
	long sum=0;
	for(i=0;i<n;i++){
		scanf("%d",&array[i]);
		sum+=array[i];
	}
	min=array[0];
	max=array[0];
	for(i=0;i<n;i++){
		if(array[i]<min){
			min=array[i];
		}else if(array[i]>max){
			max=array[i];
		}
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
VI findAll(string S,string pattern){VI P;ll pos=(ll)S.find(pattern);
while(pos!=string::npos){P.push_back(pos);pos=(ll)S.find(pattern,pos+1);}return P;}
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
bool is_prime(ll n){if(n<2)return 0;for(int i=2;i*i<n;i++)if(n%i==0)return 0;return 1;}
inline void eratosthenes(VB& p){rep(i,SZ(p))p[i]=1;p[0]=p[1]=0;
rep(i,SZ(p)/2+1){if(p[i])for(ll j=i+i;j<SZ(p);j+=i)p[j]=0;}}
inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
using Graph=vector<vector<int> >;//int と P

int main(){
    int n,k;cin>>n>>k;
    VI V(n);rep(i,n)cin>>V[i];
    ll ans=-INFTY;
    for(int i=0;i<=min(n,k);i++){
        for(int j=0;j+i<=min(n,k);j++){
            ll cur=0;
            VI list;
            for(int a=0;a<i;a++){list.push_back(V[a]);cur+=V[a];}
            for(int b=0;b<j;b++){list.push_back(V[n-b-1]);cur+=V[n-b-1];}
            sort(ALL(list));
            for(int index=0;index<c_min(k-i-j,list.size());index++){
                if(list[index]<0)cur-=list[index];
            }
            chmax(ans,cur);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>          
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)	make_pair((a),(b))
#define fixed(n) fixed<<setprecision((n))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long MOD = 1000000007;

int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

vector<pii> c;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;
	int sum = 2;
	rep(i,m-1){
		sum *= 2;
	}
	cout << sum * m * 1900 + sum * (n-m) * 100 << '\n';
	return 0;
}


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

int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int num = 0;
    int max = 0;
    for(int i = 0;i < n;i++){
        if(s[i] == 'I') num += 1;
        if(s[i] == 'D') num -= 1;
        if(num > max) max = num;
    }
    cout << max << endl;
}


Measured memory_bytes: 256
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
// #include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=2010;
const int P=924844033;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int del(int x) { return x>=P?x-P:x; }
void add(int &x,int y) { x=del(x+y); }
int f[N][N][2][2],g[N][N],h[N],H[N];
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	int n,k; sc(n),sc(k);
	int m=(n-1)/k+1;
	f[1][0][0][0]=1,f[1][1][0][1]=1;
	for (int i=1; i< m; i++)
		for (int j=0; j<=i; j++)
		{
			int x;
			x=f[i][j][0][0],add(f[i+1][j][0][0],x),add(f[i+1][j+1][0][0],x),add(f[i+1][j+1][0][1],x);
			x=f[i][j][0][1],add(f[i+1][j][1][0],x),add(f[i+1][j+1][1][0],x),add(f[i+1][j+1][1][1],x);
			x=f[i][j][1][0],add(f[i+1][j][0][0],x),add(f[i+1][j+1][0][1],x);
			x=f[i][j][1][1],add(f[i+1][j][1][0],x),add(f[i+1][j+1][1][1],x);
		}
	for (int i=max (m-1,1); i<=m; i++)
		for (int j=0; j<=i; j++)
		{
			if (j) add(g[i][j],((LL)f[i-1][j-1][0][0]+f[i-1][j-1][0][1])%P);
			add(g[i][j],((LL)f[i-1][j][0][0]+f[i-1][j][0][1]+f[i-1][j][1][0]+f[i-1][j][1][1])%P);
		}
	g[1][0]=1;
	h[0]=1;
	int sum=0;
	for (int x=1; x<=k; x++)
	{
		int id=(n-x)/k+1;
		memcpy (H,h,sizeof (int)*(sum+1));
		memset (h,0,sizeof (int)*(sum+1));
		for (int i=sum; i>=0; i--) if (H[i])
			for (int j=0; j<=min (n-i,id); j++)
				add(h[i+j],(LL)H[i]*g[id][j]%P);
		sum+=id;
	}
	for (int i=0,jc=1; i<=n; i++)
		h[n-i]=(LL)h[n-i]*jc%P,jc=(LL)jc*(i+1)%P;
	int ans=0;
	for (int i=0; i<=n; i++)
		add(ans,(i&1)?(P-h[i]):h[i]);
	pr(ans);

    return 0;
}

Measured memory_bytes: 64512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	buttons := make([]int, N)
	for i := 0; i < N; i++ {
		buttons[i] = nextInt()
	}
	next := buttons[0] - 1
	count := 1
	seen := make(map[int]bool)
	for next != 1 && !seen[next] {
		seen[next] = true
		next = buttons[next] - 1
		count++
	}
	if next == 1 {
		fmt.Println(count)
	} else {
		fmt.Println(-1)
	}
}


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

char pos[10][8] = {
  {'*', ' ', '=', ' ', '*', '*', '*', '*'},
  {'*', ' ', '=', '*', ' ', '*', '*', '*'},
  {'*', ' ', '=', '*', '*', ' ', '*', '*'},
  {'*', ' ', '=', '*', '*', '*', ' ', '*'},
  {'*', ' ', '=', '*', '*', '*', '*', ' '},
  {' ', '*', '=', ' ', '*', '*', '*', '*'},
  {' ', '*', '=', '*', ' ', '*', '*', '*'},
  {' ', '*', '=', '*', '*', ' ', '*', '*'},
  {' ', '*', '=', '*', '*', '*', ' ', '*'},
  {' ', '*', '=', '*', '*', '*', '*', ' '},
};

int main() {
  int n, abcus[8][5], time = 0;
  while(cin >> n) {
    if(time++ > 0) cout << endl;
    char ans[8][5];
    int reed = 10000;
    int cnt = 0;
    while(cnt < 5) {
      int num = n/reed;
      for(int i = 0; i < 8; i++) {
        ans[i][cnt] = pos[num][i];
      }
      if(num > 0) n -= num * reed;
      reed /= 10;
      cnt++;
    }
    for(int i = 0; i < 8; i++) {
      for(int j = 0; j < 5; j++) {
       printf("%c", ans[i][j]);
      }
      cout << endl;
    }
  }
}

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

int abc116_c() {
    //入力
    int n;
    bool flag=true;
    cin >> n;
    vector<int> h;
    for(int i=0 ; i<n ; ++i){
        int a;
        cin >> a;
        h.push_back(a);
    }
    int cnt=0;

    //処理
    while(flag){
        flag = false;
        if(h[0]) ++cnt;
        for(int i=0 ; i<n ; ++i){
            if(!h[i] && h[i+1]) ++cnt;
            if(h[i]) --h[i];
        }
        for(int i=0 ; i<n ; ++i){
            if(h[i]){
                flag = true;
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

int main(){
    abc116_c();
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())

ans = 1
if n == m:
    for i in range(1,n+1):
        ans *= i
        ans %= 10**9 + 7
    for i in range(1,n+1):
        ans *= i
        ans %= 10**9 + 7
    ans *= 2
    ans %= 10**9 + 7
elif abs(n-m) == 1:
    for i in range(1,n+1):
        ans *= i
        ans %= 10**9 + 7
    for i in range(1,m+1):
        ans *= i
        ans %= 10**9 + 7
else:
    print(0)
    import sys
    sys.exit()

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int c1,c5,c10,c50,c100,c500,a;
	scanf("%d" "%d" "%d" "%d" "%d" "%d",&c1,&c5,&c10,&c50,&c100,&c500);
	a=c1+(c5*5)+(c10*10)+(c50*50)+(c100*100)+(c500*500);
	if(a>=1000){
		printf("1\n");
	}
	else{
		printf("0\n");
	}
	return 0;
}


Measured memory_bytes: 2064
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

/// 数の読み込み
auto readNum(T = int)() {
	return readNums!T.front;
}

/// 指定行数読み込み
auto readRows(size_t rows) {
	return generate(() => readln().chomp).take(rows).array;
}

/// 範囲の計算
auto range(T)(T a, T b, T c, T d) {
    auto start = max(a, c);
    auto end = max(b, d);
    return (start < end) ? tuple(start, end) : tuple(cast(T) 0, cast(T) 0);
}

auto maxElement(R)(R r) {
    return r.reduce!((a, b) => max(a, b));
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}

void main() {
	const n = readNum();
	writefln("%s", readNums().map!(x => cast(int) log2(x & (~x + 1))).sum);
}

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

int main()
{
  string s;
  cin >> s;
  bool flag = true;
  for(char a = 'a';a <= 'z';a++){
    int cnt = 0;
    for(int i = 0;i < s.size();i++){
      if(s[i] == a){
        cnt++;
        if(cnt > 1) flag = false;
      }
    }
  }
  if(flag) cout << "yes" << endl;
  else cout << "no" << endl;
}


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

using namespace std;

int n;
vector<int> arr;

int dp[100005];

/*long long calc(int i)
{
	if(i == n-1)	return 0;
	long long option1=INT_MAX, option2=INT_MAX;

	if(dp[i] != 0)	return dp[i];
	if(i+1 < n)
		option1 =  abs(arr[i+1]-arr[i]) + calc(i+1);
	if(i+2 < n)
		option2 =  abs(arr[i+2]-arr[i]) + calc(i+2);

	dp[i] =  min(option1, option2);
	return dp[i];
}
*/
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);	cout.tie(0);
	
	int k;
	cin >> n >> k;
	arr.resize(n);
	for(int i=0; i<n;i++)	cin >> arr[i];			

	dp[n-1] = 0;

	for(int i=n-2; i>= 0; i--)
	{
		dp[i] = INT_MAX;
		for(int j=1; j<=k && i+j<n; j++)
		{
			dp[i] = min(dp[i], dp[i+j]+abs(arr[i+j]-arr[i]));
		}
	}

	long long ans = dp[0];
		
	cout <<ans<<endl;
		
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
	char str[1201];
	int i;
	
	fgets(str, 1200, stdin);
	for(i = 0; str[i] != '\0'; i++){
		if(65 <= str[i] && str[i] <= 90){
			str[i] += 32;
		}else if(97 <= str[i] && str[i] <= 122){
			str[i] -= 32;
		}
	}
	printf("%s", str);
	
	return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; string S; cin >> N >> S;
    int count[26] = {};
    REP(i, 0, S.size()) count[S[i] - 'a']++;

    ll ans = 1;
    REP(i, 0, 26) {
        if (count[i] == 0) continue;
        ans = ans * (count[i] + 1) % MOD;
    }

    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 512
fn main() {
  let (n, m): (usize, usize) = get::tuple();

  let ans = (1900*m + 100*(n-m)) * 2usize.pow(m as u32);
  println!("{}", ans)
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}



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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int res = 0;
    for (int x = 1; ; x++) {
        int y = n - x;
        if (y <= x) break;
        res++;
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
// 以下のソースを勉強する.
// zscoder氏.
// https://atcoder.jp/contests/dp/submissions/3936103
#include <bits/stdc++.h>
using namespace std;

// 強連結成分分解(Strongly Connected Components).
struct SCC{
    const int INF = int(1e9);
    vector<vector<int>> vec;
    int index;
    vector<int> idx;
    vector<int> lowLink;
    vector<bool> onStack;
    stack<int> sccStack;
    vector<int> sccIndex;
    int sccCount;
    vector<int> topological;
    
    // lower sccIndex means appear later
    void init(int N){
        idx.assign(N, -1);
        index = 0;
        onStack.assign(N, 0);
        lowLink.assign(N, INF);
        while(!sccStack.empty()) sccStack.pop();
        sccIndex.assign(N, -1);
        sccCount = 0;
        vec.clear();
        topological.clear();
        vec.resize(N);
    }
    
    // u -> v
    void addEdge(int u, int v){ vec[u].push_back(v); }
    
    void connect(int u){
        idx[u] = index;
        lowLink[u] = index;
        index++;
        sccStack.push(u);
        onStack[u] = true;
        for(int i = 0; i < vec[u].size(); i++){
            int v = vec[u][i];
            if(idx[v] == -1){
                connect(v);
                lowLink[u] = min(lowLink[u], lowLink[v]);
            }else if(onStack[v]){
                lowLink[u] = min(lowLink[u], idx[v]);
            }
        }
        if(lowLink[u] == idx[u]){
            while(1){
                int v = sccStack.top();
                sccStack.pop();
                onStack[v] = false;
                sccIndex[v] = sccCount;
                if(v == u) break;
            }
            sccCount++;
        }
    }
    
    void tarjan(){
        for(int i = 0; i < vec.size(); i++) if(idx[i] == -1) connect(i);
    }
    
    // if graph is a DAG and i just want to topological sort.
    void topologicalSort(){
        tarjan();
        int N = vec.size();
        topological.resize(N);
        vector<pair<int, int>> tmp;
        for(int i = 0; i < N; i++) tmp.push_back({sccIndex[i], i});
        sort(tmp.begin(),tmp.end());
        reverse(tmp.begin(),tmp.end());
        for(int i = 0; i < N; i++){
            topological[i] = tmp[i].second;
            if(i > 0) assert(tmp[i].first != tmp[i - 1].first);
        }
    }
};

int dp[111111];
vector<int> adj[111111];

int main(){
    
    // 1. 入力情報取得.
    int N, M;
    scanf("%d %d", &N, &M);
    SCC scc;
    scc.init(N);
    
    // 2. グラフ構築.
    vector<pair<int, int>> E;
    for(int i = 0; i < M; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        u--; v--;
        scc.addEdge(u,v);
        E.push_back({u, v});
    }
    scc.tarjan();
    for(int i = 0; i < M; i++){
        int u = E[i].first;
        int v = E[i].second;
        adj[scc.sccIndex[u]].push_back(scc.sccIndex[v]);
    }
    
    // 3. dp更新.
    int ans=0;
    for(int i = 0; i < N; i++){
        dp[i] = 1;
        for(int v : adj[i]) dp[i] = max(dp[i], dp[v] + 1);
        ans = max(ans, dp[i]);
    }
    
    // 4. 出力.
    printf("%d\n", ans - 1);
    return 0;
}

Measured memory_bytes: 15348
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		int a = 0;

		for (int i = 0; i < n; i++) {
			a = sc.nextInt();
			for (int j = 0; j * a + 1 <= d; j++) {
				x++;
			}
		}
		System.out.println(x);

	}

}


Measured memory_bytes: 21204
A,B,M = gets.split.map(&:to_i)
a  = gets.split.map(&:to_i)
b  = gets.split.map(&:to_i)
res = a.min + b.min
M.times do |i|
    x,y,c  = gets.split.map(&:to_i)
    price = a[x-1] + b[y-1] - c
    res = price if price < res
end
puts res

Measured memory_bytes: 18588
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n; char c;
	while (cin >> n) {
		if (n == 0)break;
		int alp[26] = {}; int no2=0; int no1=0;
		int i; char aa[100];
		for (int i = 0; i < n; i++) {
			cin >> c; aa[i] = c;
		}
		for (i = 1; i <= n; i++) {
			int t = aa[i-1] - 'A';
			alp[t]++;
			if (alp[t] > no1) {
				no1++;
			}
			else if (alp[t] > no2) {
				no2 = alp[t];
			}
			if (no1 > no2 + n - i) break;
		}
		if (no1 == no2) {
			cout << "TIE" << endl;
		}
		else {
			int check = 0;
			for (int j = 0; j < 26; j++) {
				if (alp[j] == no1)check = j;
			}
			cout << char('A' + check) << " " << i << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3092
N = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0
for j in range(1,N-1):
    for i in range(j):
        for k in range(j+1,N):
            if L[i] + L[j] > L[k] and L[i] != L[j] and L[k] != L[j] and L[i] != L[k]:
                cnt += 1
print(cnt)

Measured memory_bytes: 67920
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	int64 dp[2019];
	memset(dp, 0, sizeof(dp));
	dp[s[0] - '0'] = 1;
	int64 ans = 0;
	for (int i = 1; s[i]; ++ i) {
		int d = s[i] - '0';
		int64 tdp[2019];
		memset(tdp, 0, sizeof(tdp));
		tdp[d] = 1;
		for (int j = 0; j < 2019; ++ j) {
			int rem = (10 * j + d) % 2019;
			if (rem == 0) ans += dp[j];
			tdp[rem] += dp[j];
		}
		for (int j = 0; j < 2019; ++ j) {
			dp[j] = tdp[j];
		}
	}
	cout << ans;
}

Measured memory_bytes: 3692
N,K=map(int,input().split())
H=list(map(int,input().split()))
H=sorted(H)
H.reverse()
H_len=len(H)
H_len-=K
if H_len>0:
    ans=sum(H[len(H)-H_len::])
else:
    ans=0
print(ans)


Measured memory_bytes: 26360
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
int a[4][4];
int main(){
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			scanf("%d",&a[i][j]);
		}
	}
	int d1 = a[2][1] - a[1][1];
	int d2 = a[3][1] - a[2][1];
	int d3 = a[1][2] - a[1][1];
	int d4 = a[1][3] - a[1][2];
	if(a[2][2] - a[1][2] != d1 || a[2][3] - a[1][3] != d1) puts("No");
	else if(a[3][2] - a[2][2] != d2 || a[3][3] - a[2][3] != d2) puts("No");
	else if(a[2][2] - a[2][1] != d3 || a[3][2] - a[3][1] != d3) puts("No");
	else if(a[2][3] - a[2][2] != d4 || a[3][3] - a[3][2] != d4) puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXA 1001
#define MAXB 1001
#define MAXH 1000000001
#define MAXW 405
#define INF 5000
#define MAXN 200001
#define MAXM 10001
#define MAXP 1000001
#define MOD 1000000007
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
int N, M;
int A[MAXN];


int main(){
    map<int, int> ans;

    cin >> N;
    for(int i = 1;i < N;i++){
        cin >> A[i];
        A[i]--;
    }

    for(int i = 1;i < N;i++){
        ans[A[i]]++;
    }

    for(int i = 0;i < N;i++){
        printf("%d\n", ans[i]);
    }

    return 0;
}

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

const int MAX_INT = 7500000;
bool flag[MAX_INT];

int main() {
    int m, n;
    while(true) {
        cin >> m >> n;
        if (!(m + n)) break;

        memset(flag, 0, sizeof(flag));
        int count = 0;
        int num = m;
        while (count < n) {
            if (flag[num]) {
                num++;
                continue;
            }
            for (int i = 1; num * i <= MAX_INT; i++)
                flag[num * i] = true;
            count++;
            num++;
        }
        while (flag[num]) num++;
        cout << num << endl;
    }
}



Measured memory_bytes: 10384
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 100000007;
const int inf = 100000005;
const int N = 200005, M = N;
int i,j,n,m;

ll cnt , idx;
vi temp;


void solve() {
  ll n;
  cin>>n;

  ll x;
  set<ll>st;
  fo(i,0,n) cin>>x , st.insert(x);

  if(st.size() == n) cout<<"YES\n";
  else cout<<"NO\n";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




Measured memory_bytes: 12864
#include<bits/stdc++.h>
using namespace std;
int mx,mn;
int main()
{
	int n,x,y;
	cin>>n>>x>>y;
	if(x+y>=n)
	{
		mx=max(min(x,y),x+y-n);
		mn=min(min(x,y),x+y-n);
	}
	if(x+y<n)
	{
		mx=min(x,y);
		mn=0;
	} 
	cout<<mx<<" "<<mn<<endl;
	return 0;
}

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

const string digit = "01235789";

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> v;
        int t = n;
        while (t) {
            v.push_back(t % 8);
            t /= 8;
        }
        string res = "";
        for (int i=0; i<(int)v.size(); ++i) {
            res = digit[v[i]] + res;
        }
        cout << res << endl;
    }
    return 0;
}

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

using namespace std;

int a[200000], b[200000];

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

	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++)cin >> a[i] >> b[i];
	set<int> s;
	for(int i = 0; i < m; i++)
	{
		if(a[i] == 1)s.insert(b[i]);
	}
	for(int i = 0; i < m; i++)
	{
		if(b[i] == n && s.count(a[i]) == 1)
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}


Measured memory_bytes: 6528
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	
	long long int n;
	cin >> n;
	if (n % 2)cout << n * 2 << endl;
	else cout << n << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
using namespace std;

int main(){
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int ans = 0;
    ans += (a+9)/10 + (b+9)/10 + (c+9)/10 + (d+9)/10 + (e+9)/10;
    ans *= 10;
    int mintime = 10;
    if(a%10 != 0){
        mintime = min(mintime, a%10);
    }
    
    if(b%10 != 0){
        mintime = min(mintime, b%10);
    }
    if(c%10 != 0){
        mintime = min(mintime, c%10);
    }
    if(d%10 != 0){
        mintime = min(mintime, d%10);
    }
    if(e%10 != 0){
        mintime = min(mintime, e%10);
    }
    ans += mintime;
    cout << ans-10 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
    }
};

void prog()
{
    input in;
    output out;

    std::string s, t;
    in >> s, t;
    out(t + s);
}

int main()
{
    prog();
    return 0;
}


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

int main(){
  int i,j,n,a[10000],b[10000],ans;
  bool f[10000],f2;
  while(1){
    cin >> n;
    if(n == 0) break;
    for(i=0;i<n;i++){
      cin >> a[i];
      f[i] = false;
    }

    for(i=1;i<n-3;i++){
      if(a[i] == a[i+1] && a[i] == a[i+2]){
	f[i-1] = f[i+3] = true;
      }
      if(a[i-1] == a[i] && a[i-1] && a[i+2]) f[i+1] = true;
      if(a[i-1] == a[i+1] && a[i-1] && a[i+2]) f[i] = true;
    }

    ans = n;

    for(i=0;i<n;i++){
      if(f[i]){
	for(j=0;j<n;j++) b[j] = a[j];
	if(b[i-1] == b[i-2]) b[i] = b[i-1];
	else if(b[i+1] && b[i+2]) b[i] = b[i+1];
	int m = n;
	while(1){
	  f2 = false;
	  for(j=0;j<m-3;j++){
	    if(b[j] == b[j+1] && b[j] == b[j+2] && b[j] == b[j+3]){
	      f2 = true;
	      int l = 4;
	      for(int k=j+4;k<m;k++){
		if(b[j] == b[k]) l++;
		else break;
	      }

	      for(int k=j+l;k<m;k++){
		b[k-l] = b[k];
	      }
	      m -= l;
	    }
	  }
	  if(!f2){
	    ans = min(ans,m);
	    break;
	  }
	}
      }
    }

    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 956
c(int*l,int*r){return *l-*r;}A[3<<17];*B;*C;long y,n,i,j;*m;*h;b(int*l){for(h=l+n+1;h-l>1;*m>B[j]-(l<B)?h=m:(l=m))m=l+(h-l)/2;}main(){for(;~scanf("%d",A+i++););qsort(A+1,n=*A,4,c);B=A+n;qsort(C=B+n+1,n,4,c);for(;j++<n;y+=i*(C+n-h))b(A),i=h-A-1,b(C-1);printf("%ld\n",y);}

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int max=sc.nextInt();
		int min=max;
		int ichiji;
		for(int i=1;i<n;i++) {
			ichiji=sc.nextInt();
			if(max<ichiji)
				max=ichiji;
			if(min>ichiji)
				min=ichiji;
		}

		System.out.print(max-min);




	}

}


Measured memory_bytes: 22868
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    
    
    System.out.println(c + " " + a + " " + b);
  }
}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
 
public class Main {
	final static long MOD = 1000000007L;
 
	public static void main(String[] args) {
		Reader in = new Reader();
		char[] s1 = in.next().toCharArray();
		char[] s2 = in.next().toCharArray();
		int n = s1.length;
		int m = s2.length;
		int[][] dp = new int[n+1][m+1];
		for(int i = 0; i<n; i++) {
			for(int j = 0; j<m; j++) {
				if(s1[i]==s2[j]) dp[i+1][j+1] = dp[i][j]+1;
				else dp[i+1][j+1] = Math.max(dp[i][j+1], dp[i+1][j]);
			}
		}
		/*
		for(int i = 0; i<=n; i++) {
			for(int j = 0; j<=m; j++)
				System.out.print(dp[i][j]+" ");
			System.out.println();
		}
		*/
		int len = dp[n][m];
		int idx = 0;
		char[] ans = new char[len];
		int i = n; 
		int j = m;
		while(idx<len) {
			if(s1[i-1]==s2[j-1]) {
				ans[idx++] = s1[i-1];
				i--;
				j--;
			}else if(dp[i-1][j]>=dp[i][j-1]) i--;
			else j--;
		}
		for(i = ans.length-1; i>=0; i--) System.out.print(ans[i]);
	}
 
	static class Reader {
		static BufferedReader br;
		static StringTokenizer st;
		private int charIdx = 0;
		private String s;
 
		public Reader() {
			this.br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		public int[] na(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public char nextChar() {
			if (s == null || charIdx >= s.length()) {
				if (st == null || !st.hasMoreTokens())
					try {
						readLine();
					} catch (Exception e) {
					}
				s = st.nextToken();
				charIdx = 0; 
			}
			return s.charAt(charIdx++);
		}
 
		public long[] nl(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[] nca() {
			return next().toCharArray();
		}
 
		public String[] nS(int n) {
			String[] a = new String[n];
			for (int i = 0; i < n; i++)
				a[i] = next();
			return a;
		}
 
		public int nextInt() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Integer.parseInt(st.nextToken());
		}
 
		public double nextDouble() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Double.parseDouble(st.nextToken());
		}
 
		public Long nextLong() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return Long.parseLong(st.nextToken());
		}
 
		public String next() {
			if (st == null || !st.hasMoreTokens())
				try {
					readLine();
				} catch (Exception e) {
				}
			return st.nextToken();
		}
 
		public static void readLine() {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
			}
		}
	}
}

Measured memory_bytes: 80852
#include <stdio.h>

long long int count(int a,int m){
	int x = 1;
	long long int cnt = 0;
	
	do{
		x = (a*x) % m;
		cnt++;
	}while(x-1);
	
	return cnt;
}

long long int gcd(long long int a,long long int b){
	return b ? gcd(b,a%b) : a;
}

long long int lcm(long long int a,long long int b){
	return a*b/gcd(a,b);
}

int main(void) {
	int i;
	int a[3],m[3];
	long long int cnt[3];
	
	while(1){
		for(i = 0;i < 3;i++){
			scanf("%d%d",&a[i],&m[i]);
		}
		if(!a[0]) break;
		
		for(i = 0;i < 3;i++){
			cnt[i] = count(a[i],m[i]);
		}
		
		printf("%lld\n",lcm(lcm(cnt[0],cnt[1]),cnt[2]));
	}
	
	return 0;
}

Measured memory_bytes: 600
import sys
sys.setrecursionlimit(10**7)

N, M = map(int, input().split())
f = [set() for _ in range(N)]
v = [False for _ in range(N)]
ans = 1

for _ in range(M):
  a, b = map(int, input().split())
  a, b = a - 1, b - 1
  f[a].add(b)
  f[b].add(a)
  
  
def dfs(fi):
  if v[fi]: return 0
  
  v[fi] = True
  cnt = 1
  
  for fr in f[fi]:
    cnt += dfs(fr)
    
  return cnt

for i in range(N):
  cnt = dfs(i)
  ans = max(ans, cnt)
  
print(ans)
  

Measured memory_bytes: 239384