akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
//const int INF=1e+11;
const int NMAX=8;
const int MOD=10000;
const int dbase=80*160;
//157d


struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}//-1で初期化
  int root(int x) {
    if (d[x] < 0) return x;//rootを負にする（構成node数x(-1))
    //root以外は親の番号
    return d[x] = root(d[x]);
    //return(root(d[x]))とするとメモできないが上の書き方だとメモができる
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    //swapすることで小さい方を大きい方につけられ計算量減らせる
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  //同じグループ化
  int size(int x) { return -d[root(x)];}
  //グループのnode数
    int group_num(int n){
        set<int> s;
        for(int i = 0; i < n; ++i){
            s.insert(root(i));
        }
        return int(s.size());}
};

vector<int> to[55];
vector<P> edge(55);

int main(){
	int n,m;
cin>>n>>m;
	rep(i,m){
		int a1,b1;
		cin>>a1>>b1;
		a1--;b1--;
		to[a1].push_back(b1);
		to[b1].push_back(a1);
		edge[i]=make_pair(a1,b1);

	}
	int ans=0;
	rep(i,m){
		UnionFind uf(n);
		rep(j,m){
			if (i!=j) {
				uf.unite(edge[j].first,edge[j].second);
			}
		}
		int tmp=uf.group_num(n);
		if (tmp!=1) ans++;
	}

cout<<ans;

}


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

int main() {
  long long int n;
  long long int H = 0;
  cin >> n;
  long long int N = n;

  while (N > 0) {
    H += (N % 10);
    N /= 10;
  }

  if (n % H == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;

const int V_MAX = 10000;
const int INF = 100000000;

struct Edge {
	bool operator< (const Edge& e)const {
		return e.w > w;
	}
	int s;
	int t;
	int w;
};

int parent(int uft[], int child) {
	if (uft[child] == -1)return child;
	return uft[child] = parent(uft, uft[child]);
}

int main() {
	int v, e;
	vector<Edge> edge;
	int uft[V_MAX];
	int ans = 0;
	
	scanf("%d%d", &v, &e);
	for (int i = 0; i < v; i++) {
		uft[i] = -1;
	}
	for (int i = 0; i < e; i++) {
		Edge e;
		scanf("%d%d%d", &e.s, &e.t, &e.w);
		
		edge.push_back(e);
	}

	sort(edge.begin(), edge.end());

	for (int i = 0; i < e; i++) {
		Edge e = edge[i];
		
		int p1 = parent(uft, e.s);
		int p2 = parent(uft, e.t);
		if (p1 != p2) {
			uft[p1] = p2;
			ans += e.w;
		}
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 4084
n, m = map(int, input().split())
city = []
for i in range(m):
    p, y = map(int, input().split())
    city.append([p, y, i])

id = []
city.sort(key=lambda x: x[1])
city.sort(key=lambda x: x[0])

pref = city[0][0]
num = 0
for i in range(m):
    if city[i][0] == pref:
        num += 1
        P = str(city[i][0]).zfill(6)
        Y = str(num).zfill(6)
        id.append([P+Y, city[i][2]])
    else:
        num = 1
        pref = city[i][0]
        P = str(city[i][0]).zfill(6)
        Y = str(num).zfill(6)
        id.append([P + Y, city[i][2]])

id.sort(key=lambda x: x[1])
for i in range(m):
    print(id[i][0])


Measured memory_bytes: 41388
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  if(n==2){
    std::cout << 1 << '\n';
    return 0;
  }
  ll ans = 2;
  // N, N-1
  set<ll> st;

  //2~root N-1
  for(ll i=2;i*i<=n;i++){
    ll tmp = n;
    while(tmp%i==0) tmp/=i;
    if(tmp%i==1) ans++, st.insert(i);
  }

  // root N ~ N-2
  for(ll i=2;i*i<=n;i++){
    if((n-1)%i==0&&st.find((n-1)/i)==st.end()){
      ans++;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include<bits/stdc++.h>
#include <vector>

using namespace std;

int main()
{
   string s;
   
   getline(cin,s);
   int c1=0;
   int c2=0;
   for(int i=0;i<3;i++){
   	if(s[i]=='A'){
   		c1++;
   		
	   }
   	else if(s[i]=='B'){
   		c2++;
	   }
	else{
	}   
   }
   if(c1==3){
   	cout << "No";
   }
   else if(c2==3){
   	cout << "No";
   }
   else{
   	cout << "Yes";
   }
}





Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>
#include<list>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




void solve(){
	int n;
	cin >> n;
	cout << n*n*n << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

int main(){
    int n, x;
    int count = 0;
    while(1){
        cin >> n >> x;
        count = 0;
        if(n == 0 && x == 0) break;
        for (int a = 1; a <= n; a++){
            for (int b = a + 1; b <= n; b++){
                for (int c = b + 1; c <= n; c++){
                    if(a + b + c == x) count++;
                }
            }
        }
        cout << count << endl;
    }
}



Measured memory_bytes: 3108
S = input()
ans = 0
pos = 0
scount = 0

while pos < len(S):

    while pos <len(S) and S[pos] == 'T':
        pos += 1
        ans += 1
    if pos >= len(S):
        break

    while pos <len(S) and S[pos] == 'S':
        pos += 1
        scount += 1
    if pos >= len(S):
        ans += scount
        break

    tcount = 0
    while pos < len(S) and S[pos] == 'T':
        pos += 1
        tcount += 1
    if pos >= len(S):
        ans += abs(scount-tcount)
        break
      
    if scount >= tcount:
        scount = scount -tcount
    else: #scount < tcount
        ans += tcount-scount
        scount = 0

print(ans)


Measured memory_bytes: 3500
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>x>>k;
    for(ll i=-1000;i<=1000;i++){
        if(k-x+1<=i&&i<=k+x-1) cout<<i<<" ";
    }


    return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define ALL(x) (x).begin(),(x).end()


void solve(long long N, long long D, long long X, std::vector<long long> A){
  long long acc = X;
  REP(i, N) {
    acc += (((D-1)/A[i]) + 1);
  }
  cout << acc << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long D;
  scanf("%lld",&D);
  long long X;
  scanf("%lld",&X);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
    solve(N, D, X, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int pcnt(int x)
{
	int res = 0;
	while (x) {
		res += x & 1;
		x >>= 1;
	}
	return res;
}

int f(int x)
{
	if (x == 0) return 0;
	return f(x % pcnt(x)) + 1;
}

int main()
{
	int n;
	string s;
	cin >> n >> s;
	vector<int> x(n);
	for (int i = 0; i < n; i++) x[i] = s[i] - '0';

	int pc = 0; // 初期のポップカウント。
	for (int i = 0; i < n; i++) pc += x[i];

	vector<int> ans(n);
	for (int b = 0; b < 2; b++) {
		int npc = pc;
		if (b == 0) npc++;  // b==0の時、0を1に反転する。
		else npc--;			// b==1の時、1を0に反転する。
		if (npc <= 0) continue;

		// ビットを反転していないxをnpcで割った余りを求める。
		int r0 = 0;
		for (int i = 0; i < n; i++) r0 = (r0 * 2 + x[i]) % npc;

		// n桁すべてのbitが1の場合、各桁までのnpcで割った余りの配列を求める。
		vector<int> rArray(n);
		int pre = 1;
		for (int i = n - 1; 0 <= i; i--) {
			rArray[i] = pre % npc;
			pre *= 2;
			pre %= npc;
		}

		// i桁のビットを反転してf(r)を求める。
		for (int i = n - 1; 0 <= i; i--) {
			if (x[i] == b) {
				int r = r0;
				if (b == 0) r = (r0 + rArray[i]) % npc;
				else r = (r0 - rArray[i] + npc) % npc;
				ans[i] = f(r) + 1;
			}
		}
	}

	for (const auto& item : ans) cout << item << endl;
}


Measured memory_bytes: 6004
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
	int N,sum1,sum2=0,i,j,k,l,m;
	scanf("%d",&N);
	int x[2][100];
	for(i=0;i<N;i++){
		cin>>x[0][i];
	}
	for(j=0;j<N;j++){
		scanf("%d", &x[1][j]);
	}
	for(k=0;k<N;k++){
		sum1=0;
		for(l=0;l<=k;l++){
			sum1=sum1+x[0][l];
		}
		for(m=k;m<N;m++){
			sum1=sum1+x[1][m];
		}
		if(sum1>sum2){
			sum2=sum1;
		}
	}
	cout<<sum2;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	int n;
	cin>>n;
	int mi=INT_MAX,mx=INT_MIN;
	while(n--) {
		int val;
		cin>>val;
		mi=min(mi,val);
		mx=max(mx,val);
	}
	cout<<mx-mi;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3660
#!/usr/bin/env python3
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

ans = 'No'
cnt = 0
while A >= B:
    B = B * 2
    cnt += 1
while B >= C:
    C = C * 2
    cnt += 1

if cnt <= K and A < B and B < C:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=200001;

int32_t main(){
	IOS;
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	vi v[n+1];
	
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j+=i){
			v[j].pb(i);
		}
	}
	int cnt=0;
	int b[n+1]={0};
	set<int> s;
	for(int i=n;i>=1;i--){
		b[i]%=2;
		if(a[i-1]==b[i]) continue;
		else{
			cnt++;
			s.insert(i);
			for(int j=0;j<v[i].size();j++)
				b[v[i][j]]++;
		}
	}
	cout<<cnt<<endl;
	for(auto it=s.begin();it!=s.end();it++)
		cout<<*it<<" ";
}

Measured memory_bytes: 40960
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  int a;
  cin >> a;
  cout << a*a*a << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();

    if (((b - a) % 2) == 0) {
      System.out.println("Alice");
      return;
    } else {
      System.out.println("Borys");
      return;
    }

  }
}

Measured memory_bytes: 35808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
const int INF = 1001001001;

int main(){
    int x,y;cin>>x>>y;
    if(y<2*x || y>4*x || y%2)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    
    return 0;
}

Measured memory_bytes: 3544
from collections import deque

is_reverse = False
s = deque(input())
q = int(input())
for _ in range(q):
    query = input().split()
    if query[0] == '1':
        is_reverse = not is_reverse
    else:
        if (not is_reverse and query[1] == '1') or (is_reverse and query[1] == '2'):
            s.appendleft(query[2])
        else:
            s.append(query[2])
print(''.join(s)[::-1]) if is_reverse else print(''.join(s))


Measured memory_bytes: 8436
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

const int MAX = 5e5;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;
  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n = n >> 1;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }
  return ret;
}

int main(){
  int n, q;
  string s;
  cin >> n >> s >> q;

  vector<set<int>> C(26);
  rep(i,26) C[i].insert(1e9);
  rep(i,n) C[s[i]-'a'].insert(i);

  while(q--){
    int f,l,r;
    char c;
    cin >> f;
    if(f == 1){
      cin >> l >> c; l--;
      C[s[l]-'a'].erase(l);
      s[l] = c;
      C[c-'a'].insert(l);
      continue;
    }
    // f = 2
    cin >> l >> r; l--; r--;
    int cnt = 0;
    rep(i,26) {
      int p = *C[i].lower_bound(l);
      if(p <= r) cnt++;
    }
    cout << cnt << endl;
  }
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

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

ll cul0[61];
ll cul1[61];

int main() {
  ll N;
  scanf("%lld", &N);

  vector<ll> a_list(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    a_list[i] = v;
  }

  for (ll i = 0; i < a_list.size(); i++) {
    // ビットごとに考える
    for (ll k = 0; k < 60; k++) {
      bool t = (a_list[i] & (1LL << k));
      if (t) {
        cul1[k]++;
      } else {
        cul0[k]++;
      }
    }
  }

  ll ans = 0;

  for (ll k = 0; k < 60; k++) {
    ll base = (1LL << k) % MOD;
    ll count = cul0[k] * cul1[k] % MOD;
    ll plus = base * count % MOD;

    ans += plus;
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 2560
#include<stdio.h>

int main(){
int a[6],i,j=1;
for(i=0;i<6;i++){
scanf("%d",&a[i]);
}
for(i=1;i<5;i++){
if((a[0]==i||a[1]==i)&&(a[2]==i||a[3]==i)&&(a[4]==i||a[5]==i)){
j=0;
break;
}
}
puts(j?"YES":"NO");
}

Measured memory_bytes: 128
D = [[-1, 0], [1, 0], [0, -1], [0, 1]]

def puyo_rensa(cnt, fld)
  erase = 8.times.map{ [-1] * 14 }
  (1..6).each do |i|
    (1..12).each do |j|
      if fld[i][j] =~ /[^O.]/ && erase[i][j] < 0
        puyo_connector(i, j, fld, erase){ |arr|
          arr.each do |s, t|
            D.each do |x, y|
              p, q = s + x, t + y
              erase[p][q] += 2 if fld[p][q] == 'O'
            end
            erase[s][t] += 1
          end
        }
      end
    end
  end
  if erase.flatten.any?{ |v| v >= 1 } then puyo_rensa(cnt + 1, puyo_eraser(fld, erase))
  else cnt
  end
end

def puyo_connector(i, j, fld, visit)
  arr = [[i, j]]
  ret = [[i, j]]
  visit[i][j] += 1
  until arr.empty?
    i, j = arr.shift
    D.each do |x, y|
      p, q = i + x,  j + y
      if visit[p][q] < 0 && fld[i][j] == fld[p][q]
        visit[p][q] += 1
        arr << [p, q]
        ret << [p, q]
      end
    end
  end
  yield(ret) if ret.size >= 4
end

def puyo_eraser(fld, erase)
  (1..6).each do |i|
    fld[i].map!.with_index{ |c, j| c unless erase[i][j] >= 1 }.compact!
    (14 - fld[i].size).times{ fld[i].unshift('.') }
  end
  fld
end

gets.to_i.times do
  fld = 8.times.map{ ['.'] * 14 }
  12.times do |i|
    gets.chomp.split('').each_with_index do |c, j|
      fld[j+1][i+1] = c
    end
  end
  p puyo_rensa(0, fld)
end

Measured memory_bytes: 9216
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    string s;
    cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    int m = 2019;
    int x = 1, tot = 0;
    vector<int> cnt(m);
    ll ans = 0;
    rep(i, n) {
        cnt[tot]++;
        tot += (s[i] - '0') * x;
        tot %= m;
        ans += cnt[tot];
        x = x * 10 % m;
    }
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

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

int main() {
  char c;
  const char vowels[] = "aiueo";
  cin >> c;
  bool isVowel = find(vowels, vowels + 5, c) < (vowels + 5);

  cout << (isVowel ? "vowel" : "consonant") << endl;
}


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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

const long long max_n = 100011, inf = 1000111222;

char s1[max_n], s2[max_n];
int n, m;

int main() {
	cin >> n >> m;
	scanf("%s%s", s1, s2);
	int g = __gcd(n, m);
	for (int i = 0; i < g; ++i) {
		if (s1[1LL * i * n / g] != s2[1LL * i * m / g]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << 1LL * n * m / g << endl;
	return 0;
}


Measured memory_bytes: 384
import fractions
a,b=map(int,input().split())

g=fractions.gcd(a,b)
org=g
counter=1
for i in range(2,int(g**0.5)+1):
	if g%i == 0:
		counter += 1
		g //= i
		while g % i ==0:
			g //= i

if g > int(org ** 0.5):
	counter += 1

print(counter)



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

x_b = b * 10

min_a = (25/2) * a
max_a = (25/2) * (a + 1)

min_b = 10 * b
max_b = 10 * (b + 1)

min_ = max(min_a, min_b)
max_ = min(max_a, max_b)

_min = int(min_ + 0.5)
_max = int(max_)

if _min >= _max:
    print(-1)

else:
    print(_min)


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

ll calc(int i){
  ostringstream oss;
  oss << i;
  string s = oss.str();
  int last = s.length()-1;
  if ( s[last] == '0'){
    return 0;
  }
  ll sum = 0;
  if ( s[0] == s[last]){
    if ( s.length() <= 2){
      sum = s.length();
    } else {
      for ( int i = 0; i <= s.length()-3; i++){
        sum += pow(10, i);
      }
      int num;
      string sub = s.substr(1, last-1);
      istringstream ss(sub);
      ss >> num;
      sum+=2;
      sum+=num;
    }
    return (sum-1)*2+1;
  } else if ( s[0] < s[last]){
    if ( s.length() <= 2){
      return 0;
    } else {
      for ( int i = 0; i <= s.length()-3; i++){
        sum += pow(10, i);
      }
    }
    return sum*2;
  }else if ( s[0] > s[last]){
    for ( int i = 0; i <= s.length()-2; i++){
      sum += pow(10, i);
    }
    return sum*2;
  }
}

int main(){
  int n;
  cin >> n;
  ll x[200001];
  for ( int i = 0; i <= 9; i++){
    x[i] = i;
  }
  for ( int i = 10; i <= n; i++){
    x[i] = x[i-1] + calc(i);
  }

  cout << x[n] << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <deque>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair

int n, m;
int card[200];

void shuffle() {
	deque<int> a;
	deque<int> b;
	rep(i,n) {
		a.push_back(card[i]);
	}
	for(int i = n; i < 2 * n; i++) {
		b.push_back(card[i]);
	}
	for(int i = 0; i < n; i++) {
		card[2 * i] = a.front();
		a.pop_front();
		card[2 * i + 1] = b.front();
		b.pop_front();
	}
}

void cat(int k) {
	deque<int> a;
	deque<int> b;
	rep(i,k) {
		a.push_back(card[i]);
	}
	for(int i = k; i < 2 * n; i++) {
		b.push_back(card[i]);
	}
	int count = 0;
	while(!b.empty()) {
		card[count++] = b.front();
		b.pop_front();
	}
	while(!a.empty()) {
		card[count++] = a.front();
		a.pop_front();
	}
}

int main() {
	scanf(" %d %d", &n, &m);
	memset(card, 0, sizeof card);
	rep(i,2 * n) {
		card[i] = i + 1;
	}
	rep(i,m) {
		int t;
		scanf(" %d", &t);
		if(t == 0) {
			shuffle();
		} else {
			cat(t);
		}
	}
	rep(i,2 * n) {
		printf("%d\n", card[i]);
	}
	return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
K = int(input())

def gcd(p, q):
  if(p % q == 0):
    return q
  else:
    return gcd(q, p % q)

sum1 = 0
for a in range(1, K+1):
  for b in range(a+1, K+1):
    for c in range(b+1, K+1):
      sum1 += gcd(a, gcd(b, c))

sum2 = 0
for a in range(1, K+1):
  for c in range(a+1, K+1):
      sum2 += gcd(a, c)

sum3 = 0
for a in range(1, K+1):
  sum3 += a

sum = sum1*6 + sum2*6 + sum3
print(sum)


Measured memory_bytes: 9140
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}

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

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	long n;cin>>n;
	long a[n];for(long i=0;i<n;i++)cin>>a[i];
	vector<pair<long,long>> v;
	long long r=1000;
	int i = 0; 
    while (i < n - 1) { 
  
        // Find Local Minima 
        // Note that the limit is (n-2) as we are 
        // comparing present element to the next element 
        while ((i < n - 1) && (a[i + 1] <= a[i])) 
            i++; 
  
        // If we reached the end, break 
        // as no further solution possible 
        if (i == n - 1) 
            break; 
  
        // Store the index of minima 
        int buy = i++; 
  
        // Find Local Maxima 
        // Note that the limit is (n-1) as we are 
        // comparing to previous element 
        while ((i < n) && (a[i] >= a[i - 1])) 
            i++; 
  
        // Store the index of maxima 
        int sell = i - 1; 
  
        v.push_back({buy,sell});
    } 

		// for(auto it:v)cout<<it.first<<" "<<it.second<<endl;
		// 	cout<<endl;
	if(v.size()==0){cout<<"1000\n";return 0;}
	else{
		for(long i=0;i<v.size();i++){
			r=(r/a[v[i].first])*a[v[i].second]+r%a[v[i].first];
			// cout<<r<<endl;
		}
	}
	cout<<r<<endl;
	return 0;
}

Measured memory_bytes: 3576
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
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 fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, k = MAP()
ans = k * (k - 1) ** (n - 1)
print(ans)

Measured memory_bytes: 59628
#include<bits/stdc++.h>
using namespace std;
typedef long  long int ll;
int main(){
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll>p(a);
    vector<ll>q(b);
    vector<ll>r(c);
    for(ll i=0;i<a;i++)
        cin>>p[i];
    for(ll i=0;i<b;i++)
        cin>>q[i];
    for(ll i=0;i<c;i++)
        cin>>r[i];
    vector<ll>final;
    sort(r.begin(),r.end());
    sort(q.begin(),q.end());
    sort(p.begin(),p.end());

    for(ll i=0;i<x;i++)
    {
        final.push_back(p[a-1-i]);
    }
    for(ll i=0;i<y;i++)
    {
        final.push_back(q[b-1-i]);
    }
    sort(final.begin(),final.end());
    ll j=c-1;
    for(ll i=0;i<min(x+y,c);i++)
    {
        if(final[i]<=r[j])
        {
            final[i]=r[j];
            j--;
        }
        else
        {
            break;
        }
        
    }
    ll sum=0;
    for(ll i=0;i<x+y;i++)
    {
        // cout<<final[i];
        sum+=final[i];
    }
    cout<<sum<<"\n";
}

Measured memory_bytes: 4852
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,m,*x=map(int,open(0).read().split());x.sort();print(sum(sorted(j-i for i,j in zip(x,x[1:]))[-n::-1]))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 13924
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->
int ans = 0;
void solve()
{
    string s;
    cin>>s;

    rep(i,0,s.length()){
        int j = i;
        if( s[i] == 'S' ){
            continue;
        }
        while( s[j] == s[i] && j < s.length() ){
            j++;
        }
        ans = max(ans,j-i);
    }

    cout<<ans<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main() {
  int M,K;
  cin >> M >> K;
  int m2 = 1 << M;
  
  if ( M == 0 ) {
    if ( K == 0 ) {
      cout << "0 0" << endl;
    } else {
      cout << "-1" << endl;
    }
    return 0;
  } else if ( M == 1 ) {
    if ( K == 0 ) {
      cout << "0 0 1 1" << endl;
    } else {
      cout << "-1" << endl;
    }
    return 0;
  }
  if ( K >= m2 ) {
    cout << "-1" << endl;
    return 0;
  }
  REP(i, m2) {
    if ( i != K ) {
      cout << i << " ";
    }
  }
  cout << K << " ";
  for (int i=m2-1; i>=0; --i ){
    if ( i != K ) {
      cout << i << " ";
    }
  }
  cout << K << endl;
}


Measured memory_bytes: 1792
local mfl, mce = math.floor, math.ceil
local mab = math.abs
local n = io.read("*n", "*l")
local s = io.read()
local t = {}
for i = 1, n - 1 do
  t[i] = mab(s:sub(i + 1, i + 1):byte() - s:sub(i, i):byte())
end
local hasone = false
for i = 1, n - 1 do
  if t[i] == 1 then hasone = true break end
end
if hasone then
  for i = 1, n - 1 do
    t[i] = t[i] % 2
  end
else
  for i = 1, n - 1 do
    t[i] = t[i] / 2
  end
end

n = n - 1

-- odd: True
local function solve(depth, left)
  local mul, stage = 2, 1
  while true do
    if depth <= mul then break end
    stage = stage + 1
    mul = mul * 2
  end
  -- print("SOLVE", depth, left, stage, mul)
  if stage == 1 then
    return true
  else
    local depth_ofst = depth - (mul / 2)
    if left <= depth_ofst then
      return solve(depth_ofst, left)
    else
      if (mul / 2) < left then
        return solve(depth_ofst, left - (mul / 2))
      else
        return false
      end
    end
  end
end
local ret = 0
for i = 1, n do
  local f = solve(n, i)
    -- print("SOLVE", i, f)
  if f then -- Odd
    if t[i] % 2 == 1 then
      ret = (ret + 1) % 2
    end
  end
end
if not hasone then ret = ret * 2 end
print(ret)


Measured memory_bytes: 12076
n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_sum = sum(a)
b_sum = sum(b)

if a_sum > b_sum:
    print("No")
    exit(0)

less_a_cnt = 0
less_b_cnt = 0

for i in range(n):
    if a[i] < b[i]:
        less_a_cnt += int((b[i] - a[i]) / 2)
    else:
        less_b_cnt += a[i] - b[i]

if less_a_cnt < less_b_cnt:
    print("No")
else:
    print("Yes")


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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int INF = 1000000007;
const ll MOD = 1000000007;

const int N = 1000005;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    int sum = 0;
    for(char c : s)
    {
        int x = c-'0';
        sum = (sum+x)%9;
    }
    if(sum == 0)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3704
def main():
  n = int(input())
  num = [int(x) for x in input().split()]
  odd = []
  for i in num:
    odd.append((i & 1)) 

  pre = [1]
  for i in range(len(odd)):
    if odd[i] == 1:
      pre.append(pre[-1] * 1)
    else:
      pre.append(pre[-1] * 2)

  ans = 0
  for i in range(len(odd)):
    if odd[i] == 0:
      cur = 1
    else:
      cur = 2

    ans += pre[i] * cur * (3 ** (n - i - 1)) 

  print(ans)



if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int h,w;
int dy[]={0,0,1,1},dx[]={0,1,0,1};
map<char,int>M;
int flag[1000][1000];
int cnt[1000][1000][5];
int emb[2][2];
int main(){
    M['J']=0;
    M['O']=1;
    M['I']=2;
    cin>>h>>w;
    int ans=0;
    for(int i=0;i<h;i++){
        string str;
        cin>>str;
        for(int j=0;j<w;j++)
            flag[i][j]=M[str[j]];
    }
    for(int i=0;i<2;i++){
        string str;
        cin>>str;
        for(int j=0;j<2;j++)
            emb[i][j]=M[str[j]];
    }

    for(int i=0;i<h-1;i++){
        for(int j=0;j<w-1;j++){
            int c=0,memo;
            for(int k=0;k<4;k++){
                if(flag[i+dy[k]][j+dx[k]]==emb[dy[k]][dx[k]])c++;
                else memo=k;
            }
            if(c==4){
                for(int k=0;k<4;k++)
                    cnt[i+dy[k]][j+dx[k]][0]++;
                ans++;
            }
            else if(c==3){
                int y=i+dy[memo],x=j+dx[memo];
                int v=emb[y-i][x-j]+1;
                cnt[y][x][v]++;
            }

        }
    }
    int sub=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(cnt[i][j][0])continue;
            for(int k=1;k<4;k++)
                sub=max(sub,cnt[i][j][k]);
        }
    }
    cout<<ans+sub<<endl;
}

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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

string s;
int cnt;
int main() {
    cin >> s;
    char mem = s[0];
    for (int i=0; i<s.size(); i++) {
        // cout << i << " " << mem << " " << cnt << endl;
        if(i==0) continue;

        if (s[i] == mem) {
            cnt ++;
            if (mem == '0') mem = '1';
            else mem = '0';
        } else {
            mem = s[i];
        }
    }
    int e = s.size() - cnt;
    int mx = min(e, cnt);
    cout << mx << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }
// ans_buf
#include<cstdio>
template<int BUFSIZE>
struct ans_buf {
  char buf[BUFSIZE];
  int i;
  ans_buf(): i(0) {}
  void putS(std::string const& s, char delim='\n') {
    std::copy_n(s.c_str(), s.size(), buf+i);
    i += s.size();
    buf[i++] = delim;
  }
  void out() { std::fwrite(buf, 1, i, stdout); }
};

uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

int const MAXN = 1e5;

int G[MAXN];

int main() {
  int N = getZ(), K = getZ(), Q = getZ();
  std::fill_n(G, N, K-Q);
  for(int i = 0; i < Q; ++i) ++G[getZ()-1];
  ans_buf<MAXN*4> buf;
  for(int i = 0; i < N; ++i) buf.putS(G[i]>0? "Yes": "No");
  buf.out();
  return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000000000000009
#define N 305
using namespace std;

typedef long long ll;
typedef pair < ll , ll > ii;

ll n, k, a[N], dp[N][N][N];

ll f(ll ind, ll son, ll kac){
	// cout << ind << " " << son << " " << kac << endl;
	if(ind > n)
		return 0;
	ll &r = dp[ind][son][kac];
	if(r != -1)
		return r;
	r = inf;
	if(kac)
		r = min(r, f(ind + 1, son, kac - 1));
	r = min(r, f(ind + 1, ind, kac) + max(0ll, a[ind] - a[son]));
	return r;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	memset(dp, -1, sizeof dp);
	scanf("%lld %lld",&n ,&k);
	for(ll i = 1; i <= n; i++)
		scanf("%lld",a + i);
	printf("%lld\n", f(1, 0, k));
	return 0;
}

Measured memory_bytes: 221952
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int unsigned long long
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define MOD 998244353
signed main(){
	int h,w;
	cin>>h>>w;
	if(h<w)
        swap(h,w);
        if(w==1)
        {
            cout<<1;
            return 0;
        }
    if(h%2==w%2)
    {
        //if(h%2==0)
        //{
            int n = (w-2)/2 + 1,tt = (h+w)/2;
            int su = n*n;
            su = 2*su;
            tt -= 2*n;
            su += tt*(w);
            cout<<su;
       // }
    }
    else
    {
        int an = (w*(w+1))/2;
        int tt = (h+w)/2;
        tt -= w;
        an += tt*(w);
        cout<<an;
    }


	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();

        ArrayList<Integer> series = new ArrayList<>();


        ArrayList<Integer> accs = new ArrayList<>();

        int acc = 0;

        for(int i=0; i<N; i++){
            int tmp = scanner.nextInt();
            series.add(tmp);
            acc += tmp;
            accs.add(acc);
        }


        int minDiff = Integer.MAX_VALUE;

        for(int tmpAcc: accs){
            int rest = acc - tmpAcc;

            int tmpDiff = Math.abs(rest - tmpAcc);

            if(tmpDiff < minDiff){
                minDiff = tmpDiff;
            }
        }

        System.out.println(minDiff);

    }
}


Measured memory_bytes: 21844
# AOJ 0009 Prime Number
# Python3 2018.6.9 bal4u

w = int(input())
s = [i for i in range(w+1)]
n = int(input())
for i in range(n):
    a = list(map(int, input().split(',')))
    s[a[0]], s[a[1]] = s[a[1]], s[a[0]]

for i in range(1, w+1):
    print(s[i])



Measured memory_bytes: 5604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long Q = GetLong();
		var S = GetString();
		var A = new List<long>();
		for(int i = 0; i < N - 1; i++)
		{
			if(S[i] == 'A' && S[i + 1] == 'C')
				A.Add(i);
		}

		var ans = new long[Q];
		for(long i = 0; i < Q; i++)
		{
			long l = GetLong() - 1;
			long r = GetLong() - 1;
			long low = bs1(A, l);
			long high = bs2(A, r);
			ans[i] = Max(0, high - low + 1);
		}
		WriteLine(string.Join("\n", ans));
	}

	private long bs1(List<long> list, long key)
	{
		long ng = -1;
		long ok = list.Count;
		while(ok - ng > 1)
		{
			long mid = (ng + ok) / 2;
			if(list[(int)mid] >= key)
				ok = mid;
			else
				ng = mid;
		}
		return ok;
	}

	private long bs2(List<long> list, long key)
	{
		long ng = ng = list.Count;
		long ok = -1;
		while(ng - ok > 1)
		{
			long mid = (ng + ok) / 2;
			if(list[(int)mid] < key)
				ok = mid;
			else
				ng = mid;
		}
		return ok;
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (a%b == 0) {
        return(b);
    } else {
        return(gcd(b, a%b));
    }
}

int main() {
    int K;
    cin >> K;
    long ans = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                ans += gcd(gcd(a, b), c);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;
class Main{
	//private static Scanner scan=new Scanner(System.in);
	public static void main(String[] args){
		for(int i=1;i<10;++i){
			for(int ii=1;ii<10;++ii){
				System.out.println(i+"x"+ii+"="+i*ii);
			}
		}
	}
}

Measured memory_bytes: 16852
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N,C,K;
int T[100010];

int main(){
	scanf("%d%d%d" , &N , &C , &K);
	repp(i,0,N){
		scanf("%d" , T + i);
	}
	sort(T,T+N);
	int ans = 0;
	int x = 0;
	int y = 0;
	repp(i,0,N){
		if(x > 0 && T[i] > x){
			++ans;
			y = 0;
			x = 0;
		}
		if(x == 0){
			x = T[i] + K;
		}
		++y;
		if(y == C){
			++ans;
			x = y = 0;
		}
	}
	if(y > 0) ++ans;
	printf("%d\n" , ans);
	return 0;
}


Measured memory_bytes: 512
N=int(input())
A=list(map(int, input().split()))
B=[0]*N
for i in range(N):
  B[0]+=A[i] if i&1==0 else (-1)*A[i]
for i in range(1, N):
  B[i]=2*A[i-1]-B[i-1]
print(" ".join(str(b) for b in B))

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

int main() {
  int a,b,c;
  bool x=false;
  cin >> a>>b>>c;
  if(a==b){
      if(b!=c){
          x=true;
      }
  }
  else{
      if(b==c||a==c){
          x=true;
      }
  }
  
  if(x){
      cout << "Yes" << endl;
  }
  else{
      cout <<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int A,B;
    cin>>A>>B;
    if(A/10==0 &&B/10==0){
        cout<<A*B<<endl;
    }else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 3632
from collections import Counter
N = int(input())
A = Counter(map(int,input().split()))

rect = [-1, -1]
for key in sorted(A.keys(), reverse=True):
  if A[key] >= 4:
    print(max(rect[0]*key, key**2))
    exit()
  elif A[key] >= 2:
    if rect == [-1,-1]: rect[0] = key
    else:
      print(rect[0]*key)
      exit()
print(0)

Measured memory_bytes: 67608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n; cin>>n;
ll a[n]; for(int i=0;i<n;i++) cin>>a[i];
sort(a,a+n); 
ll ans=a[n-1];
int i=0,k=n-2;
for(int i=0;i<n-2;i++){
if(i%2==0){ ans+=a[k]; }
else { ans+=a[k]; k--; }
}
cout<<ans<<endl;
}
 

Measured memory_bytes: 5208
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<iomanip>
#include<string>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define setp(n) fixed<<setprecision(n)


int num[100010];

int main(){
    int Q;
    int N;
    string s;
    cin>>N>>Q>>s;
    for(int i=0;i<N;i++){
        if(s[i-1]=='A'&&s[i]=='C'){
           num[i+1]+=num[i]+1; 
        }
        else{
            num[i+1]+=num[i];
        }
    }
    rep(i,Q){
        int l,r;
        cin>>l>>r;
        cout<<endl;
        cout<<num[r]-num[l];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1408
function Main(input) {

    var input = input.split("\n");

    const N = Number(input[0].split(" ")[0]);
    const K = Number(input[0].split(" ")[1]);
    const H = input[1].split(" ").map(Number);

    const sortDesc = H.sort(function (a, b) {
        return b - a;
    });

    var answer = 0;
    for (var i = K; i < N; i++) {
        answer += sortDesc[i];
    }

    //出力
    console.log(answer);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 34512