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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;
typedef long long ll;

const int nc = 26;
int D;
ll c[40], t[400];
ll s[400][40];

void scoring(){
	vector<int> last(nc+10, -1);

	long long sat = 0;

	for(ll d = 0; d < D; d++){
		last[t[d]] = d;

		for(int i = 0; i < nc; i++){
			sat -= c[i] * (d - last[i]);
		}
		sat += s[d][t[d]];
		cout << sat << endl;
	}
}

int main(){
	cin >> D;

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

	for(int i = 0; i < D; i++){
		for(int j = 0; j < nc; j++){
			cin >> s[i][j];
		}
	}

		for(int i = 0; i < D; i++){
		cin >> t[i];
		t[i]--;
	}

	scoring();

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int X, Y; cin >> X >> Y;
  for(int i=0;i<=50;i++){
    for(int j=0;j<=50;j++){
      if(i+j==X && i*2+j*4==Y){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main()
{
	int A,B,C;
	cin>>A>>B>>C;
	if(A!=B&&A!=C&&B!=C)
	{
		cout<<"3";
	}
	else if(A==B&&A==C&&B==C)
	{
		cout<<"1";
	}
	else
	{
		cout<<"2";
	}
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    
    vector<int> X(N);
    for (int j=0; j<N; j++) {
        cin >> X.at(j);
    }
    
   
    long long mint = 922337203685477580;
    for (int i=1; i<=100; i++) {
         int t=0;
        for (int j=0; j<N; j++) {
            t+=(X.at(j)-i)*(X.at(j)-i);
        }
        if ( t<mint ) {
        mint = t;
        }
    }
    
    cout << mint << endl;
    
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    ll N,M,tmp;
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC"<<endl;
    else
        cout<<"ABC"<<endl;

    return 0;

}


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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    ll l = 0, r = 200005;
    vector<ll>v(n);
    for(auto &i:v)cin >> i;
    sort(v.begin(),v.end());
    while(r - l > 1){
        int mid = (l + r) >> 1;
        ll cnt = 0;
        cnt = v.end() - lower_bound(v.begin(),v.end(),mid/2+(mid&1));
        for(int i = 0 ; i < n ; i++){
            cnt += (v.end() - lower_bound(v.begin() + i + 1, v.end(), mid - v[i])) * 2;
        } 
        if(cnt >= k){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    ll cnt = 0;
    ll ans = 0;
    ll suf[n+5] ={};
    for(int i = n - 1 ; i >= 0 ; i--){
        suf[i] = suf[i + 1] + v[i];
    }
    for(int i = 0 ; i < n ; i++){
        if(v[i] * 2 > l){
            ans += v[i] * 2;
            cnt++;
        }
        int j = upper_bound(v.begin()+i+1,v.end(),l - v[i]) - v.begin();
        ll cur = n - j;
        cnt += cur * 2;
        ans += suf[j] * 2 + v[i] * cur * 2;
    }
    ans += (ll)(k - cnt) * l;
    cout << ans << '\n';
}

Measured memory_bytes: 1792
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD (1e9+7)
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  long long n;cin>>n;
  if(n%2){
    cout << 0 << endl;
  }else{
    long long ans = n/10;
    long long nw = 50;
    while(nw <= n){
      ans += n/nw;
      nw*=5;
    }
    
    cout << ans << endl;
  }
}

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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

const int N = 110;

ll n,W,w[N],v[N],dp[N][100100];

int main()
{
    scanf("%lld%lld",&n,&W);
    for(int i=1;i<=n;i++)
        scanf("%lld%lld",&w[i],&v[i]);

    for(int i=n;i>=1;i--)
        for(int j=0;j<=W;j++)
        {
            dp[i][j] = dp[i+1][j];

            if( j-w[i] >= 0 )
                dp[i][j] = max( dp[i][j] , dp[i+1][j-w[i]] + v[i] );
        }

    printf("%lld\n",dp[1][W]);
}


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

typedef long double ld;

double a[10005];
ld sum = 0, avg = 0;

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

	int cnt;

	while (n != 0) {
		sum = 0;
		cnt = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			sum += a[i];
		}
		avg = sum / (double)n;
		for (int i = 0; i < n; i++) {
			if (a[i] <= avg) {
				cnt++;
			}
		}
		cout << cnt << endl;
		cin >> n;
	}

	return 0;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
int a[(int)1e5+1]={0};
int main()
{
	int n,i,s=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		s+=abs(a[i-1]-a[i]);
	}
	s+=abs(a[i-1]-a[i]);
	for(i=1;i<=n;i++)
	{
		printf("%d\n",s-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))+abs(a[i-1]-a[i+1]));
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>

using namespace std;
int main()
{
	long N;
	cin >> N;
	vector<long> avec;
	for (long i = 0; i < N; ++i)
	{
		long a;
		cin >> a;
		avec.emplace_back(a);
	}

	long long currentMoney = 1000;
	long long currentStock = 0;
	for (long i = 1; i < N; ++i)
	{
		if (avec[i] > avec[i - 1])
		{
			// Buy
			currentStock = currentMoney / avec[i - 1];
			currentMoney = currentMoney - currentStock * avec[i - 1];
			//cout << "money=" << currentMoney << ", stock=" << currentStock << endl;

			// Sell
			currentMoney = currentMoney + currentStock * avec[i];
			currentStock = 0;
			//cout << "money=" << currentMoney << ", stock=" << currentStock << endl;
		}
	}

	cout << currentMoney << endl;
}

Measured memory_bytes: 3620
x1, y1, x2, y2 = map(int, input().split())

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx

x4 = x3 - dx
y4 = y3 - dy

print(x3, y3, x4, y4)


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

int main(){
    const long long smax=(long long) 1e9+7;
    int n,m;
    cin >> n >> m;
    long long x[n], y[m];
    long long sumx, sumy, sum;
    for(int i=0; i<n; i++){
        cin >> x[i];
    }
    for(int i=0; i<m; i++){
        cin >> y[i];
    }

    sumx=0;
    for(int i=1; i<n; i++){
        sumx+= i*x[i]-(n-i)*x[i-1];
        sumx=sumx%smax;
        //cout << "sumx " << sumx << endl;
    }
    sumy=0;
    for(int i=1; i<m; i++){
        sumy+= i*y[i]-(m-i)*y[i-1];
        sumy=sumy%smax;
        //cout << "sumy " << sumy << endl;
    } 

    sum=sumx*sumy;
    sum=sum%smax;
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1792
a = list(map(int, input().split()))
d = list(map(int, input().split()))

rq = "NNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNNSNNNNWNNNNWNNNNWNNNN"

for i in rq:
  if i == "E":
    d[0], d[2], d[3], d[5] = d[3], d[0], d[5], d[2]
  elif i == "N":
    d[0], d[1], d[4], d[5] = d[1], d[5], d[0], d[4]
  elif i == "S":
    d[0], d[1], d[4], d[5] = d[4], d[0], d[5], d[1]
  elif i == "W":
    d[0], d[2], d[3], d[5] = d[2], d[5], d[0], d[3]

  if a == d:
      print("Yes")
      exit()

print("No")


Measured memory_bytes: 5608
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()

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

#include <bits/stdc++.h>
using namespace std;

int main() {
  
  int n,m;
  cin>>n;
  
  vector<int> vec(n),ans(n),p;
  rep(i,n) cin>>vec[i];
  
  for(int i=n;i>=1;i--){
    int d=0;
    
    if(i>n/2){
      if(vec[i-1]==1){
        ans[i-1]=1;
        m++;
        p.push_back(i);
      }
    }
    else{
      for(int j=2;j<=n/i;j++){
        if(ans[i*j-1]==1) d++;
      }
      if(d%2 != vec[i-1]){
        ans[i-1]=1;
        m++;
        p.push_back(i);
      }
    }    
  }
  
  cout << m <<endl;
  if(m!=0){
    for(int i=0;i<p.size();i++) cout << p[i] <<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3064
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    if("B" in S and "A" in S):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Measured memory_bytes: 66284
S = list(input())
T = list(input())
lt = len(T)

result = 10**5
for i in range(len(S) - len(T) + 1):
    cnt = 0
    for s, t in zip(S[i: (i + lt)], T):
        if s != t:
            cnt += 1
    result = min(cnt, result)
print(result)

Measured memory_bytes: 67772
from math import gcd
from collections import defaultdict

n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]

MOD = 1000000007

box = defaultdict(int)
zeros = 0
for a, b in AB:
  if a == b == 0:
    zeros += 1
  else:
    if a != 0 and b == 0:
      box[(-1, 1, 0)] += 1
    elif a == 0 and b != 0:
      box[(1, 0, 1)] += 1
    else:
      g = gcd(a, b)
      ga = a // g
      gb = b // g
      if (a // b) < 0:
        s = -1
      else:
        s = 1
      box[(s, abs(ga), abs(gb))] += 1
   
nakawaru = dict()
others = 0

for (s, i, j), v in box.items():
    if (-s, j, i) in box.keys():
        if (s, i, j) not in nakawaru.keys() and (-s, j, i) not in nakawaru.keys():    
            nakawaru[(s, i, j)] = (box[(s, i, j)], box[(-s, j, i)])
    else:
        others += v

seed = 1
for i, j in nakawaru.values():
    seed *= (pow(2, i, MOD) + pow(2, j, MOD) - 1)
    seed %= MOD

ans = zeros + pow(2, others, MOD) * seed - 1
ans %= MOD

print(ans)


Measured memory_bytes: 83060
import java.util.Scanner;

public class Main {

	void main() {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String str = sc.next();
			if(str.equals("-")) break;
			int m = sc.nextInt();
			for(int i=0;i<m;i++) {
				int h = sc.nextInt();
				String head = str.substring(0, h);
				String tail = str.substring(h,str.length());
				str = tail + head;
			}
			System.out.println(str);
		}
			
	}
	
	public static void main(String[] args) {
		new Main().main();
	}

}





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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b,c;cin>>a>>b>>c;
    if (c>=a&&c<=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

string f(int r) {
    if (r < 1200) {
        return "ABC";
    }
    if (r < 2800) {
        return "ARC";
    }
    return "AGC";
}

int main() {

    int r;
    cin >> r;

    string result = f(r);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sat Dec  8 17:43:02 2018
//
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	arr := make([]int, N+1)
	for i := 1; i < len(arr); i++ {
		fmt.Scan(&arr[i])
	}

	var ans int64
	counts := map[int]int64{}
	for i := range arr {
		if i+1 < len(arr) {
			arr[i+1] += arr[i]
			arr[i+1] %= M
		}
		ans += counts[arr[i]]
		counts[arr[i]]++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8576
#include <stdio.h>
#include <cstdio>
#include <string.h>
int MAX_L = 200001;

int main(){
  /* read input */
  char S[MAX_L];
  char T[MAX_L];
  scanf("%s", S);
  scanf("%s", T);
  int l = strlen(T);
  
  /* solve problem*/
  int table[26][26]; // S[i] - T[j]
  for(int i = 0; i < 26; i++){
    for(int j = 0; j < 26; j++){
      table[i][j] = 0;
    }
  }
  
  for(int i = 0; i < l; i++){
    table[(int)S[i] - (int)'a'][(int)T[i] - (int)'a'] = 1;
  }
  /*chech table*/
  int check_r = 0;
  int check_c = 0;
  for(int i = 0; i < 26; i++){
    check_r = 0;
    check_c = 0;
    for(int j = 0; j < 26; j++){
      check_c += table[i][j];
      check_r += table[j][i];
    }
    if(check_r > 1 || check_c > 1){ /* if result is negative*/
      printf("No");
      return 0;
    }
  }
  printf("Yes"); /*if cleared all check*/
  
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    cin >> n >> m;

    ll x = 1900*m + 100*(n-m);
    rep(i, m) {
        x *= 2;
    }

    out(x);
    re0;
}

Measured memory_bytes: 256
def nyu():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()

    return N,A

def kans(N,A):
    
    min_cnt = 0
    max_cnt = 0
    flg_hai = 0
    flg_tya = 0
    flg_mido = 0
    flg_mizu = 0

    flg_ao = 0
    flg_ki = 0
    flg_dai = 0
    flg_red = 0


    for a in range(len(A)):
        if A[a] < 400 and flg_hai == 0:
            flg_hai = 1
            min_cnt += 1
            max_cnt += 1
        elif 400<= A[a] < 800 and flg_tya  == 0:
            flg_tya  = 1
            min_cnt += 1
            max_cnt += 1
        elif 800<= A[a] < 1200 and flg_mido  == 0:
            flg_mido  = 1
            min_cnt += 1
            max_cnt += 1
        elif 1200<= A[a] < 1600 and  flg_ao   == 0:
            flg_ao   = 1
            min_cnt += 1
            max_cnt += 1
        elif 1600<= A[a] < 2000 and flg_mizu   == 0:
            flg_mizu   = 1
            min_cnt += 1
            max_cnt += 1           
        elif 2000<= A[a] < 2400 and flg_ki   == 0:
            flg_ki   = 1
            min_cnt += 1
            max_cnt += 1            
        elif 2400<= A[a] < 2800 and flg_dai   == 0:
            flg_dai   = 1
            min_cnt += 1
            max_cnt += 1
        elif 2800<= A[a] < 3200 and flg_red   == 0:
            flg_red   = 1
            min_cnt += 1
            max_cnt += 1 
        elif 3200<= A[a]:
            if min_cnt == 0:
                min_cnt = 1
                max_cnt += 1
            else:
                max_cnt += 1
    print(min_cnt,max_cnt)



N,A = nyu()
kans(N,A)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

#define TRUE 1
#define FALSE 0

int main(void) {
	char WORDS[4][8] = { "dreamer", "eraser", "dream", "erase" };
	char s[100000];
	scanf("%s", s);
	int sw = TRUE, len;
	len = (int)strlen(s);
	while ((sw) && (s[0] != '\0')) {
		sw = FALSE;
		for (int i = 0; i < 4; i++) {
			int len_of_WORD = (int)strlen(WORDS[i]);
			if (((int)strlen(s) >= len_of_WORD) && (strcmp(s + len - len_of_WORD, WORDS[i]) == 0)) {
				s[len - len_of_WORD] = '\0';
				len = (int)strlen(s);
				sw = TRUE;
				break;
			}
		}
	}
	if (sw) {
		printf("YES\n");
	}
	else if (!sw) {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<map>
#include <bits/stdc++.h>
#include<cmath>
#define mod 1000000007
#define ll long long 
using namespace std;

int main() {


  
 ll n,k;
 cin>>n>>k;
 ll a[n];
 for(ll i=0;i<n;i++)
 {
 	cin>>a[i];
 }
 sort(a,a+n);
 ll sum=0;
 for(ll i=0;i<k;i++)
 {
 	sum=sum+a[i];
 }
 cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3680
#include <stdio.h>
#include <algorithm>
#include <deque>
#include <tuple>
using namespace std;
using ll = long long;

int h, w, n, sr, sc;
char s[200010], t[200010];
int main() {
	scanf("%d %d %d", &h, &w, &n);
	scanf("%d %d", &sr, &sc);
	scanf("%s", s);
	scanf("%s", t);

	int u = sr, d = sr, l = sc, r = sc;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'U')
			u--;
		else if (s[i] == 'D')
			d++;
		else if (s[i] == 'L')
			l--;
		else if (s[i] == 'R')
			r++;

		if (u < 1 || h < d || l < 1 || w < r) {
			printf("NO\n");
			return 0;
		}

		if (t[i] == 'U')
			d = max(1, d - 1);
		else if (t[i] == 'D')
			u = min(h, u + 1);
		else if (t[i] == 'L')
			r = max(1, r - 1);
		else if (t[i] == 'R')
			l = min(w, l + 1);
	}
	printf("YES\n");
}

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

//read_kaisetsu
int main() {
    int n,t;cin>>n>>t;
    int a[n];rep(i,n)cin>>a[i];
    
    int ma=0;
    int mi=a[0];
    rep(i,n){
        mi=min(mi,a[i]);
        if(a[i]-mi>ma)ma=a[i]-mi;
    }
    int ans=0;
    mi=a[0];
    rep(i,n){
        mi=min(mi,a[i]);
        if(a[i]-mi==ma)++ans;
    }
    cout<<ans<<endl;
	return 0;
}

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

int main(){
	string s;cin >> s;
	long long  ans=0,len=(int)s.size()-1;
	for(int i=0;i<(1<<len);++i){
		long long sum=s.at(0)-'0';
		for(int j=0;j<len;++j){
			if(i & (1<<j)){
				ans+=sum;
				sum=0;
			}
			sum=sum*10 + (s.at(j+1)-'0');
		}
		ans+=sum;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,m,n) for(int i=m;i<=n;i++)
const int M = 1e5 + 10;
const int inf = 0x3f3f3f3f;

//*************************************
int n,m,cnt;
int head[M];
struct node {
	int to,id,nxt;
} E[M << 2];
void add(int u,int v,int id) {
	E[++cnt] = {v,id,head[u]};
	head[u] = cnt;
}
//*************************************
int dis[M],ind[M];
set<int> vis[M];
void a() {
	priority_queue<pair<int, int> > Q;
	Q.push({0,1});
	dis[1] = 0;
	while(!Q.empty()) {
		int now =  Q.top().second;
		int   d = -Q.top().first;
			  	   Q.pop();
		if(dis[now] < d) continue;
		for(int i=head[now]; i; i=E[i].nxt) {
			int    v = E[i].to;
			int   id = E[i].id;
			int cost = d + (!vis[now].count(id));
			if(dis[v] > cost) {
				dis[v] = cost;
				Q.push({-cost,v});
				vis[v].clear();
				vis[v].insert(id);
			} else if(dis[v] == cost) {
				if(ind[v] <= 2) 
					ind[v]++,
					Q.push({-cost,v});
				vis[v].insert(id);
			}
		}
	}
	printf("%d\n",dis[n] == inf? -1:dis[n]);
}
//******************************************
void init() {
	rep(i,1,n) {
		head[i] = 0;
		dis[i] = inf;
		ind[i] = 0;
		vis[i].clear();
	}
	cnt = 0;
}
int main() {
	while(~scanf("%d %d",&n,&m)) {
		init();
		while(m--) {
			int a,b,c;
			scanf("%d %d %d",&a,&b,&c);
			add(a,b,c);
			add(b,a,c);
		}
		a();
	}
}

Measured memory_bytes: 21744
/*Author : Hrishi*/

/*When I wrote this, only God and I understood what I was doing.
Now, only God knows.*/

#include <bits/stdc++.h>

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define PB push_back
#define F(i,L,R) for(auto i=L; i<R ;i++)
#define FR(i,L,R) for(auto i=R-1;i>=L;i--)
#define show(x) cout<<(#x)<<" is "<<(x)<<"\n";
#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define M 1000000007

using namespace std;

vector<vl> dp(1000,vl(1000,0));
char arr[1000][1000];
int h,w;
int main() 
{
	cin>>h>>w>>ws;
	F(i,0,h)
	    F(j,0,w)
	        cin>>arr[i][j];
	        
    if(arr[h-1][w-1]=='#' || arr[0][0]=='#')
    {
        cout<<0<<"\n";
    }
    else
    {
        F(i,0,w)
            if(arr[0][i]=='.')
                dp[0][i]=1;
            else
                break;
        F(i,0,h)
            if(arr[i][0]=='.')
                dp[i][0]=1;
            else
                break;
                
        F(i,1,h)
            F(j,1,w)
            {
                if(arr[i][j]=='.')
                    dp[i][j] = (dp[i-1][j]+dp[i][j-1])%M;
            }
        
        cout<<dp[h-1][w-1]<<"\n";
    }

}




Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
const int maxn=1e5+10;
ll ans=0;
int a[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		ll now=0;
		for(int k=1;k<=(n-1)/i;k++){
			int x=n-1-k*i;
			if(x<=i||x%i==0&&x/i<=k)break;
			now+=a[x]+a[k*i];
			ans=max(ans,now);
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
//typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) <<double値
string s;

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    cin >> s;
    ll cnt=0;
    int cntb=0;
    rep(i,s.size()){
        if(s[i] == 'B'){
            cntb++;
        }else{
            cnt+=cntb;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  VI xs(3);
  REP(i,3) cin >> xs[i];
  if(xs[0] == xs[1]) cout << xs[2] << endl;
  else if(xs[0] == xs[2]) cout << xs[1] << endl;
  else if(xs[2] == xs[1]) cout << xs[0] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(2e6)+10;
int n,d[1010],tot,nxt[maxn];
int head[maxn],to[maxn];
int in[maxn],dis[maxn];
queue<int> q;
int haxi(int i,int j) {
	if (i>j) swap(i,j);
	return (i-1)*n+j;
}
void add(int x,int y) {
	//printf("%d %d\n",x,y);
	in[y]++; tot++;
	nxt[tot]=head[x];
	head[x]=tot; to[tot]=y;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) {
		for (int j=1;j<n;j++) read(d[j]);
		for (int j=1;j<n-1;j++)
			add(haxi(i,d[j]),haxi(i,d[j+1]));
	}
	for (int i=1;i<=n*n;i++)
		if (!in[i]) q.push(i),dis[i]=1;
	int cnt=0,mx=0;
	while (!q.empty()) {
		int u=q.front(); cnt++; q.pop();
		mx=max(mx,dis[u]);
		//printf("%d %d\n",u,dis[u]);
		for (int i=head[u],v;i;i=nxt[i]) {
			v=to[i];
			in[v]--;
			if (in[v]==0) {
				dis[v]=dis[u]+1;
				q.push(v);
			}
		}
	}
	if (cnt!=n*n) printf("-1\n");
	else printf("%d\n",mx);
	return 0;
}

Measured memory_bytes: 30976
LI = lambda: list(map(int, input().split()))

N, M = LI()
AB = [LI() for _ in range(M)]


class Node:

    def __init__(self, num):
        self.num = num
        self.parent = None

    def root(self):
        if self.parent is None:
            return self
        self.parent = self.parent.root()
        return self.parent


class UnionFind:

    def __init__(self, n):
        self.n = n
        self.nodes = [Node(i) for i in range(n)]
        self.groups = {i: 1 for i in range(n)}
    
    def unite(self, x, y):
        x = self.nodes[x].root().num
        y = self.nodes[y].root().num
        if x == y:
            return
        if self.groups[x] < self.groups[y]:
            x, y = y, x
        self.groups[x] += self.groups[y]
        del self.groups[y]
        self.nodes[y].parent = self.nodes[x]
    
    def same(self, x, y):
        a = self.nodes[x].root()
        b = self.nodes[y].root()
        return True if a == b else False


def main():
    uf = UnionFind(N)
    for a, b in AB:
        uf.unite(a - 1, b - 1)
    ans = max(uf.groups.values())
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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

vector<ll> acc;

int main() {

#ifndef ONLINE_JUDGE
    //freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m, v, p;
    cin >> n >> m >> v >> p;
    vi arr(n);
    for (int &x : arr)cin >> x, acc.pb(x);
    sort(ALL(arr));
    sort(ALL(acc));
    range(i, 1, n - 1)acc[i] += acc[i - 1];

    loop(i, n) {
        if (arr[i] == arr[n - p]) {
            cout << n - i << endl;
            return 0;
        }

        int cur = arr[i] + m;
        int curv = v - p;
        int idx = upper_bound(ALL(arr), cur) - arr.begin();
        if (idx < n - p + 1)continue;
        if (curv <= 0) {
            cout << n - i << endl;
            return 0;
        }

        idx = n - p + 1;
        ll have = curv * 1LL * m;
        ll canTake = (idx - 1 - i) * 1LL * cur - acc[idx - 1] + acc[i]; // bigger than me
        canTake += 1LL * i * m;

        if (canTake >= have) {
            cout << n - i << endl;
            return 0;
        }
    }

    assert(0);

    return 0;
}


Measured memory_bytes: 1784
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int h,i;
  int n;
  for(h=1;cin>>n,n;h++){
    int x[50],y[50];
    for(i=0;i<n;i++)
      cin>>x[i]>>y[i];
    int sm=0;
    for(i=2;i<n;i++)
      sm+=(x[i-1]-x[0])*(y[i]-y[0])-(x[i]-x[0])*(y[i-1]-y[0]);
    printf("%d %.1lf\n",h,fabs(sm)/2);
  }
  return 0;
}

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

int main()
{
	string A;
	cin >> A;
	ll n = A.size();
	ll res = 1;
	for (ll i = 1; i < n - 1; i++) {
		res += min(i, n - 1 - i);
	}
	for (ll i = 1; i < n; i++) {
		res += min(i, n - i);
	}
	vector<ll> cnt(26);
	for (auto c : A) {
		cnt[c - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (cnt[i] >= 2) {
			res -= cnt[i] * (cnt[i] - 1) / 2;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
a,b = map(int,input().split())
#for i in range(b):
#    A=list(map(int,input().split()))
As=[]
for i in range(b):
    A=list(map(int,input().split()))
    As.append(A)
B=list(map(int,input().split()))

count=0
arr=[]
for i in range(2**a):
    tmp=bin(i)
    tmparr=[int(j) for j in tmp[2:]]
    while len(tmparr)<a:
        tmparr.insert(0,0)
    #arr.append(tmparr)
    #print(tmparr)

    for num,j in enumerate(As):
        on=0
        flag=1
        #print(j,tmparr)
        for k in j[1:]:
            on=on^tmparr[k-1]
        if  B[num]!=on:
            flag=0
            break
            #count+=1
            #print(tmparr)
    if flag==1:
        count+=1
print(count)
       


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

vector< ll > ret;

vector<ll> divisor(ll n) {
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}


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

bool isPrime(ll num)
{
    if (num < 1) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    
    return true;
}

int main(){
    ll a,b;
    cin >> a >> b;
    
    
    ll gcd = findGcd(a, b);

    divisor(gcd);
    
    int ans = 0;
    
    for(ll i = 0; i < ret.size(); i++){
        if(isPrime(ret[i])) ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int n;
		n=sc.nextInt();
		char ch[] = String.valueOf(n).toCharArray();
		for(int i=0;i<3;i++)
		{
			if(ch[i]==49)
				ch[i]=57;
			else
				ch[i]=49;
		}
		System.out.println(ch);
	}
}


Measured memory_bytes: 22868
from itertools import accumulate
n=int(input()) 
S=[]
T=[0]*n
for i in range(n):
    s,t=input().split()
    S.append(s)
    T[i]=int(t)
x=input()
Tsum=list(accumulate(T))
print(Tsum[-1]-Tsum[S.index(x)])


Measured memory_bytes: 38256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a,b;
		a=sc.nextInt();
		b=sc.nextInt();
		if(a>b){;
		System.out.println("a > b");}
		else if(a==b)
			System.out.println("a == b");
		else
			    System.out.println("a < b");
		sc.close();
        }
}


Measured memory_bytes: 26148
#!/usr/bin/ruby
#encoding: utf-8

n,x = gets.split.map(&:to_i)
m = Array.new(n)
(0..n-1).each do |i|
  m[i] = gets.to_i
end

msum = m.inject(:+)
min = m.min
puts n + (x-msum)/min


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

using namespace std;
using ll = long long;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> L(M), R(M);
  int maxl=0, minr=100010;
  for (int i = 0; i < M; ++i) {
    cin >> L[i] >> R[i];
    maxl = max(maxl, L[i]);
    minr = min(minr, R[i]);
  }
  cout << max(0, minr-maxl+1) << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int a, b; cin >> a >> b;
	cout << a + b/2 << endl;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll N;
    cin >> N;
    rep(i, N) {
        if (floor((i+1) * 1.08) == N) {
            print(i+1);
            return 0;
        }
    }
    print(":(");
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int k = sc.nextInt();
    Set<Integer> available = new HashSet<>();
    for (int i = 0; i < 10; i++) {
      available.add(i);
    }
    for (int i = 0; i < k; i++) {
      available.remove(sc.nextInt());
    }

    while (!isOk(n, available)) n++;
    os.println(n);
  }

  private static boolean isOk(int value, Set<Integer> available) {
    while (value > 0) {
      int d = value % 10;
      if (!available.contains(d)) return false;
      value /= 10;
    }
    return true;
  }

  private static class Scanner {

    private final InputStream is;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    Scanner(InputStream is) {
      this.is = is;
    }

    private boolean hasNextByte() {
      if (ptr < buflen) {
        return true;
      } else {
        ptr = 0;
        try {
          buflen = is.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (buflen <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte()) {
        return buffer[ptr++];
      } else {
        return -1;
      }
    }

    private static boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
        ptr++;
      }
      return hasNextByte();
    }

    public String next() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    public long nextLong() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

    public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
        throw new NumberFormatException();
      }
      return (int) nl;
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }
}


Measured memory_bytes: 21204
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt64(scanner)
	b := getNextInt64(scanner)
	c := getNextInt64(scanner)
	d := getNextInt64(scanner)
	ans := a * c
	ans = max(ans, a*d)
	ans = max(ans, b*c)
	ans = max(ans, b*d)
	fmt.Fprintln(writer, ans)
}
func max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 1816
#include<stdio.h>
int main(void)
{
	int a,op,b;
	for(;;){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='+'){
			printf("%d",a+b);
		}else if(op=='-'){
			printf("%d",a-b);
		}else if(op=='*'){
			printf("%d",a*b);
		}else if(op=='/'){
			printf("%d",a/b);
		}else{
			break;
		}
		printf("\n");
	}
	return 0;
}

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

int main(void){
  char s;
  int a[26]={0};
  while (cin >> s) {
    if (cin.eof()) break;
    if(isalpha(s)){
      a[(char)tolower(s)-'a']++;
    } 
  }
  for (int i=0;i<26;i++) {
    cout << (char)('a'+i) << " : " << a[i] << endl;
  }
}


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

int main() {
    int A, B;
    cin >> A >> B;
    int ans;

    if(A == B) {
        ans = 2*A;
    }
    else {
        if(A < B) {
            int t = A;
            A = B;
            B = t;
        }
        
        ans = 2*A - 1;
    }

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

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

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

  vector<int> cards(N);
  
  for(int i=0;i<N;i++){
    cin >> cards.at(i);
  }
  
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());

  int sum = 0;
  for(int i=0;i<N;i++){
    if(i % 2 == 0){
      sum += cards.at(i);
    }else{
      sum -= cards.at(i);
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r1 = ReadSplit();
            var n = r1[0].ToLong();
            var max = r1[1].ToLong();

            var dp = new long[110][];
            var w = new long[n];
            var v = new long[n];
            for (int i = 0; i < 110; i++)
            {
                dp[i] = new long[110000];
            }
            for (int i = 0; i < n; i++)
            {
                var r2 = ReadSplit();
                w[i] = r2[0].ToLong();
                v[i] = r2[1].ToLong();
            }
            for (int i = 0; i < n; i++)
            {
                for (long s = 1; s <= max; s++)
                {
                    if (s - w[i] >= 0)
                    {
                        ChangekMax(ref dp[i + 1][s], dp[i][s - w[i]] + v[i]);
                    }
                    ChangekMax(ref dp[i + 1][s], dp[i][s]);
                }
            }
            WriteRead(dp[n].Max());
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int ToInt32(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long ToLong(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal ToDecimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double ToDouble(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))


        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 110716
H, W = map(int, input().split())
grid = []

for h in range(H):
    temp = []
    line = input()
    for w in range(W):
        temp.append(line[w])
    grid.append(temp)

for h in range(H):
    if all([grid[h][w] == '.' for w in range(len(grid[h]))]):
        for w in range(len(grid[h])):
            grid[h][w] = ''

for w in range(W):
    if all([grid[h][w] in ('', '.') for h in range(len(grid))]):
        for h in range(len(grid)):
            grid[h][w] = ''

for h in range(len(grid)):
    if not all([grid[h][w] == '' for w in range(len(grid[h]))]):
        print(''.join(grid[h]))

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

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

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


int T, n, m, to[10101];
vector<int> v[404];
vector<P> G[404];
vector<vector<int>> dist(404, vector<int>(404, INF));
vector<int> route[404][404];
int now = 1, next_t = 0;
int have[404] = {0};

void floyd(){
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= n; k++){
				if(dist[j][k] > dist[j][i] + dist[i][k]){
					//route[j][k] = route[j][i]+route[i][k];
					route[j][k] = route[j][i];
					route[j][k].insert(route[j][k].end(),route[i][k].begin(),route[i][k].end());
					dist[j][k] = dist[j][i] + dist[i][k];
				}
			}
		}
	}
}

P choice_next(int start, int t){
	i64 ma = -1, k = -1;
	for(int i = 2; i <= n; i++){
		if(!have[i]) continue;
		if(dist[start][i] >= T-t) continue;
		int cnt = 0;
		for(int j = 0; j < route[start][i].size(); j++){
			cnt += have[route[start][i][j]];
		}
		if(ma < cnt * 10000000 / (dist[start][i]*dist[start][i])){
			ma = cnt;
			k = i;
		}
	}
	return P(ma, k);
}

int Move(int start, int next_t){
	P choice = choice_next(start, next_t);
	int ma = choice.first, k = choice.second;
	if(ma >= 1){
		int npos = route[start][k][0];
		have[npos] = 0;
		for(int i = 0; i < dist[now][npos]; i++){
			if(next_t >= T) break;
			next_t++;
			cout << npos << endl;
		}
		now = npos;
		next_t = Move(now, next_t);
		
		return next_t;
	}
	for(int i = route[1][now].size()-2; i >= -1; i = route[1][now].size()-2){
		int npos;
		if(i == -1) npos = 1;
		else npos = route[1][now][i];
		for(int j = 0; j < dist[now][npos]; j++){
			if(next_t >= T) break;
			next_t++;
			cout << npos << endl;
		}
		now = npos;
	}
	return next_t;
}

int main(){
	cin >> n >> m;
	for(int i = 0; i <= n; i++){
		dist[i][i] = 0;
	}
	for(int i = 0; i < m; i++){
		int a,b,c;
		cin >> a >> b >> c;
		G[a].push_back(P(b,c));
		G[b].push_back(P(a,c));
		dist[a][b] = c;
		dist[b][a] = c;
		route[a][b].push_back(b);
		route[b][a].push_back(a);
	}
	cin >> T;
	for(int i = 0; i < T; i++){
		int a,b,c;
		cin >> a;
		if(a){
			cin >> b >> c;
			v[c].push_back(i);
			to[i] = c;
		}
	}
	
	floyd();
	
	for(int t = 0; t < T; t++){
		if(now == 1) have[to[t]]++;
		if(next_t > t) continue;
		next_t = Move(1, t);
		if(next_t == t){
			cout << -1 << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 27136
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>


using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
	cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	
	int score[2] = {};
	for(int i=0;i<n;i++){
	score[i%2] += a[i];
	}
	cout << score[0] - score[1] << endl;
	
	return 0;
}

Measured memory_bytes: 256