akhauriyash/Code-Regression huggingface dataset:
/******************************************
* AUTHOR : SHUBHAM KUMAR *
* NICK : { "CODECHEF" : "SCHELEON",
		   "CODEFORCES" : "SCH3130N" } * 	
* INSTITUTION : BIT MESRA *
******************************************/

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sd(x) scanf("%lld",&x)
#define ll long long int
#define large 100005
#define MOD 1000000007
#define dd double
#define pb push_back
#define mk make_pair
#define rep0(i,b) for(int i=0;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define pll pair<ll, ll>
#define ld long double
#define vll vector<ll>
#define vpll vector<pll>
#define sortv(v) sort(v.begin(),v.end())  

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

using namespace std;

ll dp[large];

ll solve(ll h[], ll i, ll k, ll prev){
	if(i<0)
		return MOD;
	if(i==0)
		return 0;
	if(dp[i]!=MOD)
		return dp[i];
	for(int ii = 1; ii <= k;ii++){
		if(i>=ii)
			dp[i] = min(dp[i], abs(h[i-ii]-h[i])+solve(h, i-ii, k, i));
		else
			break;
	}

	return dp[i];
		// return dp[i];
}

int main() {
	//#ifndef _DEBUG
    #ifdef ONLINE_JUDGE
    // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output.txt", "w", stdout);
	#endif

	fastio
	//ios_base& scientific (ios_base& str);

	//ll T; cin>>T; while(T--){}

	ll n,k;
	cin>>n>>k;
	ll h[n];
	rep0(i,n){
		cin>>h[i];
		dp[i]=MOD;
	}
	cout<<solve(h, n-1, k, n-1);
	return 0;
}

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

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

int N;
vector<int> E[202020];
const ll mo=998244353;
ll dp[202020][3][3];

pair<int,int> farthest(int cur,int pre,int d,vector<int>& D) {
	D[cur]=d;
	pair<int,int> r={d,cur};
	FORR(e,E[cur]) if(e!=pre) r=max(r, farthest(e,cur,d+1,D));
	return r;
}

pair<int,vector<int>> diameter() { // diameter,center
	vector<int> D[2];
	D[0].resize(N);
	D[1].resize(N);
	auto v1=farthest(0,0,0,D[0]);
	auto v2=farthest(v1.second,v1.second,0,D[0]);
	farthest(v2.second,v2.second,0,D[1]);
	pair<int,vector<int>> R;
	R.first = v2.first;
	//重心を取る場合
	for(int i=N-1;i>=0;i--) if(D[0][i]+D[1][i]==R.first && abs(D[0][i]-D[1][i])<=1) R.second.push_back(i);

	return R;
}

void dfs(int cur,int pre,int lef) {
	if(lef==0) {
		dp[cur][1][1]=1;
	}
	else {
		dp[cur][0][0]=1;
	}
	
	FORR(e,E[cur]) if(e!=pre) {
		dfs(e,cur,lef-1);
		ll to[3][3]={};
		int a1,a2,b1,b2;
		FOR(a1,3) FOR(a2,3) FOR(b1,3) FOR(b2,3) {
			// +1
			to[min(a1+b1,2)][a2]+=dp[cur][a1][a2]*dp[e][b1][b2]%mo;
			// 0
			to[a1][a2]+=dp[cur][a1][a2]*dp[e][b1][b2]%mo;
			// -1
			to[a1][min(a2+b2,2)]+=dp[cur][a1][a2]*dp[e][b1][b2]%mo;
		}
		
		FOR(a1,3) FOR(a2,3) dp[cur][a1][a2]=to[a1][a2]%mo;
	}
	
}

void dfs2(int cur,int pre,int lef) {
	if(lef==0) {
		dp[cur][0][1]=1;
	}
	else {
		dp[cur][0][0]=1;
	}
	FORR(e,E[cur]) if(e!=pre) {
		dfs2(e,cur,lef-1);
		ll to[3]={};
		int a,b;
		FOR(a,3) FOR(b,3) {
			// +1
			to[min(a+b,2)]+=dp[cur][0][a]*dp[e][0][b]%mo;
			// 0,-1
			to[a]+=2*dp[cur][0][a]*dp[e][0][b]%mo;
		}
		
		FOR(a,3) dp[cur][0][a]=to[a]%mo;
	}
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	
	auto R=diameter();
	if(R.second.size()==1) {
		x=R.second[0];
		dfs(x,-1,R.first/2);
		cout<<dp[x][1][1]*((mo+1)/2)%mo<<endl;
	}
	else {
		x=R.second[0];
		y=R.second[1];
		dfs2(x,y,R.first/2);
		dfs2(y,x,R.first/2);
		ll ret=(dp[x][0][1]%mo*dp[y][0][1])%mo;
		cout<<ret<<endl;
	}
}


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


Measured memory_bytes: 37344
#include <iostream>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#include <string>
#include <vector>
#include <algorithm>
int main() {
	int n;

	
	long long int p[20000],a[20000],b[20000];
	cin >> n;
	rep(i, n)
		cin >> p[i];
	for (int i = 0; i < n; i++) {
		a[i] = n+n*i;
		b[i] = n*(n - i);
	}
	
	for (int i = 0; i < n; i++) {
		a[p[i]-1] += i;
		}


	rep(i, n - 1)
		cout << a[i] << " ";
	cout << a[n - 1] << endl;
	rep(i, n - 1)
		cout << b[i] << " ";
	cout << b[n - 1] << endl;




}

Measured memory_bytes: 1152
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {
			// AtCoder_C
			Scanner sc = new Scanner(System.in);
			int ans = 0;

			int A = sc.nextInt();
			int B = sc.nextInt();

			while((A-1)*(ans-1)+A < B) {
				ans++;
			}

			System.out.println(ans);

    	    // Scannerクラスのインスタンスをクローズ
    		sc.close();
    	}
    }

Measured memory_bytes: 35748
#include <stdio.h>

int main(void){
	int a, b, c, n, i, m, p, cur;
	scanf("%d", &n);
	scanf("%d", &m);
	scanf("%d", &p);
	a=p-m;
	if(m>p){
		m=p;
	}	
	for (i = 2; i < n; i++){
		scanf("%d", &cur);
		b = cur-p;
		c = cur-m;
		if(b>c){
			if(a<b)a=b;
		}else if(a<c){
			a=c;
		}
		if(m>cur){
			m=cur;
		}
		p=cur;
	}
	printf("%d\n", a);
	return 0;
}

Measured memory_bytes: 1852
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <limits.h>

using namespace std;
int main() {
	int n;
	cin >> n;
	vector<long long> da(n);
	long long su = 0;
	vector<long long> ev(n / 2 + 2),od(n/2+2);
	long long E = 0, O = 0;
	for (int i = 0;i < n;i++) {
		cin >> da[i];
		su += da[i];
		if (i % 2) {
			O += da[i];
			od[i / 2 + 1] = O;//i=odd
		}
		else {
			E += da[i];
			ev[i / 2 +1] = E;//i=even
		}
	}
	vector<long long> ans(n);
	//da[i]=(ans[i]+ans[i+1])/2
	//su=sum(da[i])=sum(ans[i])
	//0<=i<n=even
	for (int i = 0;i < n;i++) {
		if (i % 2==0) {
			ans[i] = su - (O - od[i / 2]) * 2 - (ev[i / 2] ) * 2;
		}
		else {
			ans[i] = su - (E - ev[i / 2 + 1]) * 2 - (od[i / 2]) * 2;
		}
	}
	for (int i = 0;i < n;i++) {
		if (i != n - 1) {
			cout << ans[i] << ' ';
		}
		else {
			cout << ans[i] << endl;
		}
	}
}

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

using namespace std;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

using Graph = vector<vector<int>>;
const int MAX_N = 100010;
Graph g(MAX_N);

int dfs(int cur, int pre) {
  if ((int)g[cur].size() == 1) {
    if (cur == 0) return 1;
    return 0;
  }
  int ch = g[cur].size();
  if (cur != 0) ch--;
  int ok = 0;
  for (auto nxt : g[cur]) {
    if (nxt == pre) continue;
    ok ^= (1+dfs(nxt, cur));
  }
  return ok;
}

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

  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  cout << (dfs(0, -1) ? "Alice" : "Bob") << endl;
}


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

using namespace std;

int main(){

  string s;

  cin>>s;

  int cnt=0;

  for(int i=0;i<s.size();++i){

	int temp=0;
	bool judge=true;
	
	if(s[i]=='J'){
	  
	  temp++;
	  i++;

	  while(1){
		if(s[i]=='J'){
		  temp++;
		  i++;
		}
		
		else if(s[i]=='I')
		  break;
		
		else if(s[i]=='O'){
		  
		  int j=0;
		  while(1){
			if(s[i]=='O'){
			  if(j>=temp){
				judge=false;
				break;
			  }
			  else{
				i++;
				j++;
			  }
			}
			
			else if(s[i]=='J'){
			  i--;
			  judge=false;
			  break;
			}
			
			else if(s[i]=='I'){
			  temp=j;

			  for(int k=0;k<temp;++k){
				if(s[i]!='I'){
				  i--;
				  judge=false;
				  break;
				}
				if(k==temp-1){
				  if(cnt<temp)
					cnt=temp;
				  
				  judge=false;
				  
				}
				else
				  i++;
			  }
			  
			}
			else break;
			
			if(judge==false)
			  break;
			
		  }
		  
		}
		else break;
		
		if(judge==false)
		  break;
	  }
	}
  }
  
  cout<<cnt<<endl;
	
}
  



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

int N,t;
typedef  pair<int,int>  P;
P task[200000];


int main(void){
    cin >> N;
    rep(i,N)cin>>task[i].second >>task[i].first;
    sort(task,task+N);
    rep(i,N){
        t += task[i].second;
        
        if(t>task[i].first){
            cout << "No" << endl;
            return 0;
        }
    }    
    cout << "Yes" << endl;
}


Measured memory_bytes: 1792
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){

    int M1,M2,D1,D2;

    cin >> M1 >> D1 >> M2 >> D2;

    if(D2 == 1) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        char[] x = fs.next().toCharArray();
        int n = x.length;
        int sCount = 0;
        int res = n;
        for(int i=0;i<n;i++){
            if(x[i]=='S'){
                sCount++;
            }else if(sCount > 0){
                res-=2;
                sCount--;
            }
        }
        System.out.println(res);
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

const ll inf = (ll)1e6;

ll ks(ll i, ll W, std::vector<ll> wt, std::vector<ll> val) {
	if (W<0) return 0;
	if (i==wt.size()) return 0;

	ll incl;
	if (W-wt[i]>=0) incl = ks(i+1, W-wt[i], wt, val) + val[i];
	else incl = INT_MIN;
	ll excl = ks(i+1, W, wt, val);

	return max(incl, excl);
}

int main(){
	ll n, W;
	cin >> n >> W;
	vector<ll> wt(n), v(n);
	for (ll i = 0; i < n; ++i)
	{
		cin >> wt[i] >> v[i];
	}
	// cout << ks(0, W, wt, v);

	vector<vector<ll>> dp(W+1, vector<ll>(n+1));
	for (ll i = 0; i <= n; ++i)
	{
		dp[0][i] = 0;
	}
	for (ll i = 0; i <= W; ++i)
	{
		dp[i][0] = 0;
	}
	for (ll w = 1; w <= W; ++w)
	{
		for (ll i = 1; i <= n; ++i)
		{
			ll v1 = INT_MIN;
			if (w >= wt[i-1]) v1 = dp[w - wt[i-1]][i-1] + v[i-1];
			ll v2 = dp[w][i-1];
			dp[w][i] = max(v1, v2);
		}
	}

	cout << dp[W][n]
;

}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,a,ans=1000000000;

main() {
    cin >> n;
    rep(i,n) {
        int cnt=0;
        cin >> a;
        while(!(a%2)) {
            a/=2;
            cnt++;
        }
        ans = min(ans,cnt);
    }
    ct(ans)
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		long[] plus = new long[N+1];
		long[] minus = new long[N+1];
		for( int i=0; i<N; i++ ){
			A[i] = sc.nextInt();
			B[i] = A[i];
		}
		Arrays.sort(B);
		long count = 1;
		long total = 0;      
		for( int i=1; i<N; i++ ){
			if( B[i]==B[i-1] ){
				count++;
			}
			if( B[i]!=B[i-1] || i==N-1 ){
				plus[B[i-1]] = count*(count-1)/2;
				if( count>1 ){
					total += plus[B[i-1]];
				}                
				minus[B[i-1]] = (count-1)*(count-2)/2;
				count = 1;
			}
		}        
		for( int i=0; i<N; i++ ){
			System.out.println( total - plus[A[i]] + minus[A[i]] );
		}    
	}
}


Measured memory_bytes: 106036
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

int main(){
    int A,B,X;
    cin >> A >> B >> X;
    int a = A * (X / 1000 + (!!(X % 1000)));
    int c = A * (X / 1000) + B * ((X % 1000) < 500 ? 1 : 2);
    int b = B * (X / 500  + (!!(X % 500)));
    
    cout << min({a,b,c}) << endl;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
using namespace std;
#define int ll

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,k;
	cin>>n>>k;
	int a[k];
	for(int i=0;i<n;i++)
		cin>>a[i];
	
	
	int dp[k+1];
	dp[k]=0;
	for(int i=k-1;i>=0;i--)
	{
		dp[i]=0;
		for(int j=0;j<n;j++)
		{
			if(i+a[j]<=k)
				if(dp[i+a[j]]==0)
					dp[i]=1;
		}
	}
	//for(int i=0;i<=k;i++)
	//	cout<<dp[i]<<' ';
	if(dp[0]==1)
	cout<<"First\n";
	else
		cout<<"Second\n";
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
WA = [0] * n
AC = [0] * n

for i in range(m):
    p, s = map(str, input().split())
    p = int(p) - 1
    if s == "AC":
        AC[p] = 1
    elif s == "WA" and AC[p] == 0:
        WA[p] += 1

for i in range(n):
    WA[i] = 0 if AC[i] == 0 else WA[i]

print(sum(AC), sum(WA))


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int a, b, c;
int main() {
    cin >> a >> b >> c;
    int cnt = (a%2) + (b%2) + (c%2);
    if (cnt >= 2) cout << "Hom" << endl;
    else cout << "Tem" << endl;
}



Measured memory_bytes: 3112
def swap(a, b):
    dummy = a
    a = b
    b = dummy
    return a, b


while 1:
    
    x, y = list(map(int, input().split()))
    if x == y and x == 0:
        break

    if x > y:
        x, y = swap(x, y)

    print(x, y)




Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	if(n<10) cout << n << endl;
	else{
		ll ans = 9;
		vvl sum(10,vl(10,0));
		REP(i,1,10) sum[i][i]++;
		REP(i,1,n+1){
			ll tmp = i;
			ll back = i%10;
			while(tmp>=10){
				tmp /= 10;
			}
			ll fi = tmp;
			sum[fi][back]++;
		}
		REP(i,10,n+1){
			ll tmp = i;
			ll back = i%10;
			while(tmp>=10){
				tmp /= 10;
			}
			ll fi = tmp;
			ans += sum[back][fi];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
cnt = Hash.new(0)
ans = 0
as.each_with_index do |a,i|
	cnt[a - i - 1] += 1
end

as.each_with_index do |a,i|
	ans += cnt[-a-i-1]
end

puts ans

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

struct UnionFind {
  vector<ll> data;

  UnionFind(ll sz) { data.assign(sz, -1); }

  bool unite(ll x, ll y) {
    x = find(x), y = find(y);
    if (x == y) return (false);
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  ll find(ll k) {
    if (data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  ll size(ll k) { return (-data[find(k)]); }

  bool same(ll x, ll y) {
    int rx = find(x);
    int ry = find(y);
    return rx == ry;
  }
};

int main() {
  auto uf = UnionFind(100005);
  ll N, M;
  scanf("%lld %lld", &N, &M);

  for (ll i = 0; i < M; i++) {
    ll x, y, z;
    scanf("%lld %lld %lld", &x, &y, &z);

    uf.unite(x, y);
  }

  ll ans = 0;

  mll m;

  for (ll i = 1; i <= N; i++) {
    ll root = uf.find(i);
    if (m[root]) {
      continue;
    }

    // ans += uf.size(i) - 1;
    ans++;

    m[root] = 1;
  }

  cout << (ans) << endl;
}


Measured memory_bytes: 8144
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    if(abs(x-a)>abs(x-b))printf("B\n");
    else printf("A\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int powe[32];
int a[200100],b[200100];
int moda[200100],modb[200100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		cin>>b[i];
	}
	powe[0]=1;
	for(int i=1;i<=30;i++){
		powe[i]=powe[i-1]*2;
	}
	int res=0;
	for(int i=0;i<=29;i++){
		for(int j=1;j<=n;j++){
			moda[j]=a[j]%powe[i+1];
		}
		for(int j=1;j<=n;j++){
			modb[j]=b[j]%powe[i+1];
		}
		int TOT=0;
		sort(modb+1,modb+n+1);
		for(int j=1;j<=n;j++){
			int CUR1=lower_bound(modb+1,modb+n+1,2*powe[i]-moda[j])-lower_bound(modb+1,modb+n+1,1*powe[i]-moda[j]);
			int CUR2=lower_bound(modb+1,modb+n+1,4*powe[i]-moda[j])-lower_bound(modb+1,modb+n+1,3*powe[i]-moda[j]);
			TOT+=(CUR1+CUR2)%2;
			TOT%=2;
		}
		if(TOT==1)
			res+=powe[i];
	}
	cout<<res<<endl;
	return 0;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> H(N);
	for (int i = 0; i < N; i++) cin >> H[i];
	sort(H.begin(), H.end());
	int MIN = 1000000001;
	for (int i = 0; i < N - K + 1; i++) MIN = min(MIN, H[i + K - 1] - H[i]);
	cout << MIN << endl;
}


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

int main() {
	char s;
	cin >> s;
		if(s == 'A'){
			cout << "T";
		}else if(s == 'T'){
			cout << "A";
		}else if(s == 'C'){
			cout << "G";
		}else if(s == 'G'){
			cout << "C";
		}
	
	cout << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class Mod{
  public:
    ll mod;
    ll kaijou[200005];
    ll inv[200005];
    // mod must be a prime number
    Mod(ll m){
        mod = m;
        kaijou[0] = 1;
        for (ll i = 1;i <= 200003;i++){
            kaijou[i] = kaijou[i-1]*i%mod;
            inv[i] = modpow(kaijou[i],mod-2);
        }
    }
    //a^p
    ll modpow(ll a, ll p){
        if(p == 0) return 1;
        if(p%2 == 0){
            ll half = modpow(a, p/2);
            return half * half % mod;
        }
        else return a * modpow(a,p-1) % mod;
    }

    //nCr
    ll comb(ll n, ll r){
        if(r > n-r) return comb(n,n-r);
        if(r == 0) return 1;
        return (kaijou[n]*inv[n-r]%mod)*inv[r]%mod;
    }
};

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

    ll N,M,K; cin >> N >> M >> K;

    ll ans = 0;

    Mod m(998244353);

    for (ll i = 0;i <= K;i++){
        ll sum = (m.comb(N-1,i)*M%m.mod)*m.modpow(M-1,N-i-1)%m.mod;
        //cout << sum << " " << m.comb(N-1,i) << endl;
        ans += sum;
        ans %= m.mod;
    }

    cout << ans << endl;

    /*while(true){
        ll a,b; cin >> a >> b;
        cout << m.kaijou[a] << " " << m.kaijou[b] << endl;
        cout << m.kaijou[a]*m.inv[a]%m.mod << endl;
        cout << m.comb(a,b) << endl;
    }*/

    return 0;

}

Measured memory_bytes: 6760
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let mut s = 0;
    for &a in &a {
        s ^= a;
    }
    for a in a {
        println!("{}", s ^ a);
    }
}


Measured memory_bytes: 6380
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
ll power(ll x, ll y); 

const ll MOD = 1000000007;

vector<int> v[300005];
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    int n, m;
    cin >> n >> m;
    int h[n + 5];
    repp(i, 1, n) cin >> h[i];
    in_edges(m);

    int c = 0;
    repp(i, 1, n){
        int f = 1;
        for(auto j : v[i]) if(h[j] >= h[i]) f = 0;
        c += f;
    }

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


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

int main() {
  int n, m;
  cin >> n >> m;
  int t, a = 0, b = 0;
  string s;
  vector<int> p(n+1, 0);
  vector<bool> ac(n+1, false);
  for (int i = 0; i < m; ++i) {
    cin >> t >> s;
    if (ac[t]) continue;
    if (s == "AC") {
      b += p[t];
      ++a;
      ac[t] = true;
    } else {
      ++p[t];
    }
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 768
a,b = map(int,input().split())
 
t = b//1000
 
f = False
 
for i in range(t//10+1):
    for j in range((t-i*10)//5+1):
        if a == t - i*9 - j*4 and t == i*10+j*5+(a-i-j) and a-i-j>=0:
            f = True
            break
    if f:
        break
 
if f:
    print(i,j,a-i-j)
else:
    print(-1,-1,-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;

int main()
{
  int N,K,Y,X,res=0;
  cin >> N >> K >> X >> Y;
  for(int i=1;i<=N;i++){
    if(i <= K)
      res += X;
    else
      res += Y;
  }
  cout << res << endl;
 
  return 0;
}



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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

int main(void)
{
  ll n, m;
  cin >> n >> m;
  vector<ll> p(m), s(m);
  REP(i, m) {
    string s1;
    cin >> p[i] >> s1;
    s[i] = (s1 == "AC") ? 0 : 1;
  }

  ll ca = 0;
  ll cp = 0;
  vector<bool> aced(n+1);
  vector<ll> pec(n+1);
  REP(i, n+1) {
    aced[i] = false;
    pec[i] = 0;
  }
  REP(i, m) {
    if(!aced[p[i]]) {
      if(s[i] == 0) { //AC
	ca++;
	aced[p[i]] = true;
      } else { // WA
	pec[p[i]]++;
      }
    }
  }
  REP(i, n+1) {
    if(aced[i]) cp += pec[i];
  }
  cout << ca << " " << cp << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000
using ll = long long;

int main(){
  int n;
    cin>>n;
  vector<ll> H(n);
  rep(i,n){
    cin>>H.at(i);
  }
  int ans = 0,tmp = 0;
  rep(i,n-1){
    if(H.at(i)>=H.at(i+1))tmp++;
    else{
      ans=max(ans,tmp);
      tmp=0;
    }
  }
  ans=max(ans,tmp);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
import sys
N = int(input())
A = [0] * N
B = [0] * N
C = [0] * N
for i, e in enumerate(sys.stdin):
    A[i], B[i], C[i] = map(int, e.split())
dp = [[0] * 3 for _ in range(N + 1)]
for i in range(N):
    dp[i][0] = max(dp[i - 1][1] + A[i], dp[i - 1][2] + A[i])
    dp[i][1] = max(dp[i - 1][0] + B[i], dp[i - 1][2] + B[i])
    dp[i][2] = max(dp[i - 1][0] + C[i], dp[i - 1][1] + C[i])
print(max(dp[N - 1]))

Measured memory_bytes: 34632
use std::vec::Vec;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let (n, m) = {
      let v: Vec<usize> = read_vec();
      (v[0], v[1])
    };

    let mut res: (i64, i64) = (1, n as i64);

    for _ in 0..m {
      let v: Vec<i64> = read_vec();
      res = (cmp::max(res.0, v[0]), cmp::min(res.1, v[1]));
    }

    if res.1 >= res.0 {
      println!("{}", res.1 - res.0 + 1);
    }
    else {
      println!("{}", 0);
    }
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int A;
  cin >> A;
  int B;
  cin >> B;
  int C;
  cin >> C;
  int X;
  cin >> X;
  const int coins[] = {500, 100, 50};
  int ans = 0;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (coins[0] * i + coins[1] * j + coins[2] * k == X)
          ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n;
  scanf("%d", &n);
  long long int h[n];
  for(int i = 0; i < n; i++) {
    scanf("%lld", &h[i]);
  }
  int max = 0;
  int current = 0;
  for(int i = 1; i < n; i++) {
    if(h[i-1] >= h[i]) {
      current++;
    }
    else {
      if(current > max) {
        max = current;
      }
      current = 0;
    }
  }

  if(current > max) {
    max = current;
  }

  printf("%d\n", max);
    
  return 0;
}


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


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException{
    int i = 1;
    String s;
    int W,H,x,y,r;
    W = 0;
    H = 0;
    x = 0;
    y = 0;
    r = 0;
        while(i>0){
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            s = br.readLine();
            StringTokenizer st = new StringTokenizer(s," ");
            W = Integer.parseInt(st.nextToken());
            H = Integer.parseInt(st.nextToken());
            x = Integer.parseInt(st.nextToken());
            y = Integer.parseInt(st.nextToken());
            r = Integer.parseInt(st.nextToken());
            if(W >= -100 && W <= 100 )
                i = -1;
            else if(H >= -100 && H <= 100)
                i = -1;
            else if(x > 0 && x <= 100)
                i = -1;
            else if(y > 0 && y <= 100)
                i = -1;
            else if(r > 0 && r <= 100)
                i = -1;
            else
                i = 1;
         }
            if(x-r>=0 && x+r<=W){
            if(y-r>=0 && y+r<=H)
                System.out.println("Yes");
            else
                System.out.println("No");
            }
            else
                System.out.println("No");
    }
}

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

ll power(ll n,ll m)
{
    ll ans=1;
    for (int r=0;m>>r>0;r++)
    {
        if ((m>>r)&1) ans=ans*n;
        n=n*n;
    }
    return ans;
}

int main()
{
    ll num;
    cin >> num;
    string alpha="abcdefghijklmnopqrstuvwxyz";
    string ans="";
    ll cnt=26;
    
    while (num>0)
    {
        ans+=alpha[(num-1)%cnt];
        if (num%cnt==0) num=num/cnt-1;
        else num=num/cnt;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
class Traveling:
    def calculate(self, N: int, T: list) -> bool:
        for t in T:
            n = int(t[1]) + int(t[2])
            if n % 2 !=0:
                n_is = "odd"
            else: 
                n_is = "even"
            if int(t[0]) % 2 != 0:
                t0_is = "odd"
            else:
                t0_is = "even"
            
            if int(t[0]) < n or n_is != t0_is:
                return False
        return True

if __name__ == '__main__':
    N = int(input())
    T = [input().split() for i in range(N)]
    t = Traveling()
    res = t. calculate(N, T)
    if res:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 32144
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
ll mod = 1e9+7;
ll modpow(ll a, ll b) {
	ll c = 1;
	while (b > 0) {
		if (b & 1) c = a * c%mod; 
    	a = a * a%mod;
    	b >>= 1;
	}
	return c;
}
int main() {
    ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) { cin >> a[i]; }
	//(N-1)!
	ll fac = 1;
	for(int i=1; i<n; i++) fac = fac * i%mod;
	//mod inverse(逆元)
	//fermatの小定理版
	vector<ll> cnt(n);
	for(int i=1; i<n; i++) {
		cnt[i] = fac * modpow(i, mod - 2) % mod;
		cnt[i] = (cnt[i] + cnt[i - 1]) % mod;
	}
    ll ans = 0;
	rep(i, n-1) {
		ans += (a[i + 1] - a[i]) * cnt[i+1];
		ans %= mod;
	}
	cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector< pair<int64_t,int64_t> > vp(N);
  for(int i=0;i<N;i++){
    int64_t X,L;
    cin >> X >> L;
    vp.at(i)=make_pair(X+L,X-L);
  }
  sort(vp.begin(),vp.end());
  int64_t ans=N;
  int pre=0;
  for(int i=1;i<N;i++){
    if(vp.at(i).second<vp.at(pre).first){
      ans--;
    }else{
      pre=i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N, K;
    cin >> N >> K;
    vector<lint> A(N);
    REP(i, N) cin >> A[i];
    if(N == K) {
        lint ans = 1;
        REP(i, N) ans = ans * abs(A[i]) % MOD;
        bool minus = false;
        REP(i, N) if(A[i] < 0) minus = !minus;
        if(minus) ans = (MOD - ans) % MOD;
        cout << ans << endl;
        return 0;
    }
    vector<lint> plus;
    vector<lint> minus;
    REP(i, N) {
        if(A[i] >= 0) plus.push_back(A[i]);
        else if(A[i] < 0) minus.push_back(-A[i]);
    }
    sort(ALL(minus), greater<lint>());
    if(plus.size() == 0 && K%2 != 0) {
        sort(ALL(minus));
        lint ans = 1;
        REP(i, K) ans = ans * abs(minus[i]) % MOD;
        ans = (MOD - ans) % MOD;
        cout << ans << endl;
        return 0;
    }
    sort(ALL(plus), greater<lint>());
    while(plus.size() > K) plus.erase(prev(plus.end())); 
    while(plus.size() < K) plus.push_back(0);
    sort(ALL(plus));
    int idx = 0;
    while(idx+1 < minus.size() && idx+1 < plus.size()) {
        if(minus[idx] * minus[idx+1] > plus[idx] * plus[idx+1]) {
            plus[idx] = minus[idx];
            plus[idx+1] = minus[idx+1];
        } else {
            break;
        }
        idx += 2;
    }
    lint ans = 1;
    REP(i, K) ans = ans * plus[i] % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 9432
a,b,k=map(int,input().split())
ans=[]
i=0
while i<k and a+i<=b-i:
  ans.append(a+i)
  ans.append(b-i)
  i=i+1
ans=list(set(ans))
ans.sort()
for i in range(0,len(ans)):
  print(ans[i])

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

int main() {
        ios_base:: sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n, l;
        cin >> n >> l;
        int mn = INT_MAX;
        int sum = 0;
        bool neg = false;
        for(int i = 1; i <= n; i++) {
                int flavor = l + i - 1;
                sum = sum + flavor;
                if(mn > abs(flavor)) {
                        mn = abs(flavor);
                        neg = (flavor < 0);
                }
        }
        if(neg)
                mn *= (-1);
        cout << sum - mn;
        return 0;
}

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

int main(){
    int a, b, c, t;
    cin >> a >> b >> c;
    if(a > b){
        t = a;
        a = b;
        b = t;
    }
    if(b > c){
        t = b;
        b = c;
        c = t;
    }
    if(a > b){
        t = a;
        a = b;
        b = t;
    }
    
    cout << a << " " << b << " " << c << endl;

    
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int n, k;
// main solution goes here:
void execute(int test_number)
{
    cin>>n>>k;
    int ans=0;
    while (n>0)
    {
        ans++;
        n/=k;
    }
    cout<<ans;
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    freopen("test.inp", "r", stdin);
    freopen("test.out", "w", stdout);
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int A,B;
  scanf("%d %d",&A,&B);
int K;
  if((A+B)%2==0){
    K=(A+B)/2;
    printf("%d",K);
  }
  else
    printf("IMPOSSIBLE\n");

  return 0;
}

Measured memory_bytes: 128
import math

input = raw_input

def isprime(n):
    if n == 1: return True
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

A,B = map(int, input().split(" "))

a = []
for i in range(1,int(math.sqrt(A))+1):
    if A % i == 0:
        a.append(i)
        if i != A / i:
            a.append(A/i)

b = []
for i in range(1,int(math.sqrt(B))+1):
    if B % i == 0:
        b.append(i)
        if i != B / i:
            b.append(B/i)
c = 0
for i in a:
    if i in b and isprime(i):
        c += 1
print(c)


Measured memory_bytes: 33004
s=input()
a=0
b=0
if(s[0]=='0' and s[1]!='0'):
  a=1
elif(s[0]=='1' and (s[1]=='0' or s[1]=='1' or s[2]=='2')):
  a=1

if(s[2]=='0' and s[3]!='0'):
  b=1
elif(s[2]=='1' and (s[3]=='0' or s[3]=='1' or s[3]=='2')):
  b=1
  
if(a==1 and b==1):
  print("AMBIGUOUS")
elif(a==1 and b==0):
  print("MMYY")
elif(a==0 and b==1):
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{

      unordered_map<string,ll>mp;
      mp["MON"]=1;
      mp["TUE"]=2;
      mp["WED"]=3;
      mp["THU"]=4;
      mp["FRI"]=5;
      mp["SAT"]=6;
      mp["SUN"]=7;

      string s;
      cin>>s;
      ll ans = abs(mp["SUN"]-mp[s]);
      if(ans==0)
      {
          ans=7;
      }
      cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = 1;
  int state = 0;
  for (int i = 0; i < N - 1; i++) {
    if (A[i] < A[i + 1]) {
      if (state == -1) {
        ans++;
        state = 0;
      } else {
        state = 1;
      }
    }
    if (A[i] > A[i + 1]) {
      if (state == 1) {
        ans++;
        state = 0;
      } else {
        state = -1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
bool ifprime(ll x){
    if(x==1) return false;
    if(x==2) return true;
    for(ll i=2; i*i<=x; i++){
        if(x%i==0) return false;
    }
    return true;
}


int main(){
    ll q; cin>>q;
    vector<ll> memo(100005, 0);
    for(ll i=1; i<=100003; i++){
        memo[i]=memo[i-1];
        if(i%2==0) continue;
        if(ifprime(i) && ifprime((i+1)/2)) memo[i]++;
    }
    rep(i,q){
        ll l,r; cin>>l>>r;
        cout<<memo[r]-memo[l-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1408
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var S=Console.ReadLine().ToCharArray().OrderBy(x=>x).ToArray();
        var able = S[0] == S[1] && S[2] == S[3] && S[0] != S[2];
        var ans = able ? "Yes" : "No";
        Console.WriteLine(ans);
    }
}


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

int dp[223456][3];
bool used[223445][3];
long long n, a[3123123], b[312312], c[312312];
vector <int> g[3123123];
int tin[3123123], tout[3123123];
int timer;
int q;

void dfs(int u, int p = 0) {
	tin[u] = ++timer;
	for(int i = 0; i < g[u].size(); i++) {
		int to = g[u][i];
		if(to == p) continue;
		dfs(to, u);

	}
	tout[u] = timer;
}
int main() {
    ios_base::sync_with_stdio(0);
   cin >> n >> q;
   for(int i = 1; i < n; i++) {
   	int u, v;
   	cin >> u >> v;
   	g[u].push_back(v);
   	g[v].push_back(u);

   }

   dfs(1);

   while(q--) {
   	int x, y;
   	cin >> x >> y;
   	a[tin[x]] += y;
   	a[tout[x ] + 1] -= y;
   }
   for(int i = 1; i <= 3123123- 1; i++)
   	a[i] += a[i - 1];
   for(int i = 1; i <= n; i++) cout << a[tin[i]] << ' ';
}



Measured memory_bytes: 126336
package main

import (
	"fmt"
)

func main() {
	var k, s int
	fmt.Scan(&k, &s)

	count := 0
	for X := 0; X <= k; X++ {
		for Y := 0; Y <= k; Y++ {
			Z := s - (X + Y)

			if 0 <= Z && Z <= k {
				count++
			}
		}		
	}

	fmt.Println(count)
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
#define MOD 1000000007
int main()
{   
   int x, y;
    cin >> x >> y;
 
    vector<int> dx = {1, 0, -1, 0};
    vector<int> dy = {0, -1, 0, 1};
 
    vector<string> board(x);
    rep(i, x) cin >> board[i];
 
    rep(i, x)
    {
        rep(j, y)
        {
            rep(k, 4)
            {
                int xx = i + dx[k];
                int yy = j + dy[k];
                if (0 <= xx && xx < x && 0 <= yy && yy < y && board[i][j] == '#' && (board[xx][yy] == '#' || board[xx][yy] == 'O'))
                {
                    board[i][j] = 'O';
                    board[xx][yy] = 'O';
                }
            }
        }
    }
 
    rep(i, x)
    {
        rep(j, y)
        {
            if (board[i][j] == '#')
            {
                cout << "No" << '\n';
                return 0;
            }
        }
    }
    cout << "Yes" << '\n';

    return 0;
}

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

int main() {
  int n;
  cin>>n;
  int r[n];
  for(int i=0;i<n;i++) cin>>r[i];
  int mini=r[0];
  int ans=r[1]-r[0];
  for(int i=1;i<n;i++){
    ans=max(r[i]-mini,ans);
    mini=min(mini,r[i]);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3868