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

typedef pair<int,int> P;

char C[51][51];

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

vector<P> G[51][51];
int dp[52][52][52][52];

#define INF (1<<29)

int H,W;

int solve(int x1,int y1,int x2,int y2){
  int &res = dp[x1][y1][x2][y2];
  if( res != -1 ) return res;
  res = -INF;
  // cout << "in " << x1 << " " << y1 << " " << C[x1][y1] << " "<< x2 << " " << y2 << " " << C[x2][y2]<< " " << res << endl;
  if( x1 >= W || y1 >= H || x2 >= W || y2 >= H  ) return res;
  if( x1 == x2 && y1 == y2 ) return res = 0;
  if( x1 > x2 || y1 > y2 ) return res;
  if( C[x1][y1] == '#' || C[x2][y2] == '#' ) return res;  
  if( 'a' <= C[x1][y1] && C[x1][y1] <= 'z' ){
    for(int i=0;i<(int)G[x1][y1].size();i++){
      int mx = G[x1][y1][i].first, my = G[x1][y1][i].second;
      if( mx > x2 || my > y2 ) continue;
      for(int j=0;j<2;j++){
        for(int k=2;k<4;k++){
          int nx1 = x1 + dx[j], ny1 = y1 + dy[j];
          int nx2 = mx + dx[k], ny2 = my + dy[k];
          if( C[nx1][ny1] == '#' || C[nx2][ny2] == '#' ) continue;
          res = max( res,
                     solve(nx1,ny1,nx2,ny2) + solve(mx,my,x2,y2) + 1 );
        }
      }
    }
  }
  for(int i=0;i<2;i++){
    int nx1 = x1 + dx[i], ny1 = y1 + dy[i];
    //    if( C[nx1][ny1] == '#' ) continue;
    res = max( res, solve(nx1,ny1,x2,y2) );
  }
  return res;
}



int main(){
  int T = 1;
  while( cin >> H >> W && (H||W) ){
    for(int i=0;i<H;i++)
      for(int j=0;j<W;j++)
        cin >> C[j][i];
    /*
    if( T == 75 ){
      cout << H << " " << W << endl;
      for(int i=0;i<H;i++){
        for(int j=0;j<W;j++)
          cout << C[j][i];
        cout << endl;
      }
      
    }
    T++;
    continue;
    */
    queue<P> q;
    int h[51][51]={};
    q.push(P(0,0) );
    h[0][0] = 1;
    while( !q.empty() ){
      P p = q.front(); q.pop();
      int x = p.first, y = p.second;
      for(int i=0;i<2;i++){
        int nx = x + dx[i], ny = y + dy[i];
        if( nx >= W || ny >= H ) continue;
        if( h[nx][ny] ) continue;
        if( C[nx][ny] == '#' ) continue;
        q.push( P(nx,ny) );
        h[nx][ny] = 1;
      }
    }

    if( !h[W-1][H-1] )
      cout << -1 << endl;
    else {
      for(int i=0;i<H;i++)
        for(int j=0;j<W;j++)
          for(int k=0;k<H;k++)
            for(int l=0;l<W;l++)
              dp[j][i][l][k] = -1;

      for(int i=0;i<H;i++)
        for(int j=0;j<W;j++)
          G[j][i].clear();

      for(int y1=0;y1<H;y1++)
        for(int x1=0;x1<W;x1++)
          if( 'a' <= C[x1][y1] && C[x1][y1] <= 'z' ) 
            for(int y2=y1;y2<H;y2++)
              for(int x2=x1;x2<W;x2++)
                if( C[x2][y2] - C[x1][y1] == 'A' - 'a' ) 
                  G[x1][y1].push_back( P(x2,y2) );
              
      // cout << " in " << endl;
      int res=solve(0,0,W-1,H-1);
      cout <<res << endl;
    }
  }
}

Measured memory_bytes: 28692
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
b = [int(input()) for _ in range(N)]

cnt1 = 0
for i in A1:
    if i in b:
        cnt1 += 1
    if cnt1 == 3:
        flag1 = 1
    else:
        flag1 = 0

cnt2 = 0
for i in A2:
    if i in b:
        cnt2 += 1
    if cnt2 == 3:
        flag2 = 1
    else:
        flag2 = 0

cnt3 = 0
for i in A3:
    if i in b:
        cnt3 += 1
    if cnt3 == 3:
        flag3 = 1
    else:
        flag3 = 0

cnt4 = 0
for i in [A1[0], A2[1], A3[2]]:
    if i in b:
        cnt4 += 1
    if cnt4 == 3:
        flag4 = 1
    else:
        flag4 = 0

cnt5 = 0
for i in [A1[2], A2[1], A3[0]]:
    if i in b:
        cnt5 += 1
    if cnt5 == 3:
        flag5 = 1
    else:
        flag5 = 0

cnt6 = 0
for i in [A1[0], A2[0], A3[0]]:
    if i in b:
        cnt6 += 1
    if cnt6 == 3:
        flag6 = 1
    else:
        flag6 = 0

cnt7 = 0
for i in [A1[1], A2[1], A3[1]]:
    if i in b:
        cnt7 += 1
    if cnt7 == 3:
        flag7 = 1
    else:
        flag7 = 0

cnt8 = 0
for i in [A1[2], A2[2], A3[2]]:
    if i in b:
        cnt8 += 1
    if cnt8 == 3:
        flag8 = 1
    else:
        flag8 = 0

if flag1 == 1 or flag2 == 1 or flag3 == 1 or flag4 == 1 or flag5 == 1 or flag6 == 1 or flag7 == 1 or flag8 == 1:
    print('Yes')
else:
    print('No')


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

int main(){
    int K,N;
    cin >> K >> N;
    vector<int>a(N);
    vector<int>b(N);
    for(int i = 0; i < N;i++){
        cin >> a[i];
    }
    for(int i = 0; i < N - 1; i++){
        b[i] = a[i + 1] - a[i];
    }
    b[N - 1] = K + a[0] - a[N - 1];
    sort(b.begin(),b.end());
    cout << K - b[N - 1] << endl;
}

Measured memory_bytes: 1920
#include<cstdio>
#include<algorithm>
using namespace std;

//bool cmp(int a,int b){
//	return  a<=b;
//}

int main()
{
	int k,n;
	scanf("%d%d",&n,&k);
	int *p=new int[n] ;
	for(int i=0;i<n;i++){
		scanf("%d",&p[i]);
	}
	sort(p,p+n);
	int sum(0);
//	for(int i=0;i<n;i++){
//		printf("%d ",p[i]);
//	}
//	printf("\n");
	for(int i=0;i<k;i++){
		sum+=p[i];
	}
	printf("%d",sum);
	delete []p;
	return 0;
}

Measured memory_bytes: 3252
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, A;
int main()
{
    cin >> N;
    cin >> A;
    N %= 500;
    if (N <= A)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a;
  cin>>a;
  for(int i=0;i<3;i++){
    a%=10;
  }
  if(a==3) cout<<"bon\n";
  else if(a==0||a==1||a==6||a==8) cout<<"pon\n";
  else cout<<"hon\n";
}


Measured memory_bytes: 3644
a,b,c,d=map(int,input().split())
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
    
def lcm(a,b):
    return a*b//gcd(a,b)
    
a=a-1
b=b-b//c-b//d+b//lcm(c,d)
a=a-a//c-a//d+a//lcm(c,d)
print(b-a)

Measured memory_bytes: 3060
#include <stdio.h>

void print_a(int a[],int n) {
  int i;

  for (i = 0; i < n; i++) {
    printf("%d", a[i]);
    if (i < n - 1)
      printf(" ");
  }
  printf("\n");
}

void insertion_sort(int a[],int n) {
  int i, j;
  int num;
  
  for (i = 1; i < n; i++) {
    print_a(a, n);
    j = i;
    num = a[i];
    while(j > 0 && num < a[j - 1]) {
      a[j] = a[j - 1];
      j--;
    }
    a[j] = num;
  }
}

int main(void) {
  int n;
  int a[1000];
  int i;

  scanf("%d", &n);

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

  print_a(a, n);
  
  return 0;
}



Measured memory_bytes: 1976
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}

signed main(){
	int a,b,c,n,ans=0;
	cin>>a>>b>>c>>n;
	for(int i=0;i<=3000;i++){
		for(int j=0;j<=3000;j++){
			if(a*i+b*j>n)continue;
			int x=n-(b*j+a*i);
			if(x%c==0)ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int a[105];
int main()
{
    int N;
    cin>>N;
    for(int i=0;i<N;i++)
        cin>>a[i];
    if(N==1)
        cout<<'0'<<endl;
    else
    {
        int d1,d2,sum=0,sum1=0,sum2=0;
        for(int i=0;i<N;i++)
            sum+=a[i];
        d1=sum/N+1;
        d2=sum/N;
        for(int i=0;i<N;i++)
        {
            sum1+=(a[i]-d1)*(a[i]-d1);
            sum2+=(a[i]-d2)*(a[i]-d2);
        }
        cout<<min(sum1,sum2)<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
  int n, k, r, s, p;
  string t;
  ll sum=0;
  cin >> n >> k;
  cin >> r >> s >> p;
  cin >> t;
  for (int i = 0; i < k; i++) {
    char a = t[i];
    if (a == 'r') {
      sum += p;
    } else if (a == 's') {
      sum += r;
    } else {
      sum += s;
    }
    bool flg = false;
    for (int j = i + k; j < n; j += k) {
      if (a != t[j]) {
        a = t[j];
        if (a == 'r') {
          sum += p;
        } else if (a == 's') {
          sum += r;
        } else {
          sum += s;
        }
        flg=false;
      }else{
        if(flg){
          if (a == 'r') {
            sum += p;
          } else if (a == 's') {
            sum += r;
          } else {
            sum += s;
          }
          flg=false;
        }else{
          flg=true;
        }
      }
    }
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,K;
    cin >> N >> K;
    vector<int> V(N);
    rep(i,0,N)cin >> V[i];
    sort(V.begin(), V.end());
    int mini = INF;
    rep(i,0,N-K+1)mini = min(mini, V[i+K-1] - V[i]);
    cout << mini << endl;
}

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

using namespace std;

// Self settings
// clang-format off
#define MAX_N 100
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int N;

int P[MAX_N + 1];
string S[MAX_N + 1];

typedef struct {
  string s;
  int p;
  int idx;
} Shop;

bool operator<(const Shop &Shop1, const Shop &Shop2)
{
  if (Shop1.s != Shop2.s) {
    return Shop1.s > Shop2.s;
  }
  return Shop1.p < Shop2.p;
};

int main(void)
{
  priority_queue<Shop> que;
  scanf("%d\n", &N);
  const char *fmt = "%d %d\n";
  for (int i = 1; i <= N; ++i) {
    cin >> S[i] >> P[i];
    Shop s = {S[i], P[i], i};
    que.push(s);
  }
  while (!que.empty()) {
    Shop s = que.top();
    cout << s.idx << endl;
    que.pop();
  }
  return 0;
}


Measured memory_bytes: 888
import java.util.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer N = Integer.parseInt(scanner.next());
        TreeSet<Integer> ts = new TreeSet<>();

        for (int i = 0; i < N; i++) ts.add(Integer.parseInt(scanner.next()));

        if(N == ts.size()) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 70584
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  string S;
  cin >> S;
  bool flag = false;
  for(int i = 0; i < 4; i++){
    if(S[i%4]==S[i+1%4]&&S[i+1%4]==S[i+2%4]){
      flag = true;
      break;
    }
  }
  if(flag) printf("Yes\n");
  else printf("No\n");
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define N 1000000
#define pb push_back
int a[N][2];
signed main()
{
    SPEED;
    int n;
    cin>>n;
    string s[n];
    for(int i=0;i<n;++i)
    {
        cin>>s[i];
        int c1=0,c2=0;
        for(int j=0;j<s[i].length();++j)
        {
            if(s[i][j]==')')
                c1++;
            else 
                c2++;
            a[i][0]=max(a[i][0],c1-c2);
        }
        c1=0;c2=0;
        int l=s[i].length();
        for(int j=l-1;j>=0;--j)
        {
            if(s[i][j]=='(')
                c1++;
            else 
                c2++;
            a[i][1]=max(a[i][1],c1-c2);
        }
    }
    vector<pair<int,int>> s1,s2;
    for(int i=0;i<n;++i)
    {
        if(a[i][1]-a[i][0]>=0)
            s1.pb({a[i][0],a[i][1]});
        else
            s2.pb({a[i][1],a[i][0]});
    }
    sort(s1.begin(),s1.end());
    sort(s2.rbegin(),s2.rend());
    int j=0,k=0,sum=0,f=0;
    for(int i=0;i<n;++i)
    {
        if(j<s1.size())
        {
            sum-=s1[j].first;
            if(sum<0)
                break;
            sum+=s1[j].second;
            j++;
        }
        else
        {
            sum-=s2[k].second;
            if(sum<0)
                break;
            sum+=s2[k].first;
            k++;
        }
    }
    if(sum!=0)
        cout<<"No";
    else
        cout<<"Yes";
}




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

#define LL long long
#define LD long double
#define INF 1000000000LL
#define PR pair<int,int>
#define Min(a,b) a=min(a,b)
#define Max(a,b) a=max(a,b)
#define pb push_back
#define mp make_pair

string s, t;
int dp[3005][3005], b[3005][3005];

void ans(int i, int j) {
    if (i == 0 || j == 0) return;
    if (b[i][j] == 0) {
        ans(i - 1,j - 1);
        cout << s[i - 1];
    } else if (b[i][j] == 1) ans(i - 1, j);
    else ans(i, j - 1);
}

int main() {
	cin >> s >> t;
	
	int n = s.length(), m = t.length();
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i-1] == t[j-1]) {
				dp[i][j] = dp[i-1][j-1] + 1;
				b[i][j] = 0;
			} else if (dp[i - 1][j] >= dp[i][j - 1]) {
				dp[i][j] = dp[i - 1][j];
				b[i][j] = 1;
			} else {
				dp[i][j] = dp[i][j - 1];
				b[i][j] = -1;
			}
		}
	}

	ans(n, m);
	cout << endl;
}

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

using namespace std;
typedef long long ll;
const int maxN = (int)1e5 + 10;
int a[maxN];
const int mod = 998244353;
ll gcd(ll a, ll b) {
    while (a > 0 && b > 0) {
        if (a < b) swap(a, b);
        a %= b;
    }
    return (a + b);
}
int n;
int main() {
    //freopen("input.txt", "r", stdin);
    srand(239);
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    int ans = 1;
    for (int i = 1; i <= n; i++) {
        int d = gcd(a[i], i - 1);
        ans = (1LL * ans * d) % mod;
    }
    cout << ans;
    return 0;
}



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

#define ll long long int
#define endl "\n"
#define mod 1000000007
#define maxN 200005


int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll a,b;
  	cin>>a>>b;
  	cout<<a*b<<endl;
	
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=1e5+3;
vector<int> v[MAX_N];
int d[2][MAX_N];
 
void dfs(int prv, int now, int b, int cnt) {
    d[b][now] = cnt;
    for(auto nxt : v[now]) {
        if(nxt != prv) {
            dfs(now, nxt, b, cnt + 1);
        }
    }
}

int main(){
    int N;cin>>N;
    REP(i,N-1){
        int a,b;
        cin>>a>>b;a--;b--;
        v[a].PB(b);v[b].PB(a);
    }
    dfs(-1,0,0,0);
    dfs(-1,N-1,1,0);
    int f=0;
    REP(i,N)if(d[0][i]<=d[1][i])f++;
    if(f*2>N){
        cout<<"Fennec"<<endl;
    }else{
        cout<<"Snuke"<<endl;
    }
    return 0;
}


Measured memory_bytes: 12800
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

#[allow(unused_macros)]
macro_rules ! min {($ a : expr $ (, ) * ) => {{$ a } } ; ($ a : expr , $ b : expr , $ (, ) * ) => {{std :: cmp :: min ($ a , $ b ) } } ; ($ a : expr , $ ($ rest : expr ) ,+ $ (, ) * ) => {{std :: cmp :: min ($ a , min ! ($ ($ rest ) ,+ ) ) } } ; }
#[allow(unused_macros)]
macro_rules ! chmin {($ base : expr , $ ($ cmps : expr ) ,+ $ (, ) * ) => {{let cmp_min = min ! ($ ($ cmps ) ,+ ) ; if $ base > cmp_min {$ base = cmp_min ; true } else {false } } } ; }

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut cum = vec![0; n + 1];
    for i in 0..n {
        cum[i + 1] = cum[i] + a[i];
    }

    let mut ret = std::i64::MAX;
    for i in 1..n {
        chmin!(ret, (2 * cum[i] - cum[n]).abs());
    }

    println!("{}", ret);
}


Measured memory_bytes: 5148
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int A = scn.nextInt();
		int B  =scn.nextInt();
		int C  =scn.nextInt();
		if(A==B) {
			System.out.println(C);
		}
		if(A==C) {
			System.out.println(B);
		}
		if(C==B) {
			System.out.println(A);
		}
	}

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
int a, b;
int main()
{
	cin >> a >> b;
	cout << a + b / 2 << endl;
	return 0;
}


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

int main() {
  int N;
  cin>>N;
  vector<int> p(N);
  vector<int> q(N);
  map<pair<int,int>,int> m;
  vector<pair<int,int>> c;
  for(int i=0;i<N;i++){
    cin>>p.at(i)>>q.at(i);
    for(int j=0;j<i;j++){
      int a=p.at(i)-p.at(j),b=q.at(i)-q.at(j);
      if(a<0){
        a*=-1,b*=-1;
      }
      if(a==0){
        b=abs(b);
      }
      c.push_back(make_pair(a,b));
      m[make_pair(a,b)]++;
    }
  }
  int Z=0;
  for(auto x:c){
    Z=max(Z,m[x]);
  }
  cout<<N-Z<<endl;
    
}

Measured memory_bytes: 384
h,w=map(int,input().split())
field=[]
for i in range(h):
    field.append(list(map(int,input().split())))
opr=0
ans=[]
for j in range(h):
    for k in range(w):
          if field[j][k]%2==1 and k!=w-1:
              field[j][k]-=1
              field[j][k+1]+=1
              opr+=1
              ans.append([j+1,k+1,j+1,k+2])
          elif field[j][k]%2==1 and k==w-1 and j<h-1: 
              field[j][k]-=1
              field[j+1][k]+=1
              opr+=1
              ans.append([j+1,k+1,j+2,k+1]) 
   
print(opr)
for l in range(len(ans)):
    print(ans[l][0],ans[l][1],ans[l][2],ans[l][3])

Measured memory_bytes: 31256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  ll N;
  cin >> N;
  map<ll,ll> a,b;

  for(int i=0;i<N;i++){
    ll A; cin >> A;
    a[i-A]++;
    b[i+A]++;
  }

  ll ans=0;
  for(auto ai:a){
    if(b.count(ai.first)==1) ans+=(ai.second)*b[ai.first];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 26640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] a)throws IOException{
    	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String str = null;
        int gameNum;
        int scoreA = 0;
        int scoreB = 0;
        int numA;
        int numB;                
        
    	while((str = in.readLine()) != null){
            if(str.equals("0")){
                System.exit(0);
            }else{
                gameNum = Integer.parseInt(str);

                for(int i=0;i<gameNum;i++){
                    str = in.readLine();
                    numA = Integer.parseInt(str.split(" ")[0]);
                    numB = Integer.parseInt(str.split(" ")[1]);
                    
                    if(numA > numB){
                        scoreA += (numA + numB);
                    }else if(numA < numB){
                        scoreB += (numA + numB);                    
                    }else{
                        scoreA += numA;
                        scoreB += numB;
                    }
                }                    
                
                System.out.println(scoreA+" "+scoreB);
                scoreA = 0;
                scoreB = 0;
            }
        }
    }
}

Measured memory_bytes: 49696
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto K = RD;
	auto l = RDR.ARR;
	l.sort!"a > b"();
	long ans;
	foreach (i; 0..K)
		ans += l[i];

	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

int main() {    
    int n,y;
    cin >> n >> y;
    for(int i = 0; i < n+1; i++) {
        for(int j = 0; i+j< n+1; j++) {
            int sum = 10000*i + 5000*j + 1000*(n-i-j);
            if(sum == y) {
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
K,N=io.read("*n","*n")
A={}
for i=1,N do
A[i]={i,io.read"*n"}
end
table.sort(A,function(a,b)return a[2]<b[2]end)
B={}
for i=1,N-1 do
B[i]={i,A[i+1][2]-A[i][2]}
end
B[N]={N,K+A[1][2]-A[N][2]}
local max=B[1]
for i=2,N do
	if(B[i][2]>max[2])then max=B[i] end
end
print(K-max[2])

Measured memory_bytes: 29424
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
struct edge {int to, cost;};
string s[114];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> s[i];
	int flg = 0;
	rep(i, n - 1) {
		if (s[i][s[i].size() - 1] != s[i + 1][0])flg++;
	}
	set<string>S;
	rep(i, n)S.insert(s[i]);
	if (S.size() != n)flg++;
	if (flg)puts("No");
	else puts("Yes");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(){
   int n,d[100000],i;
    
   scanf("%d",&n);
   for (i=0;i<n;i++) scanf("%d",&d[i]);
   qsort(d,n,sizeof(int),asc);
   printf("%d\n",d[n/2]-d[n/2-1]);
   return 0;
}


Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main(){
int x,a,b;
  cin>>x>>a>>b;

  if((a+b)/2<x){
    if(max(a,b)==a){
        cout<<'A'<<endl;
    }
    else{
        cout<<'B'<<endl;
    }
}

    if((a+b)/2>x){
        if(min(a,b)==a){
            cout<<'A'<<endl;
        }
        else{
            cout<<'B'<<endl;
        }
    }
  }

Measured memory_bytes: 384
<?php

fscanf(STDIN, "%d %d", $n, $k);
$H = [];
for ($i = 0; $i < $n; ++$i) {
    $H[] = intval(trim(fgets(STDIN)));
}
$H[] = PHP_INT_MAX;
sort($H);

$r = 0;
$min = PHP_INT_MAX;
$cnt = 0;
for ($l = 0; $l < $n; ++$l) {
    while ($r < $n && $cnt < $k) {
        ++$cnt;
        ++$r;
    }
/* echo "l: $l, r: $r, cnt: $cnt, ", PHP_EOL; */

    if ($cnt !== $k) break;

    $min = min($min, $H[$r - 1] - $H[$l]);

    --$cnt;
}
echo $min, PHP_EOL;


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

int main(){
  int n,m,sum=0,ip;
  cin >> n >> m;
  while(m--){
    cin >> ip;
    sum += ip;
  }
  if(n-sum < 0)cout << "-1" << endl;
  else cout << (n-sum) << endl;
  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     db(i)               cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    int n,a,b; cin>>n>>a>>b;
    n = b/n-(a-1)/n;
    if(n>0){
    	cout<<"OK\n";
    }
    else{
    	cout<<"NG\n";
    }
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 3652
import itertools

N, M, Q = [int(x) for x in input().split()]

Xn = []
for i in range(Q):
    Xn.append([int(x) for x in input().split()])

num_list = [int(x) for x in range(1, M+1)]
pairs = []

for pair in itertools.combinations_with_replacement(num_list, N):
    pairs.append(pair)

ans = 0

# ペアを指定
for pair in pairs:
    now_sum = 0
    # そのペアでのsumを計算
    for target_row in Xn:
        #print(target_row)
        ai = target_row[0]
        bi = target_row[1]
        ci = target_row[2]
        di = target_row[3]
        # A[bi] - A[ai] - ciを計算
        if(pair[bi-1] - pair[ai-1] - ci == 0):
            now_sum = now_sum + di
    ans = max(ans, now_sum)
    #print(f"今のペア:{pair}→合計点:{now_sum}")

print(ans)


Measured memory_bytes: 21612
N,K=map(int,input().split())
A=list(map(int,input().split()))
tmp=10**9+7

cna=0
for i,a in enumerate(A):
    for at in A[i+1:]:    
        if a>at:
            cna+=1

cna2=0
for a in A:
    for at in A:    
        if a>at:
            cna2+=1


kt=(K-1)*(K)//2

#kt=int((K-1)*(K)/2)
#the expression gives a bit different value
#because double precision can deal with the number till 2**53
#due to the memory is 52 bit for expression besides exponetial


print((K*cna+kt*cna2)%tmp)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>

using namespace std;
using int64 = long long;
using P = pair<int,int>;

int main () {
    int n,m;
    string s;
    cin >> n >> m >> s;
    vector<int> ans;
    while(n > 0) {
        int t = m;
        while(t>0 && n-t >= 0 && s[n-t] == '1') t--;
        if (t == 0) {
            ans = {-1};
            break;
        }
        if (n-t < 0) t = n;
        ans.push_back(t);
        n -= t;
    }

    reverse(ans.begin(), ans.end());
    for (int i=0; i<ans.size(); i++) {
        cout << ans[i] << (i!=ans.size()-1? " " : "\n");
    }
}


Measured memory_bytes: 1080
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0)
    cout<<1;
  else if(b==0)
    cout<<2;
  else if(c==0)
    cout<<3;
  else if (d==0)
    cout<<4;
  else
    cout<<5;
  return 0;
}  

Measured memory_bytes: 3624
n = int(input())
s = list(input())
e = []
d = []
if n % 2 == 1:
  print("No")
else:
  for i in range(n // 2):
    e += [s[i]]
    d += [s[(n//2)+i]]
  if e == d:
    print("Yes")
  else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main() {
  int a, b;
  int degree[5000] = {0};
  while (cin >> a, cin >> b) {
    if (a == -1 && b == -1) break;
    degree[a]++;
    degree[b]++;
    if (a == 0) {
      int flg = 0;
      for (int i = 0; i < 5000; i++)
        if (degree[i]%2 && i != 1 && i != 2) flg++;
        else if	(!(degree[i]%2)	&& (i == 1 || i	== 2)) flg++;
      if (flg) cout << "NG" << endl;
      else cout << "OK" << endl;
      memset(degree, 0, sizeof(degree));
    }
  }
  return 0;
}

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

using namespace std;

typedef long long Int;

class Fraction{
public:
  Int numerator,denominator;
};

void reduce(Fraction &);
Int gcd(Int,Int);

ostream &operator << (ostream &os,Fraction f){
  reduce(f);
  if(f.numerator == 0){
    os << "0";
  }else if(f.denominator == 1){
    os << f.numerator;
  }else{
    os << f.numerator << "/" << f.denominator;
  }
  return os;
}

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

Int lcm(Int a,Int b){
  return a*b/gcd(a,b);
}

void reduce(Fraction &f){
  Int x = gcd(f.numerator,f.denominator);
  f.numerator /= x;
  f.denominator /= x;
}

Fraction sub(Fraction f,Int num,Int den){
  Fraction g = {num,den}; reduce(g);
  Int nd = lcm(f.denominator,g.denominator);
  f.numerator *= (nd/f.denominator);
  g.numerator *= (nd/g.denominator);
  f.denominator = g.denominator = nd;
  f.numerator -= g.numerator;
  return f;
}

Fraction add(Fraction f,Int num,Int den){
  Fraction g = {num,den}; reduce(g);
  Int nd = lcm(f.denominator,g.denominator);
  f.numerator *= (nd/f.denominator);
  g.numerator *= (nd/g.denominator);
  f.denominator = g.denominator = nd;
  f.numerator += g.numerator;
  return f;
}

int main(){
  string in;

  while(cin >> in, in != "#"){
    string s;
    int size = 0;
    for(int i = 0 ; i < (int)in.size() ; size++){
      if(in[i] == 'n'){
        s += 'n';
        i += 5;
      }else{
        s += 'w';
        i += 4;
      }
    }
    reverse(s.begin(),s.end());
    Fraction f;
    int n = 1;
    if(s[0] == 'n'){
      f.numerator = 0;
      f.denominator = 1;
    }else{
      f.numerator = 90;
      f.denominator = 1;
    }
    for(int i = 1 ; i < size ; i++,n++){
      if(s[i] == 'n'){
        f = sub(f,90,(Int)pow(2.,n));
      }else{
        f = add(f,90,(Int)pow(2.,n));
      }
      reduce(f);
    }
    cout << f << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <climits>
#include <bitset>
#include <cassert>

using namespace std;

const int SIZE = 1 << 17;

int pointer = SIZE;
char buffer[SIZE];

char Advance() {
    if (pointer == SIZE) {
        fread(buffer, 1, SIZE, stdin);
        pointer = 0;
    }
    return buffer[pointer++];
}

int Read() {
    int answer = 0, sign = 1;
    char ch = Advance();
    while (!isdigit(ch) && ch != '-')
        ch = Advance();
    if (ch == '-') {
        sign = -1;
        ch = Advance();
    }
    while (isdigit(ch)) {
        answer = answer * 10 + ch - '0';
        ch = Advance();
    }
    return answer * sign;
}

char ReadCh() {
    char ch = Advance();
    while (!isalpha(ch))
        ch = Advance();
    return ch;
}

const int MAXN = 10000;

int a[1 + MAXN], b[1 + MAXN];

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    int n;
    long long suma = 0, sumb = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        suma += a[i];
    }
    for (int i = 1; i <= n; i++) {
        scanf("%d", &b[i]);
        sumb += b[i];
    }
    if (suma > sumb) {
        printf("No\n");
        return 0;
    }
    long long deltaa = 0, deltab = 0;
    for (int i = 1; i <= n; i++)
        if (a[i] > b[i])
            deltab += a[i] - b[i];
        else
            if ((b[i] - a[i]) % 2 == 0)
                deltaa += (b[i] - a[i]) / 2;
            else {
                deltaa += (b[i] - a[i] + 1) / 2;
                deltab++;
            }
    if (deltab <= sumb - suma && deltaa <= sumb - suma && 2 * (sumb - suma - deltaa) == sumb - suma - deltab)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<functional>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
using namespace std;
int main()
{
  int n, k, q;
  cin >> n  >> k >> q;
  vector<int > A(q);
  REP(i,q){ cin >> A[i];}
  vector<int > B(n, 0);
  REP(i,q){
    B[A[i] - 1] ++;
  }
  //  REP(i,n){
  //    cout << B[i] << endl;
  //  }
  //  cout << "test" << endl;
  REP(i,n){
    if(k + B[i] - q > 0 ){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }

  }
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	string str;
	cin >> str;
	if(str.find('7') == string::npos) cout << "No\n";
	else cout << "Yes\n";
}


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

def power_func(a,n,p):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res

def cmb(n, r, mod):
    if ( r<0 or r>n ):
       return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353
N = 2*(10**5)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

p=mod
ans=0
for i in range(k+1):
  x=power_func(m-1,n-1-i,p)
  y=cmb(n-1, i, mod)
  ans=(ans+m*x*y)%p
print(ans)

Measured memory_bytes: 33256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    vector<string> s(3);
    cin >> s[0] >> s[1] >> s[2];
    string ret(3, 'A');
    for (int i = 0; i < 3; ++i) {
        ret[i] = (s[i][0] + 'A' - 'a');
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	scan(N);
	double ans;
	if(N%2) ans=(double)(N/2+1)/N;
	else ans=0.5;
	prin(setprecision(10)<<ans);
	return 0;
}


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

int main()
{
  int a,b;
  int arr[999];
  arr[0]=1;
  cin >> a >> b;
  for(int i=1; i<999; i++){
    arr[i]=arr[i-1]+(i+1);
  }
  cout << arr[b-a-1]-b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
int main(){
    string s,t;
    ll ans=0;
    cin >> s >> t;
    for (ll i=0;i<s.size();i++){
        if (s[i]!=t[i])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3848
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

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

    int k;
    cin >> k;

    while (b <= a)
        b *= 2, k--;
    while (c <= b)
        c *= 2, k--;

    if (k >= 0)
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    solve();

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
// check for edge cases in limits
// printing double may print 1.223232e9 like values, beware of that
// carefully observe simulation of test cases


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
long long ans, v, temp;
long long G[3010][3010];
long long dp[3010][3010][4];
int h, w, k, r, c;
int main(){
  cin >> h >> w >> k;
  for(int i=0; i<k; i++){
    cin >> r >> c >> v;
    r -= 1;
    c -= 1;
    G[r][c] = v;
  }
  dp[0][0][1] = G[0][0];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j>0){
        dp[i][j][0] = dp[i][j-1][0];
        for(int k=1;k<4;k++){
          dp[i][j][k] = max({dp[i][j][k], dp[i][j-1][k-1]+G[i][j], dp[i][j-1][k]});
        }
      }
      if(i>0){
        temp = max({dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3]});
        dp[i][j][0] = max(dp[i][j][0], temp);
        dp[i][j][1] = max(dp[i][j][1], temp+G[i][j]);
      }
    }
  }
  ans = max({dp[h-1][w-1][0],dp[h-1][w-1][1],dp[h-1][w-1][2],dp[h-1][w-1][3]});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 356128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const double pi=3.14159265358979323846;
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  int x,y;
  cin >> x >> y;
  if(x%y==0){
    cout << -1 << endl;
  }else{
    cout << x << endl;
  }
}


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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	int D;
	cin >> D;
	if(D == 22)
		cout << "Christmas Eve Eve Eve" << endl;
	else if(D == 23)
		cout << "Christmas Eve Eve" << endl;
	else if(D == 24)
		cout << "Christmas Eve" << endl;
	else if(D == 25)
		cout << "Christmas" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int dp[1001][1001];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    int n = a.size(), m = b.size();
    memset(dp, 0, sizeof(dp));
    rep(i, m + 1) dp[0][i] = i;
    rep(i, n + 1) dp[i][0] = i;
    REP(i, 1, n + 1) REP(j, 1, m + 1){
        dp[i][j] = dp[i - 1][j - 1];
        if(a[i - 1] != b[j- 1]) dp[i][j] += 1;
        int temp = min(dp[i - 1][j] + 1, dp[i][j - 1] + 1);
        dp[i][j] = min(temp, dp[i][j]);
    }
    cout << dp[n][m] << endl;
    return 0;
}

Measured memory_bytes: 5112
#include <stdio.h>

int main() {
    int i, j, tmp, c, D, N;
    scanf("%d%d", &D, &N);
    for (i=1,c=0; ;i++) {
        for (j=1,tmp=i; j <= D ;j++) {
            if (tmp % 100) break;
            tmp = tmp / 100;
        }
        if (j == D+1 && tmp % 100) {
            if (++c == N) break;
        }
    }
    printf("%d\n", i);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

int main(){
    ll n;
    cin>>n;
    ll cnt=0;
    char color[200002];
    for(ll i=1; i<=n; i++) cin>>color[i];
    for(ll i=1; i<=n; i++) {
        if (color[i]=='R') cnt++;
    }
    ll ans=0;
    for(ll i=1; i<=cnt; i++){
        if(color[i]=='W') ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3828