akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ std::cin >> head; _cin(std::forward<Tail>(tail)...); }
void _cout(){ std::cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ std::cout << head; _cout(std::forward<Tail>(tail)...); }
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; For(i, n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__);
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Couty(cond) Cout((cond) ? "Yes" : "No")
#define CoutY(cond) Cout((cond) ? "YES" : "NO")

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cins(int, n, x);
    Sort(x);
    Cout(x.back() - x.front())
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[252521], b[252521];
int c[252521];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  REP(i,n)scanf("%d",b+i);
  int ans = 0;
  FOR(i,0,30){
    int msk = (1<<(i+1)) - 1;
    int mmsk = msk>>1;
    int xx = 1<<i;
    REP(j,n)c[j] = a[j] & msk;
    sort(c,c+n);
    // REP(j,n)printf("%3d",c[j]);puts("");
    int add = 0;
    REP(j,n){
      int x = b[j] & msk;
      int cnt = 0;
      if((x>>i)&1){
        // printf("[%d, %d), [%d, %d)\n",0,xx-(x&mmsk),xx+xx-(x&mmsk),2*xx);
        // [0, x-xx), [2xx-x, 2xx)
        cnt += lower_bound(c,c+n,xx-(x&mmsk)) - lower_bound(c,c+n,0);
        cnt += lower_bound(c,c+n,2*xx) - lower_bound(c,c+n,2*xx-(x&mmsk));
      }else{
        // printf("[%d, %d)\n",xx-x, 2*xx-x);
        // [xx-x, 2xx-x)
        cnt += lower_bound(c,c+n,2*xx-x) - lower_bound(c,c+n,xx-x);
      }
      // printf("%d : %d\n",x,cnt);
      add ^= cnt;
    }
    if(add&1){
      ans ^= xx;
    }
    // puts("");
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <utility>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <queue>
#include <stack>
using namespace std;

#define LL   long long
#define ld   long double
#define pii  pair<int,int>
#define pLL  pair<LL,LL>
#define vint vector<int>
#define vLL  vector<LL>

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define MP make_pair
#define PB push_back

#define Si(x) scanf("%d",&(x));
#define Sii(x,y) scanf("%d %d",&(x),&(y));
#define Siii(x,y,z) scanf("%d %d %d",&(x),&(y),&(z));
#define SL(x) scanf("%lld",&(x));
#define SLL(x,y) scanf("%lld %lld",&(x),&(y));
#define SLLL(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z));

#define Pi(x) printf("%d\n",(x));
#define Pii(x,y) printf("%d %d\n",(x),(y));
#define Piii(x,y,z) printf("%d %d %d\n",(x),(y),(z));
#define Piiii(x,y,z,w) printf("%d %d %d %d\n",(x),(y),(z),(w));
#define Piiiii(a,b,c,d,e) printf("%d %d %d %d %d\n",(a),(b),(c),(d),(e));
#define Piiiiii(a,b,c,d,e,f) printf("%d %d %d %d %d %d\n",(a),(b),(c),(d),(e),(f));
#define PL(x) printf("%lld\n",(x)*1LL);
#define PLL(x,y) printf("%lld %lld\n",(x)*1LL,(y)*1LL);
#define PLLL(x,y,z) printf("%lld %lld %lld\n",(x)*1LL,(y)*1LL,(z)*1LL);
#define PLLLL(x,y,z,w) printf("%lld %lld %lld %lld\n",(x)*1LL,(y)*1LL,(z)*1LL,(w)*1LL);

#define Pi1(x) printf("%d",  (x));
#define PiL(x) printf("%lld",(x));
#define Pspace putchar(' ');
#define Pendl  puts("");

#define MEM0(x) memset( (x), 0, sizeof( (x) ) )
#define MEM1(x) memset( (x),-1, sizeof( (x) ) )
#define REP1(i,n)  for (int i = 1; (n) >= i ; ++i)
#define REP0(i,n)  for (int i = 0; (n) >  i ; ++i)
#define REP(L,R,k) for (int i = (L); (R) >= i; i+= (k) )

int myRnd(int L,int R) {
    return abs(( (rand()<<15)|rand() ) ) % (R-L+1) + L;
}

int main () {
    srand(time(NULL));
    int n,m;
    Sii(n,m);
    Pi( ((m*1900+(n-m)*100)<<m ) );
}



Measured memory_bytes: 256
nab_list = input().split(" ")
N = int(nab_list[0])
A = int(nab_list[1])
B = int(nab_list[2])

ab_set = N//(A+B)
ab_rem = N%(A+B)

if ab_rem >A:
    print(A + ab_set*A)
else:
    print(ab_rem + ab_set*A)


Measured memory_bytes: 3060
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();

		//Deque型のListを生成
		List<Deque<Integer>> list = new ArrayList<Deque<Integer>>();
		for(int i = 0; i < n; i++) {
			list.add(new ArrayDeque<Integer>());
		}

		for(int i = 0; i < q; i++)	{
			int query = sc.nextInt();
			int t = sc.nextInt();

			switch(query){
			case 0:
				int x = sc.nextInt();
				list.get(t).add(x);  //listの中のt番目の要素を取得し、それにaddする
				break;

			case 1:
				if(!(list.get(t).isEmpty())) {
					System.out.println(list.get(t).peekFirst());
				}
				break;

			case 2:
				list.get(t).pollFirst();
				break;
			}
		}
	}

}


Measured memory_bytes: 170544
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,d,tmp[10],tmpp,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll m,a,r,c,h;

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>n;
    rep(i,n){
        cin>>s;
        if(s[0]=='M')m++;
        else if(s[0]=='A')a++;
        else if(s[0]=='R')r++;
        else if(s[0]=='C')c++;
        else if(s[0]=='H')h++;
    }
    tmp[0]=m;
    tmp[1]=a;
    tmp[2]=r;
    tmp[3]=c;
    tmp[4]=h;
    rep(i,5){
        rrep(j,i+1,5){
            rrep(k,j+1,5){
                ans+=(tmp[i])*(tmp[j])*(tmp[k]);
            }
        }
    }
    Cout(ans);
    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  string S; cin >> S;
  if (S[S.length() - 1] == 's') S += "es";
  else S += "s";
  cout << S << endl;

  return 0;
}



Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>
#include <cassert>

using lli = long long int;
lli inf = 1000000007;
using namespace std;

void solve()
{
	lli N;
	cin >>  N;
	lli ans = 0;
	for (int i = 1; i <= N; i++)ans += i;
	cout << ans << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#define N 60
#define M 2510
#define ls x << 1
#define rs x << 1 | 1
#define inf 0x3f3f3f3f
#define inc(i) (++ (i))
#define dec(i) (-- (i))
#define mid ((l + r) >> 1)
// #define int long long
#define debug() puts("XRZ TXDY");
#define Next(i, u) for(int i = head[u]; i ; i = e[i].nxt)
#define file(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout);
#define Rep(i, a, b) for(int i = (a) , i##Limit = (b) ; i <= i##Limit ; inc(i))
#define Dep(i, a, b) for(int i = (a) , i##Limit = (b) ; i >= i##Limit ; dec(i))
using namespace std;
int a, b, c;
signed main() {
	scanf("%d%d%d", &a, &b, &c);
	if(a + b + c >= 22) puts("bust");
	else puts("win");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long a[3];
	for(int i=0;i<3;i++)
	{
		cin>>a[i];
	}
	sort(a,a+3);
	if(a[2]%2==0)
	{
		cout<<"0";
	}
	else
	{
		long long ans=a[0]*a[1];
		cout<<ans;
	}
}

Measured memory_bytes: 888
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int mod=1000000007;
const int maxn=200200;
const int maxm=2200;
int n;
int a[maxn],b[maxn];
int dp[maxm*2][maxm*2];
int flag[maxm*2][maxm*2];
int ans;

void pl(int &a,ll b){
	a=(a+b%mod)%mod;
}
void mi(int &a,ll b){
	a=a-b%mod;
	while(a<0) a+=mod;
	a=a%mod;
}

int main(){
#ifdef LZT
	freopen("in","r",stdin);
#endif
	n=read();
	rep(i,1,n) a[i]=read(),b[i]=read();
	rep(i,1,n){
		flag[2100-a[i]][2100-b[i]]++;
		flag[a[i]+2100][b[i]+2100]++;
	}
	rep(i,1,4200){
		rep(j,1,4200){
			pl(dp[i][j],dp[i-1][j]);
			pl(dp[i][j],dp[i][j-1]);
			if(flag[i][j] && i<=2100 && j<=2100) pl(dp[i][j],flag[i][j]);
			if(flag[i][j] && i>=2100 && j>=2100) pl(ans,dp[i][j]*1ll*flag[i][j]);
		}
	}
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	rep(i,0,4200){
		rep(j,0,4200){
			if(i==0 && j==0) continue;
			if(i) pl(dp[i][j],dp[i-1][j]);
			if(j) pl(dp[i][j],dp[i][j-1]);
		}
	}
	rep(i,1,n)
		mi(ans,dp[a[i]+a[i]][b[i]+b[i]]);
	ans=ans*500000004ll%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 149248
x,n = gets.split.map(&:to_i)
if n == 0
  puts x
  exit
end
p = gets.split.map(&:to_i)

ns = Array.new(102, 0)
for i in 0..(n-1)
  ns[p[i]] = 1
end

ans = 0
for i in 0..100
  if ns[[0,x-i].max] == 0
    ans = [0,x-i].max
    break
  elsif ns[[x+i,101].min] == 0
    ans = [x+i,101].min
    break
  end
end
puts ans

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

using namespace std;

#define ll long long




void solve() {

	int a, b;
	cin >> a >> b;
	if(a >= 10 || b >= 10) {
		cout << -1;
	}
	else {
		cout << a * b;
	}

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3616
n=int(input())
A=list(map(int,input().split()))
SUM=abs(A[0])
ans=[0]*n
for i in range(n-1):
    SUM+=abs(A[i+1]-A[i])
SUM+=abs(A[n-1])
A.append(0)
for i in range(n):
    if i==0:
        if A[i]<min(A[i+1],0):
            ans[i]=SUM-2*(min(A[i+1],0)-A[i])
        elif A[i]>max(A[i+1],0):
            ans[i]=SUM-2*(A[i]-max(A[i+1],0))
        else:
            ans[i]=SUM
    elif A[i]<min(A[i+1],A[i-1]):
        ans[i]=SUM-2*(min(A[i+1],A[i-1])-A[i])
    elif A[i]>max(A[i+1],A[i-1]):
        ans[i]=SUM-2*(A[i]-max(A[i+1],A[i-1]))
    else:
        ans[i]=SUM
print(*ans,sep='\n')

Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
struct Union_Find{
    int d[SIZE],num[SIZE];
    void init(int n){
        REP(i,n)d[i]=i,num[i]=1;
    }
    int find(int x){
        return (x!=d[x])?(d[x]=find(d[x])):x;
    }
    bool uu(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y)return 0;
        if(num[x]>num[y])swap(x,y);
        num[y]+=num[x];
        d[x]=y;
        return 1;
    }
}U;
int main(){
    VPII X,Y;
    vector<pair<int,PII> >ppp;
    DRI(N);
    U.init(N);
    REP(i,N){
        DRII(x,y);
        X.PB(MP(x,i));
        Y.PB(MP(y,i));
    }
    sort(ALL(X));
    sort(ALL(Y));
    REPP(i,1,N){
        ppp.PB(MP(X[i].F-X[i-1].F,MP(X[i].S,X[i-1].S)));
        ppp.PB(MP(Y[i].F-Y[i-1].F,MP(Y[i].S,Y[i-1].S)));
    }
    sort(ALL(ppp));
    int an=0;
    REP(i,SZ(ppp)){
        if(U.uu(ppp[i].S.F,ppp[i].S.S))an+=ppp[i].F;
    }
    cout<<an<<endl;
    return 0;
}


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

const ll MAX = 1e6+3;
const ll INF = 1e18L+3;
ll n,w;
struct val1{
    ll a,b;    
}val[MAX];




int main()
{
    cin>>n>>w;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>val[i].a>>val[i].b;
        sum+=val[i].b;
    }
    ll dp[sum+1];
    dp[0]=0;
    for(int i=1;i<=sum;i++)
        dp[i]=INF;
        
    for(int i=0;i<n;i++)
    {
        for(int j=(sum-val[i].b);j>=0;j--)
        {
            dp[j+(val[i].b)]=min(dp[j+(val[i].b)],dp[j]+(val[i].a));
        }
    }
    ll index=0;
    for(int i=sum;i>=0;i--)
    {
        
        if(dp[i]<=w)
        {
            index=i;
            break;
        }
    }
    cout<<index<<endl;
}

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

using namespace std;

const int N = 1e5+7;

int n, m;
int bb[N], d[N<<1], to[N];

struct Node 
{
    int a, b, id;
} p[N];

inline bool cmpa(const Node &x, const Node &y) { return x.a < y.a; }
inline bool cmpb(const Node &x, const Node &y) { return x.b < y.b; }

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> p[i].a, d[i] = p[i].a;
    for (int i = 1; i <= n; ++i) cin >> p[i].b, d[n+i] = p[i].b;
    sort(d+1, d+n*2+1);
    m = unique(d+1, d+n*2+1)-d-1;
    for (int i = 1; i <= n; ++i) {
        p[i].a = lower_bound(d+1, d+m+1, p[i].a)-d;
        p[i].b = lower_bound(d+1, d+m+1, p[i].b)-d;
    }
    sort(p+1, p+n+1, cmpb);
    for (int i = 1; i <= n; ++i) {
        bb[i] = p[i].b;
        p[i].id = i;
    }
    sort(p+1, p+n+1, cmpa);
    for (int i = 1; i <= n; ++i) {
        if (p[i].a > bb[i]) {
            cout << "No" << endl;
            return 0;
        }
        to[p[i].id] = i;
    }
    for (int i = 1; i < n; ++i) {
        if (p[i+1].a <= bb[i]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    int sz = 0, now = 1;
    do {
        ++sz;
        now = to[now];
    } while (now != 1);
    if (sz == n) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 100001
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<int,ll>Pil;
typedef pair<P1,ll> P2;
typedef list<int> li;
typedef list<li> lli;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	ll a;
	int b;
};
ll t[200002]={};
ll a[200002];

int main(){

	int n;
	cin>>n;
	rep(i,n){
		cin>>a[i+1];
		t[i+1]=t[i];
		t[i+1]+=a[i+1];
	}
	ll ans=0;
	for(int i=1; i<n; i++){
		ll x=(t[n]-t[i])%i197;
		ans+=a[i]*x;
		ans%=i197;
	}
	cout<<ans<<endl;

	return 0;
}


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

int n;
int x[20000],y[20000];
P p[40000];
vector<int>id[20000];

vector<int>E[80000],G[80000];
int N;

void init(int n){
	N=1;while(N<n)N<<=1;
	for(int i=1;i<2*N;i++){
		E[i].clear();
		G[i].clear();
	}
}
void add_edge(int l,int r,int x){
	for(l+=N,r+=N;l<r;l>>=1,r>>=1){
		if(l&1){
			E[x+N].push_back(l);
			G[l].push_back(x+N);
			l++;
		}
		if(r&1){
			r--;
			E[x+N].push_back(r);
			G[r].push_back(x+N);
		}
	}
}

bool used[80000];
vector<int>vs;
int cmp[80000];

void dfs(int v){
	used[v]=true;
	for(int u:E[v]){
		if(!used[u])dfs(u);
	}
	if(v<N&&!used[v*2])dfs(v*2);
	if(v<N&&!used[v*2+1])dfs(v*2+1);
	vs.push_back(v);
}
void rdfs(int v,int k){
	cmp[v]=k;
	for(int u:G[v]){
		if(cmp[u]==-1)rdfs(u,k);
	}
	if(v>1&&cmp[v/2]==-1)rdfs(v/2,k);
}
void scc(){
	memset(used,0,sizeof(used));
	memset(cmp,-1,sizeof(cmp));
	vs.clear();
	rep(i,2*N){
		if(!used[i])dfs(i);
	}
	int cnt=0;
	for(int i=vs.size()-1;i>=0;i--){
		if(cmp[vs[i]]==-1){
			rdfs(vs[i],cnt++);
		}
	}
}
bool C(int d){//全てd以上にできるか?
	init(2*n);
	rep(i,2*n){
		int s=lower_bound(p,p+i,P(p[i].first-d+1,-1))-p;
		int t=lower_bound(p+i,p+2*n,P(p[i].first+d,-1))-p;
		add_edge(s,i,id[p[i].second][id[p[i].second][0]==i]);
		add_edge(i+1,t,id[p[i].second][id[p[i].second][0]==i]);
	}
	scc();
	rep(i,n){
		if(cmp[id[i][0]+N]==cmp[id[i][1]+N])return false;
	}
	return true;
}
int main(){
	scanf("%d",&n);
	rep(i,n){
		scanf("%d%d",&x[i],&y[i]);
		if(x[i]>y[i])swap(x[i],y[i]);
		p[i*2]=P(x[i],i);
		p[i*2+1]=P(y[i],i);
	}
	sort(p,p+2*n);
	rep(i,2*n){
		id[p[i].second].push_back(i);
	}
	int l=0,r=INT_MAX/2;
	while(r-l>1){
		int t=(l+r)/2;
		if(C(t))l=t;
		else r=t;
	}
	cout<<l<<endl;
}

Measured memory_bytes: 19580
def solve(a, b, n):
    if n >= b - 1:
        return a * (b - 1) // b
    else:
        return a * n // b


def main():
    a, b, n = map(int, input().split())
    res = solve(a, b, n)
    print(res)


def test():
    assert solve(5, 7, 4) == 2
    assert solve(11, 10, 9) == 9


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define int double
#define float double 
#define dg(x) cout<<#x<<" :"<<x;
#define dg_array(ar) for(auto x : ar) cout<<x<<" ";cout<<endl;
#define dg_2darray(ar) for(auto x : ar) {for(auto y : x) cout<< y<<" ";cout<<endl;}
#define endl '\n'
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
    int n ; 
    cin >> n;
    int res = 2 * M_PI * n;
    cout<< res << endl;
}

void testcase()
{
    int t;
    cin>>t;
    while(t--)
        solve();
}
int32_t main(){
	fast;
//    testcase();           
   solve();              
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define ci const int&
#define Updl(x) (t[x].vl=Mrgl(t[x<<1].vl,t[x<<1|1].vl))
#define Updr(x) (t[x].vr=Mrgr(t[x<<1].vr,t[x<<1|1].vr))
#define pi pair<int,int>
#define f first
#define s second
using namespace std;
struct node{
	int l,r;
	pi vl,vr;
}t[400010];
int n,p[100010],pos[100010],l1,l2,r1,r2;
long long ans;
pi tmp;
pi Mrgl(const pi&x,const pi&y){
	return x.f>y.f?(pi){x.f,max(x.s,y.f)}:(pi){y.f,max(x.f,y.s)};
}
pi Mrgr(const pi&x,const pi&y){
	return x.f<y.f?(pi){x.f,min(x.s,y.f)}:(pi){y.f,min(x.f,y.s)};
}
void Build(ci x,ci l,ci r){
	t[x].l=l,t[x].r=r;
	if(l==r)return(void)(t[x].vr.f=pos[l],t[x].vr.s=n+1);
	int mid=l+r>>1;
	Build(x<<1,l,mid),Build(x<<1|1,mid+1,r),Updr(x);
}
void Changel(ci x,ci id,ci v){
	if(t[x].l==t[x].r)return(void)(t[x].vl.f=v);
	int mid=t[x].l+t[x].r>>1;
	id<=mid?Changel(x<<1,id,v):Changel(x<<1|1,id,v),Updl(x);
}
void Changer(ci x,ci id){
	if(t[x].l==t[x].r)return(void)(t[x].vr.f=n+1);
	int mid=t[x].l+t[x].r>>1;
	id<=mid?Changer(x<<1,id):Changer(x<<1|1,id),Updr(x);
}
pi Queryl(ci x,ci l,ci r){
	if(l>r)return(pi){0,0};
	if(t[x].l==l&&t[x].r==r)return t[x].vl;
	int mid=t[x].l+t[x].r>>1;
	return r<=mid?Queryl(x<<1,l,r):(l>mid?Queryl(x<<1|1,l,r):(Mrgl(Queryl(x<<1,l,mid),Queryl(x<<1|1,mid+1,r))));
}
pi Queryr(ci x,ci l,ci r){
	if(l>r)return(pi){n+1,n+1};
	if(t[x].l==l&&t[x].r==r)return t[x].vr;
	int mid=t[x].l+t[x].r>>1;
	return r<=mid?Queryr(x<<1,l,r):(l>mid?Queryr(x<<1|1,l,r):(Mrgr(Queryr(x<<1,l,mid),Queryr(x<<1|1,mid+1,r))));
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&p[i]),pos[p[i]]=i;
	Build(1,1,n);
	for(int i=1;i<=n;++i){
		Changer(1,p[i]),Changel(1,p[i],i),tmp=Queryl(1,p[i]+1,n),l1=tmp.f,l2=tmp.s,tmp=Queryr(1,p[i]+1,n),r1=tmp.f,r2=tmp.s;
		ans+=1ll*(i-l1)*(r2-r1)*p[i]+1ll*(l1-l2)*(r1-i)*p[i];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 10368
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
struct edge{
  int to,cap,rev;
};
vector<edge> g[100010];
bool used[100010];

void add_edge(int from,int to,int cap){
  g[from].push_back((edge){to,cap,(int)g[to].size()});
  g[to].push_back((edge){from,0,(int)g[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t) return f;
  used[v]=true;
  rep(i,g[v].size()){
    edge &e=g[v][i];
    if(!used[e.to]&&e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap-=d;
	g[e.to][e.rev].cap+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow=0;
  while(1){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0) return flow;
    flow+=f;
  }
}



int main(){
  int n;cin>>n;
  char s[110];
  rep(i,n) cin>>s[i];
  int cnl=0,cnr=0;
  rep(i,n){
    if(s[i]=='('){
      cnl++;
      add_edge(0,i+1,1);
      for(int j=i+1;j<n;j++){
	if(s[j]==')'){
	  add_edge(i+1,j+1,1);
	}
      }
    }
    else{
      cnr++;
      add_edge(i+1,n+1,1);
    }
  }
  int pair=max_flow(0,n+1);
  rep(i,cnr-pair) cout<<'(';
  rep(i,n) cout<<s[i];
  rep(i,cnl-pair) cout<<')';
  cout<<"\n";

  
  return 0;
}


Measured memory_bytes: 2688
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    return ret;
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = std::string::String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}
fn parse<T: std::str::FromStr>(s: &str) -> T { s.parse::<T>().ok().unwrap() }

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { parse(&get_word()) }

fn main() {
    let n = get();
    let s: Vec<char> = get_word().chars().collect();
    let s: Vec<i32> = s.into_iter().map(|x| if x == 'x' { 1 } else { 0 }).collect();
    // Fix the first two
    for b in 0 .. 4 {
        let mut sol = vec![0; n];
        sol[0] = b % 2;
        sol[1] = b / 2;
        for i in 2 .. n {
            sol[i] = (sol[i - 1] + sol[i - 2] + s[i - 1]) % 2;
        }
        // check the consistency with s[0] and s[n - 1]
        if s[0] == (sol[0] + sol[1] + sol[n - 1]) % 2
            && s[n - 1] == (sol[n - 1] + sol[n - 2] + sol[0]) % 2 {
                for c in sol {
                    print!("{}", if c == 1 { "W" } else { "S" });
                }
                println!("");
                return;
            }
    }
    println!("-1");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s, t;
	int c = 0;
	cin>>s>>t;
	for(int x = 0; x < s.length(); x++){
		if(s[x] != t[x])
			++c;
	}
	cout<<c<<endl;
	return 0;
}



Measured memory_bytes: 3852
import java.util.*;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n1 = sc.nextInt();
    int n2 = sc.nextInt();
    int n3 = sc.nextInt();
    
    int[] array = {n1,n2,n3};
    int matchCount1 = 0;
    int matchCount2 = 0;
    for(int val : array){
      if(val == 5){
        matchCount1++;
      }else if(val == 7){
        matchCount2++;
      }
    }
    
    if(matchCount1 == 2 && matchCount2 == 1){
      System.out.println("YES");
    } else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21844
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, M = MAP()
    A = LIST()

    minus_A = list(map(lambda x: x*(-1), A))
    heapify(minus_A)
    for i in range(M):
        temp = heappop(minus_A) * (-1)
        heappush(minus_A, temp//2 * (-1))

    print(sum(minus_A) * (-1))


if __name__ == '__main__':
        main()

Measured memory_bytes: 68504
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, K = getNM()
various = defaultdict(list)
que = [getList() for i in range(N)]

ans = 0
num = []
var_s = set()

# 美味しい順にK個とった時の幸福度
que.sort(reverse = True, key = lambda i: i[1])
for i in range(K):
    ans += que[i][1]
    # もし２番手以降ならあとで交換する用にとっておく
    if que[i][0] in var_s:
        num.append(que[i][1])
    var_s.add(que[i][0])

var = len(var_s)
ans += var ** 2

# 使ってない種類について各種類で一番大きさが大きいもの
left_l = defaultdict(int)
for i in range(N):
    if not que[i][0] in var_s:
        left_l[que[i][0]] = max(left_l[que[i][0]], que[i][1])

num.sort(reverse = True)
left_l = [i[1] for i in left_l.items()]
left_l.sort()

# M回交換する
opt = ans
M = min(len(num), len(left_l))
for i in range(M):
    u = num.pop()
    s = left_l.pop()
    # 寿司単体の幸福度
    opt -= (u - s)
    # 種類が増える分
    opt += 2 * var + 1
    var += 1
    ans = max(opt, ans)

print(ans)

Measured memory_bytes: 118916
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 100000

typedef long long ll;
typedef pair<int,int> P;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a,b) << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
 int K;
 int i;
 int odd,even;
 cin >> K;
 for(i=0;i<K;i++){
	if(i%2==0){
		even++;
	}else{
		odd++;
	}
 }
 cout << even*odd << endl;

 return 0;
}



Measured memory_bytes: 256
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
ll ans[100005],vis[100005];
void dfs(ll ind,vector<ll>v[],vector<ll>m[])
{
	vis[ind]=1;
	for(ll i=0;i<v[ind].size();i++)
	if(!vis[v[ind][i]])
	{
	if(m[ind][i]%2)	
	ans[v[ind][i]]=ans[ind]^1;
	else
	ans[v[ind][i]]=ans[ind];	
	dfs(v[ind][i],v,m);	
	}
	return;
}
int main()
{
	sync;
	ll n;
	cin>>n;
	vector<ll>v[n+1];
	vector<ll>m[n+1];
	for(ll i=0;i<n-1;i++)
	{
		ll u,vi,w;
		cin>>u>>vi>>w;
		v[u].push_back(vi);
		v[vi].push_back(u);
		m[u].push_back(w);
		m[vi].push_back(w);
	}
	dfs((ll)1,v,m);
	for(ll i=1;i<=n;i++)
	cout<<ans[i]<<"\n";
}


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

int main(){
	// your code goes here
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	cout.tie(NULL);
	
	int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	cin>>k;
	cout<<arr[k-1];
	
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
s = []
for i in range(m):
  s.append(list(map(int, input().split()))[1:])
p = list(map(int, input().split()))
casecnt = 0
for i in range(2**n):
  case = list(map(int, list(("{:0" + str(n) + "b}").format(i))))
  oncnt = 0
  for j in range(m):
    soncnt = 0
    for k in range(len(s[j])):
      soncnt += case[s[j][k]-1]
    if soncnt % 2 == p[j]:
      oncnt += 1
  if oncnt == m:
    casecnt += 1
print(casecnt)

Measured memory_bytes: 3188
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;

bool is_prime(int p){
	if(p<=1)return false;
	if(p==2)return true;
	if(!(p&1))return false;
	for(int x=3;x<=sqrt(p);++x) if(!(p%x))return false;
	return true;
}

int main(){
	bool primes[10002];
	memset(primes,0,sizeof(primes));
	for(int x=2;x<=10000;++x)if(is_prime(x))primes[x]=true;
	int n;
	while(scanf("%d",&n)==1){
		int c =0 ;
		int l = n/2;
		if(n%2==1){
			++l;
			if(primes[l])--c;
		}
		for(int x=1;x<=l;++x){
			if(primes[x] && primes[n-x+1])c +=2;
		}
		cout<<c<<endl;
	}
	return 0;	
}

Measured memory_bytes: 1224
import Data.List

solve :: Int -> Int -> Int -> Int -> Int
solve a b c d
  | b <= c = 0
  | d <= a = 0
  | True = y - x
    where
      _:x:y:_ = sort [a, b, c, d]
      
main :: IO ()
main = do
  a:b:c:d:_ <- fmap (\x -> read x :: Int) <$> words <$> getLine
  print $ solve a b c d

Measured memory_bytes: 508
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(arr[k-1])

Measured memory_bytes: 38384
import math
X, K, D = map(int,input().split())
X = math.fabs(X)
ans = 0
E = X//D
if E > K:
    ans = X - K * D
elif K%2 == E%2:
    ans = X-E*D
else:
    ans = -X+(E+1)*D
print(int(ans))

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

using namespace std;

int n;

struct node
{
    char s[15];
    int a;
    int cou;
}a[101];

bool cmp(node a,node b)
{
    if(strcmp(a.s,b.s) != 0)
    {
        return strcmp(a.s,b.s) < 0;
    }
    else
        return a.a > b.a;
}

int main()
{
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
    {
        scanf("%s%d",a[i].s,&a[i].a);
        a[i].cou = i;
    }
    sort(a + 1,a + 1 + n,cmp);
    for(int i = 1;i <= n;i++)
        printf("%d\n",a[i].cou);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = [list(map(str,input().split())) for i in range(n)]
for i in range(n):
    l[i][0] = float(l[i][0])
#print(n,l)

ans = 0
for i in range(n):
    if l[i][1] == "BTC":
        ans += l[i][0] * 380000.0
    else:
        ans += l[i][0]
print(ans)

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

int A,B,C,D;

int main()
{
    scanf("%d%d%d%d",&A,&B,&C,&D);
    if(abs(A - C) <= D || (abs(A - B) <= D && abs(B - C) <= D))printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for i in range(N):
  x = A[i] - 1
  ans += B[x]
  if i >= 1 and A[i] == A[i-1] + 1:
    ans += C[A[i-1]-1]
print(ans)

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int h, w;
    cin >> h >> w;
    char a[h][w];
    rep(i, 0, h) {
        rep(j, 0, w) {
            cin >> a[i][j];
        }
    }

    vector<tuple<int, int, int, int>> ans;
    rep(i, 0, h - 1) {
        rep(j, 0, w) {
            if (a[i][j] % 2 == 1) {
                a[i][j]--;
                a[i + 1][j]++;
                ans.push_back(make_tuple(i, j, i + 1, j));
            }
        }
    }

    rep(j, 0, w - 1) {
        if (a[h - 1][j] % 2 == 1) {
            a[h - 1][j]--;
            a[h - 1][j + 1]++;
            ans.push_back(make_tuple(h - 1, j, h - 1, j + 1));
        }
    }

    cout << ans.size() << endl;
    for (auto i : ans) {
        cout << get<0>(i) + 1 << " " <<get<1>(i) + 1<< " " << get<2>(i) + 1 << " " << get<3>(i) + 1<< endl;
    }
    return 0;
}


Measured memory_bytes: 4464
using System;
class aoj
{
    static void Main()
    {
        string a;
        while (true)
        {
            a = Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            int d = 0,c= 0;
            for(int i = 0; i < a.Length - 2; i++)
            {
                string b = a.Substring(i, 3);
                if (b == "JOI") d++;
                else if (b == "IOI") c++; 
            }
            Console.WriteLine(d + "\n" + c);
        }
    }
}

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

using namespace std;

void dfs (int currentIdx, int parentIdx, int point, vector<int>* tree, vector<int>* treeB, long long* scores)
{
    scores[currentIdx] = scores[currentIdx] + point;
    for (auto e : tree[currentIdx]) {
      	if (e == parentIdx) continue;
        dfs(e, currentIdx, scores[currentIdx], tree, treeB, scores);
    }
  	for (auto e : treeB[currentIdx]) {
      	if (e == parentIdx) continue;
        dfs(e, currentIdx, scores[currentIdx], tree, treeB, scores);
    }
}

int main(){
    int N, Q; cin >> N >> Q;
    vector<int> tree[N];
  	vector<int> treeB[N];
    long long scores[N]{0};

    for (int i=0;i<N-1;i++) {
        int a, b; cin >> a >> b;
        tree[a-1].push_back(b-1);
        treeB[b-1].push_back(a-1);
    }
    for (int i=0;i<Q;i++) {
        int p, x; cin >> p >> x;
        scores[p-1] += x;
    }
    dfs(0, -1, 0, tree, treeB, scores);
  
  	for (auto e:scores) cout << e << " ";
}

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

using namespace std;
using ll = long long;

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

    int N,K;cin >> N >> K;
    double ans = 0;
    for(int a = 1;a <= N;a++){
        int i = 0;
        int j = a;
        while(j < K){
            j *= 2;
            i++;
        }
        ans += 1.0/pow(2,i);
    }
    cout<<ans/N<<endl;
}


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

int ans[26];
int main() {
int a,b,c,d;
cin >>a >>b>>c >> d;

int start = max(a,c);
int end = min(b,d);

if(start < end){
  cout << end-start <<endl;
}
else{
  cout << 0 <<endl;
}
}

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

vector<int> border(vector<int> S)
{
    int n = (int)S.size();
    vector<int> B(n+1);

    B[0] = -1;
    int j = -1;
    for (int i=1; i<=n; i++)
    {
        while (j>=0 && S[i-1]!=S[j])
            j = B[j];
        j++;
        B[i] = j;
    }

    return B;
}

//  B = border(P)
vector<int> search(vector<int> T, vector<int> P, vector<int> B)
{
    int n = (int)T.size();
    int m = (int)P.size();

    vector<int> A;
    int j = 0;
    for (int i=0; i+m<=n;)
    {
        if (j<m && T[i+j]==P[j])
        {
            j++;
            if (j==m)
                A.push_back(i);
        }
        else
        {
            i += j-B[j];
            if (j>0)
                j = B[j];
        }
    }
    return A;
}

#include <iostream>

int main()
{
    int N;
    cin>>N;
    vector<int> a(N), b(N);
    for (int &t: a)
        cin>>t;
    for (int &t: b)
        cin>>t;

    vector<int> ax(N), bx(N);
    for (int i=0; i<N; i++)
    {
        ax[i] = a[i]^a[(i+1)%N];
        bx[i] = b[i]^b[(i+1)%N];
    }
    for (int i=0; i<N-1; i++)
        ax.push_back(ax[i]);

    vector<int> K = search(ax, bx, border(bx));
    for (int k: K)
        cout<<k<<" "<<(a[k]^b[0])<<endl;
}


Measured memory_bytes: 10088
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
   int a1, a2, a3;
   cin >> a1 >> a2 >> a3;

   int cal = a1 + a2 + a3;
   cout << (cal >= 22 ? "bust" : "win") << endl;
   return 0;
}


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





int main(){
    vector<int> primeList{2};
    int X;
    int N = 2;
    cin >> X;
    if (X == 2){
         cout << N << endl; 
         return 0;
    }
    bool flag = true;
    while (true){
        for(const auto& e : primeList){
            if (N % e == 0){
                flag = false;
            }
        }
        if (flag) {
            primeList.push_back(N);
            if (X <= N){
                cout << N <<endl;
                return 0;
            } 
        }
        N++;
        flag = true;

    }

}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdint>
using namespace std;

int main() {
    uint32_t n, k; cin >> n >> k;
    vector<int32_t> h(n);
    for (auto &e : h) cin >> e;

    vector<uint32_t> dp(n);
    // 1 <= K のため、足場 0 と足場 1 への移動にかかる最小コストは決定している
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    // i 番目へ飛ぶのに掛かる最小コストを計算する
    for (uint32_t i = 2; i < n; ++i) {
        uint32_t m = UINT32_MAX;
        // i から j 前の足場からジャンプした時のコストを計算
        for (uint32_t j = 1; j <= k; ++j) {
            // 足場 0 よりも前からジャンプはできない
            if (i < j) break;
            // それまでのコストとの最小値を m に保存
            m = min(m, dp[i - j] + abs(h[i - j] - h[i]));
        }
        // i へのジャンプに必要な最終コストを dp に保存
        dp[i] = m;
    }

    // n 番目(0 インデックス)へのジャンプに必要な最小コストを出力
    cout << dp[n - 1] << endl;
}



Measured memory_bytes: 4012
import java.util.*;
import java.io.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=Integer.parseInt(in.next());
		Btree tree=new Btree(n);
		
		for(int i=0;i<n;i++) {
			int id=Integer.parseInt(in.next());
			int L=Integer.parseInt(in.next()), R=Integer.parseInt(in.next());
			
			if(L!=-1) {
				tree.T[id].l=L;
				tree.T[L].p=id;
			}
			if(R!=-1) {
				tree.T[id].r=R;
				tree.T[R].p=id;
			}
		}
		
		tree.root();
		
		char odr[]= {'f','m','l'};
		String str[]= {"Preorder","Inorder","Postorder"};
		PrintWriter out=new PrintWriter(System.out);
		for(int i=0;i<3;i++) {
			List<Integer> res=tree.walk(odr[i]);
			out.println(str[i]);
			for(int j=0;j<res.size();j++)out.print(" "+res.get(j));
			out.println();
		}
		out.flush();
	}
}

class BtreeNode{
	int p=-1,l=-1,r=-1;
}

class Btree{
	static BtreeNode T[];	
	static List<Integer> A;
	static int r=0;
	
	Btree(int n){
		T=new BtreeNode[n];
		for(int i=0;i<n;i++)T[i]=new BtreeNode();
	}
	
	static List<Integer> walk(char o){
		A=new ArrayList<>();
		if(o=='f') fw(r);
		else if(o=='m')mw(r);
		else if(o=='l')lw(r);
		return A;
	}
	
	static void root() {
		r=getRoot(0);
	}
	
	private static int getRoot(int i) {
		if(T[i].p==-1)return i;
		else return getRoot(T[i].p);
	}
	
	private static void fw(int i) {
		A.add(i);
		if(T[i].l!=-1)fw(T[i].l);
		if(T[i].r!=-1)fw(T[i].r);
	}
	
	private static void mw(int i) {
		if(T[i].l!=-1)mw(T[i].l);
		A.add(i);
		if(T[i].r!=-1)mw(T[i].r);
	}
	
	private static void lw(int i) {
		if(T[i].l!=-1)lw(T[i].l);
		if(T[i].r!=-1)lw(T[i].r);
		A.add(i);
	}
}


Measured memory_bytes: 26304
#include <iostream>

int main() {
	int a = 0;
	int b = 0;
	int result = 0;
	char op = '\0';

	std::cin >> a >> op >> b;
	
	if (op == '+') {
		result = a + b;
	}
	else if (op == '-') {
		result = a - b;
	}

	std::cout << result;

	return 0;
}

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

using namespace std;

#define MOD 1000000007

typedef __int128 ll;
typedef vector< vector<ll> > Matrix;

Matrix operator *(const Matrix& A, const Matrix& B) {
	Matrix ret(2, vector<ll>(2, 0));
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 2; ++j) {
			for (int k = 0; k < 2; ++k) {
				ret[i][j] = (ret[i][j] + A[i][k] * B[k][j]) % MOD;
			}
		}
	}
	return ret;
}

ll fib(ll n) {
	if (n == 0) return 1;

	Matrix A = {
		{1, 1},
		{1, 0},
	};
	Matrix B = {
		{1, 0},
		{0, 1},
	};
	for (ll i = 1; i <= n; i <<= 1) {
		if (n & i) {
			B = A * B;
		}
		A = A * A;
	}
	return (B[1][0] + B[1][1]) % MOD;
}

int main() {
	long long _K; cin >> _K;
	ll K = _K-1;

	ll l = 0, r = 1000000000000LL;
	while (l < r-1) {
		ll m = (l + r) / 2;
		if ( m * (m + 1) <= K ) {
			l = m;
		}
		else {
			r = m;
		}
	}

	K -= l * (l+1);
	ll pos = l * 2; ++l;
	if (K >= l) {
		K -= l;
		++pos;
	}

	ll x = K >= (l+1)/2 ? l - (K*2-(l+1)) - 2 : K*2;
//	cout << (long long)K << " " << (long long)l << " " << (long long)pos << " " << (long long)x << endl;
	cout << ((long long)(fib(pos-x+1) * fib(x+1))%MOD) << endl;
/*
	vector<ll> v;
	for (int i = 1; i < 10; ++i) {
		for (int j = 1; j < 10; ++j) {
			int v = (int)(fib(i) * fib(j));
			if (i <= j) {
				printf("%4d ", v);
			}
			else {
				printf("     ");
			}
//			v.push_back(fib(i) * fib(j));
		}
		cout << endl;
	}
*/
//	sort(v.begin(), v.end());
//	v.erase(unique(v.begin(), v.end()), v.end());
}

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

typedef long long LL;
#define MAXN 100003

char S[MAXN];


int main()
{
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "wt", stdout);
    
    scanf("%s", S);
    int n = strlen(S);

    int i = 0; 
    int j = n-1;
    int ans = 0;
    while (i < j) {
        if (S[i] == S[j]) {
            i++; j--;
        } else if (S[i] == 'x') {
            ans++; i++;
        } else if (S[j] == 'x') {
            ans++; j--;
        } else {
            printf("-1");
            return 0;
        }
    }
    
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S >> T;
    if (S == T.substr(0, S.size())) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3636
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        int X = sc.nextInt();
        double r = (double)T / (double)X;
        System.out.println(String.format("%1$.10f", r));
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(){
    ll n, k;
    cin >> n >> k;
    ll h[n];
    for (ll i = 0; i < n; i++) cin >> h[i];
    sort(h, h+n);

    ll ans = 10000000000;
    for (ll i = 0; i < n - k + 1; i++){
        ans = min(ans, h[i + k - 1] - h[i]);
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024