akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = (1ll<<31)-1;

struct Rmin {
private:
	int N;
	vector<ll> node;

public:
	Rmin(vector<ll> v) {
		int size = v.size();
		N = 1;
		while (N < size) N <<= 1;
		node.resize(2*N-1, INF);

		for (int i=0; i < size; i++) node[i+N-1] = v[i];
		for (int i=N-2; i>=0; i--) node[i] = min(node[(i<<1)+1], node[(i<<1)+2]);
	}

	Rmin(int size) {
		N = 1;
		while (N < size) N <<= 1;
		node.resize(2*N-1, INF);		
	}

	ll Access(int x) {
		return node[x+N-1];
	}

	void Update(int x, ll val) {
		x += N-1;
		node[x] = val;
		while (x > 0) {
			x = (x-1)>>1;
			node[x] = min(node[(x<<1)+1], node[(x<<1)+2]);
		}
		return;
	}

	//[a, b)
	ll GetValue(int a, int b, int k=0, int l=0, int r=-1) {
		if (r < 0) r = N;
		if (a >= r || b <= l) return INF;
		if (a <= l && r <= b) return node[k];
		ll vl = GetValue(a, b, (k<<1)+1, l, (l+r)>>1);
		ll vr = GetValue(a, b, (k<<1)+2, (l+r)>>1, r);
		return min(vl, vr);
	}
};

int main() {
	int n, q; cin >> n >> q;
	Rmin segtree(n);
	for (int i = 0; i < q; ++i)
	{
		int com; cin >> com;
		if (com == 0) {
			int x; cin >> x;
			ll y; cin >> y;
			segtree.Update(x, y);
		}
		else {
			int x, y; cin >> x >> y;
			cout << segtree.GetValue(x, y+1) << endl;
		}
	}
}


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

int main() {
  string s;
  cin >> s;
  int w;
  cin >> w;
  string r;
  for (int i = 0; i < s.size(); i += w) {
    r.push_back(s[i]);
  }
  cout << r << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String ans = " ";
		if(S.equals("ABC")){
			ans = "ARC";
		}else{
			ans = "ABC";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35672
#include <bits/stdc++.h>
#define maxn 3086

using namespace std;

int n, m, k;
int a[maxn][maxn];
int x, y, z;
long long f[maxn][maxn][4];

inline void Max(long long &x, long long y){
	x = max(x, y);
}

int main(){
	scanf("%d%d%d", &n, &m, &k);
	while(k--){
		scanf("%d%d%d", &x, &y, &z);
		a[x][y] = z;
	}
	memset(f, -0x3f, sizeof(f));
	f[1][1][0] = 0;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			for(int k = 0;k <= 3;k++){
				Max(f[i][j][k], f[i - 1][j][0]);
				Max(f[i][j][k], f[i - 1][j][1]);
				Max(f[i][j][k], f[i - 1][j][2]);
				Max(f[i][j][k], f[i - 1][j][3]);
				Max(f[i][j][k], f[i][j - 1][k]);
			}
			if(a[i][j]) for(int k = 3;k;k--) Max(f[i][j][k], f[i][j][k - 1] + a[i][j]);
		}
	}
	long long ans = -1e18;
	for(int i = 0;i <= 3;i++) Max(ans, f[n][m][i]);
	printf("%lld", ans);
}


Measured memory_bytes: 337504
#import sys
n, m = map(int, input().split())
s = input()
t = input()

if s[0] != t[0]:
    print(-1)
    exit()
    #sys.exit(0)

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

l = lcm(n, m)
step = min(l//n, l//m)

for i in range(0, l, step):
    if i % (l//n) == 0 and i % (l//m) == 0:
        if s[i * n // l] != t[i * m // l]:
            print(-1)
            exit()
            # sys.exit(0)

print(l)


Measured memory_bytes: 3444
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
res = INF
for i in range(-100,101):
    cnt = sum((i-x)**2 for x in a)
    res = min(res, cnt)
print(res)


Measured memory_bytes: 5068
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> N;
    cout << N+N*N+N*N*N;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
long long res = 0, sum = 0, k, a[501], n;
void check (long long val) {
  multiset <long long> s;
  long long sumf = 0, sumz = 0;
  for (int i = 1; i <= n; ++ i) {
    s.insert (a[i] % val);
    sumf += (val - (a[i] % val));
  }
  for (auto v : s) {
    sumz += v;
    sumf -= (val - v);
    if (sumz == sumf && sumz <= k) {
      res = max (res, val);
    }
  }
}
int main () {
  if (fopen ("test.inp", "r")) {
    freopen ("test.inp", "r", stdin);
  }
  ios_base :: sync_with_stdio (0);
  cin.tie (nullptr);
  cout.tie (nullptr);
  cin >> n >> k;
  for (int i = 1; i <= n; ++ i) {
    cin >> a[i];
    sum += a[i];
  }
  for (long long i = 1; i <= sqrt (sum); ++ i) {
    if (sum % i == 0) {
      check (i);
      check (sum / i);
    }
  }
  cout << res;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<queue>

typedef long long ll;
using namespace std;
const int max_n =1e5 + 1;
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)


int n;
int a[max_n];
int odd, even, fourth;
//set<int>odd,even,fourth;
int main() 
{
	IOS;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] % 2 != 0)
			odd++;
		else if (a[i] % 2 == 0 && a[i] % 4 != 0)
			even++;
		else
			fourth++;
	}
	 
	if (even == 0)
	{
		if (odd > fourth + 1)
			cout << "No";
		else
			cout << "Yes";
	}
	else {
		if (odd > fourth)
			cout << "No";
		else
			cout << "Yes";
	}
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    int A,B;
    int ans = 0;
    cin >> A >> B ;
    while(A <= B){
        int C = A/10000;
        int D = A/1000-C*10;
        int E = A/100-C*100-D*10;
        int F = A/10-C*1000-D*100-E*10;
        int G = A-C*10000-D*1000-E*100-F*10;
        if(C == G && D == F){
            ans = ans + 1;
        }
        A = A + 1 ;
    }
    cout << ans << endl;
    return 0;

}

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

using namespace std;

int main() {
    int N, K;
    int A[100000];

    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    int r = (N - 1) / (K -1);
    if( (N-1) % (K -1) != 0){
        r++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  string str,str2[100]={"AKIHABARA","KIHBR","AKIHBR","KIHABR","KIHBAR","KIHBRA","AKIHABR","AKIHBRA","AKIHBAR","KIHABAR","KIHABRA","KIHBARA","AKIHABAR","AKIHABRA","KIHABARA"};
  cin>>str;
  bool flag=false;
  for(int i=0;i<100;i++){
    if(str.compare(str2[i])==0){
      flag=true;
      break;
    }
  }
  if(flag)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}


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

const int MAXN = 1005;
const int MAXV = MAXN*(MAXN-1)/2;
vector<int> to[MAXV];
int id[MAXN][MAXN];
//頂点番号
int toId(int i, int j) {
    if (i > j) swap(i,j);
    return id[i][j];
}
/*
 i
 [id]
 \ |0  1  2  3
 --+-----------
 0 |   0  1  2
 1 |      3  4
 2 |         5
 [a]
 \ |0  1  2
 --+---------
 0 |1  2  3
 1 |0  2  3
 2 |3  0  1
 3 |2  0  1
 
 [a]
 \ |0  1  2
 --+---------
 0 |0  1  2
 1 |0  3  4
 2 |5  1  3
 3 |5  2  4
 */
bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV]; // max length of path from v
int dfs(int v) {
    if (visited[v]) {
        if (!calculated[v]) return -1;
        return dp[v];
    }
    visited[v] = true;
    dp[v] = 1;
    for (int u : to[v]) {
        int res = dfs(u);
        if (res == -1) return -1;
        dp[v] = max(dp[v], res+1);
    }
    calculated[v] = true;
    return dp[v];
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n-1));
    rep(i,n) {
        rep(j,n-1) {
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    int V = 0;
    rep(i,n)rep(j,n) {
        if (i < j) {
            id[i][j] = V++;
        }
    }
    rep(i,n) {
        //頂点番号に書き換え
        rep(j,n-1) {
            a[i][j] = toId(i,a[i][j]);
        }
        //辺を張る
        rep(j,n-2) {
            to[a[i][j]].push_back(a[i][j+1]);
        }
    }
    int ans = 0;
    rep(i,V) {
        int res = dfs(i);
        if (res == -1) {
            puts("-1");
            return 0;
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 38528
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
const int MAXN = 1e5 + 7;
int n;
string s;
int cntR[MAXN], cntG[MAXN], cntB[MAXN];
void get_count(string s)
{
    if (s[0] == 'R') cntR[0]++;
    else if (s[0] == 'G') cntG[0]++;
    else cntB[0]++;
    for (int i = 1; i < (int)s.size(); i++)
    {
        if (s[i] == 'R')
            cntR[i] = cntR[i - 1] + 1;
        else
            cntR[i] = cntR[i - 1];
        if (s[i] == 'G')
            cntG[i] = cntG[i - 1] + 1;
        else
            cntG[i] = cntG[i - 1];
        if (s[i] == 'B')
            cntB[i] = cntB[i - 1] + 1;
        else
            cntB[i] = cntB[i - 1];
    }
}
int32_t main() {
    fast_io();
    cin >> n >> s;
    get_count(s);
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if (s[i] != s[j])
            {
                if ((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R'))
                {
                    int val = cntB[n - 1] - cntB[j];
                    if (val >= 1)
                    {
                        res += val;
                        if (((2 * j - i) < n) && (s[j + (j - i)] == 'B')) res--;
                    }
                }
                else if ((s[i] == 'G' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'G'))
                {
                    int val = cntR[n - 1] - cntR[j];
                    if (val >= 1)
                    {
                        res += val;
                        if (((2 * j - i) < n) && (s[j + (j - i)] == 'R')) res--;
                    }
                }
                else if ((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R'))
                {
                    int val = cntG[n - 1] - cntG[j];
                    if (val >= 1)
                    {
                        res += val;
                        if (((2 * j - i) < n) && (s[j + (j - i)] == 'G')) res--;
                    }
                }
            }
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
  #endif

  long long a,b,c,k;
  cin >> a >> b >> c >> k;

  long long a1, b1, c1;
  a1 = min(a, k);
  k -= a1;
  b1 = min(b, k);
  k -= b1;
  c1 = min(c, k);
  k -= c1;

  cout << a1+(c1*-1) << endl;

  return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < 10; i++) {
    if (n % i == 0 && n / i < 10) {
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<long long> &v) {
    std::for_each(v.begin(), v.end(),
                  [](long long x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    long long N;
    cin >> N;
    map<long long, long long> m;
    vector<long long> a(N);
    REP(i, N) { cin >> a[i]; }
    REP(i, N) {
        long long cnt = 0;
        while(a[i] % 2 == 0) {
            a[i] /= 2;
            cnt++;
        }
        a[i] = cnt;
        if(a[i] > 2) {
            a[i] = 2;
        }
        m[a[i]]++;
    }
    if(m[1] == 0) {
        if(m[0] <= m[2] + 1) {
            cout << "Yes" << endl;
        } else {
            cout << " No " << endl;
        }
        return 0;
    }
    if(m[0] <= m[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        if (n < 1200) {
            System.out.println("ABC");
        } else if (n < 2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
    }

    static final class Util {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Util() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}


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

int main() {
	int H, W;
	cin >> H >> W;

	vector<int> vy = {-1, -1, -1,  0, 0,  1, 1, 1};
	vector<int> vx = {-1,  0,  1, -1, 1, -1, 0, 1};

	vector<string> vecs(H + 2);
	string dummy = "dd";
	for (int j = 0; j < W; j++) {
		dummy += 'd';
	}
	vecs.at(0) = dummy;
	for (int i = 0; i < H; i++) {
		string s;
		cin >> s;
		vecs.at(i+1) = 'd' + s + 'd';
	}
	vecs.at(H+1) = dummy;

	for (int i = 0; i < H; i++) {
		string line = "";
		for (int j = 0; j < W; j++) {
			if (vecs.at(i + 1).at(j + 1) == '.') {
				//int cnt = 0;
				char cnt = '0';
				for (int k = 0; k < 8; k++) {
					if (vecs.at(i + 1 + vy.at(k)).at(j + 1 + vx.at(k)) == '#') {
						cnt++;
					}
				}
				//line += char(cnt + '0');	// intをcharに変換
				line += cnt;	// cntはchar型
			}
			else {
				line += vecs.at(i + 1).at(j + 1);
			}
		}
		cout << line << endl;
	}
}

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

using namespace std;

bool isSolved[101][101];
int pena[101][101];
int solvedCnt[101];
int teamPena[101];

typedef pair<int,int> pii;
typedef pair<pii,int> ppii;

int main(){
  int T,P,R;
  while(cin>>T>>P>>R&&(T|P|R)){
    memset(isSolved,0,sizeof(isSolved));
    memset(pena,0,sizeof(pena));
    memset(solvedCnt,0,sizeof(solvedCnt));
    memset(teamPena,0,sizeof(teamPena));
    for(int i=0;i<R;i++){
      int tid,pid,time;
      string msg;
      cin>>tid>>pid>>time>>msg;
      if(msg=="WRONG"){
	pena[tid][pid]++;
      }
      else if(!isSolved[tid][pid]){
	isSolved[tid][pid]=true;
	solvedCnt[tid]++;
	teamPena[tid]+=pena[tid][pid]*1200+time;
      }
    }
    vector<ppii> vp;
    for(int i=1;i<=T;i++){
      vp.push_back(make_pair(pii(-solvedCnt[i]
				 ,teamPena[i]),i));
    }
    sort(vp.begin(),vp.end());
    for(int i=0;i<(int)vp.size();i++){
      cout<<vp[i].second<<" "<<-vp[i].first.first<<" "<<vp[i].first.second<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 972
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}

char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
string s1,s2,s3;
  cin>>s1>>s2>>s3;
  cout<<tobig(s1[0])<<tobig(s2[0])<<tobig(s3[0]);
  
      
}
// int *p = new int[N];

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
#define REPSTR(i,s) for(int i=0; (s)[i]; i++)
#define REPITR(i,s) for(auto i=(s)begin(); i!=(s).end();i++)

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

#define ALL(a) (a).begin(), (a).end()

#define EXIST(s,x) ((s).find(x)!=(s).end())

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#define DEBUG(x) cerr<<#x<<":"<<x<<endl
#define PRINTJOIN(x,n) rep(i,n){if(i)cout<<" ";cout<<x[i];}cout<<endl 

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef stringstream SS;

#define PQ priority_queue

#define FST first
#define SEC second

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

//------------------HEAD---------------------

char _field[1005][1005];
int field[1005][1005];

int h,w;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w;
    rep(x,h){
        rep(y,w){
            char t;
            cin>>t;
            _field[x][y]=t=='.'?0:t-'1'+1;
        }
    }
    queue<PII> Q;
    FOR(x,1,h-1){
        FOR(y,1,w-1){
            if(_field[x][y]==0){
                field[x][y]=0;
                continue;
            }
            int s=0;
            rep(i,8){
                if(_field[x+dx[i]][y+dy[i]]==0)s++;
            }
            field[x][y]=max(0,_field[x][y]-s);
            if(_field[x][y]<=s)Q.push(mp(x,y));
        }
    }
    if(Q.empty()){
        cout<<0<<endl;
        return 0;
    }
    int cnt=1;
    Q.push(mp(-1,-1));
    while(!Q.empty()){
        PII p=Q.front();Q.pop();
        int x=p.FST;int y=p.SEC;
        if(p==mp(-1,-1)){
            if(Q.empty())break;
            else{
                cnt++;
                //cerr<<"wave "<<cnt<<endl;
                Q.push(mp(-1,-1));
            }
            continue;
        }
        rep(i,8){
            int nx=x+dx[i];
            int ny=y+dy[i];
            if(field[nx][ny]==0)continue;
            field[nx][ny]--;
            if(field[nx][ny]==0){
                Q.push(mp(nx,ny));
                //cerr<<"("<<nx<<","<<ny<<") crashed"<<endl;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 8036
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int a,b;
	while(~getII(a,b)) printf("%d\n",max(a,b)+max(max(a,b)-1,min(a,b))); 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

constexpr int P = 1000000007;

int inv(int n) {
    int m = P, y = 0, v = 1;
    while (1) {
        int q = m / n;
        int r = m % n;
        if (r == 0) return v < 0 ? v + P : v;
        y -= v * q;
        swap(y, v);
        m = n;
        n = r;
    }
}

int comb(int n, int k) {
    if (n < k || k < 0) return 0;
    int64_t t = 1;
    k = min(k, n - k);
    for (int i = 2; i <= k; i++) {
        t = (t * i) % P;
    }
    t = inv(t);
    for (int i = n - k + 1; i <= n; i++) {
        t = (t * i) % P;
    }
    return t;
}

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    a = h - a;
    h--; w--;
    
    int64_t r = 0, s = comb(h + w - b, h), t = 1;
    for (int i = 0; i < a; i++) {
        if (i != 0) {
            s = s * inv(h + w - b - (i - 1)) % P * (h - (i - 1)) % P;
            t = t * (b - 1 + i) % P * inv(i) % P;
        }
        //if (i < 10) cout << s << ' ' << t << endl;
        r += s * t % P;
        //b+i C i
        //
    }

    cout << r % P << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

dp = [[0]*(N+1) for i in range(N+1)]
#数列の長さ
for w in range(1,N+1):
    #左の位置
    for l in range(N-w+1):
        #右の位置
        r = l + w
        dpl = -dp[l+1][r] + a[l]
        dpr = -dp[l][r-1] + a[r-1]
        dp[l][r] = max(dpl,dpr)
print(dp[0][N])

Measured memory_bytes: 112220
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  vector<int> a(3);
  rep(i, 3) cin >> a[i];

  sort(a.begin(), a.end()); 
  int ans = 10000000; 
  do {
    int sum = 0;   
    sum = abs(a[1] - a[0]) + abs(a[2] - a[1]);
    ans = min(sum , ans);
  } while(next_permutation(a.begin(), a.end()));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
import itertools
import heapq
import bisect
import math
import queue
from operator import itemgetter #sortedの対象を決めたい
from fractions import gcd #最大公約数
from copy import deepcopy #参照で影響されないコピー
from collections import Counter, deque, defaultdict #要素ごとの出現回数、双方向アクセス可能データ型
from functools import reduce
mod = 1000000007
inf = 10**10
sys.setrecursionlimit(1000000)

input = sys.stdin.readline

def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res
 
def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)
# template


def main():
    n, w = map(int, input().split())
    dp = np.zeros(w+1)

    for _ in range(n):
        weight, value = map(int, input().split())

        dp[weight:] = np.maximum(dp[weight:], dp[:-weight]+value)

    print(int(dp[-1]))

if __name__ == "__main__":
    main()



Measured memory_bytes: 16276
#define _USE_MATH_DEFINES
#pragma region include

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N, i;
	cin >> N >> i;
	int ans = N+1 - i;
	cout << ans << endl;
}

#pragma region main
signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

int main()
{
	int W, H, N, res;
	cin >> W >> H >> N;
	vector<vector<bool>> is(W, vector<bool>(H));
	res = W * H;
	for (int i = 0, x, y, a; i < N; i++) {
		cin >> x >> y >> a;
		switch (a) {
		case 1:
			for (int i = 0; i < x; i++) {
				for (int j = 0; j < H; j++) {
					if (!is[i][j]) {
						res--;
						is[i][j] = true;
					}
				}
			}
			break;
		case 2:
			for (int i = x; i < W; i++) {
				for (int j = 0; j < H; j++) {
					if (!is[i][j]) {
						res--;
						is[i][j] = true;
					}
				}
			}
			break;
		case 3:
			for (int i = 0; i < W; i++) {
				for (int j = 0; j < y; j++) {
					if (!is[i][j]) {
						res--;
						is[i][j] = true;
					}
				}
			}
			break;
		case 4:
			for (int i = 0; i < W; i++) {
				for (int j = y; j < H; j++) {
					if (!is[i][j]) {
						res--;
						is[i][j] = true;
					}
				}
			}
			break;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    S = input()
    head = int(S[:2])
    tail = int(S[2:])

    def can_month(i):
        return 1 <= i and i <= 12

    if can_month(head):
        if can_month(tail):
            print('AMBIGUOUS')
        else:
            print('MMYY')
    else:
        if can_month(tail):
            print('YYMM')
        else:
            print('NA')


main()

Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();

        int pos = 0;
        for (int i = 0; i < n; ++i) {
            pos += sc.nextInt();
            if (pos > x) {
                System.out.println(i + 1);
                return;
            }
        }
        System.out.println(n + 1);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
ll a[3009][3009];
ll b[200003];
ll n,m;
bool vis[1009][1009];
struct threeElements{
int _1st,_2nd,_3rd;
};
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   //18:17
    ll x;
    cin>>x;
    int q=x%11;
    x=x*1.0/11;
    x*=2;
    if(q==0)
        return cout<<x,0;
    if(q<=6)
        x++;
    else
        x+=2;
    cout<<x;
}


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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl "\n"

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
	while(x!=parent[x]){
		parent[x] = parent[parent[x]];
		x = parent[x];
	}
	return x;
}

void sunion(int x,int y){
	int rx = root(x);
	int ry = root(y);
	if(rx != ry){
		if(Size[rx] > Size[ry]){
			parent[ry] = parent[rx];
			Size[rx] += Size[ry];
		}
		else{
			parent[rx] = parent[ry];
			Size[ry] += Size[rx];
		}
	}
}
*/

ll n,k;
ll dp[100001];

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

ll solve(ll x){
	if(x==k) dp[x] = 1;
	else{
		ll a = k/x;
		ll ans = binpow(a,n);
		for(ll i=2*x;i<=k;i+=x){
			ans = (ans-dp[i]+INF)%INF;
		}
		dp[x] = ans;
	}
	return dp[x];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		cin >> n >> k;
		ll ans=0;
		for(ll i=k;i>=1;i--){
			// cout << solve(i) << endl;
			ans = (ans+(i*solve(i))%INF)%INF;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 4320
#include<stdio.h>
int main()
{
    long long A,B,X;
    scanf("%lld %lld %lld",&X,&A,&B);
    if(A-B>=0)
    {
        printf("delicious");
    }
    else if(A-B>=-X)
    {
        printf("safe");
    }
    else if(A-B<-X)
    {
        printf("dangerous");
    }
    return 0;
}

Measured memory_bytes: 128
N, Q, S, *L = open(0).read().split()
N = int(N)
Q = int(Q)
l = -1
r = N
while l+1<r:
  s = (l+r)//2
  p = S[s]
  m = s
  for t,d in zip(*[iter(L)]*2):
    if p==t:
      if d=='L':
        m -= 1
      else:
        m += 1
    if m<=-1:
      l = s
      break
    if N<=m:
      r = s
      break
    p = S[m]
  else:
    r = s
ans = l+1
l = -1
r = N
while l+1<r:
  s = (l+r)//2
  p = S[s]
  m = s
  for t,d in zip(*[iter(L)]*2):
    if p==t:
      if d=='L':
        m -= 1
      else:
        m += 1
    if N<=m:
      r = s
      break
    if m<=-1:
      l = s
      break
    p = S[m]
  else:
    l = s

ans += N-r
print(N-ans)

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

namespace ProconTemplate
{
    class Doing
    {
        public static void Main(string[] args)
        {
            var inputInt = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            if(inputInt[1] % inputInt[0] == 0){
                Console.WriteLine(inputInt[0] + inputInt[1]);
            }
            else
            {
                Console.WriteLine(inputInt[1] - inputInt[0]);
            }
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> x(n);
    for(int i=0;i<n;i++)cin>>x[i];
    int ans=1e9;
    for(int i=0;i<n-k+1;i++){
        int l=x[i],r=x[i+k-1];
        int sum=min(abs(l)+abs(r-l),abs(r)+abs(r-l));
        if(ans>sum)ans=sum;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
long long n, m;
long long dp[100000];
vector<long long> graph[100000];
bool used[100000];
stack<long long> topsort;
void dfs(long long vertex)
{
    if(!used[vertex])
    {
        used[vertex]=true;
        for(int i=0;i<graph[vertex].size();i++)
        {
            dfs(graph[vertex][i]);
        }
        topsort.push(vertex);
    }
}
int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        long long x,y;
        cin>>x>>y;
        graph[x-1].push_back(y-1);
    }
    for(int i=0;i<n;i++)
    {
        if(!used[i])
        {
            dfs(i);
        }
    }
    for(int i=0;i<n;i++)
    {
        long long vertex=topsort.top();
        topsort.pop();
        //cout<<vertex<<endl;
        for(int i=0;i<graph[vertex].size();i++)
        {
            dp[graph[vertex][i]]=max(dp[graph[vertex][i]],dp[vertex]+1);
        }
    }
    long long ans=0;
    for(int i=0;i<n;i++)
    {
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8832
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut s1 = buf.trim().to_string();
	let mut flag = true;
	let mut ret:usize = 0;
	if s1.len()%2 == 1 {
		s1 = format!("{}", &s1[..(s1.len()-1)]);
		if &s1[..(s1.len()/2)] == &s1[(s1.len()/2)..] {
			flag = false;
			ret = s1.len();
		}
	}
	let mut s2 = s1.clone();
	if flag {
		for i in 1.. {
			if 2*i >= s1.len() {
				break;
			}
			s2 = format!("{}", &s2[..(s2.len() - 2)]);
			if &s2[..(s2.len()/2)] == &s2[(s2.len()/2)..] {
				ret = s2.len();
				break;
			}
		}
	}
	println!("{}", ret);
}

Measured memory_bytes: 4352
/*input
1000000


*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 998244353
#define ll long long
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define mp make_pair
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(long long* a,long long n,long long val){
	for(long long i=0;i<n;i++)
		a[i]=val;
}

ll fact[10000001],inv[10000001];

ll func(ll n,ll r){
	return (((fact[n]*inv[r])%M)*inv[n-r])%M;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j;
	ll n;
	cin>>n;
	ll ans=power(3,n,M);
	ll k=n/2+1;
	t=0;
	fact[0]=1,inv[0]=1;
	rep(i,1,10000001){
		fact[i]=i*fact[i-1];
		fact[i]%=M;
		inv[i]=power(fact[i],M-2,M);
	}
	rep(i,k,n+1){
		t+=(func(n,i)*(power(2,n-i,M)))%M;
		t%=M;
	}
	t*=2;
	t%=M;
	ans-=t;
	ans+=M;
	ans%=M;
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 156544
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
struct Node{
	int a,b;
	bool operator < (const Node &c)const{return a<c.a;} 
}a[N];
struct Edge{
	int next,to;
}edge[N*4];
int c[N],fi[N],se=1;
inline void add_edge(int u,int v){edge[++se].next=fi[u],edge[se].to=v,fi[u]=se;} 
inline void add(int u,int v){add_edge(u,v),add_edge(v,u);}
bool vis[N],use[N*2];
bool dfs(int x){
	vis[x]=1;
	int w=a[x-1].b;
	for(int i=fi[x];i;i=edge[i].next){
		int v=edge[i].to;
		if(!vis[v]&&dfs(v))w^=1,use[i>>1]^=1;
	}
	return w;
}
int main(){
	int n,m,l,r;scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%d%d",&a[i].a,&a[i].b);
	sort(a,a+n);
	for(int i=n;i;i--)c[i]=a[i].a,a[i].b^=a[i-1].b;c[n]=1e9+5,c[0]=a[0].a;
	for(int i=0;i<m;i++){
		scanf("%d%d",&l,&r);
		l=lower_bound(c,c+n+1,l)-c+1,r=upper_bound(c,c+n+1,r)-c+1;
		add(l,r);
	}
	for(int i=1;i<=n+1;i++)if(!vis[i]&&dfs(i))return puts("-1"),0;
	int num=0;for(int i=1;i<=m;i++)if(use[i])num++;
	printf("%d\n",num);
	for(int i=1;i<=m;i++)if(use[i])printf("%d ",i);
	return 0;
}

Measured memory_bytes: 7424
L=parse(Int,readline())
a=L
l=0
c=0
while a>0
	c+=a%2
	a=div(a,2)
	l+=1
end
println(l,' ',l*2-3+c)
a=1
for i=1:l-1
	println(i,' ',i+1,' ',0)
	println(i,' ',i+1,' ',a)
	if L&a>0
		println(i,' ',l,' ',L-=a)
	end
	a*=2
end


Measured memory_bytes: 164944
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int i;
	char s[100010];
	chin(s);
	for(i=0;i<strlen(s);i+=2)
		putchar(s[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9 + 34;
const int N = (int)1e6 + 34;

typedef long long ll;

void solve()
{
	int n;
	string s;
	cin >> n >> s;
	int ans = n;
	int sumW = 0, sumE = 0;
	for (int i = 0; i < n; i++) if (s[i] == 'E') sumE++;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'E') sumE--;
		int cur = sumW + sumE;
		ans = min(ans, cur);
		if (s[i] == 'W') sumW++;
	}

	cout << ans << "\n";
}

int main()
{
#ifdef SERT
	freopen("a.in", "r", stdin);
	solve();
	solve();
#endif
	solve();
	return 0;
}

Measured memory_bytes: 900
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

const Mod = 1000000007

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func main() {
	sc.Split(bufio.ScanWords)
	n, a, b := readInt(), readInt(), readInt()

	ans := ModPow(2, n)

	ans -= 1

	ans -= ModComb(n, a)
	if ans < 0 {
		ans += Mod
	}

	ans -= ModComb(n, b)
	if ans < 0 {
		ans += Mod
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <limits.h>
#include <map>
#include <string>
#include <bitset>
#include <vector>
using namespace std;
int a[105];
int main() {
    int m,n,sum=0,cnt=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]*m*4>=sum) cnt++;
    }
    if(cnt>=m) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int a[100010];
int main()
{
	int n,i=0,ans=0;
	cin>>n;
	for(int k=1;k<=n;k++)
	{
		cin>>a[k];	
	}
	while(i<n)//Ò»µ©==ËµÃ÷ÐòÁÐÅÅÍê 
	{
		int j=i+1,low=-1,up=-1;
		if(a[j]>=a[j+1])//³¢ÊÔ½µÐò 
		{
			for(;j<=n;j++)
				if(a[j]<a[j+1]||j==n)//Éìµ½½µÐòÁÐÄ©¶Ë 
					{low=j;break;}
			
			j=i+1;//ÌØÅÐµÈÓÚ 
		}
		if(a[j]<=a[j+1])//³¢ÊÔÉýÐò 
		{
			for(;j<=n;j++)
				if(a[j]>a[j+1]||j==n)//Éìµ½upÄ©¶Ë 
					{up=j;break;}
		}
		i=max(up,low);//´æÏÂÄ¿Ç°µÄ×î´óÑÓÉìÁ¿ 
		//i=min(n,i);//±£ÏÕÌØÅÐ 
		ans++;
	//	cout<<1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
import scala.annotation.tailrec
import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._
  val target = "01+-*()="
  val exp = readLine.trim.toList
  val symbol = if (exp.contains('=')) target.filterNot(_ == '=') else target
  val suspects = exp.filter(_.isLetter).distinct
  var result = 0
  for (usage ← symbol.combinations(suspects.length)){
    for (map ← usage.permutations.map{u ⇒ suspects.zip(u).toMap.withDefault(c ⇒ c)}){
      exp.map(map) match {
        case Q() ⇒ result += 1
        case _ ⇒
      }
    }
  }
  println(result)

  object Q{
    def unapply(arg: List[Char]): Boolean = {
      arg match {
        case l E '='::(r E Nil) ⇒ l == r
        case _ ⇒ false
      }
    }
  }
  object E{
    def unapply(arg: List[Char]): Option[(Int, List[Char])] = {
      arg match {
        case l T t ⇒ Some(takeAll(t, l))
        case _ ⇒ None
      }
    }
    @tailrec
    private[this] def takeAll(arg: List[Char], left: Int): (Int, List[Char]) = {
      arg match {
        case '-'::(r T t) ⇒ takeAll(t, left - r)
        case '+'::(r T t) ⇒ takeAll(t, left + r)
        case _ ⇒ (left, arg)
      }
    }
  }
  object T{
    def unapply(arg: List[Char]): Option[(Int, List[Char])] = {
      arg match {
        case l F t ⇒ Some(takeAll(t, l))
        case _ ⇒ None
      }
    }
    @tailrec
    private[this] def takeAll(arg: List[Char], left: Int): (Int, List[Char]) = {
      arg match {
        case '*'::(r F t) ⇒ takeAll(t, left * r)
        case _ ⇒ (left, arg)
      }
    }
  }
  object F{
    def unapply(arg: List[Char]): Option[(Int, List[Char])] = {
      arg match {
        case n N t ⇒ Some(n, t)
        case '-'::(f F t) ⇒ Some(-f, t)
        case '('::(e E ')'::t) ⇒ Some(e, t)
        case _ ⇒ None
      }
    }
  }
  object N{
    def unapply(arg: List[Char]): Option[(Int, List[Char])] = {
      arg.span(_.isDigit) match {
        case ('0'::Nil, t) ⇒ Some(0, t)
        case (n@'1'::_, t) ⇒ Some(n.foldLeft(0){(a, b) ⇒ a * 2 + b.asDigit}, t)
        case _ ⇒ None
      }
    }
  }
  implicit class Extension[T](val value :T) extends AnyVal {
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


Measured memory_bytes: 184528
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <typeinfo>

typedef long long ll;

int main(){
    int a, b;
    std::cin >> a >> b;
    if (a <= 0 && b>=0){
        std::cout << "Zero" << "\n";
        return 0;
    }
    if (a > 0){
        std::cout << "Positive" << "\n";
    } 
    else if (a < 0){
        if ((ll)(b-a+1)%2 != 0) std::cout << "Negative" << "\n";
        else std::cout << "Positive" << "\n";
    }
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n,m;

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

  cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2<<endl;

  return 0;
}


Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
for ($i = 0; $i < $n; ++$i) {
    $a[$i] = trim(fgets(STDIN));
}
$b = $a;
rsort($b);
$sai = $b[0];
$sai1 = $b[1];


for ($i = 0; $i < $n; ++$i) {
    if ($sai != $a[$i])  {
        echo $sai . PHP_EOL;
    } else{
        echo $sai1 . PHP_EOL;
    }

}
?>

Measured memory_bytes: 28528
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}


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

    Int a, b, c;
    cin >> a >> b >> c;
    Int ans = c-(a-b);
    cout << (ans >= 0 ? ans : 0) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(){
    int N;
    cin >> N;
    set<string> U;
    while(N--){
        string id;
        cin >> id;
        U.insert(id);
    }
    bool cl = true;
    int M;
    cin >> M;
    while(M--){
        string T;
        cin >> T;
        if(!U.count(T))T = "Unknown " + T;
        else{
            T = (cl? "Opened by ": "Closed by ") + T;
            cl = !cl;
        }
        cout << T << '\n';
    }
    return 0;
}

Measured memory_bytes: 1228
import sys
input = sys.stdin.readline
def main():
    S = input().rstrip()
    days = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
    today = days.index(S)
    ans = 7 - today
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 38256