akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define INF (1 << 30)
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    string S;
    cin >> S;
    int S_size = S.length();
    char c[S_size];
    int ans[S_size];
    rep(i, S_size){
        c[i] = S[i];
        ans[i] = 0;
    }
    int left_r_index = 0;
    int right_l_index = 1;
    bool right_end = false;
    while(true){
        // find left_r_index;

        int tmp_index = left_r_index;
        int r_num = 1;
        int l_num = 1;
        while(true){
            if(c[tmp_index+1] == 'R'){
                left_r_index = tmp_index+1;
                tmp_index++;
                r_num++;
            }else{
                right_l_index = tmp_index+1;
                break;
            }
        }
        // count l_num;
        tmp_index = right_l_index+1;
        while(true){
            if(tmp_index >= S_size){
                right_end = true;
                break;
            }else{
                if(c[tmp_index] == 'L'){
                    l_num++;
                    tmp_index++;
                }else{
                    break;
                }
            }
        }
        // ans: r_num = 3, l_num = 4 -> (2,1) + (2, 2)
        // cout << left_r_index << " : " << right_l_index << endl;
        // cout << r_num << " : " << l_num << endl;
        ans[left_r_index] += (r_num+1)/2 + l_num/2;
        ans[right_l_index] += r_num/2 + (l_num+1)/2;

        if(right_end == true){
            break;
        }
        // next r
        left_r_index = right_l_index+1;
        while(true){
            if(c[left_r_index] == 'L'){
                left_r_index++;
            }else{
                break;
            }
        }
    }
    rep(i, S_size){
        cout << ans[i];
        if(i != S_size-1){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;

#define mod 1e9 + 7
#define INF (int) 1e9 + 5

#define add emplace
#define pb push_back
#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define exist(a, x) (a.find(x) != end(a))
#define log(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define loop(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vstr = vector<string>;


ll dp[3005][3005][2]={};
vll best2(vll& a, int n) {
	int i=0, j=0;
	int winsize = 1;

	while (winsize <= n) {
		i = 0, j = winsize - 1;

		while (j < n) {
			if (i == j) {
				dp[i][i][0]=a[i];
				dp[i][i][1]=0;
			}
			else {
				ll * fr = dp[i+1][j],
					* ba = dp[i][j-1];

				ll frnt = a[i] + fr[1],
					bck = a[j] + ba[1];

				if (frnt > bck)
					dp[i][j][0] = frnt, dp[i][j][1] = fr[0];
				else
					dp[i][j][0] = bck, dp[i][j][1] = ba[0];
			}
			++i, ++j;
		}
		++winsize;
	}

	return {dp[0][n-1][0], dp[0][n-1][1]};
}


int main() {
	int n; cin >> n;
	vll a(n);
	rep (i, n)
		cin>>a[i];
	vll s = best2(a, n);
	printf("%lld\n", s[0]-s[1]);
	return 0;
}


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

seitou=0
pe=0
cont=0
q=[0]*(n+1)
pena=[0]*(n+1)
for i in range(m):
    
    p,s=input().split()
    p=int(p)
    if q[p]==0:
        if s=="WA":pena[p]+=1
        if s=="AC":
            seitou+=1
            q[p]=1    
for i in range(n+1):
    if q[i]==1:
        pe+=pena[i]
print(sum(q),pe)

Measured memory_bytes: 4596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(int argc, char *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);//incompatible with `while (cin >> ...)'
    int a,b,c,d;
    cin >>a>>b>>c>>d;
    int x=c-a,y=d-b;
    cout<<c-y<<' '<<d+x<<' '<<a-y<<' '<<b+x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main(void)
{
    double r;
    cin >> r;
    double circum = r * r * M_PI;
    double area = 2 * r * M_PI;
    cout << fixed << setprecision(6) << circum << ' ' << fixed << setprecision(6) << area << endl;
    return 0;
}

Measured memory_bytes: 3280
#include<stdio.h>
int A[100000],n;
int binarysearch(int key);

int main(){
  int i,j,q,goukei=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&j);
    if(binarysearch(j)) goukei++;
      }
  printf("%d\n",goukei);
  return 0;

}


int binarysearch(int key){
  int l=0,r=n,m;

  while(l<r){
    m=(r+l)/2;
    if(key==A[m])return 1;
    if(key>A[m]) l=m+1;
    else if(key<A[m]) r=m;
  }
  return 0;
}




Measured memory_bytes: 2108
def main():
    n = int(input())
    p = [True] * 55556
    p[0] = False
    p[1] = False
    curr = 2
    while curr * curr <= 55555:
        if p[curr]:
            for i in range(curr * curr, 55556, curr):
                p[i] = False
        curr += 1
    fives = []
    for i in range(2, 55556):
        if p[i] and i % 5 == 1:
            fives.append(i)
    print(*fives[:n])
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 9104
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
long long C,N,x[100050],v[100050],ni[100050],shun[100050],ssum[100050],nsum[100050],ans;
int main ()
{

        while(cin>>N>>C)
        {

                ans=0;
                memset(shun,0,sizeof(shun));
                memset(shun,0,sizeof(ssum));
                memset(nsum,0,sizeof(nsum));
                memset(ni,0,sizeof(ni));
                for(int i=1;i<=N;i++)
                {
                        scanf("%lld %lld",&x[i],&v[i]);
                        ssum[i]=ssum[i-1]+v[i];
                }
                for(int i=1;i<=N;i++)
                {
                        shun[i]=max(shun[i-1],ssum[i]-x[i]);
                }
                for(int i=N;i>=1;i--)
                {
                        nsum[i]=nsum[i+1]+v[i];
                        ni[i]=max(ni[i+1],nsum[i]-(C-x[i]));
                }
                for(int i=0;i<=N;i++)
                {
                       // cout<<shun[i]<<" "<<ni[i]<<endl;
                       // cout<<ssum[i]<<" "<<nsum[i]<<endl;
                }
                for(int i=1;i<=N;i++)
                {
                        ans=max(ans,ssum[i]-2*x[i]+ni[i+1]);
                       // cout<<ssum[i]<<" "<<ni[i-1]<<endl;
                        ans=max(ans,shun[i]);
                }
                for(int i=N;i>=1;i--)
                {
                        ans=max(ans,nsum[i]-2*(C-x[i])+shun[i-1]);
                        ans=max(ans,ni[i]);
                }
               // cout<<ans<<endl;




                cout<<ans<<endl;


        }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i=0; i<N; ++i) cin >> H[i];
    --H[0];
    for(int i=1; i<N; ++i) {
        if(H[i - 1] > H[i]) {
            cout << "No" << endl;
            return 0;
        } else if(H[i - 1] < H[i]) {
            --H[i];
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 640
/**
 *     author: qodjf
 *     created: 04.23.2020 00:17:46
 */
#include <bits/stdc++.h>
using namespace std;

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 1e9 + 7;

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

struct DSU {
  vector<int> fa;
  DSU(int n) {
    fa.resize(n);
    for (int i = 0; i < n; i++) fa[i] = i;
  }
  int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
  void merge(int x, int y) { fa[find(y)] = find(x); }
  bool test(int x, int y) { return find(x) == find(y); }
};

struct edge {
  int u, v, cost;
  edge(int u_, int v_, int cost_) : u(u_), v(v_), cost(cost_) {}
  bool operator<(const edge &b) const { return cost < b.cost; }
};

int kruskal(int n, vector<edge> &es) {
  DSU dsu(n);
  sort(es.begin(), es.end());
  int ans = 0;
  for (const auto &e : es) {
    if (!dsu.test(e.u, e.v)) {
      dsu.merge(e.u, e.v);
      ans += e.cost;
    }
  }
  return ans;
}

struct Point {
  int x, y, idx;
};

bool cmp1(const Point &a, const Point &b) { return a.x < b.x; }

bool cmp2(const Point &a, const Point &b) { return a.y < b.y; }

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

  int N;
  cin >> N;
  vector<Point> ps;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    ps.emplace_back(Point{x, y, i});
  }

  vector<edge> es;
  sort(ps.begin(), ps.end(), cmp1);
  for (int i = 1; i < N; i++) {
    es.emplace_back(ps[i].idx, ps[i - 1].idx, ps[i].x - ps[i - 1].x);
  }
  sort(ps.begin(), ps.end(), cmp2);
  for (int i = 1; i < N; i++) {
    es.emplace_back(ps[i].idx, ps[i - 1].idx, ps[i].y - ps[i - 1].y);
  }

  cout << kruskal(N, es) << endl;
}


Measured memory_bytes: 6132
N=int(input())
t1 = 0
x1 = 0
y1 = 0
for i in range(N):
  t2,x2,y2=map(int,input().split())
  d = abs(x1 - x2) + abs(y1 - y2)
  dt = t2 - t1
  if d > dt:
    print('No')
    exit()
  if dt%2!=0 and d%2==0:
    print('No')
    exit()
  if dt%2==0 and d%2!=0:
    print('No')
    exit()
  t1,x1,y1=t2,x2,y2
print('Yes')

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

int main(){
  ll N;
  cin >> N;
  ll sum = 0;
  map<ll,ll> m;
  m[0]++;
  rep(i, N){
    ll a;
    cin >> a;
    sum += a;
    m[sum]++;
  }
  ll ans = 0;
  for(auto x : m){
    ans += (x.second*(x.second-1))/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12800
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
N = int(input())
A = inputlist()
B = inputlist()
C = inputlist()
A.sort()
B.sort()
C.sort()
index = {}
from bisect import bisect_left
for i in range(N):
    indexa = bisect_left(A,B[i])
    index[B[i]] = indexa
ans = 0
B_sum = [0]*(N+1)
for i in range(N):
    B_sum[i+1] = B_sum[i]+index[B[i]]
for i in range(N):
    indexa = bisect_left(B,C[i])
    ans += B_sum[indexa]
print(ans)

Measured memory_bytes: 30012
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define abu ios_base::sync_with_stdio(0)
#define said cin.tie(0)
using namespace std;
ll const MOD = 1000000007;

void yes(){
    cout<<"YES"<<'\n';
}

void no(){
    cout<<"NO"<<'\n';
}

ll fact(int n){
    ll ans = 1;
    for(int i=2;i<=n;i++){
        ans = (ans*i)%MOD;
    }

    return ans;
}

ll powM(int n, int x){
    if(x==0){
        return 1;
    }
    if(x==1){
        return n%MOD;
    }

    if(x%2==0){
        ll a = powM(n,x/2);
        return (a*a)%MOD;
    }else{
        return (n*powM(n,x-1))%MOD;
    }
}

ll C(int n, int k){
    return (fact(n) * powM((fact(k)*fact(n-k))%MOD,MOD-2))%MOD;
}

ll A(int n, int k){
    return (fact(n) * powM(fact(n-k)%MOD,MOD-2))%MOD;
}

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

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



void solve(){
    int n,k;
    cin>>n>>k;
    vi dp(k+1);
    dp[0] = 1;

    for(int i=0;i<n;i++){
        int u;
        cin>>u;
        vi pref(k+1);
        for(int j = k;j>=0;j--){
            int val = dp[j];
            int l = j+1;
            int r = j + min(u,k-j);
            if(l<=r){
                add_self(pref[l],val);
                if(r+1<=k){
                    sub_self(pref[r+1],val);
                }
            }
        }
        int pre = 0;
        for(int j = 0;j<=k;j++){
            add_self(pre,pref[j]);
            add_self(dp[j],pre);
        }
    }

    cout<<dp[k]<<'\n';
}

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

    return 0;
}


Measured memory_bytes: 1024
def ascan; gets.split.map(&:to_i);end

Ori = [[-1,0],[0,1],[1,0],[0,-1]]

while (n = gets.to_i) > 0
    top, bottom, left, right = 0,0,0,0
    pos = Array.new(n){[0,0]}
    (n-1).times do |_i|
        i = _i+1
        j, r = ascan
        
        o = Ori[r]
        pos[i] = [pos[j][0]+o[0], pos[j][1]+o[1]]
        
        top    = [pos[i][1], top].min
        bottom = [pos[i][1], bottom].max
        left   = [pos[i][0], left].min
        right  = [pos[i][0], right].max
    end
    puts [right-left+1, bottom-top+1]*" "
end



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

int main(){
    int a[6] = {0};

    for(int i = 0; i < 6; i++){
        cin >> a[i];
    }

    int flag = 0;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(j != i){
                if(a[i*2+1] == a[2*j]){
                    for(int k = 0; k < 3; k++){
                        if(k != i && k != j){
                            if(a[2*j+1] == a[2*k] || a[2*j+1] == a[2*k+1]){
                                flag = 1;
                                /*
                                cout << i << endl;
                                cout << j << endl;
                                cout << k << endl;
                                */
                            }
                        }
                    }
                } else if(a[i*2] == a[j*2+1]){
                    for(int k = 0; k < 3; k++){
                        if(k != i && k != j){
                            if(a[2*j] == a[2*k] || a[2*j] == a[2*k+1]){
                                flag = 1;
                                /*
                                cout << i << endl;
                                cout << j << endl;
                                cout << k << endl;
                                */
                            }
                        }
                    }
                }
            }
        }
    }

    if(flag == 0){
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M,L;
  cin>>N>>M>>L;
  lint d[N][N];
  lint inf =1e15;
  REP(i,N)REP(j,N)d[i][j]=inf;
  REP(i,N)d[i][i]=0;
  REP(i,M){
    int A,B,C;
    cin>>A>>B>>C;
    A--;B--;
    d[A][B]=C;
    d[B][A]=C;
  }
  REP(k,N)REP(i,N)REP(j,N){
    d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  }
  lint D[N][N];
  REP(i,N)REP(j,N)D[i][j]=inf;
  REP(i,N)D[i][i]=0;
  REP(i,N)REP(j,N)if(i!=j)if(d[i][j]<=L)D[i][j]=1;
  REP(k,N)REP(i,N)REP(j,N){
    D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
  }
  int Q;
  cin>>Q;
  int s[Q],t[Q];
  REP(i,Q){
    cin>>s[i]>>t[i];
    s[i]--;t[i]--;
  }
  REP(i,Q){
    cout<<(D[s[i]][t[i]]!=inf?D[s[i]][t[i]]:0)-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 2688
def countPakages(P, k, W):
    i, n = 0, len(W)
    for j in range(k):
        s = 0
        while s + W[i] <=P:
            s += W[i]
            i += 1
            if i == n:
                return n
    return i

def ALDS1_4D():
    n_limit, k_limit, wi_limit = 100000, 100000, 10000
    n, k= map(int, input().split())
    W = [int(input()) for i in range(n)]
    Pleft, Pright = 0, n_limit * wi_limit
    while Pright - Pleft > 1:
        Pmid = (Pleft+Pright)//2
        v = countPakages(Pmid, k, W)
        if v < n:
            Pleft = Pmid
        else:
            Pright = Pmid

    return Pright
if __name__ == '__main__':
    print(ALDS1_4D())

Measured memory_bytes: 11696
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int max=0;
      int count=0;
      for(int i=0;i<N;i++)
      {
        int temp=sc.nextInt();
        if(max<=temp)
        {
          count++;
          max=temp;
        }
      }
		System.out.println(count);
	}
}


Measured memory_bytes: 35668
//============================================================================
// Name        : HairetuTest.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int x,y,b;
	while(1){
		cin>>x>>y;
		if(x==0 && y==0)break;
		if(x>y){
			b=x;
			x=y;
			y=b;
		}
		cout<<x<<" "<<y<<endl;
	}
}



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif


const LL mod = 998244353;
const int MAXN = 305;

vector<int> A;

LL fatto[MAXN][MAXN][MAXN];
//~ map<tuple<int,int,int>,LL> fatto;

LL F(int R, int B, int K) {
    //~ if (R == 0) cout << R << " " << B << " " << K << ": " << 1 << endl;
    if (B > K) return 0;
    //~ if (R == 0) cout << R << " " << B << " " << K << ": " << 1 << endl;
    if (R == 0) return 1;
    if (fatto[R][B][K] != -1) return fatto[R][B][K];
    LL res = 0;
    //~ if (R == 1 and B == 0) cout << A[R] << endl;
    for (int s = 0; s <= min(A[R] + B, K); s++) {
        res += F(R-1, s, K - max(B-s, 0)), res %= mod;
    }
    fatto[R][B][K] = res;
    //~ cout << R << " " << B << " " << K << ": " << res << endl;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    for (int i = 0; i < MAXN; i++) for (int j = 0; j < MAXN; j++) for (int k = 0; k < MAXN; k++) fatto[i][j][k] = -1;

    string S;
    cin >> S;
    S += '0';
    int K;
    cin >> K;
    int at = 0;
    int qq = 0;
    for (char c : S) {
        if (c == '0') {
            A.push_back(at);
            at = 0;
        }
        else at++, qq++;
    }

    
    //~ for (int x : A) cout << x << " ";
    //~ cout << endl;
    int L = A.size();
    cout << F(L-1, 0, min(K, qq)) << "\n";
}


Measured memory_bytes: 225316
#include <stdio.h>

int main() {
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a==b){
    printf("%d\n",c);
  }
  if(a==c){
    printf("%d\n",b);
  }
  if(b==c){
    printf("%d\n",a);
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;

int main(){
	ll a,b;cin>>a>>b;
	if(a==b){
		puts("1");
		return 0;
	}
	bool flag=false;
	ll A=0,B=0,T=0,C=0;
	for(int i=60;i>=0;i--){
		if(!flag&&!(a>>i&1)&&(b>>i&1)){
			flag=true;
			T=1LL<<i;
		}
		if(flag){
			if(B!=0&&C==0&&(b>>i&1))C=(1LL<<(i+1))-1;
			A|=(a>>i&1)<<i;
			B|=(b>>i&1)<<i;
		}
	}
	P p1=P(A,T+C);
	P p2=P(T|A,(T<<1)-1);
	ll cnt=p1.second-p1.first+1+p2.second-p2.first+1;
	if(p2.first<=p1.second)cnt-=p1.second-p2.first+1;
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
using namespace std;

long long int inv = 0;

queue<int> merge(queue<int> q1, queue<int> q2){
    queue<int> ma;
    while(q1.size() || q2.size()){
        if(!q2.size() || (q1.size() && q1.front() < q2.front())){
            ma.push(q1.front());
            q1.pop();
        }else{
            ma.push(q2.front());
            q2.pop();
            inv += q1.size();
        }
    }
    return ma;
}
queue<int> sort(queue<int> q){
    queue<int> nq;
    while(q.size() - nq.size() > 1){
        nq.push(q.front());
        q.pop();
    }
    if(!nq.size()) return q;
    return merge(sort(nq), sort(q));
}

int main() {
    int n;
    scanf("%d", &n);
    
    queue<int> q;
    while(n--){
        int i;
        scanf("%d", &i);
        q.push(i);
    }
    
    sort(q);
    printf("%lld\n", inv);
    
    return 0;
}

Measured memory_bytes: 4952
n = int(input())
p = list(map(int,input().split()))
ans = [i for i in range(1,n+1)]
cnt = 0

for i in range(n):
  if p[i] != ans[i]:
    cnt += 1
  if cnt > 2:
    print('NO')
    exit()
    
print('YES')


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    vector<int> A(N+1,0);
    for(int i = 1; i <= N; ++i) cin >> A[i];
    sort(ALL(A));
    int ng = 0, ok = N+1,md;
    const size_t M = 5000;
    while(ok-ng>1){
        md = (ok+ng)/2;
        bitset<M+1> dp;
        dp.set(0);
        for(int i = 0; i <= N; ++i) {
            if(i==md) continue;
            dp |= (dp<<A[i]);
        } 
        int flg = 0;
        for(int i = 0; i < K; ++i) {
            if(dp[i]&&i+A[md]>=K) flg = 1;
        }
        (flg?ok:ng)=md;
    }
    cout << ok-1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+5;
typedef long long ll;
const ll mod=1e9+7;
ll n,a,b;
ll s[N];
ll f[N],g[N];
int main()
{
    //freopen("division.in","r",stdin);
    //freopen("division.out","w",stdout);
    scanf("%lld%lld%lld",&n,&a,&b);
    for(ll i=1;i<=n;i++)
        scanf("%lld",&s[i]);
    if(a>b)
        swap(a,b);
    for(ll i=3;i<=n;i++)
        if(s[i]-s[i-2]<a){
            puts("0");
            return 0;
        }
s[n+1]=2e18;
    f[0]=g[0]=1;
    int l=0,r=0;
    for(int i=1;i<=n+1;i++){
        while(r<i-1&&s[i]-s[r+1]>=b)
            r++;
        if(l<=r)
            f[i]=(g[r]+mod-(l?g[l-1]:0))%mod;
        g[i]=(g[i-1]+f[i])%mod;
        if(i>1&&s[i]-s[i-1]<a)
            l=i-1;
    }
    printf("%d\n",f[n+1]);
}


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

int main() {
  string str;
  string ret;
  
  bool flag = false;
  while( cin >> str ) {
    if( flag ) ret += " ";
    
    flag = true;
    
    size_t fpos = str.find("apple");
    if( fpos != string::npos ) {
      str = str.substr( 0, fpos ) + "peach" + str.substr( fpos+5, str.size()-fpos-5);
    } else {
      fpos = str.find("peach");
      if( fpos != string::npos ) {
	str = str.substr( 0, fpos ) + "apple" + str.substr( fpos+5, str.size()-fpos-5);
      }
    }

    ret += str;
  }

  cout << ret << endl;
  
  return 0;
}

Measured memory_bytes: 1192
#include <iostream>

int main(int argc, char const* argv[])
{
    int a, b;
    std::cin >> a >> b;
    for (int i = 1; i <= 3; i++) {
        if (a != i && b != i) {
            std::cout << i << std::endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int N, a[3001];
long long dp[3002][3002] = {};

long long recursion(int l, int r)
{
	if (dp[l][r] != 0 || l > r) return dp[l][r];
	
	long long tmp[2] = {a[l] - recursion(l + 1, r), a[r] - recursion(l, r - 1)};
	dp[l][r] = (tmp[0] > tmp[1])? tmp[0]: tmp[1];
	return dp[l][r];
}

int main()
{
	int i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	printf("%lld\n", recursion(1, N));
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 48032
N, W = map(int, input().split())
ws, vs = zip(*[map(int, input().split()) for _ in range(N)])

def maxvalue_recursive(N, W):
    def memoize(func):
        func.d = d = {}
        def _f(*va):
            if va not in d: d[va] = func(*va)
            return d[va]
        return _f

    @memoize
    def maxvalue(i, w):
        if i < 0: return 0
        if w < ws[i]:
            return maxvalue(i - 1, w)
        else:
            return max(maxvalue(i - 1, w), maxvalue(i - 1, w - ws[i]) + vs[i])

    res = maxvalue(N - 1, W)
    return res

def maxvalue_dp(N, W, ws, vs):
    import numpy as np
    dp = np.zeros(W + 1, 'int64')
    ws = np.array(ws, 'int64')
    vs = np.array(vs, 'int64')
    for i in range(N):
        idx = np.arange(W + 1) - ws[i]
        dp = np.maximum(dp, (dp[idx] + vs[i]) * (idx >= 0))
    return dp[-1]

#print(maxvalue_recursive(N, W))
print(maxvalue_dp(N, W, ws, vs))

#import timeit
#print(timeit.timeit('maxvalue_recursive(N, W)', globals=globals(), number=10000))
#print(timeit.timeit('maxvalue_dp(N, W)', globals=globals(), number=10000))

Measured memory_bytes: 16120
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a,a+n);
  cout << a[n-1] - a[0] << endl;
}


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

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

using namespace std;

// return how many days passed from 1/1/1
int compute(int y, int m, int d){
    int cnt = 0;
    int b_years = (y-1)/3;
    int s_years = (y-1) - b_years;
    cnt += b_years*200 + s_years*195;

    if(y%3==0){
        cnt += (m-1)*20;
    }else{
        int s_months = (m-1)/2;
        int b_months = (m-1) - s_months;
        cnt += s_months*19 + b_months*20;
    }
    cnt += (d-1);
    return cnt;
}

int main(){
    int n,y,m,d;
    cin >> n;
    REP(k,n){
        cin >> y >> m >> d;
        cout << compute(1000,1,1) - compute(y,m,d) << endl;
    }
    return 0;
}

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

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// bool isEven(ll n) {return (n%2!=0)?false:true;};
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
// #define int ll

using namespace std;

//atcoder
//abc166

int main()
{
    int x;
    cin>>x;

    for (int a = -1000; a < 1000; ++a)
    {
        for (int b = -1000; b < 1000; ++b)
        {
            if(pow(a, 5) - pow(b, 5) == x )
            {
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
    cout<<"Shit"<<endl;
}

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

using namespace std;
using ll = long long ;
const int INF = 1001001001;

int main() {

    int x,y ;
    cin >> x >> y ;

    for (int i = 0; i <= x; i++)
    {
        for (int j  = (x-i); i+j <= x ; j++)
        {
            int ashi = i*2+j*4 ;
            //cout << ashi << endl ;
            if(ashi==y){
                cout << "Yes" << endl ;
                return 0 ;
            }
        }    
    }
    
    cout << "No" << endl ;
    return 0 ;
                }

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N, tak, aok;
vector<int> G[101010];
int d_tak[101010], d_aok[101010];

void dfs(int cur, int dist, int array[])
{
    if (array[cur] != inf)
        return;

    array[cur] = dist;

    for (auto to : G[cur])
    {
        dfs(to, dist + 1, array);
    }
}

int main()
{
    cin >> N >> tak >> aok;
    rep(i, 1, N)
    {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    if (G[tak].size() == 1 && G[tak][0] == aok)
    {
        cout << 0 << endl;
        return 0;
    }

    rep(i, 0, N + 10)
    {
        d_tak[i] = inf;
        d_aok[i] = inf;
    }

    dfs(tak, 0, d_tak);
    dfs(aok, 0, d_aok);

    int D = 0;
    repe(i, 1, N)
    {
        if (d_tak[i] < d_aok[i])
        {
            chmax(D, d_aok[i]);
        }
    }

    cout << D - 1 << endl;
}


Measured memory_bytes: 10368
n,m = gets.chomp.split(" ").map(&:to_i)
x = gets.chomp.split(" ").map(&:to_i)
y = gets.chomp.split(" ").map(&:to_i)
px,py = x[0],y[0]
sumx = 0
ans = 0
mod = 10**9+7
for i in 1..n-1
  sumx += (x[i]-px)*(n-i)*i
  sumx %= mod
  px = x[i]
end
for i in 1..m-1
  ans += (y[i]-py)*(m-i)*i
  ans %= mod
  py = y[i]
end
puts ans*sumx%mod

Measured memory_bytes: 17684
import java.util.*;

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

        String ans = "";
        for (int i=0; i < line.length(); i++) {
            char ch = line.charAt(i);

            if (ch == 'B') {
                if (! ans.isEmpty()) ans = ans.substring(0, ans.length() - 1);
            } else {
                ans = ans + ch;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val A = sc.nextInt
  val B = sc.nextInt
  val C = sc.nextInt
  val X = Array(A, B, C).sorted

  val cntCA = (X(2) - X(0)) / 2
  val cntCB = (X(2) - X(1)) / 2

  val Y = Array(X(2), X(1) + cntCB * 2, X(0) + cntCA * 2)

  val cnt = Y.count(_ == X(2))

  if (cnt == 3) {
    println(cntCA + cntCB)
  } else if  (cnt == 2) {
    println(cntCA + cntCB + 2)
  } else {
    println(cntCA + cntCB + 1)
  }


}

Measured memory_bytes: 25668
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll inf=1e9+7;
const ll mod=998244353;
const int MAX=1000010;
vector<vector<ll> >comp_g(710);
vector<ll>color(710,-1);
bool f;
pll dfs(ll i,ll p){
    ll res1=0;
    ll res0=0;
    for(auto e:comp_g[i]){
        if(p==e)continue;
        if(color[e]>=0){
            if(color[i]==color[e])f=0;
            continue;
        }
        color[e]=1-color[i];
        pll k=dfs(e,i);
        res1+=k.fi;
        res0+=k.se;
    }
    if(!color[i])res0++;
    return mp(res1+1,res0);
}
signed main(){
    ll n,m;cin>>n>>m;
    vector<vector<ll> >exist(n,vector<ll>(n));
    rep(i,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        exist[a][b]=1;
        exist[b][a]=1;
    }
    rep(i,n){
        rep(j,n){
            if(i==j||exist[i][j])continue;
            comp_g[i].pb(j);
        }
    }
    f=1;
    vector<pll>x(0);
    rep(i,n){
        if(color[i]>=0)continue;
        color[i]=0;
        pll k=dfs(i,-1);
        if(!f){
            cout<<-1<<endl;
            return 0;
        }
        pll d=mp(k.se,k.fi-k.se);
        x.pb(d);
    }
    ll s=x.size();
    vector<vector<ll> >dp(s+1,vector<ll>(n+1));
    dp[0][0]=1;
    rep(i,s){
        pll k=x[i];
        rep(j,n+1){
            if(dp[i][j]){
                dp[i+1][j+k.se]=1;
                dp[i+1][j+k.fi]=1;
            }
        }
    }
    ll ans=inf*inf;
    rep(i,n+1){
        if(dp[s][i]){
            ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int c[3][3];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }  

  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      for (int k = 0; k <= 100; k++) {
        bool ok = true;
        for (int l = 0; l < 3; l++) {
          int x = c[0][l] - i;
          int y = c[1][l] - j;
          int z = c[2][l] - k;
          ok &= (x == y && y == z);
        }
        if (ok) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    double ans;
    if (2 * x <= a * a * b) {
        ans = atan(b * b * a / (2 * x)) * 180.0 / M_PI;
    } else {
        ans = atan((2 * (a * a * b - x)) / (a * a * a)) * 180.0 / M_PI;
    }
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdlib>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  int sum = 0;
  int fsum = 0;
  int diff;
  
  for(int i = 0; i < n; i++){
    cin >> w.at(i);
    sum+= w.at(i);
  }
  diff = sum;
  
  for(int i = 0; i < n; i++){
    fsum += w.at(i);
    diff = min(diff, abs(fsum - (sum - fsum)));
  }

  cout << diff << endl;
}

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

int in[200007];
pair<int, int> store[200007];

bool cmp(pair<int, int> a, pair<int, int> b)
{
    if (a.first < b.first) return true;
    return false;
}

bool cmp2(pair<int, int> a, pair<int, int> b)
{
    if (a.second < b.second) return true;
    return false;
}

int main()
{
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        scanf("%d", &in[i]);
        store[i].first = in[i];
        store[i].second = i;
    }

    sort(store+1, store+N+1, cmp);

    vector<pair<int, int> > nxt;

    for (int i = 1; i <= N; i++) {
        int out = N/2;

        if (i <= out) nxt.push_back({store[out+1].first, store[i].second});
        else nxt.push_back({store[out].first, store[i].second});
    }

    sort(nxt.begin(), nxt.end(), cmp2);
    for (auto x : nxt) {
        printf("%d\n", x.first);
    }
}


Measured memory_bytes: 6256
#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int x[n], y[n], h[n];
    int x_guess, y_guess, h_guess;
    int idx;
    for(int i=0; i<n; i++)
    {
        cin>>x[i]>>y[i]>>h[i];
        if(h[i]>0) idx=i;
    }
    bool check;
    for(int i=0; i<=100; i++)
    {
        for(int j=0; j<=100; j++)
        {
            x_guess=i;
            y_guess=j;
            check=true;
            h_guess= h[idx] + abs(x[idx]-i) + abs(y[idx]-j);
            for(int k=0; k<n; k++)
            {
                if(h[k]!=max(h_guess -abs(x[k]-i) -abs(y[k]-j), 0))
                {
                    check=false;
                    break;
                }
            }
            if(check) break;
        }
        if(check) break;
    }
    cout<<x_guess<<" "<<y_guess<<" "<<h_guess<<endl;
	return 0;
}


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

int magic(int k);

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	int t;
	cin>>t;
	t=1000-(t%1000);
	cout<<t%1000;
	return 0;
		
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

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

  int ans = 0;
  int cnt = 0;
  rep (i, n) {
    if (s[i] == '.') cnt++;
  }
  ans = cnt;

  
  rep (i, n) {
    if (s[i] == '#') cnt++;
    else cnt--;
    chmin(ans, cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3
#sys.setrecursionlimit(int(1e+6))
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
MOD = int(1e+9) + 7

# 組み合わせ
def comb(n, k):
    r = 1
    for i in range(n, max(n-k, k), -1):
        r *= i
    for i in range(1, min(n-k, k) + 1, 1):
        r //= i
    return r

def main():
    N, K = i2nn()
    R = N - K + 1
    n = R
    for i in range(1, K+1):
        if i > R:
            print(0)
            continue
        n = comb(R, i)
        t = comb(K-1, i-1)
        print((n * t) % MOD)
        #n = (n * (R-i)) // (i+1)

main()


Measured memory_bytes: 45020
#include <iostream>
#include <string>

using namespace std;

int main()
{
  int n;
  cin>>n;
  
  float sum=0;
  while(n--)
  {
    float x;
    string u,curr="JPY";
    
    cin>>x>>u;
    
    if(u.compare(curr)==0)
      sum+=x;
    else
      sum+=(x*380000.0);
  }
  cout<<sum;
}

Measured memory_bytes: 256
x = int(input())

a = [i**5 for i in range(1000)]
for i in range(1000):
    for j in range(1000):
        if a[i] - a[j] == x:
            print(i, j)
            exit()
        if a[i] + a[j] == x:
            print(i, -j)
            exit()


Measured memory_bytes: 9192
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i,a,n) for(ll i=a;i<(ll)(n);i++)

int main(){
    int A,B;
    cin>>A>>B;
    cout << (B%A==0 ? A+B : B-A) << endl;
}


Measured memory_bytes: 256
s = list(input())
t = list(input())

ans = len(t)
for i in range(len(s) - len(t) + 1):
    val = 0
    for j in range(len(t)):
        if s[i + j] != t[j]:
            val += 1
    ans = min(ans, val)

print(ans)

Measured memory_bytes: 64956
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <unordered_map>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vpii = vector<pii>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
int sum[5002][5002];
int main() {
	int n, m;
	cin >> n >> m;
	vpii pos(n);
	vi x(n+1), y(n+1);
	for (int i = 0; i < n; i++) {
		int x1, y1;
		cin >> x1 >> y1;
		x[i] = x1;
		y[i] = y1;
		pos[i] = pii(x1, y1);
	}
	x.back() = -1e9 - 1;
	y.back() = -1e9 - 1;
	sort(ALL(x));
	sort(ALL(y));
	x.erase(unique(ALL(x)), x.end());
	y.erase(unique(ALL(y)), y.end());
	for (pii a : pos)sum[lower_bound(ALL(x), a.first) - x.begin()][lower_bound(ALL(y), a.second) - y.begin()]++;
	rep(i, x.size()) {
		rep(j, y.size()) {
			sum[i][j] += -(i&&j ? sum[i - 1][j - 1] : 0) + (i ? sum[i - 1][j] : 0) + (j ? sum[i][j - 1] : 0);
		}
	}
	for (int i = 0; i < m; i++) {
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1 = lower_bound(ALL(x), x1) - x.begin() - 1;
		y1 = lower_bound(ALL(y), y1) - y.begin() - 1;
		x2 = upper_bound(ALL(x), x2) - x.begin() - 1;
		y2 = upper_bound(ALL(y), y2) - y.begin() - 1;
		cout << sum[x2][y2] - sum[x1][y2] - sum[x2][y1] + sum[x1][y1] << endl;
	}
}

Measured memory_bytes: 100924
#!/usr/bin/env python3

import itertools
import numpy as np


def main():
    N, M, X = map(int, input().split())
    CA = np.array([list(map(int, input().split())) for _ in range(N)])
    C = np.array(CA[:, 0])
    A = np.array(CA[:, 1::])

    if min(np.sum(A, axis=0)) < X:
        print('-1')
        return

    pattern = []
    for i in range(1, N + 1):
        pattern.extend(list( itertools.combinations(list(range(N)), i) ))

    kumiawase = []
    for p in pattern:
        cost = sum([C[_] for _ in p])
        x = [A[_] for _ in p]
        kumiawase.append( (cost, x) )
        pass
    kumiawase = sorted(kumiawase, key=lambda x: x[0])

    for k in kumiawase:
        zz = k[1]
        if min(np.sum(zz, axis=0)) >= X:
            print(k[0])
            return

    print('-1')


if __name__ == "__main__":
    main()


Measured memory_bytes: 30916
import java.util.*;
import java.io.*;
import java.lang.*;
class Main{
	public static int dp[]=new int[100002];
	public static int frog(int arr[],int N,int K) {
		if(N==0)
			return Main.dp[0];
		if(Main.dp[N]!=-1)
			return Main.dp[N];
		int cnt=1000000000;
		for(int i=N-1;i>Math.max(N-K-1,-1);i--) {
			cnt=Math.min(cnt,Main.frog(arr,i,K)+Math.abs(arr[N]-arr[i]));
			//System.out.println(cnt);
		}
		Main.dp[N]=cnt;
		return Main.dp[N];
	}
	public static void main(String []args) {
		for(int i=1;i<100002;i++) {
			Main.dp[i]=-1;
		}
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int h[]=new int[N];
		for(int i=0;i<N;i++) {
			h[i]=sc.nextInt();
		}
		int x=Main.frog(h, N-1, K);
		//System.out.println(x);
		System.out.println(Main.dp[N-1]);
	}
}

Measured memory_bytes: 73056
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int x,y,z;
    cin>>x>>y>>z;

    cout<<z<<" "<<x<<" "<<y<<endl;

    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 200007
int a[MAXN];
bool cnt[1000007];
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n; cin >> n;
	for(int i=0; i<n; i++) {
		cin >> a[i];
	}
	sort(a,a+n);
	memset(cnt,0,sizeof cnt);
	long long ans=0;
	for(int i=0; i<n; i++) {
		int now=a[i];
		//ans+=cnt[now];
		if(cnt[now]==0 && (i+1>=n || a[i]!=a[i+1])) ans++;
		if(i==0 || a[i]!=a[i-1])
		for(int j=now; j<=1000000; j+=now) {
			cnt[j]=1;
		}
	}
	cout << ans << '\n';
}


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

int main() {

int N;
int A[200];
int hoge =0;

cin >> N;
for(int i =0;i<N;i++){
    cin >> A[i];
    int fuga = 0;
    while(A[i]%2 ==0){
        fuga++;
        A[i] = A[i]/2;
    }
    
    if(fuga<hoge || i==0){
        hoge = fuga;
    }
    
}

cout << hoge << endl;


	return 0;
}

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

int cnt[2020];
int num[200001];

int main(void)
{
    string s;
    cin >> s;
    int tmp = 0;
    int mul = 1;
    cnt[0]++;
    int size = s.size();
    for (int i = 0; i < size; i++)
    {
      tmp += (s[size - i - 1] - '0') * mul % 2019;
      tmp %= 2019;
      mul *= 10;
      mul %= 2019;
      cnt[tmp]++;
      num[size - i - 1] = tmp;
    }
    long long ans = 0;
    for (int i = 0; i < size; i++)
    {
      cnt[num[i]]--;
      ans += cnt[num[i]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4436
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

total = 0
pre = 21
for a in A:
    total += B[a - 1]
    if pre + 1 == a:
        total += C[pre - 1]
    pre = a
print(total)


Measured memory_bytes: 3060
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7; 

fn main(){
    let n: usize = read(); 
    let k: i64 = read();
    let a: Vec<isize> = (0..n).map(|_| read()).collect();
    let mut cnt1: i64 = 0;
    for i in 0..n{
        for j in i+1..n{
            if a[i] > a[j]{
                cnt1 += 1;
                cnt1 %= MOD;
            }
        }
    }
    let mut cnt2: i64 = 0;
    for i in 0..n{
        for j in 0..n{
            if a[i] > a[j]{
                cnt2 += 1;
                cnt2 %= MOD;
            }
        }
    }
    let mut ans: i64 = (cnt1 * k) % MOD;
    ans += (cnt2 * ((k * (k - 1) / 2) % MOD)) % MOD;
    ans %= MOD;
    println!("{}", ans);
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
let (+) a b = (a + b) mod 1000000007
let () =
  Scanf.scanf "%d %d" @@ fun h w ->
  let s = Array.init h (fun _ -> Scanf.scanf " %s" (fun x -> x)) in
  let dp = Array.init h (fun _ -> Array.make w 0) in
  dp.(0).(0) <- 1;
  for i = 0 to h-1 do
    for j = 0 to w-1 do
      if i > 0 && s.(i-1).[j] = '.' then dp.(i).(j) <- dp.(i).(j) + dp.(i-1).(j);
      if j > 0 && s.(i).[j-1] = '.' then dp.(i).(j) <- dp.(i).(j) + dp.(i).(j-1)
    done;
  done;
  Printf.printf "%d\n" dp.(h-1).(w-1)

Measured memory_bytes: 10752