akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		int[] merry=new int[]{1,4,1,4,1,2,1,2};
		while(sc.hasNext()){
			int index=0,max=-1,val=0;
			int[] people=new int[]{sc.nextInt(),
				sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()
				,sc.nextInt(),sc.nextInt(),sc.nextInt()};
			for(int i=0;i<8;i++){
				int sum=0;
				for(int j=0;j<8;j++){
					sum+=Math.min(merry[(i+j)%8],people[j]);
				}
				if(sum>max){
					index=i;
					max=sum;
					int v=0;
					for(int j=0;j<8;j++){
						v=merry[(i+j)%8]+v*10;
					}
					val=v;
				}else if(sum==max){
					int v=0;
					for(int j=0;j<8;j++){
						v=merry[(i+j)%8]+v*10;
					}
					if(v<val){
						index=i;
						max=sum;
						val=v;
					}
				}
			}
			for(int i=0;i<8;i++){
				pr((i==0?"":" ")+merry[(i+index)%8]);
			}
			ln();
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

class P {
	double x;
	double y;

	P(double _x, double _y) {
		x = _x;
		y = _y;
	}

	public static final P Xunit = new P(1, 0);
	public static final P Yunit = new P(0, 1);

	public static double dot(P a, P b) {
		return a.x * b.x + a.y * b.y;
	}

	public static double cross(P a, P b) {
		return a.x * b.y - a.y * b.x;
	}

	public static boolean isParallel(P a1, P a2, P b1, P b2) {
		return Math.abs(cross(a2.s(a1), b2.s(b1))) < Double.MIN_NORMAL;
	}

	public static boolean isVertical(P a1, P a2, P b1, P b2) {
		return Math.abs(dot(a2.s(a1), b2.s(b1))) < Double.MIN_NORMAL;
	}

	public P a(P a) {
		return new P(x + a.x, y + a.y);
	}

	public P s(P a) {
		return new P(x - a.x, y - a.y);
	}

	public double norm() {
		return Math.sqrt(x * x + y * y);
	}

	public double arg() {
		double s = Math.acos(x / norm());
		return y > 0 ? s : 2 * Math.PI - s;
	}

	public P rotate(double t) {
		return new P(Math.cos(t) * this.x - Math.sin(t) * this.y, Math.sin(t)
				* this.x + Math.cos(t) * this.y);
	}

	public static int ccw(P a, P b, P c) {
		if (P.cross(b.s(a), c.s(a)) > Double.MIN_NORMAL) {
			return 1;
		}
		if (cross(b.s(a), c.s(a)) < -Double.MIN_NORMAL) {
			return -1;
		}
		if (dot(b, c) < -Double.MIN_NORMAL)
			return 2;
		if (b.norm() < c.norm() - Double.MIN_NORMAL)
			return -2;
		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof P) {
			P p = (P) obj;
			return x == p.x && y == p.y;
		}
		return false;
	}

	public String toString() {
		return "(" + x + "," + y + ")";
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

deque<int> weight_list;
vi weight;
bool judge(int n, int sum, int para) {
  int s = 0;
  int lb = lower_bound(all(weight_list), weight[0] + para) - begin(weight_list);
  if (lb < n) {
    rep (i, n) {
      if (i == lb) { continue; }
      s += weight_list[i];
    }
  } else {
    s += weight_list[lb];
    rep (i, n-1) {
      if (i == lb) { continue; }
      s += weight_list[i];
    }
  }
  return s <= sum;
}

int main() {
  int n, w;
  scanf("%d%d", &n, &w);
  weight.resize(n);
  vi value(n);
  rep (i, n) {
    scanf("%d%d", &weight[i], &value[i]);
  }
  if (weight[0] < 100) {
    vvi dp(n+1, vi(w+1, 0));
    FOR (i, 1, n+1) {
      FOR (j, 1, w+1) {
        dp[i][j] = dp[i-1][j];
        if (j >= weight[i-1]) {
          dp[i][j] = max(dp[i][j], dp[i-1][j-weight[i-1]] + value[i-1]);
        }
      }
    }
    printf("%d\n", dp[n][w]);
    return 0;
  }

  vi sorted_value = value;
  sort(all(sorted_value), greater<int>());
  debug(sorted_value[0]);
  int kosu = w / (weight[0] + 3);
  int ans1= 0;
  rep (i, min(kosu, n)) {
    ans1 += sorted_value[i];
  }

  if (kosu >= n) {
    printf("%d\n", ans1);
    return 0;
  }
  {
    vi sorted_weight = weight;
    sort(all(sorted_weight));
    int wsum = 0;
    rep (i, kosu+1) {
      wsum += sorted_weight[i];
    }
    if (wsum > w) {
      printf("%d\n", ans1);
      return 0;
    }
  }

  vector<priority_queue<int> > vpi(4);
  rep (i, n) {
    int ind = weight[i] - weight[0];
    vpi[ind].push(value[i]);
  }

  weight_list.resize(n);
  rep (i, n) {
    weight_list[i] = weight[i];
  }
  sort(all(weight_list));

  int ans2 = 0;
  int w_ = w;
  rep (j, kosu+1) {
    int ma = 0;
    int ind = 0;
    rep (i, 4) {
      if (vpi[i].empty()) { continue; }
      if (w_ < weight[0] + i) { continue; }
      if (!judge(kosu+1 - j, w_, i)) { continue; }
      if (ma < vpi[i].top()) {
        ma = vpi[i].top();
        ind = i;
      }
    }
    ans2 += ma;
    vpi[ind].pop();
    w_ -= weight[0] + ind;
  }

  printf("%d\n", max(ans1, ans2));

  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int f[200010],n,k;
int l[200010],r[200010];
int sum[200010];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d%d",&l[i],&r[i]);
	}
	sum[1]=1;
	f[1]=1;
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			f[i]+=sum[max(i-l[j],0)]-sum[max(i-r[j]-1,0)];
			f[i]=(f[i]%998244353+998244353)%998244353;
		}
		sum[i]=sum[i-1]+f[i];
		sum[i]%=998244353;
	}
	printf("%d",f[n]);
	return 0;
}

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

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

  char a;
  cin >> a;
  if ('a' <= a && a <= 'z') {
    cout << 'a';
  } else {
    cout << 'A';
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x<a.x;
//        return z>a.z;
    }
};

vector<int> v[155];
//bitset<4001000> b;
int a,c,i,b,k,d,n,m,e;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[201010];
int o[200150];
int dx[10]={0,1,0,-1},dy[10]={1,0,-1,0},dz[10]={0,0,0,0,1,-1};

long long x[200100],y,z[200100],mod=1000000007;
P u[11];
int j[200011];

stack<int> s;
queue<P> q;

//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int > p;
//list<int> l;
//string r[111],r2;
char r[510][555];


bool as(P a,P b)
{
   // if(a.x!=b.x)
        return a.x<b.x;
    //return a.y>b.y;
}


int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;l[o[t]]++,t++)
        scanf("%d",&o[t]);
    sort(o+1,o+a+1);
    if(o[a]!=o[a-1])
    {
        puts("Impossible");
        return 0;
    }
    j[a]=1;
    for(int t=a-1;t>0;t--)
    if(o[t]<o[a]/2+o[a]%2)
    {
        puts("Impossible");
        return 0;
    }
    else if(j[o[t]])
    {
        j[o[a]-o[t]]++;
    }
    else j[o[t]]++;
    if(o[a]%2)
    {
        if(max(j[o[a]/2],j[o[a]/2+o[a]%2])>1)
        {
            puts("Impossible");
            return 0;
        }
    }
    else
    {
        if(j[o[a]/2]>1)
        {
            puts("Impossible");
            return 0;
        }
    }
    for(int t=1;t<=o[a];t++)
        if(j[t]==0)
    {
        puts("Impossible");
        return 0;
    }
    puts("Possible");
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
   public static void main(String[] args) {  
      Scanner sc = new Scanner(System.in);
      String s = sc.nextLine();
      int[] num = new int[s.length()];
      for(int i = 0; i < s.length(); i++){
         num[i] = Integer.parseInt(s.charAt(i)+"");
      }
      
      int a = num[0];
      int b = num[1];
      int c = num[2];
      int d = num[3];
      if(a+b+c+d==7)
         System.out.println(a + "+" + b + "+" + c + "+" + d + "=7");
      else if(a+b+c-d==7)
         System.out.println(a + "+" + b + "+" + c + "-" + d + "=7");
      else if(a+b-c-d==7)
         System.out.println(a + "+" + b + "-" + c + "-" + d + "=7");
      else if(a-b-c-d==7)
         System.out.println(a + "-" + b + "-" + c + "-" + d + "=7");
      else if(a+b-c+d==7)
         System.out.println(a + "+" + b + "-" + c + "+" + d + "=7");
      else if(a-b-c+d==7)
         System.out.println(a + "-" + b + "-" + c + "+" + d + "=7");
      else if(a-b+c+d==7)
         System.out.println(a + "-" + b + "+" + c + "+" + d + "=7");
      else 
         System.out.println(a + "-" + b + "+" + c + "-" + d + "=7");
   }
}

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

int main() {
    ll A, B, C;
    cin >> A >> B >> C;

    for (ll i = 0; i < (ll)1e8; ++i) {
        if ((A*i) % B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 384
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
S = []
for i in range(N):
    S.append(list(input()))

# 最終的な '(' - ')' の数
diff = [0]*N
for i in range(N):
    num = 0
    for j in range(len(S[i])):
        if S[i][j] == '(':
            num += 1
        else:
            num -= 1
    diff[i] = num

if sum(diff) != 0:
    print('No')
    exit()

# 条件が最も厳しい場所での括弧の数の差
bottom = [0]*N
for i in range(N):
    if diff[i] >= 0:
        num = 1 if S[i][0] == ')' else -1
        val = num
        for j in range(1,len(S[i])):
            if S[i][j] == '(':
                num -= 1
            else:
                num += 1
                val = max(val,num)
        bottom[i] = val
    else:
        num = 1 if S[i][-1] == '(' else -1
        val = num
        for j in range(1,len(S[i]))[::-1]:
            if S[i][j] == ')':
                num -= 1
            else:
                num += 1
                val = max(val,num)
        bottom[i] = val
    
up = []
down = []
for i in range(N):
    if diff[i] >= 0:
        up.append((diff[i],bottom[i]))
    else:
        down.append((diff[i],bottom[i]))

up.sort(key=lambda x: x[1])
down.sort(key=lambda x: -x[1])

r = 0
for u in up:
    if r < u[1]:
        print('No')
        exit()
    else:
        r += u[0]

r = 0
for d in down[::-1]:
    if r < d[1]:
        print('No')
        exit()
    else:
        r += -d[0]

print('Yes')

Measured memory_bytes: 282412
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val cities = IntArray(n)
    (1..m).forEach {
        readLine()!!.split(' ').forEach { cities[it.toInt() - 1]++ }
    }
    cities.forEach(::println)
}


Measured memory_bytes: 38244
A=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O',
   'P','Q','R','S','T','U','V','W','X','Y','Z']
N=int(input())
x=input()
X=[j for j in x]
for i in range(0,len(X)):
  n=(A.index(X[i])+N)%26
  X[i]=A[n]
Y=''
for i in X:
  Y+=i
print(Y)

Measured memory_bytes: 9200
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int N,K;
    scanf("%d",&N);
    char S[N];
    scanf("%s",S);
    scanf("%d",&K);
    char tmp=S[K-1];
    for (size_t i = 0; i < N; i++)
    {
        if (S[i]!=tmp)
        {
            S[i]='*';
        }
    }
    printf("%s\n",S);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi a(n), b(n);
	cin >> a >> b;
	ll suma = 0, sumb = 0;
	for (auto i : a) suma += i;
	for (auto i : b) sumb += i;
	if (suma < sumb)
	{
		cout << -1 << endl;
		return 0;
	}
	int sh = 0;
	ll rem = 0;
	vi x;
	REP(i, n)
	{
		if (a[i] < b[i])
		{
			sh++;
			rem += b[i] - a[i];
		}
		else x.push_back(a[i] - b[i]);
	}
	sort(x.rbegin(), x.rend());
	int cnt = 0;
	for (auto i : x)
	{
		if (rem <= 0) break;
		cnt++;
		rem -= i;
	}
	cout << sh + cnt << endl;
	return 0;
}

Measured memory_bytes: 2936
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    ll n, ans = 0;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) cin >> a.at(i);
    sort(a.begin(), a.end(), greater<ll>());
    for (ll i = 1; i < n; ++i) ans += a.at(i / 2);
    cout << ans << endl;
    return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
const ll mod = 1e9+7;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	ll l = s.length();
	ll dp[l+1][13];
	REP(i, l+1){
		REP(j, 13){ dp[i][j] = 0; }
	}
	dp[0][0] = 1;
	REP(i, l){
		int c;
		if (s[i] == '?') { c = -1; }
		else { c = s[i] - '0'; }
		REP(j, 10){
			if ( c != -1 && c != j){ continue; }
			else {
				REP(k, 13){
					dp[i+1][(10*k+j)%13] += dp[i][k];
				}
			}
		}
		REP(j, 13){
			dp[i+1][j] %= mod;
		}
	}
	cout << dp[l][5] << endl;
}


Measured memory_bytes: 10704
N = gets.chomp().to_i
Si = []
N.times do
  Si.push(gets.chomp().to_s)
end

ac = 0
wa = 0
tle = 0
re = 0

for result in Si do
  if result == "AC"
    ac += 1
  end
  if result == "WA"
    wa += 1
  end
  if result == "TLE"
    tle += 1
  end
  if result == "RE"
    re += 1
  end
end

puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"

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

int main(){
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  
  int ans = 0;
  if(N > K){
    ans = K * X + Y * (N - K);
  }else{
    ans = N * X;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


int solve(int a,int b) {
    if (a==0 || b==0) return 0;
    if (a<=0 && 0<=b) return 0;
    if (0<a) return 1;
    // a<0, b??
    b = min(-1, b);
    // a<0, b<0
    int d = (b-a)+1;
    // printf("a,b,d=%d %d %d\n",a,b,d);
    return d%2 ? -1 : 1;
}

int main() {
    int a,b; cin>>a>>b;
    switch(solve(a,b)) {
        case 1: cout << "Positive" << endl; break;
        case -1: cout << "Negative" << endl; break;
        case 0: cout << "Zero" << endl; break;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int N, L, sum = 0;
    scanf("%d %d", &N, &L);
    if (L >= 0)
    {
        for (int i = 2; i <= N; ++i)
        {
            sum += L + i - 1;
        }
    }
    else
    {
        if (N > -L)
        {
            for (int i = 1; i <= N; ++i)
            {
                sum += L + i - 1;
            }
        }
        else
        {
            for (int i = 1; i < N; ++i)
            {
                sum += L + i - 1;
            }
        }
    }
    printf("%d", sum);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
 
 
 
   ll power(ll x, ll p) {
    
    	ll res = 1;
    	while (p) {
    		if (p & 1) res = (res * x) % mod;
    		x = (x*x) % mod;
    		p >>= 1;
    	}
    	return res;
    }
    
    ll f(ll A[], int n) 
{ 
   
    ll array_sum = 0; 
    for (int i = 0; i < n; i++) 
        array_sum = (array_sum%mod + A[i]%mod )%mod ; 
  
  
    ll sq = (array_sum * array_sum)%mod ; 
  
   
    ll in = 0; 
    for (int i = 0; i < n; i++) 
        in =(in +  (A[i]*A[i])%mod)%mod  ; 
       
       ll rs = (((sq - in + mod)%mod) * (power(2,mod-2)%mod )) %mod;
  
    return  rs;
} 
 
int main(void){
ll n; 
cin >> n;
ll a[n];
for (int i =  0 ; i < n; i++)
cin >> a[i];
cout << f (a , n );
}


Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
   string s1;
   cin>>s1;
   ll n = s1.size();
   ll sum = 0;
   loop(i,0,n)
   sum += (s1[i]-'0');
   if(sum%9==0)
    cout<<"Yes\n";
   else
    cout<<"No\n";
    return 0;
}



Measured memory_bytes: 3760
x,y = map(int,input().split())

mod = 10 **9 + 7

n = int(( 2*y - x) /3)
m = int(( 2*x - y) /3)

from operator import mul
from functools import reduce

def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

if (x + y) %3 != 0:
    print(0)
elif n < 0 or m < 0:
    print(0)
else:
    print(combination(n+m,n,mod))


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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var nm = Input3();
            var a = Console.ReadLine().Split().Select(long.Parse).Sum();

            if (nm[0] - a < 0) Console.WriteLine(-1);
            else Console.WriteLine(nm[0]-a);

        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }

        
       
    }
}


Measured memory_bytes: 29180
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	string s;
	cin>>a>>b>>s;
	if(s[a]!='-')
	{
		cout<<"No\n";
		return 0;
	}
	for(int i=0;i<b+a;i++)
	{
		if(i==a)continue;
		if(s[i]<'0'||s[i]>'9')
		{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  int N,M;  cin>>N>>M;
  UnionFind uf(N);
  rep(i,0,M){
    int x,y;  cin>>x>>y;
    uf.merge(x-1, y-1);
  }
  ll cnt = 0;
  rep(i,0,N-1){
    if(!uf.issame(i,i+1)){
      cnt++;
      uf.merge(i, i+1);
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int GCD(int a, int b)
{
    if(b == 0) return a;
    else return GCD(b, a % b);
}
ll lcm(ll a, ll b){
    ll g = a * b;
    ll gg = GCD(a, b);
    return g/gg;
}
int main()
{
    Hello
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b);
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;

	cout << min({ a + b, b + c, c + a }) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

// bool judge(int i1, int i2, int i3, std::vector<int> &b){
// 	int n = (int)b.size();
// 	for(int i=0; i<n; i++){
		
// 	}
// }

std::string ans(std::vector<int> &a){
	if((a[0]==-1 and a[1]==-1 and a[2]==-1)) return "Yes";
	if((a[3]==-1 and a[4]==-1 and a[5]==-1)) return "Yes";
	if((a[6]==-1 and a[7]==-1 and a[8]==-1)) return "Yes";
	if((a[0]==-1 and a[3]==-1 and a[6]==-1)) return "Yes";
	if((a[1]==-1 and a[4]==-1 and a[7]==-1)) return "Yes";
	if((a[2]==-1 and a[5]==-1 and a[8]==-1)) return "Yes";
	if((a[0]==-1 and a[4]==-1 and a[8]==-1)) return "Yes";
	if((a[2]==-1 and a[4]==-1 and a[6]==-1)) return "Yes";
	return "No";
}

void mark(std::vector<int> &a, const int b){
	int n = (int)a.size();
	for(int i=0; i<n; i++){
		if(a[i]==b){
			a[i] = -1;
			return;
		}
	}
	return;
}

int main(){
	int n, b;
	std::vector<int> a(9);
	for(int i=0; i<9; i++){
		std::cin >> a[i];
	}
	std::cin >> n;
	for(int i=0; i<n; i++){
		std::cin >> b;
		mark(a, b);
	}
	std::cout << ans(a) << std::endl;
}


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

int main(int argc, char **argv)
{
	int n;
	cin >> n;

	vector<int> a(n+1);

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

	int count = 0;
	bool f = false;

	int target = 1;
	while (count < n)
	{
		target = a[target];
		count++;

		if (target == 2)
		{
			f = true;
			break;
		}
	}

	if (f) std::cout << count << std::endl;
	else std::cout << -1 << std::endl;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s,t;
	cin>>n>>s>>t;
	for(int i=n;i>=0;i--){
		if(s.substr(n-i,i)==t.substr(0,i)){
			cout<<n*2-i<<endl;
			return 0;
		}
	}
}


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

int main() {
  int n,m;
  cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2<<endl;
  return 0;
}


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

using namespace std;
const int N=2e5+5;
vector<vector<int> >g;
int p1[N],p2[N];
int n,m,k;
int findset(int p[],int u)
{
    if (p[u]<0) return u;
    else return p[u]=findset(p,p[u]);
}
void Union(int p[],int u, int v)
{
    if (p[u]>p[v]) swap(u,v);
    p[u]+=p[v];
    p[v]=u;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m>>k;
    g.resize(n+1);
    for(int i=1;i<=n;i++)
    {
        p1[i]=p2[i]=-1;
    }
    for(int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        int t=findset(p1,u);
        int s=findset(p1,v);
        if (t!=s) Union(p1,t,s);
    }
    for(int i=1;i<=k;i++)
    {
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
        int t=findset(p2,u);
        int s=findset(p2,v);
        if (t!=s) Union(p2,t,s);
    }
    map<pair<int,int>,int> mp;
    for(int u=1;u<=n;u++)
    {
        mp[make_pair(findset(p1,u),findset(p2,u))]++;
    }
    for(int u=1;u<=n;u++)
    {
        cout<<mp[make_pair(findset(p1,u),findset(p2,u))]<<' ';
    }
    return 0;
}


Measured memory_bytes: 22728
#include <stdio.h>

int main()
{
	unsigned long long n, k;
	unsigned long long int i;
	scanf("%lld %lld", &n, &k);
	for (i = 1; n > 1; i++)
	{
		n /= k;

	}
	if (n != 1) 
	{
		i--;
	}
	printf("%lld", i);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

struct nd{
    vector<ll> ady;
}G[100010];

ll n,k,curr,nxtColor;
pair<ll,ll> e[200010];
map< pair<ll,ll> , ll > color;
queue< ll > node;
set< ll > ok[200010];
set< pair<ll,ll> > use;

int main()
{

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

    cin >> n;
    for(ll i=1; i<n; i++){
        cin >> e[i].fi >> e[i].se;
        if( e[i].fi > e[i].se ) swap( e[i].fi , e[i].se );
        G[ e[i].fi ].ady.pb( e[i].se );
        G[ e[i].se ].ady.pb( e[i].fi );
        k = max( k , (ll)G[ e[i].fi ].ady.size() );
        k = max( k , (ll)G[ e[i].se ].ady.size() );
    }

    cout << k << "\n";
    node.push( 1 );

    while( !node.empty() ){
        curr = node.front();
        node.pop();

        nxtColor = 1;
        for( auto sig:G[curr].ady ){
            if( use.find( { min( curr , sig ) , max( curr , sig ) } )!=use.end()  ) continue;
            while( ok[ curr ].find( nxtColor )!=ok[ curr ].end() ) nxtColor++;
            use.insert( { min( curr , sig ) , max( curr , sig ) } );
            color[ { min( curr , sig ) , max( curr , sig ) } ] = nxtColor;
            ok[ curr ].insert( nxtColor );
            ok[ sig ].insert( nxtColor );
            node.push( sig );
        }
    }

    for(ll i=1; i<n; i++) cout << color[ e[i] ] << "\n";

    return 0;
}


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

int main() {
	int n;
	cin >> n;
	string a,b,c;
	cin >> a >> b >> c;
	int d=0;
	for(int i=0;i<n;i++){
		if(a[i]==b[i] && b[i]==c[i]){
			
		}
		else if(a[i]==b[i] && b[i]!=c[i]){
			d++;
		}
		else if(a[i]==c[i] && b[i]!=c[i]){
			d++;
		}
		else if(c[i]==b[i] && a[i]!=c[i]){
			d++;
		}
		else{
			d+=2;
		}
	}
	cout << d;
}

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

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

int main(void) {
    int w, h, n, x, y, a, min_x, max_x, min_y, max_y;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> w >> h >> n;
    min_x = w; min_y = h;
    max_x = max_y = 0;
    REP(i, n) {
        cin >> x >> y >> a;
        switch (a) {
            case 1:
                max_x = max(max_x, x);
                break;
            case 2:
                min_x = min(min_x, x);
                break;
            case 3:
                max_y = max(max_y, y);
                break;
            case 4:
                min_y = min(min_y, y);
                break;
        }
    }

    cout << max(0, min_x - max_x) * max(0, min_y - max_y) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  ll N, A, B; cin >> N >> A >> B;

  if ((B-A)%2==0) cout << (B-A)/2 << endl;
  else cout << min(A-1,N-B)+1+(B-A-1)/2 << endl;

  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 256
import sys
import numpy as np
from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func()
    input_str = input_raw.strip().split()
    value_list = []
    order_list = np.array([i + 1 for i in range(N)])
    for i in range(N):
        value_list.append(int(input_str[i]))

    value_list = np.array(value_list)

    eq_list = (value_list == order_list)

    swap_count = 0
    i = 0
    while i < N:
        if i + 1 == N:
            if eq_list[i] == True:
                swap_count += 1
            i += 1
        else:
            if eq_list[i] == True:
                swap_count += 1
                i += 2
            else:
                i += 1

    print swap_count


if __name__ == '__main__':
    main()

Measured memory_bytes: 23304
a,b = map(int,input().split())

if((a<=0 and b>=0)):
    print("Zero")
elif(a<0 and b<0):
    if(abs(a-b)%2==0):
        print("Negative")
    else:
        print("Positive")
elif(a>0 and b>0):
    print("Positive")
else:
    if(abs(a)%2==0):
        print("Positive")
    else:
        print("Negative")


Measured memory_bytes: 38256
import bisect
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
X = list(map(int, sys.stdin.readline().split()))
L = int(sys.stdin.readline())
Q = int(sys.stdin.readline())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(Q)]

N += 2
X = [X[0]] + X + [X[-1]]
X = np.array(X, dtype=int)
# dp[d][i]: i番のホテルから(2^d)日で何個右までいけるか
dp = np.zeros((N, N.bit_length() + 1), dtype=int)
dp[:, 0] = np.searchsorted(X, X + L, side="right") - 1
for d in range(1, N.bit_length() + 1):
    dp[:, d] = dp[dp[:, d - 1], d - 1]
dp = dp.tolist()


def solve(l, r):
    ret = 0
    while l + 1 < r:
        d = max(0, bisect.bisect_left(dp[l], r) - 1)
        ret += pow(2, d)
        l = dp[l][d]
    if l < r:
        ret += 1
    return ret


ans = []
for a, b in AB:
    ans.append(solve(min(a, b), max(a, b)))
print(*ans, sep='\n')


Measured memory_bytes: 131088
#include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<cstring>
    #include<string>
    #include<stack>
    #include<queue>
    #include<vector>
    #include<algorithm>
    #include <iomanip>
    typedef long long int ll;
    using namespace std;
    #define FOR(i,a,b) for (int i=(a);i<(b);i++)
    #define REP(i,n) for (int i=0;i<(n);i++)
    #define EREP(i,n) for (int i=1;i<=(n);i++)
    #define ALL(a) (a).begin(),(a).end()
    #define EVEL 1
     
    #ifndef EVEL
    #define DEB(X) cout << #X << ":" <<X<<" " ;
    #define TF(f) f ? cout<<"true  " : cout<<"false ";
    #define END cout<<"\n";
    #else
    #define DEB(X) {X=X;}
    #define TF(f) {f=f;}
    #define END {}
    #endif
    const int MOD = 1000000007;
    const ll INF =  1000000000;
    const ll SIZE= 100010;
        ll N,A[100010];
        ll ans=1;
        bool flag=false;
     
    int main() {
        ios_base::sync_with_stdio(false);
        cin>>N;
        REP(i,N)cin>>A[i];
        ll temp=0;
        int mode=1;
        // 0+ 1= 2-
        REP(i,N){
            if(i==0||A[i-1]==A[i])continue;
            DEB(i)DEB(A[i-1])DEB(A[i])DEB(mode)END
            if(A[i-1]==A[i])mode=1;
            if(A[i-1]<A[i]){
                if(mode==2){ans++;mode=1;}
                else mode=0;
            }
            if(A[i-1]>A[i]){
                if(mode==0){ans++;mode=1;}
                else mode=2;
            }
            if(A[i-1]==A[i])mode=1;
        }
        cout<<ans;
        return 0;
    }

Measured memory_bytes: 1024
from sys import stdin

def main():
    
    n=int(stdin.readline().strip())
    a=list(map(int,stdin.readline().strip().split()))
    # dp=[[0,0]*4 for _ in range(n)] #0:<1, 1:-1, 2:1, 3:>1
    # dp[0][0]=[[0,inf][a[0]>=0],[a[0],0][a[0]>=0]]
    # dp[0][1]=[abs(a[0]+1),-1]
    # dp[0][2]=[abs(a[0]-1),1]
    # dp[0][3]=[[0,inf][a[0]<=0],[a[0],0][a[0]<=0]]
    dp=[[[0,0]]*2 for _ in range(n)]
    dp[0][0]=[max(1,a[0])-a[0],[1,a[0]][a[0]>0]]
    dp[0][1]=[a[0]-min(-1,a[0]),[-1,a[0]][a[0]<0]]
    for i in range(1,n):
        n0=[0,1-a[i]-dp[i-1][1][1]][a[i]+dp[i-1][1][1]<=0]
        n1=[0,1+a[i]+dp[i-1][0][1]][a[i]+dp[i-1][0][1]>=0]
        dp[i][0]=[dp[i-1][1][0]+n0,max(1,a[i]+dp[i-1][1][1])]
        dp[i][1]=[dp[i-1][0][0]+n1,min(-1,a[i]+dp[i-1][0][1])]
    print(min(dp[n-1][0][0],dp[n-1][1][0]))

if __name__=='__main__':
    main()


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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N;
    cin >> N;

    int B[N - 1];
    REP(i, N) cin >> B[i];

    int ret = B[0];
    FOR(i, 1, N - 1) {
        ret += min(B[i-1], B[i]);
    }

    ret += B[N-2];

    cout << ret << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {
	
	void Solve() {
		UL N; cin >> N;
		string S; cin >> S;
		UL Q; cin >> Q;
		/*
		//pair<UL, UL> K[75]; rep(i, Q) { cin >> K[i].first; K[i].second = i; }
		//sort(K, K + Q);
		vector<ULL> DM(N);
		{
			ULL D = 0, Dm = 0;
			rep(i, N) {
				if (S[i] == 'D') D++;
				if (S[i] == 'M') Dm += D;
				DM[i] = Dm;
				cout << Dm << " ";
			}cout << endl;
		}
		UL K[75]; rep(i, Q) cin >> K[i];
		rep(i, Q) {
			ULL ans = 0;
			UL k = K[i];
			for (UL j = 0; j < k; j++) {
				if (S[j] == 'C') ans += DM[j];
			}
			for (UL j = k; j < N; j++) {
				if (S[j] == 'C') ans += DM[j] - DM[j - k];
			}
			cout << ans << endl;
		}
		*/
		rep(q, Q) {
			ULL ans = 0;
			UL k; cin >> k;
			UL D = 0;
			UL M = 0;
			ULL DM = 0;
			for (UL i = 0; i < k; i++) {
				if (S[i] == 'D') { D++; }
				if (S[i] == 'M') { M++; DM += D; }
				if (S[i] == 'C') { ans += DM; }
			}
			for (UL i = k; i < N; i++) {
				if (S[i - k] == 'D') { DM -= M; D--; }
				if (S[i - k] == 'M') { M--; }
				if (S[i] == 'D') D++;
				if (S[i] == 'M') { M++; DM += D; }
				if (S[i] == 'C') { ans += DM; }
			}
			cout << ans << endl;
		}
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

int main() {
	ll n;
	cin >> n;
	ll ans = n * (n - 1) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    String t = sc.next();
    for(int i=0;i<n;i++){
      System.out.print(s.substring(i,i+1));
      System.out.print(t.substring(i,i+1));
    }
      
  }
  

  
}

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

int main(){

    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a) cout<<k<<endl;
    else if(k<=b) cout<<a<<endl;
    else cout<<(k-a-b)*-1+a<<endl;


    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
ll n,c,x[100010],v[100010];
ll F(){
    ll cnt=0;
    lol(i,n)cnt+=v[i];
    cnt-=2*(c-x[0]);
    
    ll ans=cnt;
    
    ll sum=0,maxi=0;
    x[n]=c;
    //cout<<"#"<<cnt<<endl;
    
    for(int k=0;k<n;k++){
	sum+=v[k];
	maxi=max(maxi,sum-x[k]);
	
	cnt-=v[k];
	cnt+=2*(x[k+1]-x[k]);
	
	//cout<<"#"<<cnt<<" "<<sum<<" "<<maxi<<endl;
	ans=max(ans,cnt+maxi);
    }
    return ans;
}
int main(){
    cin>>n>>c;
    lol(i,n)cin>>x[i]>>v[i];
    ll ans=F();
    lol(i,n){
	x[i]=c-x[i];
	if(i<n/2)swap(v[i],v[n-1-i]);
    }
    sort(x,x+n);
    ans=max(ans,F());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long m = sc.nextLong();
    String s = sc.next();
    String t = sc.next();
    long L = (n * m) / gcd(n, m);
    long nn = L / n;
    long mm = L / m;
    int p = 0;
    long ans = L;
    for(long i = 0; i < n; i++) {
      long a = (i * nn);
      if((a % mm) == 0) {
        long j = a / mm;
        if(s.charAt((int)i) != t.charAt((int)j)) {
          p++;
          break;
        }
      }
    }
    if(p > 0) ans = -1;
    System.out.println(ans);
  }

  public static long gcd(long x, long y) {
    if(y == 0) return x;
    return gcd(y, (x % y));
  }
}

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


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

    int res = true;

    int minh = a[n - 1];
    for (int i = n - 2; i >= 0; --i)
    {
        if (a[i] <= minh) 
        {
            minh = min(minh, a[i]);
        }
        else if (a[i] - 1 <= minh) 
        {
            minh = min(minh, a[i] - 1);
        }
        else
        {
            res = false;
            break;
        }
    }

    printf("%s\n", res ? "Yes"  : "No");
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	unsigned long long L, R;
	cin >> L >> R;

	auto mod = 2019ull;
	auto limit = min(L + mod, R);
	auto result = mod * mod;
	for (auto i = L; i < limit; ++i)
	{
		for (auto j = i + 1; j <= limit; ++j)
		{
			result = min(result, i % mod * j % mod);
		}
	}

	cout << result << endl;

	return 0;
}

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

const int N(22);
const int mod(1e9 + 7);

int n, m, ans;
int M[N][N];
int f[N][1<<N];
//f[i][j] - the number of ways that first i men Mes women and i's men Mes j's women
void add_self(int &a, int b)
{
	a += b;
	if (a >= mod) a -= mod;
}
int main()
{
	cin>>n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			cin>>M[i][j];
		}
	}
	f[0][0] = 1;
	for (int women = 0; women < (1 << n); women++)
	{
		int a = __builtin_popcount(women);
		for (int b = 0; b < n; b++)
		{
			if (M[a][b] && (((women >> b) & 1) == 0))
			{
				int now = women ^ (1 << b);
				add_self(f[a + 1][now], f[a][women]);
			}		
		}
	}
/*	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= 1<<n; j++)
		{
			printf("%d ", f[i][j]);
		}
		printf("\n");
	}*/
	printf("%d\n", f[n][(1 << n) - 1]);
	return 0;	
}

Measured memory_bytes: 178432
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
int main() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll ans(0);
	
	rep(i, k) {
		ans += a[i];
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int a[5], k;

int main()
{
    int ind = 0, m = 10;
    for (int i = 0; i < 5; i++)
    {
        cin >> a[i];
        if (a[i] % 10 != 0 && m > a[i] % 10)
            ind = i, m = a[i] % 10;
    }
    int ans = a[ind];
    for (int i = 0; i < 5; i++)
    {
        if (i != ind)
        {
            if (a[i] % 10 == 0)
                ans += a[i];
            else
                ans += a[i] + 10 - a[i] % 10;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
//#define int ll

const int N = 5010;
int p[N];
vector<int> have[N];

int find(int v) {
  return p[v] == v ? v : p[v] = find(p[v]);
}

void merge(int a, int b) {
  a = find(a), b = find(b);
  if (a == b) {
    return;
  }
  if (SZ(have[a]) < SZ(have[b])) {
    swap(a, b);
  }
  p[b] = a;
  for (auto it : have[b]) {
    have[a].pb(it);
  }
}

const int MOD = 1e9 + 7;

inline int mult(int a, int b) {
  return (a * 1ll * b) % MOD;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) {
    a += MOD;
  }
}

inline void add(int &a, int b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
}

int pw[N], a[N], fa[N];
int dp[N][N], sum[N];

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  fa[0] = 1;
  for (int i = 1; i <= n; i++) {
    fa[i] = mult(fa[i - 1], i);
  }
  pw[0] = 1;
  for (int i = 1; i <= n; i++) {
    pw[i] = mult(pw[i - 1], n - 1);
  }
  for (int i = 1; i <= n; i++) {
    p[i] = i;
    have[i] = {i};
  }
  int k = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] != -1) {
      merge(a[i], i);
    }
    else {
      k++;
    }
  }
  int comps = 0, zeros = 0;
  vector<int> ones;
  for (int i = 1; i <= n; i++) {
    if (find(i) == i) {
      comps++;
      int cnt = 0;
      for (auto it : have[i]) {
        if (a[it] == -1) {
          cnt++;
        }
      }
      assert(cnt <= 1);
      if (cnt == 0) {
        zeros += SZ(have[i]);
      }
      else {
        ones.pb(SZ(have[i]));
      }
    }
  }
  int ans = mult(comps - k, pw[k]);
  //cout << ans << '\n';
  for (int i = 1; i <= k; i++) {
    dp[i][1] = ones[i - 1];
    for (int j = 2; j <= i; j++) {
      dp[i][j] = mult(ones[i - 1], sum[j - 1]);
    }
    for (int j = 1; j <= i; j++) {
      add(sum[j], dp[i][j]);
    }
    add(ans, mult(ones[i - 1] - 1, pw[k - 1]));
  }
  //cout << ans << '\n';
  for (int len = 2; len <= k; len++) {
    //cout << len << ' ' << sum[len] << '\n';
    add(ans, mult(pw[k - len], mult(sum[len], fa[len - 1])));
  }
  int tans = mult(n, pw[k]);
  //cout << tans << '\n';
  sub(tans, ans);
  cout << tans << '\n';  
}

Measured memory_bytes: 70908
#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define forn(i, n) for(int i = 0; i < int__(n); i++) 
#define sz(a) int__(a.size())
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
const int MAX = 1e9 + 7;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int Mod(int x){const int mm=998244353;x%=mm;if(x<0)x+=mm;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int x,int y){return y!=0 ? gcd(y,x%y) : x;}
 
int__ main() {
	fast;
	int n; cin >> n;

	vi a(n),b(n),c(n);

	for(int i=0;i<n;i++) cin >> a[i] >> b[i] >> c[i];

	vvi dp(n,vi (3,0));
	
	dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];

	for(int i=1;i<n;i++) {
		dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][1],dp[i-1][0]);
	}

	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;
}

Measured memory_bytes: 8064