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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)

#define L 0
#define R 1

int main(){

	lli n;
	cin>>n;
	n*=2;
	string s;
	cin>>s;

	lli data[200010];
	data[0] = L;

	lli cnt[2]={0};
	cnt[L]=1;

	for(lli i=1;i<n;i++){
		if(s.at(i-1)!=s.at(i))data[i] = data[i-1];
		else data[i] = (data[i-1]+1)%2;
		cnt[data[i]]++;
	}

	if(cnt[L]!=cnt[R] || data[n-1] == L || s.at(0)=='W' || s.at(n-1) == 'W'){
		cout<<0<<endl;
		return 0;
	}

	lli lCnt=0;
	lli pattern=1;

	for(lli i=0;i<n;i++){
		if(data[i]==L)lCnt++;
		else{
			pattern *= lCnt;
			pattern %= MOD;
			lCnt--;
		}
	}

	lli ans = pattern;
	for(lli i=1;i<=n/2;i++){
		ans *= i;
		ans %= MOD;
	}

	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2180
import sys

input = sys.stdin.readline


def main():
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    xyc = [0] * M
    for i in range(M):
        xyc[i] = map(int, input().split())

    ans = min(a) + min(b)
    for x, y, c in xyc:
        price = a[x - 1] + b[y - 1] - c
        if price < ans:
            ans = price

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62244
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

n = int(input())

for k in range (n):
    ch,rank = input().split()
    cards[pattern.index(ch)][int(rank)-1] = True

for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  float tax=1.08;
  //float ex=n/tax;//税抜き価格
  //int cost=ex;
  for(int i=1;i<=50000;i++){
    int sum=i*tax;
  	if(sum==n){
    	cout<<i<<endl;
      	return 0;
    }
  }
  cout<<":("<<endl;
}

Measured memory_bytes: 3632
from sys import stdin
import sys
##  input functions for me
def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    A = ri()
    B = ri()
    for i in range(1,4):
        if i != A and i != B: print(i)


if __name__ == "__main__":
    main()


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

int main() {
  int A, B, N = 0;
  int k1, k2, k4, k5;
  cin >> A >> B;
  for ( int i = A; i <= B; i++ ) {
    k1 = i / 10000;
    k2 = i % 10000 / 1000;
    k4 = i % 100 / 10;
    k5 = i % 10;
    if( k1 == k5 && k2 == k4 ) {
      N++;
    }
  }
  cout << N << endl; 
}


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




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

	bool err = false;
	for (int i = 0; i < 5; i++)
		for (int j = i + 1; j < 5; j++) {
			if (abs(a[i] - a[j]) > k) err = true;
		}

	cout << (err ? ":(" : "Yay!") << endl;

	return 0;
}

Measured memory_bytes: 256
def solve():
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        if i%2==0:
            continue
        d = 0
        for j in range(1,i+1):
            if i%j==0:
                d+=1
        if d==8:
            ans+=1
    print(ans)
if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef unsigned long long ull;

typedef struct Item {
  ull v;
  ull w;
  Item(ull v, ull w) : v(v), w(w) {};
} Item;

bool sort_by_cost(const Item& lhs, const Item& rhs) {
  if ((__int128)lhs.v*rhs.w != (__int128)rhs.v*lhs.w) {
    return (__int128)lhs.v*rhs.w > (__int128)rhs.v*lhs.w;
  }
  else {
    return lhs.v > rhs.v;
  }
}

ull solve_greedy(const vector<Item>& items, const int i, ull W) {
  ull greedy_ans = 0;
  for (int k = i; k < items.size() && W > 0; ++k) {
    ull v = items[k].v;
    ull w = items[k].w;
    if (w <= W) {
      greedy_ans += v;
      W -= w;
    }
  }
  return greedy_ans;
}

double solve_relax(const vector<Item>& items, const int i, ull W) {
  double remain_w = W;
  double lp_ans = 0;
  for (int k = i; k < items.size() && fabs(remain_w) > 1e-15; ++k) {
    double v = items[k].v;
    double w = items[k].w;
    double use_m = min(1.0, remain_w/w);
    lp_ans += v*use_m;
    remain_w -= w*use_m;
  }
  return lp_ans;
}

ull ans;
void solve(const vector<Item>& items, const int i, const ull W, const ull total) {
  if (items.size() == i) {
    return;
  }

  ull grd_ans = solve_greedy(items, i, W);
  ans = max(ans, total + grd_ans);

  double lp_ans = solve_relax(items, i, W);
  if (total + lp_ans <= ans) {
    ans = max(ans, total);
    return;
  }

  ull v = items[i].v;
  ull w = items[i].w;

  solve(items, i+1, W, total);

  if (W >= w) {
    solve(items, i+1, W-w, total+v);
  }
}

int main () {
  int N;
  ull W;
  cin>>N>>W;
  vector<Item> items;
  for (int i = 0; i < N; ++i){
    ull v, w, m;
    cin>>v>>w>>m;
    ull k = 1;
    while (m > 0) {
      ull use_m = min(k, m);
      k <<= 1;
      m -= use_m;
      items.push_back(Item(v*use_m, w*use_m));
    }
  }

  sort(items.begin(), items.end(), sort_by_cost);

  solve(items, 0, W, 0);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3312
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

unsigned long long pat(long int a, long int b, long int c){
  if(a == 0 || b == 0 || c == 0) return 0;
  return a*b*c;
}

unsigned long long total(long int *ini){
  unsigned long long ans=0;
  for(int i=0; i<3;i++){
      for(int j=i+1; j<5;j++){
          for(int k=j+1; k<5;k++){
            ans  += pat(ini[i], ini[j],ini[k]);
          }   
      } 
  }
  
  return ans;
}

int main(){
  long long int N=0;
  cin >> N;
  char moji[5] = {'M', 'A', 'R', 'C', 'H'};
  string name;
  long int ini[5];
  for(int i=0;i<5;i++) ini[i] = 0;
  for(int i=0;i<N;i++){
    name = "\n";
    cin >> name;
    //cout << name.front();??
    for(int i=0;i<5;i++){
      if(name[0] == moji[i]) ini[i]++;
    }
  }
  // for(int i=0;i<5;i++){
  //   cout << ini[i]++ << " ";
  // }
  
  cout << total(ini) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<utility>
#include<stdio.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  const int INF=(1<<29);
  int min[1010],fix[1010];
  int map[1010][1010];
  int s1,g1; //スタート地点の座標をs1,ゴール地点の座標をg1とおく
  int n,m,i,j,x,y,z1,z2,v,price; //nは頂点の本数,mは辺の本数
  priority_queue<P,vector<P>,greater<P> > que;  //greater<P>の右の空白は重要
  scanf("%d\n%d\n",&n,&m);
  for(i=0;i<=n;i++){
    min[i]=INF,fix[i]=0;
  }
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      map[i][j]=-1;
    }
  }
  for(i=0;i<m;i++){
    scanf("%d,%d,%d,%d\n",&x,&y,&z1,&z2);
    if(map[x][y]==-1 || map[x][y]>z1){
    map[x][y]=z1;
    }
    if(map[y][x]==-1 || map[y][x]>z2){
    map[y][x]=z2;
    }
  }
  scanf("%d,%d,%d,%d\n",&s1,&g1,&v,&price);
  v=v-price;
  que.push(P(0,s1));
  min[s1]=0;
  while(!que.empty()){
    if(fix[g1]==1){
      break;
    }
    P p=que.top();
    que.pop();
    int v=p.second;
    if(min[v]<p.first){
      continue;
    }
    for(i=0;i<=n;i++){
      if(map[v][i]!=-1 && min[i]>min[v]+map[v][i] && fix[i]==0){
        min[i]=min[v]+map[v][i];
        que.push(P(min[v]+map[v][i],i));
      }
    }
    fix[v]=1;
  }
  v=v-min[g1];
  while(!que.empty()){
    que.pop();
  }
    for(i=0;i<=n;i++){
    min[i]=INF,fix[i]=0;
  }
  que.push(P(0,g1));
  min[g1]=0;
  while(!que.empty()){
    if(fix[s1]==1){
      break;
    }
    P p=que.top();
    que.pop();
    int v=p.second;
    if(min[v]<p.first){
      continue;
    }
    for(i=0;i<=n;i++){
      if(map[v][i]!=-1 && min[i]>min[v]+map[v][i] && fix[i]==0){
        min[i]=min[v]+map[v][i];
        que.push(P(min[v]+map[v][i],i));
      }
    }
    fix[v]=1;
  }
  v=v-min[s1];
  printf("%d\n",v);
  return 0;
}


Measured memory_bytes: 3284
#include <stdio.h>

int main(){
  int i,j,n,c,I,J;

  scanf("%d",&n);

  int C[n+1][n+1];

  for(i=1; i <= n; i++){
    for(j=1; j <= n; j++){
      C[i][j] = 0;
    }
  }

  for(i=1; i <= n; i++){
    scanf("%d",&I);
    scanf("%d",&c);
    for(j=1; j <= c; j++){
      scanf("%d",&J);
      C[I][J] = 1;
    }
  }

  for(i=1; i <= n; i++){
    for(j=1; j <= n; j++){
      printf("%d",C[i][j]);
      if(j != n){
	printf(" ");
      }
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2048
import sys

time = 0
def dfs(u):
    global time
    flag_list[u] = 1
    time += 1
    d_list[u] = time
    for v in range(n):
        if m_list[u][v] == 1 and flag_list[v] == 0:
            dfs(v)
    flag_list[u] = 2
    time += 1
    f_list[u] = time


input = sys.stdin.readline
n = int(input())
m_list = [[0]*n for _ in range(n)]
for _ in range(n):
    input_list = list(map(int, input().split()))
    index = input_list[0] - 1
    if input_list[1] > 0:
        for a in input_list[2:]:
            m_list[index][a-1] = 1
    
d_list = [0]*n
f_list = [0]*n
flag_list = [0]*n # 0: 未到達, 1: 処理中, 2: 完了
for i in range(n):
    if flag_list[i] == 0:
        dfs(i)

for i in range(n):
    print(i+1, d_list[i], f_list[i])



Measured memory_bytes: 5792
n = int(input())
s = []
for _ in range(n):
    s.append(input())
d = {}
name = set(s)
for a in name:
    d.update({a:0})
for x in s:
    d[x] += 1
ds = sorted(d.items(), key=lambda x:x[1])
max = ds[-1][1]
ans = []
for x in reversed(ds):
    if x[1]==max:
        ans.append(x[0])
    else:
        break
ans.sort()
for x in ans:
    print(x)

Measured memory_bytes: 57740
import bisect

n = int(input())
l = list(map(int, input().split()))

l.sort()
ans = 0
for i in range(n-1):
    b = l[:i]
    c = l[i+1:]
    for j in b:
        ans += bisect.bisect_left(c, l[i] + j)#2番目の棒より短く(left), 一定以上の長さを持つ([i+1:])
print(ans)


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

int main() {
	int N, M;
	cin >> N >> M;
	int i, j;
	vector<bool> B(31);
	for (i = 1; i <= M; i++) {
		B.at(i) = true;
	}
	for (i = 0; i < N; i++) {
		int k;
		cin >> k;
		vector<bool> b(31);
		for (j = 1; j <= M; j++) {
			b.at(j) = false;
		}
		for (j = 0; j < k; j++) {
			int a;
			cin >> a;
			b.at(a) = true;
		}
		for (j = 1; j <= M ; j++) {
			if (b.at(j) == false) {
				B.at(j) = false;
			}
		}
	}
	int A = 0;
	for (i = 1; i <= M; i++) {
		if (B.at(i) == true) {
			A++;
		}
	}
	cout << A;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    uint32_t nn;
    uint32_t mm;
    uint32_t temp = 0;
    uint32_t sum = 0;
    uint32_t pivot = 0;
    cin >> nn >> mm;

    vector<uint32_t> aray(nn, 0);
    vector<uint32_t> favaray(nn, 0);

    for(int i = 0; i < nn; i++){
        cin >> temp;
        aray[i] = temp;
        sum += temp;
    }

    sort(aray.begin(), aray.end(), greater<uint32_t>());
    /* for(int i = 0; i < nn; i++){
        cout << favaray[i] << endl;
    } */
    pivot = sum / (4 * mm);
    if(sum % (4 * mm))
        pivot++;
    for(int i = 0; i < mm; i++){
        if(aray[i] < pivot){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;

}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
Hs = list(map(int, input().split()))

min_dist = 1e10
min_idx = -1
for i, h in enumerate(Hs):
    avg = T - h * 0.006
    if abs(avg - A) < min_dist:
        min_dist = abs(avg - A)
        min_idx = i
print(min_idx + 1)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
#include<cstdlib>
#include<map>
#include<math.h>
#include<utility>
using namespace std;
typedef long long ll;

int main(){
  ll x, y;
  cin >> x >> y;
  int cnt=0;
  ll tmp = x;
  while(tmp <= y){
    tmp *= 2;
    cnt++;
  }
  cout << cnt << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>

using namespace std;

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll a,b,c,d;
	ll ans=-INFLL;
	cin >>a>>b>>c>>d;
	if(b>0 and d >0){
		chmax(ans, b * d);
	}
	if(a<0 and c <0 ){
		chmax(ans, a * c);
	}
	if(a<= 0 and b>= 0 ){
		chmax(ans, 0LL);
	}
	if (c <= 0 and d >= 0) {
		chmax(ans, 0LL);
	}
	if((a<0 and b<0 )xor (c<0 and d<0)){
		chmax(ans, -min(abs(a), abs(b)) * min(abs(c), abs(d)));
	}
	cout<<ans<<endl;
}

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

int main(){

	bool pn[1000010];
	int sum[1000010] = {0};
	int n;
	
	for(int i = 0; i <= 1000000; i++) {
		pn[i] = true;
	}
	
	pn[1] = false;
	for(int i = 1; i <= 1000000; i++) {
		if(!pn[i]) continue;
		for(int j = 2; i*j <= 1000000; j++) {
			if(pn[i*j]) pn[i*j] = false;
		}
	}
	
	for(int i = 1; i <= 1000000; i++) {
		sum[i] = sum[i-1] + pn[i];
	}
	
	while(cin >> n) {
		cout << sum[n] << endl;
	}

    return 0;
}

Measured memory_bytes: 6048
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
using namespace std;
#define int long long int
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int arr[n];
	int j=0;
	map<int,int> mp;
	int sum=0;
	for(j=0;j<n;j++)
	{
		cin>>arr[j];
		sum+=arr[j];
		mp[arr[j]]++;
	}
	int q;
	cin>>q;
	while(q--)
	{
		int b,c;
		cin>>b>>c;
		auto it=mp.find(b);
		if(it==mp.end())
		{
			cout<<sum<<endl;
		}
		else
		{
			int x=it->second;
			mp.erase(it);
			int diff=x*(c-b);
			mp[c]+=x;
			sum+=diff;
			cout<<sum<<endl;
		}
	}
}


Measured memory_bytes: 8348
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <set>
using namespace std;
int main(){
    int n,MAX = 100010,ans;
    cin >> n;
    vector<int> odd(MAX),even(MAX);
    fill(odd.begin(), odd.end(), 0);
    fill(even.begin(), even.end(), 0);
    for (int i = 1; i <= n; i++) {
        int v;
        cin >> v;
        if(i%2==0) even[v]++;
        else odd[v]++;
    }
    int oddnum, evennum, omax1 = 0, omax2 = 0, emax1 = 0, emax2 = 0;
    for (int i = 0; i < 100010; i++) {
        if(omax1 < odd[i]){
            omax2 = omax1;
            omax1 = odd[i];
            oddnum = i;
        }
        else if(omax2 < odd[i]){
            omax2 = odd[i];
        }
    }
    for (int i = 0; i < 100010; i++) {
        if(emax1 < even[i]){
            emax2 = emax1;
            emax1 = even[i];
            evennum = i;
        }
        else if(emax2 < even[i]){
            emax2 = even[i];
        }
    }
    if(oddnum != evennum) ans = n - omax1 - emax1;
    else ans = min(n - omax1 - emax2, n - omax2 - emax1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fio     ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pi      3.14159265
#define ll      long long
#define repe    ll tc,cas=0;cin>>tc;while(tc--)
#define op      freopen("output.txt", "w", stdout);

#define maxn 10000010
using namespace std;

int dp[100005];
int arr[100005],n;

int main()
{
    fio;

    cin>>n;
    for(int i=0;i<n;i++){cin>>arr[i];dp[i]=1e9;}

    dp[0]=0;

    for(int i=0;i<n-1;i++)
    {
        dp[i+1]=min(dp[i+1],dp[i]+abs(arr[i]-arr[i+1]));
        if(i<n-2)
            dp[i+2]=min(dp[i+2],dp[i]+abs(arr[i]-arr[i+2]));
    }
    cout<<dp[n-1]<<endl;;
    return 0;
}


Measured memory_bytes: 4344
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let t = read::<String>().chars().collect::<Vec<_>>();

    let mut ans = 0;
    for i in 0..3 {
        if s[i] == t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}

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

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


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

typedef long long ll;

ll gcd(ll a, ll b){
return a != 0 ? gcd(b % a, a) : b;
}

int main() {
ll a, b;
while(cin >> a >> b)
cout << gcd(a, b) << " " << a / gcd(a, b) * b << endl;}

Measured memory_bytes: 3104
#include<iostream>
#include<map>
using namespace std;
int main(){
  int p,q,k; 
  while(cin>>p>>q){
    p%=q;
    map<int,int> nums;
    for(k=0;;k++){
      if(p>=q)p%=q;
      if(nums.find(p)==nums.end()){
	nums[p] = k;
      }
      else break;
      p*=10;
      if(p)cout<<p/q;
    }
    cout<<endl;
    if(p){
      for(int i=0;i<nums[p];i++)cout<<" ";
      for(int i=nums[p];i<k;i++)cout<<"^";
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<math.h>
using namespace std;
long long int min(long long int a,long long int b)
{
	if(a<b)
	return a;
	else
	return b;
}
int main() {
	int n;
	cin>> n;
	int i;
	long long int arr[n];
	long long int sum=0;
	for(i=0;i<n;i++)
	{
		cin >> arr[i];
		sum+=arr[i];
	}
	long long int mini=10000000000;
	long long int cur=arr[0];
	sum-=arr[0];
	for(i=1;i<=n-1;i++)
	{
	mini=min(mini,abs(cur-sum));
	cur+=arr[i];
	sum-=arr[i];
	
	}
	cout << mini << endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1792
#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int64_t W[100];
int64_t V[100];
std::unordered_map<int64_t, int64_t> dp[100];
int64_t func(int i, int64_t W_MAX)
{
	if (W_MAX < 0) {
		return -100000000000000;
	}
	if (i >= N) {
		return 0;
	}
	if (dp[i].count(W_MAX)) {
		return dp[i][W_MAX];
	}
	auto& memo = dp[i][W_MAX];
	return memo = std::max(
		func(i + 1, W_MAX),
		func(i + 1, W_MAX - W[i]) + V[i]
	);
}
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	int64_t W_MAX;
	in >> N>>W_MAX;
	for (int32_t i = 0; i < N; ++i)
	{
		in >> W[i] >> V[i];
	}
	std::cout << func(0, W_MAX) << std::endl;

	return 0;
}
#endif

#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int64_t N;
int64_t T;
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N>>T;
	int64_t sum = T;
	int64_t last_t=0;
	for (int32_t i = 0; i < N; ++i)
	{
		int64_t t;
		in >> t;
		sum += T;
		sum -= std::max<int64_t>(T - (t- last_t), 0);
		last_t = t;
	}
	std::cout << sum << std::endl;


	return 0;
}
#endif


Measured memory_bytes: 888
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

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

    ll a, b, c;
    if (K - A > 0) {
        a = A;
        if((K - A) - B > 0) {
            b = B;
            if((K - A - B) - C > 0) {
                c = C;
            } else {
                c = K - A - B;
            }
        } else {
            b = K - A;
            c = 0;
        }
    } else {
        a = K;
        b = 0;
        c = 0;
    }

    ll ans = a * 1 + b * 0 + c * (-1);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3572
n = int(input())
s = input()
l_s = len(s)
l = [0 for x in range(l_s)]
for i in range(l_s):
    if s[i] == 'W':
        l[i] = 1
    else:
        l[i] = 0
p_0 = l_s-1
p_1 = 0
cnt = 0
while (p_0 >= p_1+1):
    while (l[p_0] != 0 and p_0 != 0):
        p_0 -= 1
    while (l[p_1] != 1 and p_1 != l_s-1):
        p_1 += 1
    if p_0 > p_1:
        cnt += 1
    p_0 -= 1
    p_1 += 1
print(cnt)

Measured memory_bytes: 10992
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

bool is_yymm(int x)
{
    int yy = x / 100;
    int mm = x % 100;

    if (mm <= 0 || 12 < mm) {
        return false;
    }

    return true;
}

bool is_mmyy(int x)
{
    int mm = x / 100;
    int yy = x % 100;

    if (mm <= 0 || 12 < mm) {
        return false;
    }

    return true;
}

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

    if (is_yymm(S) && is_mmyy(S)) {
        cout << "AMBIGUOUS" << endl;
    } else if(is_yymm(S)) {
        cout << "YYMM" << endl;
    } else if(is_mmyy(S)) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

ll add(ll x, ll y) {ll res=x+y; return(res>=MOD?res-MOD:res);}
ll mul(ll x, ll y) {ll res=x*y; return(res>=MOD?res%MOD:res);}
ll sub(ll x, ll y) {ll res=x-y; return(res<0?res+MOD:res);}
ll lcm(ll x, ll y) {ll res=(x*y)/__gcd(x,y); return res;}
ll power(ll x, ll y) {ll res=1; x%=MOD; while(y){if(y&1)res=mul(res,x); y>>=1; x=mul(x,x);} return res;}

int main()
{
	boost;
	ll n, i;
	cin >> n;
	
	if(n == 1) cout << 0;
	else {
		ll n2 = sub(power(10, n), power(8, n));
		ll n1 = sub(power(10, n), power(9, n));
		n1 = mul(n1, 2);
		
		n1 = sub(n1, n2);
		cout << n1;
	}
	
}


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

int main(void){
    int a,b,c;
    cin >> a >> b >> c; 
    if(a < b && b < c){
        cout << "Yes";
        cout << endl;
    }else{
        cout << "No";
        cout << endl;
    }

}



Measured memory_bytes: 3084
#include <stdio.h>

int main(void){
  int i,j,k,count=0;
  scanf("%d",&k);
  for(i=1;i<=k;i++){
    for(j=i+1;j<=k;j++){
      if(i%2==1 && j%2==0){
        count+=1;
      }else if(i%2==0 && j%2==1){
        count+=1;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
import std.stdio;
import std.array;
import std.conv;
import std.string;
import std.algorithm;

void main()
{
    string s;
    while( (s=readln.strip) != "0 0") {
        auto n = map!(to!int)(s.strip.split);
        int h = n[0], w = n[1];

        writeln(replicate("#",w));
        for(int i=1;i<h-1;i++) {
          write("#");
          write(replicate(".",w-2));
          writeln("#");
        }
       if(h>1)
         writeln(replicate("#",w));
       writeln();
    }
}

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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll  a,b,c,i,j,k,x,y,z;
 ll A,B,C,X,Y,Z;
 ll count;
signed main(){
  int N;
  cin>>N;
  set<int> st;
  REP(i,N){
  	int d;
  	cin>>d;
  	st.insert(d);
  }
  cout<<st.size()<<endl;
  

 return 0;
}


Measured memory_bytes: 3612
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine(Convert.ToInt32(Console.ReadLine()) >= 3200 ? Console.ReadLine() : "red");
        }


    }
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string s;
  cin >> s;

  bool dif = (s[0] == s[s.length()-1]);
  
  bool is_first = !((s.length()%2==0) ^ dif);


  if(is_first){
    cout << "First" << endl;
  }else{
    cout << "Second" << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

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

// 5000兆
// 5 * 10^15
int main() {
    string S;
    cin >> S; // 1 <= |S| <= 100

    long K; // 1 <= K <= 10^18
    cin >> K;

    REP(0, i, S.length()) {
        if (S[i] == '1') {
            if ((i + 1) == K) {
                cout << 1 << endl;
                return 0;
            }
        } else {
            cout << S[i] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	ll A,B;
	char op;
	cin>>A>>op>>B;
	if(op=='+'){
		ce(A+B)
	}else{
		ce(A-B)
	}
	
	
}

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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long 
using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int a[3000];
int toti[3000];
int age[3000];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
       cin>>a[i];

   for(int i=1;i<=n;i++)
   {
   	for(int j=1;j<=n;j++)
   	{
   		if(a[i]>a[j])
   		{
   			toti[i]++;
   			if(i<j)
   				age[i]++;
   		}
   	}
   }
    for(int i=1;i<=n;i++)
   {
   	int lala = (((k)*(k-1))/2)%mod;
   	 int temp = (toti[i]*lala)%mod;
   	 temp = (temp + age[i]*k)%mod;
   	 toti[i] = temp;
   }
   int output = 0;
   for(int i=1;i<=n;i++)
   	  output = (output + toti[i])%mod;
   	cout<<output;
	return 0;
}

Measured memory_bytes: 256
//
//AtCoder Beginner Contest 065
//C
//
 
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>
 
using namespace std;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;
 
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
 
const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数
 
const int mod = 1000000007;
//const int mod = 998244353;
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;}

mint kj(ll n){
    mint ret=1;
    FOR(i, 1, n) ret*=i;
    return ret;
}
int main()
{
    ll n, m;
    cin >> n >> m;

    mint ans = kj(n)*kj(m);
    if (n==m){
        ans*=2;
    }else if (abs(n-m)>1){
        ans=0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define F first
#define S second

const int N=3e2+7;

pii a[N*N];
int s[N*N];

int cnt(pii a, pii b)
{
	return abs(a.F-b.F)+abs(a.S-b.S);
}

main()
{
	int h, w, d;
	cin >> h >> w >> d;
	for (int i=0; i<h; i++)  {
		for (int j=0; j<w; j++)  {
			int tmp;
			cin >> tmp;
			a[tmp]={i, j};
		}
	}
	for (int i=d+1; i<=h*w; i++)  {
		s[i]=s[i-d]+cnt(a[i-d], a[i]);
	}
	int q;
	cin >> q;
	for (int i=0; i<q; i++)  {
		int l, r;
		cin >> l >> r;
		cout << s[r]-s[l] << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int dp[3002][3002], a[3002];
int add(int a, int b){
    return (a+b)%mod;
}
int main(){
    int n, s;
    scanf("%d%d", &n, &s);   
    for(int i=1;i<=n;i++) scanf("%d", &a[i]);
    dp[0][0] = 1;
    
    int ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=s;j>=0;j--){
            if(j+a[i] <= s) dp[i][j+a[i]] = add(dp[i][j+a[i]], dp[i-1][j]);
            dp[i][j] = add(dp[i][j], dp[i-1][j]);
        }
        dp[i][0] = add(dp[i][0], 1);
        ans = (ans + dp[i][s])%mod;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 35456
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

bool prime[100009];
int is2017[100009];

void eratosthenes(int X) {
    prime[0]=prime[1]=0;
    for ( int i = 2; i*i <= X; i++ ) {
        int v = i*2;
        while( v <= X) {
            prime[v] = false;
            v += i;
        }
    }
}

bool ck(int x){
    return (prime[x]&&prime[(x+1)/2]);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    rep(i,100009) prime[i]=1;
    eratosthenes(100000);
    
    for(int i=3;i<100000;i+=2){
        if(ck(i)) is2017[i]=1;
    }
    
    rep1(i,100000) is2017[i+1]+=is2017[i];
    
    int Q;
    cin>>Q;
    
    rep(i,Q){
        int l,r;cin>>l>>r;
        cout1(is2017[r]-is2017[l-1])
    }
}

Measured memory_bytes: 1152
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

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

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int a, b, x;
  cin >> a >> b >> x;
  if(a <= x && x <= a+b) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a, b, c = (int(_) for _ in input().split())
    i = 1
    ans = 'NO'
    while i<b:
        if(a*i % b == c):
            ans = 'YES'
            break
        i+=1
            
    print(ans)
    
if __name__ == '__main__':
    main()


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

int main()
{
 int a,b,k;
  cin>>a>>b>>k;
  set<int> s;
  for(int i=0;i<k&&a+i<=b&&b-i>=a;i++)
  {
    s.insert(a+i);
    s.insert(b-i);
  }
  for(auto i:s)
    cout<<i<<"\n";
  
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#define maxn 100005
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
using namespace std;

int ufs[maxn];
int val[maxn];
int get(int x){
    int t = (x == ufs[x]) ? x : get(ufs[x]);
    val[x] += val[ufs[x]];
    return ufs[x] = t;
}

int main(){
    int n, m;
    int x, y, d;
    scanf("%d%d", &n, &m);
    rep(i, 1, n) ufs[i] = i;
    rep(i, 1, m){
        scanf("%d%d%d", &x, &y, &d);
        int _x = get(x), _y = get(y);
        if (_x == _y) {
            if (val[x] - val[y] != d) {
                printf("No");
                return 0;
            }
        }
        else val[_x] = d + val[y] - val[x], ufs[_x] = _y;  
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,ans;
  cin >> n;
  if(n%2==1) {
    cout << 0;
  } else {
    for(long long i=10;n/i>0;i=i*10){
      ans+=n/i;
    };
    long a = 10;
    for(long long i=50;n/i>0;i=i*5){
      a=a*10;
      ans+=n/i;
      if (a>0) {
        ans-=n/a;
      } else {
        a=0;
      };
    };
    cout << ans;
  };
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    pair<int, int> p;
    cin >> n;
    forn(i, n){
        string fi, se;
        cin >> fi >> se;
        if(fi > se) p.first += 3;
        else if(fi < se) p.second += 3;
        else{
            p.first++;
            p.second++;
        }
    }
    cout << p.first << " " << p.second << endl;
}


Measured memory_bytes: 3176
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)

int main() {
    vector<pair<ld,ld>> set(4);
    set[0].second = 0.25;
    set[1].second = 0.5;
    set[2].second = 1;
    set[3].second = 2;

    cin >> set[0].first >> set[1].first >> set[2].first >> set[3].first;
    ld N;
    cin >> N;

    set[0].first *= 8;
    set[1].first *= 4;
    set[2].first *= 2;
    set[3].first *= 1;

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

    rep(i,4){
        if(set[i].second == 0.25){
            set[i].first /= 8;
        }else if(set[i].second == 0.5){
            set[i].first /= 4;
        }else if(set[i].second == 1){
            set[i].first /= 2;
        }else if(set[i].second == 2){
            set[i].first /= 1;
        }
    }

    ll result = 0;
    while(N>0){
        rep(i,4){
            if(N >= set[i].second){
                ll tmp = N / set[i].second;
                N -= (set[i].second*tmp);
                result += (set[i].first*tmp);
                break;
            }
        }
    }

    cout << result << endl;

}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
typedef unsigned long long int ull;
using namespace std;

int LIS(int* A,int L){
  int DP[L];
  fill(DP,DP+L,INF);
  rep(i,L) *upper_bound(DP,DP+L,A[i])=A[i];
  return lower_bound(DP,DP+L,INF)-DP;
}

int main(void){
  string S;
  cin >> S;
  int L=S.length();
  int dp[L+1][13]={};
  if(S[0]=='?') rep(i,10) dp[1][i]=1;
  else dp[1][S[0]-'0']=1;
  for(int i=2;i<=L;i++){
    if(S[i-1]=='?') rep(j,13) rep(k,10) dp[i][(j*10+k)%13]=(dp[i][(j*10+k)%13]+dp[i-1][j])%MOD;
    else rep(j,13) dp[i][(j*10+(S[i-1]-'0'))%13]=(dp[i][(j*10+(S[i-1]-'0'))%13]+dp[i-1][j])%MOD;
  }
  cout << dp[L][5] << endl;
}

Measured memory_bytes: 5504
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;
ll n,D,A;
pair<ll,ll>a[N];
ll seg[4*N],lazy[4*N];
void propage(int indx){
	lazy[indx*2]+=lazy[indx];
	lazy[indx*2+1]+=lazy[indx];
	seg[indx*2]+=lazy[indx];
	seg[indx*2+1]+=lazy[indx];
	lazy[indx]=0;
}
void build(int indx,int l,int r){
	if(l==r){
		seg[indx]=a[l].second;
		return;
	}
	build(indx*2,l,(l+r)/2);
	build(indx*2+1,(l+r)/2+1,r);
}
void update(int indx,int l,int r,int i,int j,ll del){
	if(l>j || r<i)return;
	if(l>=i && r<=j){
		lazy[indx]-=del;
		seg[indx]-=del;
		return;
	}
	propage(indx);
	update(indx*2,l,(l+r)/2,i,j,del);
	update(indx*2+1,(l+r)/2+1,r,i,j,del);
}
ll get(int indx,int l,int r,int pos){
	propage(indx);
	if(l==r)return seg[indx];
	if(pos<=(l+r)/2)return get(indx*2,l,(l+r)/2,pos);
	else	return get(indx*2+1,(l+r)/2+1,r,pos);
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	scanf("%lld %lld %lld",&n,&D,&A);
 	std::vector<ll> x(n);
 	for(int i=0;i<n;i++)scanf("%lld %lld",&a[i].first,&a[i].second),x[i]=a[i].first;
 	sort(all(x));
 	sort(a,a+n);
 	build(1,0,n-1);
 	ll ans = 0;
 	for(int i=0;i<n;i++){
 		ll see = get(1,0,n-1,i);
 		if(see<=0)continue;
 		ll howmany = (see + A - 1) / A;
 		int nxt = upper_bound(all(x),a[i].first+2*D)-x.begin();
 		nxt--;
 		update(1,0,n-1,i,nxt,howmany*A);
 		ans+=howmany;
 	}
 	printf("%lld\n",ans );
}		


Measured memory_bytes: 17408
#include<iostream>

using namespace std;

int main (){
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if(x+r<=W && x-r>=0 && y+r<=H && y-r>=0){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};


int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    while(n > abs(n-k)) {
        if(n > k) {
            n = n-max(1LL, (n-k)/k)*k;
        } else {
            n = k - n;
        }
    }
    cout << n << endl;
}


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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
   int n; cin>>n;
   map<string,int> mp; 
    rep(i,n){
        string s; cin>>s;
        mp[s]++;
    }
    cout<<mp.size()<<endl;
}

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

int main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  while (true) {
    C -= B;
    if (C <= 0) { cout << "Yes" << endl; break; }
    A -= D;
    if (A <= 0) { cout << "No" << endl; break; }
  }
}

Measured memory_bytes: 3592
n, l = map(int, input().split())
apples = []
check = 1000
eat = 0

for i in range(1, n+1):
    apples.append(l+i-1)
    if abs(l+i-1) < check:
        eat = l+i-1
        check = abs(l+i-1)

ans = sum(apples) - eat
print(ans)


Measured memory_bytes: 2940