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

std::map<std::pair<int, int>, int> field;
std::map<std::pair<int, int>, bool> counted;
std::pair<int, int> points[112345];
int h, w, n;
int dx[9] = {1, 1, 1, 0, 0, -1, -1, -1, 0};
int dy[9] = {1, 0, -1, 1, -1, 1, 0, -1, 0};
long ans[10];

int main() {
  scanf("%d %d %d", &h, &w, &n);
  for(int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d %d", &y, &x);
    points[i].first = x;
    points[i].second = y;
    field[points[i]] = 1;
  }

  ans[0] = (long)(w-2) * (long)(h-2);
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < 9; ++j) {
      int x = points[i].first + dx[j];
      int y = points[i].second + dy[j];
      if( x <= 1 or x >= w ) continue;
      if( y <= 1 or y >= h ) continue;
      if( counted.find(std::make_pair(x, y)) != counted.end() ) continue;
      int count = 0;
      // printf(" %d %d\n", x, y);
      for(int k = 0; k < 9; ++k) {
        int nx = x + dx[k];
        int ny = y + dy[k];
        if( field.find(std::make_pair(nx, ny)) == field.end() ) continue;
        count += 1;
      }
      ans[count] += 1;
      ans[0] -= 1;
      // printf("  %d\n", count);
      counted[std::make_pair(x, y)] = 1;
    }
  }

  for(int i = 0; i < 10; ++i) {
    printf("%ld\n", ans[i]);
  }
  
  return 0;
}



Measured memory_bytes: 63488
#include <stdlib.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;
typedef pair<uint32_t, uint32_t> P;

bool pairCompare(const P& firstElof, const P& secondElof) {
  return firstElof.second > secondElof.second;
}

int main() {
  uint32_t N, M;
  cin >> N >> M;

  vector<uint32_t> A(N);
  vector<pair<uint32_t, uint32_t>> Operation(M);

  for (uint32_t i = 0; i < N; ++i) cin >> A[i];
  for (uint32_t i = 0; i < M; ++i)
    cin >> Operation[i].first >> Operation[i].second;

  sort(A.begin(), A.end());
  sort(Operation.begin(), Operation.end(), pairCompare);

  uint32_t CurIndex = 0;

  for (uint32_t i = 0; i < M; ++i) {
    while (Operation[i].second > A[CurIndex] && Operation[i].first > 0) {
      A[CurIndex] = Operation[i].second;
      ++CurIndex;
      --Operation[i].first;
      if (CurIndex == N) {
        break;
      }
    }
  }

  uint64_t res = 0;
  for (uint32_t i = 0; i < N; ++i) res += A[i];

  cout << setprecision(14) << res << endl;

  return 0;
}


Measured memory_bytes: 1408
import math

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num):
    # ループしながら素数を検索する
    for i in range(input_num, input_num+1000):
        if isPrime(i):
            primenumber = i
            break

    # 素数配列を返す
    return primenumber

def main():
    X = int(input())

    ans = callIsPrime(X)

    print(ans)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
typedef long long ll;
int ceil(int a,int b){// a以上でｂの倍数の最小値を出力//
    return (a+b-1)/b*b;
}
int stoii(string s){//stoi関数の代用//
    return atoi(s.c_str());
}
int main(void){
   string s,t;
   cin>>s>>t;
   rep(i,stoii(s+t)){
       if(i*i==stoii(s+t)) {
           cout<<"Yes"<<endl;
           return 0;
       }
   }
   cout<<"No"<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include <string>
using namespace std;
 
typedef long long ll;
 
 
int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	int l = 0;
	int r =0;
	int res = 0;
	while(l < n && r < n){
		
		//for(int i=0;i<n;++i){
		while(r < n){
			
			string tmp = s.substr(l,r+1-l);
			string rtmp = s.substr(r+1,s.size()-r-1);
			//find
//			if(find(s.begin()+l,s.end(),tmp) == s.end()){
			if(rtmp.find(tmp) != std::string::npos){
				res = max(res,(int)tmp.size());
			}
			else{
//				l = r;
				r++;
				break;
			
			}
			r++;
//			r = r + i;
		}
		l++;
	}
	
	cout << res <<endl;
	
	return 0;
}



Measured memory_bytes: 384
/*

3
0 1 1
1 0 1
1 1 1

3

(1, 2), (2, 1), (3, 3)
(1, 2), (2, 3), (3, 1)
(1, 3), (2, 1), (3, 2)

dp[i][maskw] = No. of ways to pair men [i, i+1, ..., n-1] with women not in {maskw} 

dp[n][] = 1
dp[i][maskw] = SIGMA(dp[i+1][maskw|1<<bit], a[i][bit] = 1 && (1<<bit)&maskw = 0 )

*/

#include <bits/stdc++.h>

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = 1<<30;
const ll MOD = 1e9+7;

int n;
vector<vector<bool> > a;
vector<vector<ull> > dp;

ull f(int i, int maskw){
	int bitset = 0;
	for(int bit=0;bit<n;bit++){
		if((1<<bit)&maskw)
			bitset++;	
	}
	//cout<<i<<" "<<maskw<<" "<<bitset<<"\n";
	if(bitset!=i)
		return 0;
	if(i==n)
		return 1;

	if(dp[i][maskw] != -1)
		return dp[i][maskw];

	dp[i][maskw] = 0;
	for(int bit=0;bit<n;bit++){
		if(a[i][bit] == 1 && !(maskw & (1<<bit)))
			dp[i][maskw] = (dp[i][maskw]+f(i+1, maskw|(1<<bit)))%MOD;
	}
	return dp[i][maskw];
}

int main(){
	
	cin>>n;
	
	a.assign(n+1, vector<bool>(n+1, 0));
	dp.assign(n+1, vector<ull>(pow(2, n), -1));
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			int tmp;
			cin>>tmp;
			a[i][j] = tmp;
		}
	}
	
	cout<<f(0, 0)<<"\n";
	return 0;
}

Measured memory_bytes: 377216
S = input()
N = len(S)

ans = True


def rec(i, j):
    if(i >= j):
        return True
    if(S[i] != S[j]):
        return False
    return ans & rec(i+1, j-1)


ans1 = rec(0, N-1)
ans2 = rec(0, int((N-1)/2)-1)
ans3 = rec(int((N+3)/2)-1, N-1)
if(ans1 & ans2 & ans3):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>

using namespace std;
#define Fill(a, b) memset(a, b, sizeof(a))
#define Debug(x) cout<<#x<<"="<<(x)<<endl;
typedef long long LL;
typedef pair<int, int> P;
const LL inf = 1LL << 61;
const LL mod = 1000000007;
const int max_n = 100010;


int n;
LL T, E;
LL dp[max_n], d[max_n], dp2[max_n], p[max_n];
int main()
{
    int i = 0, j = 0, k = 0;
    LL ans;
    Fill(d, 0), Fill(dp, 0);
    Fill(dp2, 0), Fill(p, 0);
    cin >> n >> E >> T;
    //scanf("%d %I64d %I64d", &n,&E,&T);
    for(i = 1; i <= n; i++)
    {
        cin >> d[i];//scanf("%I64d", d+i);
    }
    if(n==1)
    {
        ans = E+T;
        cout << ans << endl;//printf("%I64d\n", ans);
        return 0;
    }
    int tp;
    for(i = 1; i <= n; i++)
    {
        for(tp = p[i-1]; tp < i; tp++)
        {
            if(T>2*(d[i]-d[tp+1]))
                break;
        }
        p[i] = tp;
    }
    /*
    cout << "p:\n";
    for(i = 1; i <= n; i++)
    {
        cout << p[i] << " ";
    }
    cout << endl;
    */
    dp[1] = T;
    dp2[1] = dp[1]-2*d[2];
    for(i = 2; i <= n; i++)
    {
        tp = p[i];
        dp[i] = max(T, 2*(d[i]-d[1]));
        if(tp>0)
        {
            ans = min(dp[tp]+T, 2*d[i]+dp2[tp-1]);
        }
        else
        {
            ans = dp[tp]+T;
        }
        dp[i] = min(dp[i], ans);
        if(i < n)
            dp2[i] = min(dp2[i-1], dp[i]-2*d[i+1]);
    }
    /*
    cout << "dp:\n";
    for(i = 1; i <= n; i++)
    {
        cout << dp[i] << " ";
    }
    cout << endl;
    */
    ans = dp[n]+E;
    cout << ans << endl;//printf("%I64d\n", ans);




    return 0;
}
/*
5 8 4
1 3 4 6 7
*/










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

int main(void){
   char T[101],H[101];
   int i,n,t=0,h=0;
   
   scanf("%d",&n);
   for(i=0;i<n;i++){
       scanf("%s %s",T,H);
       if(strcmp(T,H)==0) {
           t+=1;
           h+=1;
       }
       else if(strcmp(T,H)>0) t+=3;
       else if(strcmp(T,H)<0) h+=3;
   }
   
   printf("%d %d\n",t,h);
   
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint N; cin >> N;
    lint W; cin >> W;

    vector<lint> w(N);
    vector<lint> v(N);

    REP(i, N) {
      lint x;
      cin >> x; w[i] = x;
      cin >> x; v[i] = x;
    }

    vector<vector<lint>> dp(N+1, vector<lint>(W+1, 0));

    REP(i, N) {
      REP(j, W+1) {
        lint tmp = dp[i][j];
        if(j - w[i] >= 0) {
          tmp = max(tmp, dp[i][j-w[i]] + v[i]);
        }
        dp[i+1][j] = tmp;
      }
    }    
    PRINT(dp[N][W]);
    return 0;
}


Measured memory_bytes: 80256
import itertools

H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
ans = 1e4
for t in itertools.product([0, 1], repeat=H-1):
    cnt = t.count(1)
    SW = []
    tmp = [int(s) for s in S[0]]
    for i, c in enumerate(t):
        if c:
            SW.append(tmp)
            tmp = [int(s) for s in S[i+1]]
        else:
            tmp = [tmp[j] + int(S[i+1][j]) for j in range(W)]
    SW.append(tmp)
    H_ = len(SW)
    sums = [0] * H_
    if max(itertools.chain.from_iterable(SW)) > K:
        continue
    for w in range(W):
        sumtmp = [sums[i] + SW[i][w] for i in range(H_)]
        if max(sumtmp) > K:
            cnt += 1
            sums = [SW[i][w] for i in range(H_)]
        else:
            sums = sumtmp
    ans = min(ans, cnt)
print(ans)        

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

A = []
b = []
num = []
x = 0

for i in range(n):
    a = list(map(int, input().split()))    
    A.append(a)
    
for i in range(m):
    b.append(int(input()))
    
while x < n:
    for i in range(m):
        num.append(A[x][i] * b[i])
        
    x += 1
    
    print(sum(num))
    
    num = []


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

int main() {
  int a,b;
  string c;
  cin>>a>>c;
  b=0;
  if(a%2==1)b=1;
  a=a/2;
  for(int i=0;i<a;i++){
    if(!(c.at(i)==c.at(i+a)))b=1;
  }
  if(b==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

//-----------------------------------------------------------------------------

int n;
int a[]={500,100,50,10,5,1};

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

    while(true) {
	cin>>n;
	if(n==0) break;
	n=1000-n;
	int ans=0;
	REP(i,6) {
		if(n>=a[i]) {
			int tmp=n/a[i];
			ans+=tmp;
			n-=tmp*a[i];
		}
	}
	cout<<ans<<endl;
    }

	return 0;
}



Measured memory_bytes: 3148
import java.util.*;

public class Main {

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

	void run(){
		Scanner in = new Scanner(System.in);
		for(int n=in.nextInt(); n-- > 0; ){
			boolean[][] board = new boolean[10][10];
			for(int i=0; i<10; i++){
				for(int j=0; j<10; j++){
					int x = in.nextInt();
					board[i][j] = x == 1;
				}
			}
			boolean[][] ans = solve(board);
			for(int i=0; i<10; i++){
				for(int j=0; j<10; j++){
					System.out.printf("%d%c",ans[i][j]?1:0, j==9?'\n':' ');
				}
			}
		}
	}

	boolean[][] check(boolean[][] board, int bit){
		boolean[][] tmp = new boolean[10][];
		boolean[][] ans = new boolean[10][10];
		for(int i=0; i<10; i++){
			tmp[i] = board[i].clone();
		}
		for(int j=0; j<10; j++)if(((bit>>j)&1) == 1){
			ans[0][j] = true;
			for(int k=0; k<5; k++){
				int ny = 0 + dy[k], nx = j + dx[k];
				if(0<=ny && ny<10 && 0<=nx && nx<10){
					tmp[ny][nx] = !tmp[ny][nx];
				}
			}
		}
		for(int i=1; i<10; i++){
			for(int j=0; j<10; j++)if(tmp[i-1][j]){
				ans[i][j] = true;
				for(int k=0; k<5; k++){
					int ny = i + dy[k], nx = j + dx[k];
					if(0<=ny && ny<10 && 0<=nx && nx<10){
						tmp[ny][nx] = !tmp[ny][nx];
					}
				}
			}
		}
		for(int j=0; j<10; j++)if(tmp[9][j]) return null;
		return ans;
	}

	boolean[][] solve(boolean[][] board){
		for(int bit=0; bit<1<<10; bit++){
			boolean[][] ans = check(board, bit);
			if(ans != null) return ans;
		}
		return null;
	}

	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include<queue>
#include<map>
using namespace std;
typedef pair< int, int > Pi;
int info[100][100];
bool used[100];

int prim(const int& V) {
    priority_queue< Pi > que;
    que.push(Pi());
    int ret = 0;
    while (!que.empty()) {
        Pi p = que.top(); que.pop();
        if (!~- p.first || used[p.second]++) continue;
        ret -= p.first;
        for (int i = 0; i < V; i++) que.push(Pi(-info[p.second][i], i));
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> info[i][j];
        }
    }
    cout << prim(N) << endl;
}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
 
using namespace std;
 
#define MOD 1000000007
 
int n, p, ta;
long long cnt[2] = {1}, tb, tc;
 
int main() {
	scanf("%d%d", &n, &p);
	while (n--) {
		scanf("%d", &ta);
		tb = cnt[0], tc = cnt[1];
		if (ta & 1)
			swap(tb, tc);
		cnt[0] += tb;
		cnt[1] += tc;
	}
	printf("%lld\n", cnt[p]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

template<class T>
inline void read(T& x) {
  T s = 0, base = 1;
  char c;
  while (!isdigit(c=getchar())) if (c == '-') base = -base;
  while (isdigit(c)) {
    s = s * 10 + (c^48);
    c = getchar();
  }
  x = base * s;
}

int D, G;
int p[10], c[10];

int main() {
  read(D);
  read(G);
  G /= 100;

  REP(i,D) {
    read(p[i]);
    read(c[i]);
    c[i] /= 100;
  }

  int ans = numeric_limits<int>::max();
  for (int i = 0; i < (1 << D); ++i) {
    // i: 使いきったか否かを表すビット
    int sum = 0;
    int cnt = 0;

    for (int j = 0; j < D; ++j) {
      if ((i >> j) & 1) {
        sum += p[j] * (j + 1) + c[j];
        cnt += p[j];
      }
    }

    for (int j = D - 1; j >= 0; --j) {
      if (sum >= G) break;
      if ((i >> j) & 1) continue;
      
      int buf = min((G - sum + j) / (j + 1), p[j]);
      cnt += buf;
      sum += (j + 1) * buf;
      if (buf == p[j]) sum += c[j];
      break;
    }

    if (G <= sum) ans = min(ans, cnt);
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007LL
#define INF 2000000000
#define PI 3.1415926

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

typedef long long ll;

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T> inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	ll a, b; cin >> a >> b;
	a--;
	ll xa, xb;
	if(a % 4 == 0) xa = a;
	else if(a % 4 == 1) xa = 1;
	else if(a % 4 == 2) xa = a+1;
	else xa = 0;

	if(b % 4 == 0) xb = b;
	else if(b % 4 == 1) xb = 1;
	else if(b % 4 == 2) xb = b+1;
	else xb = 0;

	ll ans = xa^xb;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

n,m=map(int,sys.stdin.readline().split())
a=np.array([sys.stdin.readline().split() for _ in range(m)],dtype='int64')

num=[None]*n
for inp in a:
    if num[inp[0]-1]!=None and num[inp[0]-1]!=inp[1]:
        print('-1')
        sys.exit()
    if n!=1 and inp[0]==1 and inp[1]==0:
        print('-1')
        sys.exit()
    num[inp[0]-1]=inp[1]

if num[0]==None and n==1:
    num[0]=0
elif num[0]==None:
    num[0]=1
for i in range(n):
    if num[i]==None:
        num[i]=0
for i in range(n):
    print(num[i],end='')



Measured memory_bytes: 12516
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
long long a[1000010];
int main()
{
	int n,x=1,ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	   cin>>a[i];
	sort(a,a+n);
	for(int i=1;i<n;i++)
	{
		if(a[i]==a[i-1])
		  x=(x+1)%2;
		else
		{
			ans+=x;
			x=1;
		}	  
	}
	if(x%2)
	  ans++;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAXN 100010
#define inf 0x3f3f3f3f
#define LL long long
#define pi acos(-1)
#define MOD 1000000007
using namespace std;

int n,b[500];
char ch;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> ch;
		b[ch]++;
	}
	LL ans=1;
	for (int i = 'a'; i <= 'z'; i++) ans=(ans*(b[i]+1))%MOD;
	cout << ans-1 << endl;
	return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
//const int INF = INT_MAX  ;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;

typedef tuple<ll, int, int, int> PC;

bool isAcgt(char c) {
    return c == 'A' || c == 'C' || c == 'G' || c == 'T';
}

int main() {

    string s;
    cin >> s;


    int count = 0;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (isAcgt(s[i])) {
            count++;
        } else {
            ans = max(ans, count);
            count = 0;
        }
    }
    ans = max(ans, count);
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,tmp;
long long first=-1,second=-1;
vector<int> a;
int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&tmp);
    a.push_back(tmp);
  }
  sort(a.begin(),a.end(),greater<int>());
  tmp=-1;
  for(int i=0;i<n;i++){
    if(tmp!=a[i])tmp=a[i];
    else{
      if(first==-1){
        first=tmp;
        tmp=-1;
      }else if(second==-1){
        second=tmp;
        break;
      }
    }
  }
  printf("%lld", first==-1||second==-1 ? 0 : first*second);
  return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<cstring>
#include<climits>
#include<algorithm>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005

ll dp[MAX];
vector<ll> graph[MAX];
ll n,m;

ll solve(ll src){
    if(src>n) return 0;

    if(dp[src] != -1) return dp[src];

    ll ans=0;
    for(ll i=0; i<graph[src].size(); i++){
        ans = max(ans, solve(graph[src][i])+1);
    }
    dp[src]=ans;
    return dp[src];
}

int main(){
    cin>>n>>m;
    for(int i=1; i<=m; i++){
        ll x,y;
        cin>>x>>y;
        graph[x].push_back(y);
    }

    memset(dp, -1, sizeof(dp));
    ll ans=0;
    for(int i=1; i<=n; i++){
        ans = max(ans, solve(i));
    }
    cout<<(ans)<<endl;
    
    return 0;
}

Measured memory_bytes: 8576
#include "bits/stdc++.h"
//#include "atcoder/all"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
//using namespace atcoder;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	priority_queue<ll> pq;
	rep(i,n){
		ll a;
		cin >> a;
		pq.push(a);
	}
	rep(i,m){
		ll b = pq.top();
		b /= 2;
		pq.pop();
		pq.push(b);
	}
	ll ans = 0;
	rep(i,n){
		ans += pq.top();
		pq.pop();
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4288
import Control.Applicative ((<$>))
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as B

readInts :: IO [Int]
readInts = map (fst . fromJust . B.readInt ) . B.words <$> B.getLine

main :: IO ()
main = do
  (x:y:_) <- readInts
  if x < y
    then putStrLn "a < b"
    else if x > y
        then putStrLn "a > b"
        else putStrLn "a == b"


Measured memory_bytes: 3464
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int e[] = new int[13];
        int i;
        int p = 0;
        int k;
        for (i = 0; i < 12; i++) {
            e[i] = scan.nextInt();
        }
        for (i = 0; i < 12; i++) {
            for (int j = 0; j < 12 - i; j++) {
                if (e[j] < e[j + 1]) {
                    int y = e[j];
                    e[j] = e[j + 1];
                    e[j + 1] = y;

                }
            }
        }
        for (int u = 0; u < 3; u++) {
            for (k = 0; k < 4; k++) {
                i = u * 4;
                if (e[i] == e[i + 1] && e[i + 2] == e[i + 3] && e[i] == e[i + 2] && e[i + 1] == e[i + 3] && e[i] == e[i + 3] && e[i + 1] == e[i + 2]) {
                    p += 1;
                } else {
                    p += 0;
                }

            }

        }
        if (p == 12) {
            System.out.println("yes");
        } else {
            System.out.println("no");
        }
    }
}



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

int main() {
    int N; cin >> N;
    map<int, int> m;
    rep(i, N){
        int a; cin >> a;
        m[a]++;
    }

    int ans = 0;
    for (auto p : m){
        auto key = p.first;
        auto value = p.second;
        if(key < value){
            ans += value - key;
        } else if(key > value){
            ans += value;
        } else {
            continue;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8112
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll t,a,x,y,n,tmp,xt,ya;
  x=y=1;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> t >> a;
    xt = x/t;
    ya = y/a;
    if(x%t!=0)xt++;
    if(y%a!=0)ya++;
    tmp = max(xt,ya);
    x = tmp*t;
    y = tmp*a; 
  }
  cout << x+y<<endl;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

const ll mod = 1e9 + 7;

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  ll N, A, B; cin >> N >> A >> B;
  if (A > B) swap(A, B);
  vector<ll> S(N+1); REP(i, N) cin >> S[i+1];
  S[0] = -1e18;
  REP(i, N-1) {
    if (S[i+2] - S[i] < A) {
      cout << 0 << endl;
      return 0;
    }
  }

  vector<ll> dp(N+1), imos(N+2);
  dp[0] = imos[1] = 1;
  int left = 0;

  REP(i, N) {
    int ub = upper_bound(ALL(S), S[i+1] - B) - S.begin();
    if (left < ub) dp[i+1] = imos[i+2] = (imos[ub] - imos[left] + mod) % mod;
    imos[i+2] += imos[i+1];
    imos[i+2] %= mod;
    if (S[i+1] - S[i] < A) left = i;
  }

  ll ans = 0;
  FOR(i, left, N+1) {
    ans += dp[i];
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

int main()
{
	int n;
	si(n);
	vp vec(n);
	ll fin = 0;
	for(int i = 0; i < n; i++)
		sii(vec[i].scn, vec[i].fst);

	SORT(vec);
	bool sw = 1;
	for(int i = 0; i < n; i++)
	{
		fin += vec[i].scn;
		if(fin > vec[i].fst)
		{
			sw = 0;
			break;
		}
	}
	if(sw)
		printf("Yes\n");
	else
		printf("No\n");
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int64_t bcg(int64_t a, int64_t b){
    if(a<b) swap(a,b);
    if(a%b!=0) return bcg(b,a%b);
    return b;
}

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b;
    cin >> a >> b;
    cout << (a*b)/bcg(a,b) << endl;
}


Measured memory_bytes: 256
import math

N, M = map(int, input().split())

# N = 100000
# M = 1000000000

def pfac(n):
    values = [1, n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            values.append(i)
            values.append(n // i)
    return values

L = pfac(M)
L = [i for i in L if i * N <= M]

ans = []

for i in L[::-1]:
    # if (M - (N * i)) % i == 0:
    if M % i == 0:
        ans.append(i)

print(max(ans))


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

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

int main()
{
    int h, w, k;
    scanf("%d %d %d", &h, &w, &k);

    char inp[h][w + 2];
    for (int i = 0; i < h; i++) {
        scanf("%s", inp[i]);
    }

    int ans = 0;
    for (int i = 0; i < (1 << h); i++) {
        for (int j = 0; j < (1 << w); j++) {
            int cnt = 0;

            for (int x = 0; x < h; x++) {
                for (int y = 0; y < w; y++) {
                    if (inp[x][y] == '#' && ((i >> x) & 1) && ((j >> y) & 1))
                        cnt++;
                }
            }

            ans += (cnt == k);
        }
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 3828
def io_tmp():
    global input
    import io
    f = io.StringIO(open(0).read())
    input = f.readline

io_tmp()


from scipy.sparse.csgraph import floyd_warshall
import numpy as np

N, M, L = map(int, input().split())
graph = np.zeros((N, N), dtype=np.int64)
for _ in range(M):
    s, t, w = map(int, input().split())
    graph[s-1, t-1] = graph[t-1, s-1] = w
dist = floyd_warshall(graph, directed=False)
graph = np.ones((N, N), dtype=np.int64)
np.fill_diagonal(graph, 0)
graph[dist > L] = 0
dist = floyd_warshall(graph, directed=False)
dist[np.isinf(dist)] = 0
dist = dist.astype(int)

Q = int(input())
ans = []
for _ in range(Q):
    s, t = map(int, input().split())
    ans.append(dist[s-1][t-1] - 1)
print(*ans, sep='\n')


Measured memory_bytes: 26948
import scala.io.StdIn.{readInt,readLine}

object Main {
  def selectionSort(a:Array[Int]):Int = {
    var cnt = 0
    for(i <- 0 until a.length) {
      var mini = i
      for(j <- i until a.length) if(a(j) < a(mini)) mini = j

      val t = a(i)
      a(i) = a(mini)
      a(mini) = t
      if(i!=mini) cnt += 1
    }
    cnt
  }

  def main(args:Array[String]) = {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val cnt = selectionSort(a)

    println(a.mkString(" "))
    println(cnt)
  }
}

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

int main(){
  	string a,b,c;
	cin>>a>>b>>c;
    a[0]-=32;b[0]-=32;c[0]-=32;
    cout<<a[0]<<b[0]<<c[0]<<endl;
  	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    int n;
    cin>>n;
    set<int> s;
    rep(i,n){
        int x;
        cin>>x;
        s.insert(x);
    }
    
    if(n==s.size()) dunk("YES");
    else dunk("NO");
}



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

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

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

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

int main()
{
    ll N;
    cin >> N;
    vector<ll> X(N);
    rep(i, N) { 
        cin >> X[i];
    }
    ll mi = INF;
    rep(i, 100) {
        ll tmp = 0;
        rep(j, N) {
            tmp += (X[j] - (i+1)) * (X[j] - (i+1));
        }
        mi = min (mi, tmp);
    }
    print(mi);
    return 0;
}

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


int main() {
  string s;
  cin >> s;
  int minv = 100000;
  rep(i,s.size()-2){
    string t = s.substr(i,3);
    int u = stoi(t);
    minv = min(minv,abs(u-753));
  }
  cout << minv << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 public class Main
{
    public static void main(String[]args)
    {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        StringTokenizer dates=new StringTokenizer(sc.nextLine());
        StringTokenizer dates2=new StringTokenizer(sc.nextLine());
        int mayor=0;
        for(int i = 0; i < N; i++)
        {
            int a = Integer.parseInt(dates.nextToken());
            int b = Integer.parseInt(dates2.nextToken());
            if(a-b > 0)
            {
                mayor+= a-b;
            }
        }
        System.out.println(mayor);
  }
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (s == "Sunny") cout << "Cloudy" << '\n';
  else if (s == "Cloudy") cout << "Rainy" << '\n';
  else cout << "Sunny" << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {

    ll N;

    cin >> N;

    ll ans, tmp;

    tmp = N % 1000;
    
    if (tmp == 0) {
        ans = 0;
    }
    else {
        ans = 1000 - tmp;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main()
{

	int H,W;
	
	while( true ) {
		cin>>H>>W;	
		if( 0==H && 0==W ) { break; }
		for( int i=0; i<H; i++ ) {
			for( int j=0; j<W; j++ ) {
				cout <<"#";  
			}
			cout <<endl;  
		}
		cout <<endl; 
	}
	
    return 0;
}

Measured memory_bytes: 1156
#ナップサック問題
N, W = map(int, input().split())
dp = [[0 for i in range(W+1)]for j in range(N+1)]

for i in range(N):
    v, w = map(int, input().split())
    for j in range(W):
        if j+1 >= w:
            dp[i+1][j+1] = max(dp[i][j+1-w]+v, dp[i][j+1])
        else:
            dp[i+1][j+1] = dp[i][j+1]

print(dp[N][W])


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

const int MOD = 1000000007;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    int N;
    cin >> N;
    vector<int> A(N+1), B(N);
    rep(i, N+1) cin >> A[i];
    rep(i, N) cin >> B[i];

    lint res = 0;

    rep(i, N) {
        int diff = A[i] - B[i];
        res += min(A[i], A[i] - diff);
        A[i] = max(0, diff);
        if (diff < 0) {
            res += min(abs(diff), A[i+1]);
            A[i+1] -= min(-diff, A[i+1]);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(int& x : L) cin >> x;
  sort(L.begin(), L.end());

  auto f=[&](int i, int j){
    int th = L[i] + L[j];
    int hi = N;
    int lo = j;
    if (lo >= N) return 0;
    while (hi - lo > 1){
      int mid = (hi + lo) / 2;
      if (L[mid] >= th) {
        hi = mid;
      }
      else {
        lo = mid;
      }
    }
    return lo - j;
  };

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      ans += f(i, j);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<array>

using namespace std;
int main(){
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<int> a(n);
    vector<int> b(m);
    for(int i = 0;i < n;i++)
        cin >> a[i];
    for(int i = 0;i < m;i++)
        cin >> b[i];

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    if(a[n-1] < b[0]){
        int c = a[n-1] +1;
        while(c <= b[0]){
            if(c > x && c <= y){
                cout << "No War" << endl;
                return 0;
            }
            c++;
        }
    }
    cout << "War" << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define F first
#define S second
#define pi 6.28318530717958623200
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;

int main()
{

    int r;
    cin>>r;
    float res=(float)(r)*pi;
    printf("%.12f\n",res);



    return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    int N,K;
    ll ans = 0;
    cin >> N >> K;
    vector<pair<ll,ll> > Sushi;//d,t
    Sushi.reserve(N);
    for(int i = 0; i < N;i++){
        ll t;
        ll d;
        cin>>t>>d;
        Sushi.push_back(make_pair(d,t));
    }
    sort(Sushi.begin(),Sushi.end(),greater<pair<ll,ll> >());
    ll type = 0;
    ll D = 0;
    set<ll> st; //used type
    vector<ll> unq; //同typeの中で、一番dが高くないもの
    for(int i = 0;i < K;i++){
        D += Sushi[i].first;
        if(st.count(Sushi[i].second)==0){
            type++;
            st.insert(Sushi[i].second);
        }else{
            unq.push_back(Sushi[i].first);
        }
    }
    ans = D + type*type;

    if(unq.size()==0){
        cout<<ans<<endl;
        return 0;
    }
    vector<ll>::iterator itr = unq.end();
    itr--;
    
    for(int i = K;i < N;i++){
        if(st.count(Sushi[i].second)>0){
            continue;
        }
        st.insert(Sushi[i].second);
        type++;
        D = D - (*itr) +Sushi[i].first;
        ans = max(ans,D+type*type);
        //cout<<ans<<endl;
        if(itr==unq.begin()){
            break;
        }else{
            itr--;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5244
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N, M;
	cin >> N >> M;

	int Ncount = N * (N - 1) / 2;
	int Mcount = M * (M - 1) / 2;

	cout << Ncount + Mcount;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    clock_t start = clock();
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    ll d; cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) cin >> s[i][j];
    }
    
    vector<ll> w(0);
    for (ll i = 0; i < 26; i++) {
        w.push_back(i);
        for (ll j = 0; j < c[i]; j++) w.push_back(i);
    }
    ll m = w.size();
    
    vector<ll> t(d);
    random_device rand;
    for (ll i = 0; i < d; i++) t[i] = w[rand() % m];
    
    ll score = 0;
    {
        vector<ll> v(26, -1);
        for (ll i = 0; i < d; i++) {
            v[t[i]] = i;
            score += s[i][t[i]];
            for (ll j = 0; j < 26; j++) score -= c[j] * (i - v[j]);
        }
    }
    
    vector<set<ll>> v(26);
    for (ll i = 0; i < 26; i++) v[i].insert(-1);
    for (ll i = 0; i < d; i++) v[t[i]].insert(i);
    for (ll i = 0; i < 26; i++) v[i].insert(d);
    
    auto modified_score = [&] (ll day, ll into) {
        ll ret = score;
        ret += s[day][into] - s[day][t[day]];
        auto itr1 = v[t[day]].find(day);
        ll p = *(--itr1), q = *(++itr1), r = *(++itr1);
        ret += ((q - p) * (q - p - 1) + (r - q) * (r - q - 1)) * c[t[day]] / 2;
        ret -= (r - p) * (r - p - 1) * c[t[day]] / 2;
        auto itr2 = v[into].upper_bound(day);
        p = *(--itr2); q = day; r = *(++itr2);
        ret -= ((q - p) * (q - p - 1) + (r - q) * (r - q - 1)) * c[into] / 2;
        ret += (r - p) * (r - p - 1) * c[into] / 2;
        return ret;
    };
    
    while ((double)(clock() - start) / CLOCKS_PER_SEC <= 1.95) {
        ll day = rand() % d, into = w[rand() % m];
        ll x = modified_score(day, into);
        if (x >= score) {
            score = x;
            v[t[day]].erase(day);
            v[into].insert(day);
            t[day] = into;
        }
    }
    
    for (ll i = 0; i < d; i++) cout << t[i] + 1 << endl;
    xout << score << endl;
}

Measured memory_bytes: 3800
# -*- coding: utf-8 -*-
import sys
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))

a = np.sort(A)
b = np.sort(B)

if np.any(a > b):
    print("No")
    sys.exit()

an = np.argsort(A)
bn = np.argsort(B[an])

count = 0
p = 0
while True:
    p = bn[p]
    count += 1
    if p == 0 and count != N:
        print("Yes")
        sys.exit()       
    if count == N:
        break
    
if np.any(a[1:] <= b[:-1]):
    print("Yes")
    sys.exit()
    
print("No")

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

int main() {
  int c1, c2, c3, sum, t, p;
  while (scanf("%d %d %d", &c1, &c2, &c3)==3) {
    sum = c1 + c2;
    t = min(10, 20-sum);
    p = t;
    if (c1 <= t) --p;
    if (c2 <= t) --p;
    if (c3 <= t) --p;
    if (p*2>=7) printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 1008
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN = 1e5;
int main()
{
	int i, n;
    long long int L[MAXN];
	scanf("%d", &n);
    L[0] = 2, L[1] = 1;
	for(i = 2 ; i <= n; i++)
	{
		L[i] = L[i-1]+L[i-2];
	}
	cout<<L[n];
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> board(h);
    rep(y, h) {
        string s;
        cin >> s;
        board[y] = s;
    }

    rep(y, h) {
        rep(x, w) {

            if(board[y][x] == '#') {
                continue;
            }

            int bomb = 0;
            rep(i, 8) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                
                if(nx < 0 || w <= nx || ny < 0 || h <= ny) {
                    continue;
                } 

                if(board[ny][nx] == '#') {
                    bomb++;
                }
            }

            board[y][x] = (char)(bomb + '0');
        }
    }

    rep(y, h) {
        cout << board[y] << "\n";
    }

    return 0;
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 2 * N;

int n;
int h[N], e[M], ne[M], idx;
int da[N], db[N];
int q[N];
bool st[N];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void bfs(int s, int d[])
{
	memset(st, 0, sizeof st);
	int hh = 0, tt = -1;
	q[ ++ tt] = s;
	d[s] = 0;
	st[s] = true;
	
	while (hh <= tt)
	{
		int t = q[hh ++ ];

		for (int i = h[t]; ~i; i = ne[i])
		{
			int j = e[i];
			if (st[j]) continue;
			d[j] = d[t] + 1;
			q[ ++ tt] = j;
			st[j] = true;
		}
	}
}

int main()
{
	memset(h, -1, sizeof h);
	
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		add(a, b), add(b, a);
	}
	
	bfs(1, da);
	bfs(n, db);
	
	int a = 0, b = 0;
	for (int i = 2; i < n; i ++ )
		if (da[i] <= db[i]) a ++ ;
		else b ++ ;
	
	if (a > b) puts("Fennec");
	else puts("Snuke");
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


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

  ll n, k;
  cin >> n >> k;

  mint ans;
  for (ll i = k; i <= n+1; i++) {
    ll mi = i * ((i-1)*(1)) / 2;
    ll ma = i * n - mi;
    ans += ma - mi + 1;
  }

  cout << ans.x << endl;

  return 0;
}


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

int main() {
  long long h,w;
  cin >>h>>w;
  if(h==1||w==1){
    cout<<1<<endl;
    return 0;
  }
  long long kotae=h*w/2;
  if(h*w%2==1)kotae++;
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
 
//const int MOD=998244353;

long long modpow(long long x, long long n, long long m) {
    if (n == 0) return 1%m;
    long long u = modpow(x,n/2,m);
    u = (u*u)%m;
    if (n%2 == 1) u = (u*x)%m;
    return u;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int x,y;
    cin>>x>>y;
    
    
    
    if((2*x-y)%3 || (2*y-x)%3 || y>2*x || x>2*y){
        cout<<0;
        return 0;
    }
    
    int u=(2*y-x)/3, r=(2*x-y)/3;
    vector<long long> nfact(1000001);
    nfact[0]=1;
    for(int i=1; i<=1000000; i++){
        nfact[i]=i*nfact[i-1];
        if(nfact[i]>MOD) nfact[i]%=MOD;
    }
    long long ans=nfact[u+r];
    
    ans*=modpow(nfact[u],MOD-2,MOD);
    ans%=MOD;
    ans*=modpow(nfact[r],MOD-2,MOD);
    ans%=MOD;
    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int x, k,m;
	vector<int>O;
	cin >> x >> k;
	m = k;
	O.push_back(k);
	for (int i = 0; i < x-1; i++)
	{
		k = k - 1;
		O.push_back(k);
	}
	for (int i = 0; i < x-1; i++)
	{
		m = m + 1;
		O.push_back(m);
	}
	sort(O.begin(), O.end());
	for (int j = 0; j < O.size(); j++)
	{
		cout << O[j] << endl;;
	}
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#include <iostream>
 
inline int min(int x, int y) {return x < y ? x : y;}
inline long min(long x, long y) {return x < y ? x : y;}
inline int max(int x, int y) {return x > y ? x : y;}
inline long max(long x, long y) {return x > y ? x : y;}
 
using namespace std;
 
int main() {
    int N, A, B, C;
    int l[8];
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++) {
        cin >> l[i];
    }

    int loop_num = 1;
    for (int i = 0; i < N; i++) {
        loop_num *= 4;
    }
    int min_cost = 100000000;
    for (int s = 0; s < loop_num; s++) {
        int tmp = s;
        int null_cnt = 0;
        int group[4] = {0, 0, 0, 0};
        for (int i = 0; i < N; i++) {
            group[tmp % 4] += l[i];
            if (tmp % 4 == 3) null_cnt++;
            tmp /= 4;
        }

        if (group[0] == 0 || group[1] == 0 || group[2] == 0) continue;

        int cost = (N - null_cnt - 3) * 10;
        cost += abs(group[0] - A);
        cost += abs(group[1] - B);
        cost += abs(group[2] - C);
        min_cost = min(min_cost, cost);
    }

    cout << min_cost << endl;
}


Measured memory_bytes: 256