akhauriyash/Code-Regression huggingface dataset:
// AOJ 585 Nearest Two Points
// 2017.9.24 bal4u
// 2018.3.17
// 2018.5.3

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef struct { int x, y; } PP;

#define INF  0x10101010

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

PP L[500005], R[500005];

int cmp(PP *a, PP *b) { return a->x - b->x; }

void merge(PP *p, int low, int mid, int high)
{
	int n1, n2, i, j, k;

	n1 = mid-low, n2 = high-mid;
	memcpy(L, p+low, sizeof(PP)*n1);
	memcpy(R, p+mid, sizeof(PP)*n2);
	L[n1].y = R[n2].y = INF;

	i = 0, j = 0;
	for (k = low; k < high; k++) {
		if (L[i].y <= R[j].y) p[k] = L[i++];
		else                  p[k] = R[j++];
	}
}

int closest_pair(int n, PP *p)
{
	int m, i, j, t;
	int ans, d, x;
	long long ld;

	if(n <= 1) return INF;
	m = n >> 1;
	x = p[m].x;
	ans = closest_pair(m, p);
	d   = closest_pair(n-m, p+m);
	if (d < ans) ans = d;
	merge(p, 0, m, n);

	t = 0;
	for (i = 0; i < n; i++) {
		d = p[i].x-x; if (d < 0) d = -d;
		if (d >= ans) continue;

		for (j = 0; j < t; j++) {
			int dx = p[i].x - L[t-1-j].x;
			int dy = p[i].y - L[t-1-j].y;
			if (dy >= ans) break;
			ld = (long long)dx*dx + (long long)dy*dy;
			if (ld < ans) ans = ld;
		}
		L[t++] = p[i];
	}
	return ans;
}

PP p[500005];

int main()
{
	int n, i;

	n = in();
	for (i = 0; i < n; i++) p[i].x = in(), p[i].y = in();
	qsort(p, n, sizeof(PP), cmp);
	printf("%d\n", closest_pair(n, p));
	return 0;
}


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

int main() {
    int n, u, l;
    cin >> n;
    u = n/100; l = n - u*100;
    if(u > 0 && u <= 12) {
        u = 1;
    } else {
        u = 0;
    }
    if(l > 0 && l <= 12) {
        l = 1;
    } else {
        l = 0;
    }
    if(u && l) {
        cout << "AMBIGUOUS" << '\n';
    } else if(u && !l) {
        cout << "MMYY" << '\n';
    } else if(!u && l) {
        cout << "YYMM" << '\n';
    } else {
        cout << "NA" << '\n';
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        new Main();
    }

    static final int N = 8;
    int[][] input;

    QueensBoard board = new QueensBoard();

    public Main() {
      try{
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String s = bf.readLine();
        int n = Integer.parseInt(s);
        input = new int[n][n];

        for(int i=0 ; i<n ; i++){
          StringTokenizer S = new StringTokenizer(bf.readLine());
          for(int j=0 ; j<2 ; j++){
          input[i][j] = Integer.parseInt(S.nextToken());
            }
          }
        }
      catch(IOException e){
        System.out.println(e);
      }
        dfs(0);
    }

    //深さ優先探索
    boolean dfs(int y) {
        if (y == N) {
            if (board.checkInput(input)) {
                System.out.println(board);
                return true;
            }
            return false;
        }
        for (int x = 0; x < N; x++) {
            if (!board.isAttacked(x, y)) {
                board.setQueen(x, y, true);
                if (dfs(y + 1)) {
                    return true;
                }
                board.setQueen(x, y, false);
            }
        }
        return false;
    }

    //クイーンの配置ボード クラス
    class QueensBoard {
        boolean[] row = new boolean[N];            //行(─)の襲撃を表す
        boolean[] col = new boolean[N];            //列(│)の襲撃を表す
        boolean[] pos = new boolean[2 * N - 1];    //斜め(／)の襲撃を表す
        boolean[] neg = new boolean[2 * N - 1];    //逆斜め(＼)の襲撃を表す
        boolean[][] board = new boolean[N][N];     //クイーンの配置を表す
        //配置によるフラグのセット
        void setQueen(int x, int y, boolean flg) {
            row[y] = flg;
            col[x] = flg;
            pos[y + x] = flg;
            neg[y - x + N - 1] = flg;
            board[y][x] = flg;
        }
        //既に襲撃フラグがあるか
        boolean isAttacked(int x, int y) {
            if (row[y] || col[x] || pos[y + x] || neg[y - x + N - 1]) {
                return true;
            }
            return false;
        }
        boolean checkInput(int[][] input) {
            for (int i = 0; i < input.length; i++) {
                int y = input[i][0];
                int x = input[i][1];
                if (!board[y][x]) {
                    return false;
                }
            }
            return true;
        }
        @Override
        public String toString() {
            final StringBuilder sb = new StringBuilder(N * N + N);
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    sb.append(board[i][j] ? "Q" : ".");
                }
                if(i!=7)sb.append("\n");
            }
            return sb.toString();
        }
    }
}



Measured memory_bytes: 24980
#include <iostream>
#include <algorithm>

using namespace std;

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

int dp[50][3001];
int n, m, s;
const int mod = 100000;

int main() {
	while (cin >> n >> m >> s, n || m || s) {
		n *= n;
		
		fill(dp[0], dp[n + 1], 0);
		
		dp[0][0] = 1;
		FOR(i, 1, m + 1) for (int j = n - 1; j >= 0; j--) REP(k, s + 1) {
			if (k + i > s) break;
			dp[j + 1][k + i] += dp[j][k];
			dp[j + 1][k + i] %= mod;
		}
		
		
		cout << dp[n][s] << endl;
	}
	return 0;
}

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

vector<int> sieve_of_eratosthenes(int n) {
  vector<int> primes(n);
  for (int i = 2; i < n; ++i)
    primes[i] = i;
  for (int i = 2; i*i < n; ++i)
    if (primes[i])
      for (int j = i*i; j < n; j+=i)
        primes[j] = 0;
  return primes;
}

vector<int> like_numbers(int n){

  vector<int> prime(n);
  prime=sieve_of_eratosthenes(n);
  vector<int> like(n);
  for(int i=1;i<n;++i){
    if(prime.at(i)!=0 && prime.at((i+1)/2)!=0){
      like[i]=1;
    }
  }
  return like;
}


int main(){
  int Q;
  cin>>Q;
  
  vector<int> l(Q),r(Q);
  for(int i=0;i<Q;++i){
    cin>>l.at(i)>>r.at(i);
  }

  vector<int> like_list(100010);
  like_list=like_numbers(100010);

  vector<int> sum(100010);
  sum.at(0)=0;

  for(int i=1;i<100005;++i){
    sum.at(i)=sum.at(i-1)+like_list.at(i);
  }
  
  for(int i=0;i<Q;++i){
  cout<<sum.at(r.at(i))-sum.at(l.at(i)-1)<<endl;
  }
}

Measured memory_bytes: 2176
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int n;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>n;
	int cur=0;
	rep(i,n){
		char p;
		int x;
		cin>>p>>x;
		if(p=='(')cur+=x;
		else cur-=x;
		if(cur<0){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<(cur==0?"YES":"NO")<<endl;
}

Measured memory_bytes: 1196
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
int n,m,k;
using namespace std;

struct UnionFind {
    vector<int> par; 
    vector<int> sizes;
    UnionFind(int N) : par(N),sizes(N,1) { 
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { 
        int rx = root(x); 
        int ry = root(y); 
        if (rx == ry) return; 
        if (sizes[rx]<sizes[ry])swap(rx,ry);
        // xがyの親になるように連結する
        par[ry] = rx; 
        sizes[rx]+=sizes[ry];
    }

    bool same(int x, int y) { 
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int size(int x){
        return sizes[root(x)];
    }

};
int brockcount[111111],friendcount[111111];
signed main(){
	cin>>n>>m>>k;
	UnionFind uf(n+10),ufx(n+10);
	rep(i,m){
	    int a,b;
	    cin>>a>>b;
	    friendcount[a]++;
	    friendcount[b]++;
	    uf.unite(a,b);
	}
	rep(i,k){
	    int a,b;
	    cin>>a>>b;
	    if(uf.same(a,b)){
	        brockcount[a]++;
	        brockcount[b]++;
	    }
	    ufx.unite(a,b);
	}
	rep(i,n){
	    cout<<uf.size(i+1)-brockcount[i+1]-1-friendcount[i+1]<<" ";
	}
	cout<<endl;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<Int> A(N);
	for (int i = 0; i < N; ++i) { cin >> A[i]; }

	Int ans = 0;
	for (int i = 1; i < N; ++i) {
		if (A[i - 1] > A[i]) {
			ans += A[i - 1] - A[i];
			A[i] = A[i - 1];
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 4820
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 1;

        while (true) {
            int x = sc.nextInt();

            if (x == 0) {
                break;
            }

            System.out.println("Case " + i + ": " + x);
            i++;
        }
    }
}



Measured memory_bytes: 42532
import sys
s = input()
t = input()
dic = {'a':0,'b':1,'c':2,'d':3,'e':4,'f':5,'g':6,'h':7,'i':8,'j':9,'k':10,'l':11,'m':12,'n':13,'o':14,'p':15,'q':16,'r':17,'s':18,'t':19,'u':20,'v':21,'w':22,'x':23,'y':24,'z':25}
sl = [0]*26
tl = [0]*26
for i in s: sl[dic[i]] += 1
for i in t: tl[dic[i]] += 1
sl.sort()
tl.sort()
for i in range(26):
    if sl[i] != tl[i]:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 3632
from collections import Counter as c
N = int(input())
a = []
for _ in range(N):
  a.append(" ".join(sorted(input())))
a.sort()
l = c(a).items()
res = 0
for e in l:
  k = e[1]
  res += k * (k - 1) // 2
print(res)
  

Measured memory_bytes: 20520
n = int(input())
li_a = list(map(int, input().split()))

for a in li_a:
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            pass
        else:
            print('DENIED')
            exit(0)
else:
    print('APPROVED')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,kanou,ans;
  ans=0;
  cin>>n;
  vector<int> itirann(n);
  vector<vector<pair<int,int>>> vec(n,vector<pair<int,int>>(n));
  for(int i=0; i<n; i++){
    cin>>itirann.at(i);
    for(int j=0; j<itirann.at(i); j++){
      cin>>vec.at(i).at(j).first;
      cin>>vec.at(i).at(j).second;
    }
  }
  for (int bit = 0; bit < (1<<n); ++bit){
    kanou=1;
    for(int i=0; i<n; i++){
      //hitosyuukai
      if(bit & (1<<i) ){//syouzikikadouka
        for(int j=0; j<itirann.at(i); j++){//kyogihantei
          if(vec.at(i).at(j).second==1){
            if(!(bit & (1<<vec.at(i).at(j).first-1) ) ){
              kanou=0;
              
            }
          }
          else{
            if(bit & (1<<vec.at(i).at(j).first-1) ){
              kanou=0;
            }
          }
        }
      }
    }
    if(kanou==1){
      
      int k=0;
      int m;
      m=bit;
      while(m>0){
        k=k+m%2;
        m=m/2;
        
      }
      
      ans=max(ans,k);
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    //O(log2(max(a,b,c)))
    ll cnt=0;
    if(a==b&&b==c&&c==a){
        if(a%2==0&&b%2==0&&c%2==0)cout<<-1<<endl;
        else cout<<0<<endl;
    }
    else {
        while(a%2==0&&b%2==0&&c%2==0){
        ll half_a=a/2,half_b=b/2,half_c=c/2;
        a=half_b+half_c;b=half_a+half_c;c=half_a+half_b;
        ++cnt;
        }
        cout<<cnt<<endl;
    }
    return 0;
    }


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll a;cin>>a;
  cout<<3*a*a<<endl;

}


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

int fac(int k);

int main() {
	int A[3][3];
	int N;
	int b[10];
	
	int ans=0;
	
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			cin >> A[i][j];
		}
	}
	
	cin >> N;
	
	for(int i=0; i<N; i++){
		cin >> b[i];
		for(int m=0; m<3; m++){
			for(int n=0; n<3; n++){
				if(b[i]==A[m][n]){
					A[m][n]=0;
					break;
				}
			}
		}
	}
	
	if(A[0][0]+A[1][1]+A[2][2]==0){
		ans=1;
	}
	else if(A[0][2]+A[1][1]+A[2][0]==0){
		ans=1;
	}
	else{
	//cout << ans <<endl;
	
		for(int i=0; i<3; i++){
			int wa1=0;
			int wa2=0;
		
			for(int j=0; j<3; j++){
			
				wa1 += A[i][j];
				wa2 += A[j][i];
			}	
				if(wa1==0 || wa2==0){
					ans=1;
					//cout << i << endl;
				}
			
		}
	}
	if(ans==1){
		cout << "Yes" <<endl;
	}
	else{
		cout << "No" << endl;
	}
	
	//for(int i=0; i<3; i++){
		//for(int j=0; j<3; j++){
			//cout << A[i][j] << " ";
		//}
		//cout << endl;
	//}
}


int fac(int k){
    int sum=1;
    for (int i = 1; i <= k; i++)
    {
        sum = sum*i;
    }
    return sum;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B&lang=ja

int main() {
  while (1) {
    int n, x;
    cin >> n >> x;
    if (n == 0 && x == 0) break;
    int res = 0;
    for (int i = 1; i <= n - 2; ++i) {
      int l = i + 1;
      int r = n;
      while (l < r) {
        int sum = i + l + r;
        if (sum <= x) {
          if (sum == x) {
            ++res;
          }
          ++l;
        } else {
          --r;
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 3132
import java.util.Scanner;

// https://atcoder.jp/contests/abc143/tasks/abc143_a

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        // === ans1 ===
        int ans = a - b * 2;
        if(0 <= ans) {
            System.out.println(ans);
        } else {
            System.out.println(0);
        }

   
    }
}

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

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

    int n;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    vector<int> B(n + 1, 0);
    for(int i = 0; i < n; i++){
        B[i + 1] = A[i] + B[i];
    }

    int ans = 1e9;
    for(int i = 0; i < n; i++){
        ans = min(ans, abs(B[n]-B[i + 1]-B[i + 1]));
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  long X,N;
  int n;

  cin >> n;
  vector<long> vec(n);
  for(int i = 0;i < n;++i){
    cin >> vec.at(i);
  }

  X = -2000000000;
  N = vec.at(0);

  for(int i = 1;i < n;++i){
    X = max(X,vec.at(i) - N);
    N = min(N,vec.at(i));
  }

  cout << X << endl;
  return 0;

}



Measured memory_bytes: 4412
def line_input(f, type):
    return f(map(type, input().split(" ")))

n = input()
a = line_input(tuple, int)

from collections import Counter
c = Counter(a)
ans = 0
for k, v in c.items():
    if k > v:
        ans += v
    else:
        ans += v - k

print(ans)

Measured memory_bytes: 18168
str = input()

def check(text):
  if text=='A' or text=='G' or text=='C' or text=='T':
    return 1
  else:
    return 0

longest=0
sum=0
str=str+'B'
for i in str:
  if check(i)==1:
    sum+=1
  else:
    if longest<sum:
      longest=sum
      sum=0
    else:
      sum=0
print(longest)
    

Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	int i, N, temp, count = 1, H[100];
	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf("%d", &H[i]);
	}

	temp = H[0];
	for (i = 1; i < N; i++) {
		if (temp <= H[i]) {
			count++;
			temp = H[i];
		}
	}

	printf("%d", count);

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double S = Math.PI*r*r;
        double l = Math.PI*2*r;
        System.out.printf("%f %f",S,l);
    }
}


Measured memory_bytes: 28268
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
struct Range {
	int A, B, C;
};
vector<Range>V;
bool Pos(int A, int B, int K) {
	return A <= 1ll*K*(B + 1) && B <= 1ll*K*(A + 1);
}
void Do(int A, int B, int K) {
	int i;
	if (A >= K && Pos(A - K, B, K)) {
		int b = 1, e = A / K, r = 1;
		while (b <= e) {
			int mid = (b + e) >> 1;
			if (Pos(A - K*mid, B - mid + 1, K))r = mid, b = mid + 1;
			else e = mid - 1;
		}
		V.push_back({ K,1,r - 1 });
		V.push_back({ K,0,1 });
		A -= K*r, B -= (r - 1);
		if (!B)return;
		V.push_back({ 0,1,1 });
		Do(A, B - 1, K);
		return;
	}
	int b = 0, e = min(A,K), r = 0;
	while (b <= e) {
		int mid = (b + e) >> 1;
		if (Pos(A - mid, B, K))r = mid, b = mid + 1;
		else e = mid - 1;
	}
	if (r) {
		V.push_back({ r,0,1 });
		Do(A - r, B, K);
		return;
	}
	if (!A) {
		V.push_back({ 0,B,1 });
		return;
	}
	if (B == (A + 1)*K) {
		V.push_back({ 0,K,1 });
		V.push_back({ 1,K,A });
		return;
	}
	V.push_back({ 0,B - A*K,1 });
	V.push_back({ 1,K,A });
	return;
}
int main() {
	int Q, A, B, C, D, i, j;
	scanf("%d", &Q);
	while (Q--) {
		scanf("%d%d%d%d", &A, &B, &C, &D);
		int K = max((A + B) / (B + 1), (A + B) / (A + 1));
		V.clear();
		Do(A, B, K);
		int pv = 0;
		C--, D--;
		for (i = 0; i < V.size(); i++) {
			if (V[i].A + V[i].B == 0)continue;
			int ed = pv + (V[i].A + V[i].B)*V[i].C - 1;
			for (j = max(pv, C); j <= min(ed, D); j++) {
				if ((j - pv) % (V[i].A + V[i].B) < V[i].A)printf("A");
				else printf("B");
			}
			pv = ed + 1;
		}
		printf("\n");
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
  ll n,k;
  cin >> n >> k;

  ll ans = 0;
  for(ll i=k+1;i<=n;i++){
	ans += (i-k)*(n/i);
	if(k <= n%i) ans += n%i-(k-1);
  }

  if(k == 0) ans = n*n; 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    #n = int(stdin.readline().rstrip())
    x,k,d = map(int, stdin.readline().rstrip().split())
    #L = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    if abs(x) >= k*d:
        print(abs(x) - k*d)
        exit()
    else:
        a = abs(x) // d
        if abs(abs(x) - d*a) >= abs(abs(x) - d*(a+1)) and (k-a-1)%2 == 0:
            print(abs(abs(x) - d*(a+1)))
            exit()
        elif abs(abs(x) - d*a) >= abs(abs(x) - d*(a+1)) and (k-a-1)%2 == 1:
            print(abs(abs(x) - d*a))
            exit()
        elif abs(abs(x) - d*a) <= abs(abs(x) - d*(a+1)) and (k-a)%2 == 0:
            print(abs(abs(x) - d*a))
            exit()
        elif abs(abs(x) - d*a) <= abs(abs(x) - d*(a+1)) and (k-a)%2 == 1:
            print(abs(abs(x) - d*(a+1)))
            exit()

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
int n;
int main(){
	cin>>n;
	if(n >= 30){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

	
	return 0;
}


Measured memory_bytes: 3612
package main

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

var sc = bufio.NewScanner(os.Stdin)

// 1行読み込み
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 読み込みをint型へキャスト
func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if(err != nil) {
		panic(err)
	}
	return num
}

// 読み込みをfloat型へキャスト
func nextFloat() float64 {
	sc.Scan()
	num, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return num
}

func main() {
	// scannerの挙動を改行区切り → 空白区切りに変更
	sc.Split(bufio.ScanWords)
	x := nextInt()
	n := nextInt()
	p_list := make([]int, 0, n)
	if n == 0 {
		fmt.Println(x)
		return
	}
	for i := 0; i < n; i++ {
		p_list = append(p_list, nextInt())
	}
	p_check := make([]int, 200, 200)
	// p_check[x - 1]++
	for _, i := range p_list {
		p_check[i - 1]++
	}

	x_next := x
	x_befo := x
	for i := x; i < 1000; i++ {
		if p_check[i - 1] == 0 {
			x_next = i
			break
		}
	}
	for i := x; i > -1000; i-- {
		if i == 0 {
			x_befo = i
			break
		}
		if p_check[i - 1] == 0 {
			x_befo = i
			break
		}
	}
	next_abs := int(math.Abs(float64(x_next - x)))
	befo_abs := int(math.Abs(float64(x_befo - x)))

	if next_abs == befo_abs {
		fmt.Println(x_befo)
	} else if next_abs > befo_abs {
		fmt.Println(x_befo)
	} else {
		fmt.Println(x_next)
	}
}

Measured memory_bytes: 1756
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""


N, K =  map(int, sys.stdin.readline().split())
L =  list(sys.stdin.readline().rstrip())

target = 0
for a, b in zip(L, L[1::]):
    if a != b:
        target += 1

print(min(N - 1, N - (target - 2 * K) - 1))

Measured memory_bytes: 75884
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
    	ll n, a, b;
    	cin>>n>>a>>b;
    	if((b - a)&1){
    		cout<<min((a + b - 1)/2, (2*n - a - b + 1)/2);
    	}else{
    		cout<<(b - a)/2;
    	}
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  string s;
  cin >> s;
  int n, k;
  n=s.size();
  k=0;
  for (int i=0; i<n; i++) {
    if (s.at(i)=='C') {
      for (int j=i; j<n; j++) {
        if (s.at(j)=='F') {
          k=k+1;
        }
      }
    }
  }
  if (k>=1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#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 EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#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;
}

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

LL dp[51][2510];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, A; cin >> N >> A;
  VI xs(N);
  REP(i,N) cin >> xs[i];
  dp[0][0] = 1;
  REP(i,N){
	for(int k=i;k>=0;--k)
	  for(int j=2500;j>=xs[i];--j)
		dp[k+1][j] += dp[k][j-xs[i]];
  }

  LL ans = 0;
  FOR(i,1,N+1){
	if(i*A <= 2500)
	  ans += dp[i][i*A];
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1280
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] tx = scanner.nextLine().split(" ", 2);
        int t = Integer.parseInt(tx[0]);
        int x = Integer.parseInt(tx[1]);
        System.out.println((double)t / (double)x);
    }
}


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

int main () {
  int in;
  int ans = 0;

  int m = 101;
  for (int i = 0; i < 4; i++) {
    cin >> in;
    ans += in;
    m = min(in, m);
  }
  ans -= m;

  m = 101;
  for (int i = 0; i < 2; i++) {
    cin >> in;
    ans += in;
    m = min(in, m);
  }
  ans -= m;

  cout << ans << endl;
}

Measured memory_bytes: 3076
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, x[3009], y[3009], ok[5009][160];
int main() {
	while (scanf("%d", &n), n) {
		for (int i = 0; i < n; i++) {
			scanf("%d%d", &x[i], &y[i]);
			ok[x[i]][y[i] >> 5] |= 1 << (y[i] & 31);
		}
		int ret = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				int va = x[j] - x[i], vb = y[j] - y[i];
				int ex = x[i] + vb, ey = y[i] - va;
				int fx = x[j] + vb, fy = y[j] - va;
				if (0 <= ex && ex <= 5000 && 0 <= ey && ey <= 5000 && 0 <= fx && fx <= 5000 && 0 <= fy && fy <= 5000 && (ok[ex][ey >> 5] & 1 << (ey & 31)) && (ok[fx][fy >> 5] & 1 << (fy & 31))) {
					ret = max(ret, va * va + vb * vb);
				}
			}
		}
		printf("%d\n", ret);
		for (int i = 0; i < n; i++) ok[x[i]][y[i] >> 5] -= 1 << (y[i] & 31);
	}
	return 0;
}

Measured memory_bytes: 6316
#include <iostream>
using namespace std;
int dp[102][102];
int main()
{
    int x,y,i,j,t1,t2;
    cin>>x>>y;
    //dp[x][2]=1;
    //dp[x][4]=1;
    for(i=0;i<=x;i++){
        for(j=0;j<=y;j++)dp[i][j]=0;
    }
    dp[x][0]=1;
    for(i=x-1;i>=0;i--){
        for(j=1;j<=y;j++){
            if(y-2<0){
                t1=0;
            }
            else{
                t1=dp[i+1][j-2];
            }
            if(y-4<0){
                t2=0;
            }
            else{
                t2=dp[i+1][j-4];
            }
            dp[i][j]=t1|t2;
        }
    }
    if(dp[0][y]==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3640
"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
    for (var line of lines) {
        var l = line.trim().split(' ').map(Number);
	var h=l[0];
	var w=l[1];

	if (h===0 && w===0) {
	    break;
	}
	//console.log('h: ', h, 'w: ', w )
	console.log(aux(h,w));
    }
});

function aux(h,w)
{
    var l=[];
    l[0] = '';
    l[1] = '';
    var s='';
    for (var i=0; i<w; i++) {
	l[0] += (i%2===0) ? '#' : '.';
	l[1] += (i%2===1) ? '#' : '.';
    }
    l[0] += '\n';
    l[1] += '\n';
    
    //console.log('l[0]: ', l[0]);
    //console.log('l[1]: ', l[1]);
    
    for (var j=0; j<h; j++) {
	s += l[j % 2];
    }
    //console.log('s: ', s)

    return(s);
}


Measured memory_bytes: 16380
n = int(input())
xu = [list(input().split()) for i in range(n)]
ans = 0
for i in range(n) :
    xu[i][0] = float(xu[i][0])
    if xu[i][1] == "JPY" :
        ans += xu[i][0]

    else :
        ans += xu[i][0]*380000

print(ans)


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

int main()
{
  int N,X,T,ans=0;
  
  cin >> N >> X >> T;
  if(N%X!=0){
  	ans = N/X*T + T;
  }else{
    ans = N/X*T;
  }
  
  cout << ans;
  return 0;
}
    

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

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

  int p = 0;
  int w = 0;
  int g = 0;
  int y = 0;
  for (int i=0; i< N; i++) {
    string S;
    cin >> S;

    if (S=="P" && p==0) {
      p += 1;
    } else if (S=="W" && w==0) {
      w += 1;
    } else if (S=="G" && g==0) {
      g += 1;
    } else if (S=="Y" && y==0) {
      y += 1;
    }
  }
  if (p+w+g+y==4){
    cout << "Four" << endl;
  } else if (p+w+g+y==3) {
    cout << "Three" << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;


void solve()
{
    string x;
    cin>>x;
    if(x[2]==x[3] && x[4]==x[5])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  val r = (0 until 2).map{ i =>
    var r1 = StdIn.readLine().toInt
    val r2 = StdIn.readLine().toInt
    if(r1 < r2) r1 else r2
  }.sum

  println(r)
}


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

using namespace std;
void print_vector(vector<int>& vec){
    for(auto x : vec){
        cout << x << " ";
    }
    cout << endl;
}

void postorder(vector<int>& pre, vector<int>& in, vector<int>& ret){
    if(in.size() <= 1){
        for(auto it = in.begin(); it != in.end(); ++it){
            ret.push_back(*it);
        }
        return;
    }
    //print_vector(pre);
    //print_vector(in);
    //cout << endl;
    int root = pre[0];
    int ln = find(in.begin(), in.end(), root) - in.begin();

    vector<int> pre_left {};
    pre_left.insert(pre_left.begin(), pre.begin()+1, pre.begin()+ln+1);
    vector<int>in_left {};
    in_left.insert(in_left.begin(), in.begin(), in.begin()+ln);

    vector<int> pre_right {};
    pre_right.insert(pre_right.begin(), pre.begin()+ln+1, pre.end());
    vector<int> in_right {};
    in_right.insert(in_right.begin(), in.begin()+ln+1, in.end());

    vector<int> pre_mid {root};
    vector<int> in_mid {root};

    postorder(pre_left, in_left, ret);
    postorder(pre_right, in_right, ret);
    postorder(pre_mid, in_mid, ret);
}
int main(){
    int n;
    cin >> n;
    vector<int> pre {};
    vector<int> in {};
    for(int i = 0; i < n; ++i){
        int temp;
        cin >> temp;
        pre.push_back(temp);
    }
    for(int i = 0; i < n; ++i){
        int temp;
        cin >> temp;
        in.push_back(temp);
    }
    vector<int> post {};
    postorder(pre, in, post);
    for(auto it = post.begin(); it != post.end(); ++it){
        if(it == post.begin()){
            cout << *it;
        } else {
            cout << " " << *it;
        }
    }
    cout << endl;
}

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

int n;
vector<long long> l;

int main() {
  cin >> n;
  l.resize(n);
  for (auto &p : l) cin >> p;
  int res = 0;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j)
      for (int k = j + 1; k < n; ++k) {
        vector<int> v;
        v.push_back(l[i]);
        v.push_back(l[j]);
        v.push_back(l[k]);
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
        if (v.size() != 3) continue;
        if (v[0] + v[1] > v[2]) ++res;
      }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>

#define MIN ( -1LL << 60 )
#define T 10
#define MAXN 100

typedef long long  ll;

using namespace std;

int A[T];
int N;
int F[MAXN][T];
int P[MAXN][T+1];

ll cal ( int A[] )
{
  ll sum = 0;
  int cnt = 0;

  for ( int i = 0; i < N; ++i ) {
    cnt = 0;
    for ( int j = 0; j < T; ++j ) if ( A[j] == 1 && F[i][j] == 1 ) ++cnt;
    sum += P[i][cnt];
  }

  return sum;
}

ll findmin ( int pos )
{
  if ( pos == T ) {
    for ( int i = 0; i < T; ++i ) if ( A[i] == 1 ) return cal(A);
    return MIN;
  } else {
    ll tmp1, tmp2;
    A[pos] = 0;
    tmp1 = ( findmin(pos+1));
    A[pos] = 1;
    tmp2 = ( findmin(pos+1));

    return max(tmp1,tmp2);
  }
}

int main()
{
  cin >> N;

  for ( int i = 0; i < N; ++i ) for ( int j = 0; j < T; ++j ) scanf("%d", &F[i][j]);
  for ( int i = 0; i < N; ++i ) for ( int j = 0; j <= T; ++j ) scanf("%d", &P[i][j]);

  cout << findmin(0) << "\n";
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        //static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var CSF = new Tuple<long, long, long>[N - 1];//C,S,F
            for(var i=0;i<N-1;++i)
            {
                var csf = Sarray();
                CSF[i] = Tuple.Create(csf[0], csf[1], csf[2]);
            }
            for (var i = 0; i < N - 1; ++i)
            {
                //駅iから出発したとき加算していく
                var next = CSF[i].Item2 + CSF[i].Item1;
                for (var s = i + 1; s < N - 1; ++s)
                {
                    var t = next + (CSF[s].Item3 - next % CSF[s].Item3) % CSF[s].Item3;
                    t = Max(t, CSF[s].Item2);
                    next = t + CSF[s].Item1;
                }
                WriteLine(next);
            }
            WriteLine(0);
            //Out.Flush();
        }
    }
}


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

const long long MOD = 1e9+7;

char S[1000005];
long long fact[2000005];
long long inv[1000005];
long long invFact[1000005];
long long pow26[1000005];

int main(){
    int K;
    scanf("%d", &K);
  
  	/*getchar_unlocked();
  
  	int N = 0;
	while(getchar_unlocked() != EOF){
    	N ++;
    }*/

    scanf(" %s", S);
    int N = strlen(S);

    fact[0] = fact[1] = 1;
    inv[1] = 1;
    invFact[0] = invFact[1] = 1;
    for(int i = 2; i <= N+K; i++){
        fact[i] = fact[i-1]*i%MOD;
    }
  
  	for(int i = 2; i <= max(K, N); i ++){
      	inv[i] = (MOD-MOD/i)*inv[MOD%i] % MOD;
      	invFact[i] = invFact[i-1]*inv[i]%MOD;
    }

  	long long pow25 = 1;
    pow26[0] = 1;
    for(int i = 1; i <= K; i ++){
        pow26[i] = pow26[i-1]*26%MOD;
    }

    long long ans = 0;
  	const long long temp = inv[26];
    for(int i = 0; i <= K; i ++){
        ans += ((fact[i+N-1]*invFact[i]%MOD)*pow25%MOD) * pow26[K-i]%MOD;
      	pow25 = pow25*25%MOD;
      	//pow26 = (pow26*temp)%MOD;
    }

    ans %= MOD;
  	ans = ans*invFact[N-1]%MOD;
    printf("%lld", ans);
    return 0;
}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int H, W;
char A[1010][1010];
ll dp[1010][1010];
const int mod = 1000000000 + 7;

int main(){

    cin >> H >> W;
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            cin >> A[i][j];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            ll res = 0;
            if(i == 0 && j == 0){
                res = 1;
            }
            else{
                if(i-1>=0 && A[i-1][j] == '.')
                    (res += dp[i-1][j]) %= mod;
                if(j-1>=0 && A[i][j-1] == '.')
                    (res += dp[i][j-1]) %= mod;
            }
            dp[i][j] = res;
        }
    }

    cout << dp[H-1][W-1] << endl;
    

    return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll x;
    cin >> x;
    ll cnt=0;
    ll dx=x/11;
    cnt+=dx*2;
    ll sum=dx*11;
    if(sum<x){
        sum+=6;
        cnt++;
    }
    if(sum<x){
        sum+=5;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3612
N,Y = list(map(int, input().split()))
answer = "-1 -1 -1"
for a in range(0,N+1):
    for b in range(0,N-a+1):
        c = N-a-b
        sum = a*10000 + b*5000 + c*1000
        if Y == sum:
            answer = "%s %s %s"%(a,b,c)
print(answer)


Measured memory_bytes: 2940
N=int(input())
if N==1:
  print(0)
  exit(0)
#a=[i for i in range(1,N)]
#print(sum(a))
if (N-1)%2==0:
  print(N*((N-1)//2))
else:
  print(N*((N-1)//2)+((N-1)//2)+1)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

class UnionFind{
public:
  vector<int> parent;
  UnionFind(int N){
    parent=vector<int>(N,-1);
  }
  int root(int A){
      if(parent[A]<0) return A;
      return parent[A]=root(parent[A]);
  }
  int size(int A){
    return -parent[root(A)];
  }
  bool connect(int A,int B){
    A=root(A);
    B=root(B);
    if(A==B){
      return false;
    }
    if(size(A)<size(B))swap(A,B);
    parent[A]+=parent[B];
    parent[B]=A;
    return true;
  }
};

signed main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(M),B(M);
  rep(i,M){
    cin>>A[i]>>B[i];
    A[i]--;
    B[i]--;
  }
  vector<int> ans(M);
  ans[M-1]=N*(N-1)/2;
  UnionFind uni(N);
  for(int i=M-1;i>=1;i--){
    ans[i-1]=ans[i];
    if(uni.root(A[i])!=uni.root(B[i])){
      ans[i-1]-=uni.size(A[i])*uni.size(B[i]);
      uni.connect(A[i],B[i]);
    }
  }
  rep(i,M){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 6424
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
struct Eratosthnes {
    n: usize,  // incluesive
    bprime: Vec<bool>,  // self.bprime[5] = true
    primes: Vec<usize>, // self.primes[2] = 5
}
#[allow(dead_code)]
impl Eratosthnes {
    fn new(n: usize) -> Eratosthnes {
        let mut bprime = vec![true; n + 1];
        let mut primes = vec![];
        bprime[0] = false;
        bprime[1] = false;
        for i in 2..(n as f64).sqrt() as usize + 1 {
            if !bprime[i] { continue; }
            primes.push(i);
            if i * i > n { continue; }
            let mut j = i * i;
            while j <= n {
                bprime[j] = false;
                j += i;
            }
        }
        Eratosthnes {
            n: n,
            bprime: bprime,
            primes: primes,
        }
    }
}

fn main() {
    let n = 1e+5 as usize + 10;
    let era = Eratosthnes::new(n as usize);
    let mut sums = vec![0; n];
    for i in 1..n {
        if era.bprime[i] && era.bprime[(i + 1) / 2] { sums[i] += 1; }
        sums[i] += sums[i - 1];
    }
    let q: usize = read();
    for _ in 0..q {
        let l: usize = read();
        let r: usize = read();
        println!("{}", sums[r] - sums[l - 1]);
    }
}

Measured memory_bytes: 4732
import java.util.*;

class Main{
    final static long mod = 1000000007;
    //
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = a % 10;
        int c = a / 100;
        if(b == c) System.out.println("Yes");
        else System.out.println("No");
    }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

    vector<int> R(9,0);
    REP(i,N){
        int a; cin >> a;
        int r = a/400;
        if(r < 8) R[r]++;
        else R[8]++;
    }
    int cnt = 0;
    REP(i,8){
        if(R[i]>0) cnt++;
    }
    
    if(cnt==0 && R[8]>0){
        cout << 1 << " " << R[8] << endl;
    }else cout << cnt << " " << cnt+R[8] << endl;

    
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    if(k==0){
        cout << n*n<<endl;
        return 0;
    }
    for(ll i=k;i<=n;i++){
        ll num=n/i;
        ans+=(i-k)*num;
        ans+=max(n-num*i-k+1,0LL);
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

h, w = map(int, input().split())
a = [input().rstrip('\n') for i in range(h)]
cnt = 0

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            cnt += 1

if cnt == h + w - 1:
    print('Possible')
else:
    print('Impossible')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,a,b) for(ll i=(a);i<(b);i++)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);i--)
#define vi vector<int>
#define de deque<int>
#define del deque<ll>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define mpp map<ll,ll>
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define ln(a) a.length()
#define sz(a) a.size()
#define endl "\n"
int M=1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

string s,t;
cin>>s>>t;
int n=ln(s);int m=ln(t);
int dp[n+1][m+1];
memset(dp,0,sizeof dp);
f(i,1,n+1)
{
    f(j,1,m+1)
    {
     if(s[i-1]==t[j-1])
    {dp[i][j]=1+dp[i-1][j-1];}
     else
    {dp[i][j]=max(dp[i-1][j],dp[i][j-1]);}
    }
}
//cout<<dp[n][m]<<endl;
string ans="";
int i=n,j=m;
while(i>0 && j>0)
{
    if(s[i-1]==t[j-1])
        {ans+=s[i-1];i--;j--;}
    else if(dp[i-1][j]>dp[i][j-1]){i--;}
    else{j--;}
}
reverse(ans.begin(),ans.end());
cout<<ans<<endl;
}


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

int main() {
    int N;
    std::cin >> N;
    N = 1000 - N % 1000;
    if (N == 1000) {
        std::cout << 0 << std::endl;
    } else {
        std::cout << N << std::endl;
    }
}
        


Measured memory_bytes: 3632