akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

int isPrime(int x) {
    if (x == 2) return 1;
    if (x % 2 == 0) return 0;
    int i = 3;
    int sqrt_x = sqrt(x);
    for (i; i <= sqrt_x; i += 2) {
        if (x % i == 0) return 0;
    }
    return 1;
}

int main(void) {
    int n, x, idx, ans;
    ans = 0;
    scanf("%d", &n);

    for (idx = 0; idx < n; idx++) {
        scanf("%d", &x);
        if (isPrime(x)==1) ans++;
    }
    printf("%d\n", ans);
    return 0;
}



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

int main()
{
	int n, h, w;
	while (scanf("%d%d%d", &n, &h, &w) != EOF)
	{
		printf("%d\n", (n - h + 1) * (n - w + 1));
	}
	return 0;
}


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

int main(){
    long long n, a, m, t = 0, x = 0;
    cin >> n;
    cin >> m;
    x += (m < 0);
    m = abs(m);
    t += m;
    for(int i = 1; i < n; i++){
        cin >> a;
        x += (a < 0);
        a = abs(a);
        t += a;
        m = min(m, a);
    }
    cout << (x % 2 == 0 ? t : t - 2*m) << '\n';
}


Measured memory_bytes: 256
import heapq

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

queue = []
day, i, ans = 0, 0, 0
while day <= m:
    while i < n and AB[i][0] <= day:
        heapq.heappush(queue, -AB[i][1])
        i += 1
    if len(queue):
        ans += -heapq.heappop(queue)
    day += 1
print(ans)

Measured memory_bytes: 31596
N, M, X, Y = map(int, raw_input().split())
x = map(int, raw_input().split())
y = map(int, raw_input().split())
x.sort()
y.sort()
ans = 'War'
for i in range(X+1, Y+1):
	if x[N-1] < i and i <= y[0]:
		ans = 'No War'
		break

print ans

Measured memory_bytes: 2568
import java.util.Scanner;

public class Main {

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

		int n, a[];
		long psum[], sum = 0;
		n = sc.nextInt();
		a = new int[n];
		psum = new long[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			sum += a[i];
			psum[i] = sum;
		}
		sc.close();

		long min = (long)Math.pow(10,  10), sub;

		for (int i = 0; i < n - 1; ++i) {
			sub = Math.abs(sum - 2 * psum[i]);
			min = Math.min(min, sub);
		}

		System.out.println(min);
	}

}


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

int main(void){
    
  int N,Alice=0,Bob=0;
  cin >> N;
  int data[N];
  
  for(int i=0;i<N;i++) cin >> data[i];
  
  sort(data,data+N,greater<int>());
  
  for(int i=0;i<N;i++){
      if(i%2==0) Alice+=data[i];
      else Bob+=data[i];
  }
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define PI acos(-1LL)


#ifdef LOCAL
string to_string(const string& s){
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(T v){
    bool first = true;
    string res = "{";
    for(const auto& x: v){
        if(!first) res+=", ";
        first = false;
        res+=to_string(x);
    }
    res+="}";
    return res;
}
void bug() { cerr << endl; }
template<typename Head, typename... Tail>
void bug(Head H, Tail... T) {
    cerr << " " << to_string(H);
    bug(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__);
#else
#define debug(...) 11
#endif


const int M = 1000000007;
const int N = 2e6 + 5;
const long long INF = 2e9 + 12;


void solve(){
    int cnt = 0, n;
    cin >> n;
    vector<int> v(n);
    for(auto &x: v) cin >> x;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                set<int> st{v[i] , v[j] , v[k]};
                if(v[i] + v[j] > v[k] && v[i]+v[k] > v[j] && v[j] + v[k] > v[i] && st.size() == 3){
                    debug(i+1, j+1, k+1);
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
}
signed main(){
    FAST
#ifdef LOCAL
    clock_t start;
    double duration;
    start = clock();
#endif
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        solve();
    }
#ifdef LOCAL
    duration = (clock() - start) / (double) CLOCKS_PER_SEC;
    cerr <<"\nTotal time elapsed: "<< duration <<"sec\n";
#endif
}

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

template <class T>
void scrib_impl(char const* title, T v){
    cout << title << " ...... " << v << endl;
}
#define SCRIB(EXPR) (scrib_impl(#EXPR, (EXPR)))

int main() {
    int n;
    cin >> n;
    std::array<int, 200000> a;
    REP(i, n) {
        int temp;
        cin >> temp;
        a[i] = temp;
    }
    
    int i=n-1;
    int lf = 1;
    for(i=n-1; i>=0; i--) {
        if (a[i] == lf) {
            lf++;
            break;
        }
    }
    
    for(i=i+1; i<n; i++) {
        if (a[i] == lf) {
            lf++;
        }
    }
    
    int ans = n - lf + 1;
    if (ans == n) ans = -1;
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1024
n = int(raw_input())
t = [0]
d = [0 for i in range(n)]
f = [0 for i in range(n)]
G = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
st = [0 for i in range(n)]
 
def DFS_visit(s):
	st[s] = 1
	d[s] = t[0] = t[0] + 1
	for e in range(n):
		if M[s][e] == 1 and st[e] == 0:
			DFS_visit(e)
	f[s] = t[0] = t[0] + 1
 
def DFS():
	for s in range(n):
		if st[s] == 0:
			DFS_visit(s)
	for s in range(n):
		print s+1, d[s], f[s]

for i in range(n):
	G = map(int, raw_input().split())
	for j in range(G[1]):
		M[G[0]-1][G[j+2]-1] = 1
DFS()

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

typedef pair<long long, long long> ii;


long long mod = 1000000007;
int main(){
	//freopen("i.txt","r",stdin);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int m, d;
	cin >> m >> d;
	int ans = 0;
	for(int i = 10;i <= d;i++){
		int a = i % 10;
		int b = i / 10;
		if(a >= 2 && b >= 2 && a * b <= m) ans++;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define inf 10000000000000
using namespace std;
typedef long long ll;

ll ans = inf;
int A, B, C, X, Y;

int main() {
	cin >> A >> B >> C >> X >> Y;
	for(int i = 0; i <= 2 * max(X, Y); i += 2) {
		int t1 = max(0, X - i / 2);
		int t2 = max(0, Y - i / 2);
		ans = min(ans, (ll)i * C + (ll)A * t1 + (ll)B * t2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort()
    C.sort()

    ans = 0
    for b in B:
        a = bisect_left(A, b)
        c = bisect_right(C, b)
        ans += a * (N - c)

    print(ans)

sol()

Measured memory_bytes: 22968
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int sum=0;
  int num=101;
  int N,L;
  cin >> N >> L;
  REP(i,N){
    sum += L+i;
    if(abs(L+i)<abs(num)) num = L+i;
  }
  cout << sum - num << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 430

ll factorial(int n,int M){
  ll ret=1;
  if(n<=1) return 1;
  
  for(int i=1;i<=n;i++){
    ret = (ret*i)%M;
  }
  
  return ret;
}

ll power(int k,int n,int M){
  if(n==0) return 1;
  if(n==1) return (ll)k;
  
  ll ret = power(k,n/2,M);
  
  ret=(ret*ret)%M;
  
  if(n%2==1)
    ret=(ret*k)%M;
  
  return ret;
}


//nCm nPm nHm (mod M)

/*Combination*/
int C(int n,int m,int M){
  if(n<m) return 0;
  if(m==0 || n==m) return 1;
  
  ll chi = factorial(n,M);
  ll mot = (factorial(m,M) * factorial(n-m,M))%M;
  
  mot = power((int)mot,M-2,M);
  
  ll ret = (chi*mot)%M;
  
  return (int)ret;
}
/*Permutation*/
int P(int n,int m,int M){
  if(n<m) return 0;
  if(m==0) return 1;
  
  ll chi = factorial(n,M);
  ll mot = factorial(n-m,M);
  
  
  mot = power((int)mot, M-2,M);
  
  ll ret = (chi*mot)%M;
  
  return (int)ret;
}
/*Combination with Repetitions*/
int H(int n,int m,int M){
  if(m<0) return 0;
  if(n==0 && m==0) return 1;
  return C(n+m-1,m,M);
}



ll p[SIZE][SIZE];
ll q[SIZE][SIZE];

int main(){
  int n,c;
  int a[SIZE],b[SIZE];
  ll f = 1;
  
  scanf("%d%d",&n,&c);

  for(int i=0;i<n;i++) scanf("%d",a+i);
  for(int i=0;i<n;i++) scanf("%d",b+i);

  for(int i=0;i<n;i++){
    f = (f * (b[i]-a[i]+1))%mod;
  }
  
  ll dp[SIZE][SIZE];
  
  dp[0][0] = 1;


  for(int i=0;i<=400;i++){
    p[i][0] = 1;
    for(int j=1;j<=c;j++){
      p[i][j] = (p[i][j-1] * i)%mod;
    }
  }

  for(int i=0;i<n;i++){
    for(int k=0;k<=c;k++){
      for(int l=a[i];l<=b[i];l++){  
        q[i][k] = (q[i][k] + p[l][k])%mod;
      }
    }
  }
        
  for(int i=0;i<n;i++){
    for(int j=0;j<=c;j++){
      for(int k=0;k<=c-j;k++){
          dp[i+1][j+k] = (dp[i+1][j+k] + (dp[i][j] * q[i][k])%mod)%mod;
      }
      
    }
  }
    
  printf("%lld\n",dp[n][c]);
  
  return 0;
}


Measured memory_bytes: 4224
n,m=map(int,input().split())
t=[]
for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    d=0
    for i in c:
        d+=2**(i-1)
    t.append([a,d])
e=[float("INF")]*(2**n)
e[0]=0
for i,j in t:
    for h in range(2**n):
        e[h|j]=min(i+e[h],e[h|j])
print(e[-1] if e[-1]!=float("INF") else -1)

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<long long int> A(N);
  vector<long long int> VL(N),VR(N);
  long long int t = 0LL;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    t += A[i];
    VL[i] = VR[i] = t;
  }
  
  //先手が正
  long long int l = 0LL, r = 0LL;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0){
      if(VL[i] > 0){
        if(i < N-1) VL[i+1] = VL[i] + A[i+1];
      }else{
        l += 1 - VL[i];
        VL[i] = 1;
        if(i < N-1){
          VL[i+1] = VL[i] + A[i+1];
        }
      }
    }else{
      if(VL[i] < 0){
        if(i < N-1) VL[i+1] = VL[i] + A[i+1];
      }else{
        l += VL[i] + 1;
        VL[i] = -1;
        if(i < N-1){
          VL[i+1] = VL[i] + A[i+1];
        }
      }    
    }
  }
  //先手が負
  for(int i = 0; i < N; i++){
    if(i % 2 == 0){
      if(VR[i] < 0){
        if(i < N-1) VR[i+1] = VR[i] + A[i+1];
      }else{
        r += VR[i] + 1;
        VR[i] = -1;
        if(i < N-1){
          VR[i+1] = VR[i] + A[i+1];
        }
      }
    }else{
      if(VR[i] > 0){
        if(i < N-1) VR[i+1] = VR[i] + A[i+1];
      }else{
        r += 1 - VR[i];
        VR[i] = 1;
        if(i < N-1){
          VR[i+1] = VR[i] + A[i+1];
        }
      }    
    }
  }
  
  
  
  //for(int i = 0; i < N; i++) cout << VL[i] << " ";
  //cout << endl;
  //for(int i = 0; i < N; i++) cout << VR[i] << " ";
  //cout << endl;
  
  cout << min(l,r) << endl;
}


Measured memory_bytes: 2560
n = int(input())
A = list(map(int, input().split()))
A.sort()
from itertools import accumulate
C = [0]+A
C = list(accumulate(C))

def is_ok(x):
    if x < 0:
        return False
    cur = C[x+1]
    for i in range(x+1, n):
        if A[i] <= 2*cur:
            cur += A[i]
        else:
            break
    else:
        return True
    return False

ng = -1
ok = n-1
while ng+1 < ok:
    c = (ok+ng)//2
    if is_ok(c):
        ok = c
    else:
        ng = c

ans = n-ok
print(ans)

Measured memory_bytes: 84900
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >>s;
  int n;
  n= s.size();
  int error =0;
  for(int i=0; i<(n-1)/2;i++){
  if(s.at(i)!=s.at(n-1-i)){error=1;}
  }
  if(error==1){cout <<"No"<<endl;}
  else{
  	for(int i=0; i<=(n-3)/4;i++){
  		if(s.at(i)!=s.at((n-3)/2 -i)||s.at((n+1)/2 +i)!=s.at(n-1-i))
  			{error=2;break;}
    }  
  if(error==2){cout <<"No"<<endl;}
  else{cout <<"Yes"<<endl;}
  }
  
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main()
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (a[0] < 10 & a[1] < 10)
            {
                Console.WriteLine(a[0] * a[1]);
            }
            else
            {
                Console.WriteLine("-1");
            }
        }
    }

}


Measured memory_bytes: 13396
'''
x+y+z=N
10000x+5000y+1000z=Y

z=N-x-y
10000x+5000y+1000(N-x-y)=Y
=> 9000x+4000y=Y-1000N
=> 9x+4y=(Y/1000)-N

'''
A = list(map(int, input().split(' ')))
N = A[0]
Y = A[1]
ans =[]
#print('N:{},Y:{}'.format(N,Y))

right = (Y/1000) - N
#print('right:{}'.format(right))


for x in range(N+1):
	for y in range(N-x+1):
		tmp = 9*x + 4*y
		#print('x:{},y{},tmp:{}'.format(x,y,tmp))
		if tmp == right and x+y <= N:
			print('{} {} {}'.format(x,y,(N-x-y)))
			quit()

print('-1 -1 -1')

Measured memory_bytes: 3064
H,W=map(int,input().split())
t = 0
while not ( H == 0 and W == 0 ):
	for h in range(H):
		line = ""

		ptn=["#","."]

		for w in range(W):
			line += ptn[(h+w)%2]

		print(line)

	print("")
	t+=1
	H,W=map(int,input().split())



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

int main(void){
    int n;
    cin >> n;
    vector<int> a;
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        a.push_back(x);
    }

    int m;
    cin >> m;
    vector<int> b;
    for(int i=0; i<m; i++){
        int x;
        cin >> x;
        b.push_back(x);
    }

    // aの中にbが入ってるなら1、そうでないなら0
    if(includes(a.begin(), a.end(), b.begin(), b.end())){
        cout << 1 << "\n";
    }
    else{
        cout << 0 << "\n";
    }
    return 0;
}


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

int n,mod,l[510],r[510],f[261][261][261],la,p,nw,ans;

int main()
{
	scanf("%d%d",&n,&mod);
	l[0]=n,r[0]=2*n-1;
	for (int i=1; i<2*n; i++)
	{
		l[i]=l[i-1],r[i]=r[i-1];
		while (l[i]&&(l[i]-1)*(l[i]-1)+i*i>=n*n) l[i]--;
		while (r[i]*r[i]+i*i>4*n*n) r[i]--;
	}
	la=2*n;
	for (int i=0; i<=n; i++) f[n][0][i]=1;
	for (int i=n-1; i>=0; i--)
	{
		for (int j=0; j<=n-i-1; j++)
		{
			p=la,nw=1;
			while (r[p-1]<l[i]) nw=1ll*nw*(r[p-1]+1-(j+(2*n-p)))%mod,p--;
			f[i][j][j]=(f[i][j][j]+1ll*nw*(r[i]+1-(2*n-1-i))%mod*f[i+1][j][j])%mod;
			for (int k=j+1; k<=n; k++)
				f[i][j+1][k]=(f[i][j+1][k]+1ll*nw*(l[i]-j-(2*n-p))%mod*f[i+1][j][k])%mod,
				f[i][j][k]=(f[i][j][k]+1ll*nw*(r[i]+1-(k-j+(2*n-1-i)))%mod*f[i+1][j][k])%mod;
		}
		la=p;
	}
	ans=0;
	for (int i=0; i<=n; i++) 
	{
		nw=1;
		for (int j=n; j<la; j++) nw=1ll*nw*(r[j]+1-(i+(2*n-j-1)))%mod;
		if (i&1) ans=(ans+1ll*(mod-nw)*f[0][i][i])%mod;
		else ans=(ans+1ll*nw*f[0][i][i])%mod;
	}
	return printf("%d\n",ans),0;
}

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

using namespace std;

int N, Q;
set<pair<int, int>> st;
vector<pair<int, pair<int, int>>> v;
int ans[200005];

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> Q;
    for(int i =1 ; i<=N; i++){
        int l, r, x;
        cin >> l >> r >> x;
        v.push_back({x, {l, r}});
    }
    for(int i = 1; i<=Q; i++){
        int n;
        cin >> n;
        st.insert({n, i});
    }
    st.insert({INT_MAX, Q+1});
    sort(v.begin(), v.end());
    fill(ans, ans+1+Q, -1);
    pair<int, int> * ptr;
    for(auto p : v){
        while(st.lower_bound({p.second.first-p.first, 0}) != st.end() &&
              st.lower_bound({p.second.first-p.first, 0})->first < p.second.second-p.first){
            ans[st.lower_bound({p.second.first-p.first, 0})->second] = p.first;
            st.erase(st.lower_bound({p.second.first-p.first, 0}));
        }
    }
    for(int i = 1; i<=Q; i++){
        cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 14448
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  x:
    ll n,x;
    cin >>n>>x;
    if(n==0&&x==0){
        return 0;
    }else{
        ll ans =0;
        
       for(int i=1;i<n-1;i++){
           for(int j=i+1;j<n;j++){
               for(int k=j+1;k<n+1;k++){
                   if(i+j+k==x){
                       ans++;
                   
                   }
                   
               }
           }
       }
       cout <<ans<<endl;
    }
  goto x;
}


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

int main() {
  string s,t;
  cin >> s >> t;
  bool ans  = false;
  rep(i,s.size()){
    if(s == t) ans  = true;
    s = s.back() + s.substr(0,s.size()-1);
  }
  puts(ans?"Yes":"No");
 }


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

signed main() {
	int n; cin >> n;
	vector<int> a(n); for (auto &A : a) cin >> A;
	vector<int> head;
	for (int i = 0; i < n; ++i) {
		auto it = upper_bound(head.begin(), head.end(), -a[i]);
		if (it == head.end())
			head.push_back(-a[i]);
		else
			*it = -a[i];
	}
	cout << head.size();
}

Measured memory_bytes: 1276
use std::io::Read;
use std::cmp;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf);

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    let p: usize = iter.next().unwrap().parse().unwrap();
    let q: usize = iter.next().unwrap().parse().unwrap();
    let r: usize = iter.next().unwrap().parse().unwrap();

    let mut vec = vec![p, q, r];
    vec.sort();

    println!("{}", vec[0] + vec[1]);
}

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

using namespace std;

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

	long long n, w;
	cin >> n >> w;

	vector<long long> weights(n);
	vector<long long> values(n);

	for (long long i = 0; i < n; i++)
	{
		cin >> weights[i] >> values[i];
	}

	vector<vector<long long>> dp(n + 1, vector<long long>(w + 1));

	dp[0][0] = 0;

	for (long long i = 1; i <= n; i++)
	{
		dp[i][0] = 0;
	}

	for (long long j = 0; j <= w; j++)
	{
		dp[0][j] = 0;
	}

	for (long long i = 1; i <= n; i++)
	{
		for (long long j = 1; j <= w; j++)
		{
			dp[i][j] = dp[i - 1][j];
			if (j >= weights[i - 1])
			{
				dp[i][j] = max(dp[i][j], values[i - 1] + dp[i - 1][j - weights[i - 1]]);
			}
		}
	}
  
	cout << dp[n][w] << endl;
	return 0;
}

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

using namespace std;

#define ll long long
#define inf 100000000

int main()
{
	int h, w, modl = 1000000007;
	cin >> h >> w;
	char inp[h][w];
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			cin >> inp[i][j];

	int ans[h][w];
	ans[h-1][w-1] = 1;
	
	for(int i = h-1; i >=0; i--)
	{
		for(int j = w-1; j >= 0; j--)
		{
			if(i== h-1 && j == w-1)
				continue;
			else
			{
				ans[i][j] = 0;
				if(inp[i][j] == '#')
					continue;
				else
				{
					if(i < h-1)
						ans[i][j] = (ans[i][j]%modl + ans[i+1][j]%modl)%modl;
					if(j < w-1)
						ans[i][j] = (ans[i][j]%modl + ans[i][j+1]%modl)%modl;
				}
			}
		}
	}
	cout << ans[0][0];
}

Measured memory_bytes: 5120
root = [[1,2],[-1,3],[1,-1],[4,5],[5,2],[2,1]]
while 1:
	n = raw_input()
	if n == "#": break
	cur = 0
	for i in n:
		cur = root[cur][int(i)]
		if cur == -1: break
	print "Yes" if cur == 5 else "No"

Measured memory_bytes: 4220
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[301],n,dp[301][301];
int main(){
  while(cin>>n,n){
    int ans=0;
    r(i,n)cin>>a[i];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i+=2)
      for(int j=0;j<n-i;j++){
dp[j][j+i]=dp[j+1][j+i-1];
        for(int k=1;k<i;k+=2)dp[j][j+i]=max(dp[j][j+i],dp[j][j+k]+dp[j+k+1][j+i]);
        if(abs(a[j]-a[j+i])<2&&dp[j+1][j+i-1]==i-1)dp[j][j+i]=max(dp[j][j+i],i+1);
      }
    r(i,n)r(j,n)ans=max(ans,dp[i][j]);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3428
// doot diddly donger cuckerino Hahahahahah

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

using namespace std;
using namespace __gnu_pbds;

typedef long long int LL;
typedef unsigned int UINT;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef tuple<int, int, int> TPL;
typedef priority_queue<int> pqueue;
typedef priority_queue<int, VI, greater<>> pdqueue;

const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, 1, 0, -1, -1, 1, -1, 1};
const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define endl '\n'
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define F first
#define S second
#define SZ(x)           ((int) (x).size())
#define MAX(a, b)      ((a)>(b)?(a):(b))
#define MIN(a, b)      ((a)<(b)?(a):(b))
#define ALL(a)         std::begin(a), std::end(a)
#define Fill(n, x)      memset(n,x,sizeof n);
#define IN_REP         int _t; cin >> _t ; while(_t--)
#define IOS            ios::sync_with_stdio(false);cin.tie(NULL)
#define FORD            for(int i=(a);i<(b);i+=(c))
#define FOR(i, a, b)    for(int i=(a);i<(b);i++)
#define REP(i, n)       FOR(i,0,n)
#define FORR(i, n)      for(int i=(n);i>=0;i--)
#define EPS (double) 1e-9
#define MOD (long long)(1000*1000*1000 + 7)
#define INF 1011111111
#define LLINF 1000111000111000111LL
#define MAXN 5000007

template<typename T>
inline void maxi(T &x, T y) { x = max(x, y); }

template<typename T>
inline void mini(T &x, T y) { x = min(x, y); }

template<typename T>
inline void add(T &x, T y) {
    x += y;
    if (x >= MOD) x -= MOD;
}

template<typename T>
inline void sub(T &x, T y) {
    x -= y;
    if (x < 0) x += MOD;
}

template<typename T>
inline T mul(T a, T b) {
    LL x = (long long) a * b;
    x %= MOD;
    return x;
}

template<typename T>
inline T power(T base, T exp) {
    T result = 1;
    while (exp) {
        if (exp & 1)result *= base;
        exp >>= 1;
        base *= base;
    }
    return result;
}

template<typename T>
inline T power(T a, T b, T mod) {
    T res = 1;
    while (b > 0) {
        if (b & 1) { res = mul(res, a); }
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}

template<typename T>
inline T modInverse(T n, T p) { return power(n, p - 2, p); }

template<typename T>
inline bool isPrime(T n) {
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (LL i = 5; i * i <= n; i += 6) { if ((n % i == 0) || (n % (i + 2) == 0)) { return false; }}
    return true;
}


int main() {
    int n ;cin >> n;
    VI a(n); REP(i,n) cin >> a[i];
    sort(ALL(a));
    LL sum = 0;
    REP(i,n-1) sum+=a[i];
    sum+=a[n-1]/2;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func check(s string) bool {
	var found [26]bool
	for _, r := range s {
		if found[int(r-'a')] {
			return false
		}
		found[int(r-'a')] = true
	}
	return true
}

func main() {
	var s string
	fmt.Scan(&s)
	if check(s) {
		fmt.Println("yes")
	} else {
		fmt.Println("no")
	}
}


Measured memory_bytes: 512
import sys
# input処理を高速化する
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
expo = set()
for i in range(1, 32):
    for j in range(2, 10):
        if i ** j > 1000:
            break
        expo.add(i ** j)
expo = sorted(list(expo), reverse=True)
for e in expo:
    if e <= N:
        print(e)
        exit()

Measured memory_bytes: 3064
//Code Author:-code_kika //
//Institution:-IIT(BHU)  //
#include<bits/stdc++.h>
using namespace std;

//io
#define sf(x) scanf("%d",&x);
#define sf2(x,y) scanf("%d %d",&x,&y);
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z);
#define pf(x) printf("%d",x);
#define pf2(x,y) printf("%d %d",x,y);
#define pf3(x,y,z) printf("%d %d %d",x,y,z);
#define sfl(x) scanf("%lld",&x);
#define sfl2(x,y) scanf("%lld %lld",&x,&y);
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z);
#define pfl(x) printf("%lld",x);
#define pfl2(x,y) printf("%lld %lld",x,y);
#define pfl3(x,y,z) printf("%lld %lld %lld",x,y,z);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//basic
#define pb push_back
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007LL

//typedefs
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vll vector<ll>
#define vi vector<int>

//functions
#define all(c) c.begin(),c.end()
#define fill(c,val) memset(c,val,sizeof(c))

//debug
#ifdef TRACE
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace(x)
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif

int main(){
	ll n,m,fac[100005],i;
	fac[0]=1;
	for(i=1;i<=100003;i++){
		fac[i]=(fac[i-1]*i)%mod;
	}
	cin>>n>>m;
	if(abs(n-m)>1){
		cout<<"0";
		return 0;
	}
	if(n==m){
	cout<<(((2*fac[n])%mod)*fac[m])%mod;
	}
	else{
		cout<<(((1*fac[n])%mod)*fac[m])%mod;

	}
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int num3 = sc.nextInt();
		int[][] table = new int[num1][num2];
		int[][] grid = new int[num2][num3];

		for (int i1 = 0; i1 < num1; i1++) {
			for (int i2 = 0; i2 < num2; i2++) {
				table[i1][i2] = sc.nextInt();
			}
		}

		for (int i1 = 0; i1 < num2; i1++) {
			for (int i2 = 0; i2 < num3; i2++) {
				grid[i1][i2] = sc.nextInt();
			}
		}

		long [][] sum = new long[num1][num3];
		for (int i3 = 0; i3 < num1; i3++) {
			for (int i1 = 0; i1 < num3; i1++) {
				for (int i2 = 0; i2 < num2; i2++) {
					sum[i3][i1] += table[i3][i2] * grid[i2][i1];
				}

				if (i1 >= num3-1) {
					System.out.println(sum[i3][i1]);
				} else {
					System.out.print(sum[i3][i1] + " ");
				}
			}
		}
	}
}


Measured memory_bytes: 53472
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int A, B, K;

int main(void){
	//IO("test.in", "test.out");
	scanf("%d%d%d", &A, &B, &K);
	for(int i = A; i <= B; i++)
		if(i < A + K) printf("%d\n", i);
		else if(i > B - K) printf("%d\n", i);
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> data = {{0, 0, 0}};
  int t, x, y;
  for (int i=0; i<N; i++) {
    cin >> t >> x >> y;
    data.push_back({t, x, y});
  }
  for (int i=1; i<N+1; i++) {
    int distance = abs(data[i][1] - data[i-1][1]) + abs(data[i][2] - data[i-1][2]);
    int time = data[i][0] - data[i-1][0];
    if (time < distance || (time - distance) % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 6580
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int ans = 0;
		for(int i = 1; i < n; i++) {
			Set<Character> a = new HashSet<>();
			Set<Character> b = new HashSet<>();
			for(int j = 0; j < i; j++) {
				a.add(s.charAt(j));
			}
			for(int j = i; j < n; j++) {
				b.add(s.charAt(j));
			}
			b.retainAll(a);
			ans = Math.max(ans, b.size());
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
/*input
105
*/
#include <bits/stdc++.h>
#pragma GCC optmize("O2")
using namespace std;
#define int long long
#define F first
#define S second
#define pii pair<int, int>
main () {
    int n; cin >> n;
    int out = 0;
    for(int i = 1; i <= n; i += 2) {
        int ans = 0;
        for(int j = 1; j <= i; j ++) {
            ans += (i % j == 0);
        }
        if(ans == 8) out ++;
    }
    cout << out;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n;
    long long int hasil = 0;
    
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        if(i%3==0){
        
        }
        else if(i%5==0){
    
        }
        else{
            hasil+= i;
        }

    }
    printf("%lld", hasil);
    
    return 0;
}

Measured memory_bytes: 1676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n;
  ll ans = 0;
  cin >> n;
  vector<ll> a(n);

  REP(i, n) { cin >> a[i]; }
  sort(ALL(a));

  //重複消去
  int pre = -1;
  set<int> nlist;
  REP(i, n) {
    int tmp = a[i];
    if (pre == a[i]) {
      a[i] = INF;
      nlist.insert(tmp);
    }
    pre = tmp;
  }
  sort(ALL(a));
  a.erase(find(ALL(a), INF), a.end());

  n = a.size();
  vector<int> cnt(1000001, -1);

  REP(i, n) { cnt[a[i]] = 0; }
  REP(i, n) {
    if (cnt[a[i]] == 0) {
      for (int j = 2; (a[i] * j) <= a[n - 1]; j++) cnt[a[i] * j] = -1;
    }
  }
  REP(i, 1000001) {
    if (cnt[i] == 0) {
      bool flag = true;

      if (nlist.count(i)) flag = false;

      if (flag) ans++;
    }
  }
  // DEBUGS(a);
  // REP(i, 6) { cout << i << " " << cnt[i] << endl; }
  // while(!nlist.empty()){
  //   cout << nlist.front();
  //   nlist.pop();
  // }
  // cout << "\n";
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 9504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define double ld
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ifstream in("input.txt");ofstream out("output.txt");
const int inf=1e18;
const int mod=1e9+7;
int n,m;
vector<vector<char> > mat;
vector<vector<int> > dp;

void init()
{
    cin>>n>>m;
    mat.resize(n,vector<char>(m));
    dp.resize(n,vector<int>(m,inf));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>mat[i][j];
        }
    }
    dp[0][0]=1;
}

int go(int i,int j)
{
    if(i<0&&j<0)
        return 0;
    if(dp[i][j]!=inf)
        return dp[i][j];
    int ans=0;
    if(i-1>=0&&mat[i-1][j]!='#')
        ans+=go(i-1,j);
    if(j-1>=0&&mat[i][j-1]!='#')
        ans+=go(i,j-1);
    ans%=mod;
    return dp[i][j]=ans;
}

signed main()
{
    init();
    cout<<go(n-1,m-1);
    return 0;
}















Measured memory_bytes: 9216
from itertools import combinations, count
 
n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y].add(x - 1)
r = next(i for i in count(n, - 1) for x in map(set, combinations(r, i))
         if all(a[j][0].isdisjoint(x) and a[j][1] < x for j in x))
print(r)


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

int  main() {
  int A, B;
  cin >> A >> B;
  
  int A_min = 0, A_max = 0;
  int B_min = 0, B_max = 0;
  int ans = -1;
  bool possible = false;
  
  //たかだか1009円までしか考える必要がないので、もう全部探索する
  for(int i = 0; i < 1010; i++) {
    if(floor(i * 0.08) == A && floor(i * 0.1) == B) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  
/*
  //税がA円になる税抜価格の最小値と最大値を求める
  A_min = A / 0.08;
  A_max = (A+1) / 0.08;
  
  B_min = B / 0.10;
  B_max = (B+1) / 0.10;
  
//  cout << A_min << endl;
//  cout << A_max << endl;
  
  //共通範囲を求める、というか共通範囲があるかを判定する
  //あるなら、その区間の端の小さい方が答え
  if (B_min <= A_min && A_min <= B_max) {
    ans = A_min;
  }
  if (A_min <= B_min && B_min <= A_max) {
    ans = B_min;
  }
  
  cout << ans << endl;
  */
  
}



Measured memory_bytes: 256
#include	<stdio.h>

int main(void)
{
	int indat[10];
	int max;
	int i, j;

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

	for (i = 0; i < 3; i++){
		max = 0;
		for (j = 0; j < 10; j++){
			if (indat[j] > indat[max]){
				max = j;
			}
		}
		printf("%d\n", indat[max]);
		indat[max] = 0;
	}

	return 0;
}

Measured memory_bytes: 600
import java.util.*

fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)
    var N = reader.nextLong()
    var copyN = N
    var alpabitNums = 1
    var startTypes = 1L
    do {
        startTypes *= 26
        if(startTypes >= copyN){
            break
        }
        copyN -= startTypes
        alpabitNums++
    }while (true)

    startTypes = startTypes.div(26)
    var resultStr = ""
    //copyN = N
   // println(alpabitNums)
    //println(copyN)
    //println(startTypes)
    repeat(alpabitNums){
        if(it== alpabitNums - 1){
            resultStr += 'a' + copyN.toInt() - 1
        }
        else {
            var value= copyN / startTypes
            var startValue= 'a'
            if(copyN.rem(startTypes) > 0){
                resultStr += (startValue + value.toInt())
                copyN -= (value) * startTypes
            }
            else {
             resultStr += (startValue + value.toInt() - 1)
                copyN -= (value- 1) * startTypes
            }
            
        }
        startTypes = startTypes.div( 26)
    }
    println(resultStr)
}

Measured memory_bytes: 36348
#include <cstdio>
#include <cstring>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

ll vs[200000+10];
int n;

ll calc(ll x) {
  ll res = 0;
  REP(i, n) {
    res += abs(vs[i]-x);
  }
  return res;
}

int main(void) {
  scanf("%d", &n);
  REP(i, n) {
    scanf("%lld", &vs[i]);
    vs[i] -= i+1;
  }
  sort(vs, vs + n);
  ll res = min(calc(vs[n/2]), calc(vs[(n-1)/2]));
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));


#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

signed main(){
  int R; cin >> R;
  cout << 2 * R * M_PI << endl;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
using LL = long long;
typedef long long LL;
int n, m;
char g[22][22];

bool v[22][22];
int dfs(int x, int y) {
  if (x < 0 || y < 0 || x == n || y == m) return 0;
  if (v[x][y] || g[x][y] != '#') return 0;
  v[x][y] = true;
  return 1 + dfs(x+1,y) + dfs(x,y+1);
}

void f() {
  puts("Impossible");
  exit(0);
}

int main() {
  scanf("%d%d", &n, &m);
  REP(i, n) scanf("%s", g[i]);
  int cnt = 0;
  REP(i, n) REP(j, m) cnt += g[i][j] == '#';
  if (cnt != n + m - 1) f();
  if (g[0][0] != '#') f();
  if (g[n - 1][m - 1] != '#') f();
  if (dfs(0, 0) != cnt) f();
  puts("Possible");
  return 0;
}



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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    ll x;
    cin >> x;

    for (ll a = 1; a <= 1000; a++) {
        ll hoge = a * a * a * a * a - x;
        ll hoge_abs = abs(hoge);

        ll bb = -1;
        for (ll b = 0; b <= 1000; ++b) {
            if (b * b * b * b * b > hoge_abs) break;
            if (b * b * b * b * b == hoge_abs) {
                bb = b;
                break;
            }
        }

        if (bb < 0) continue;

        if (hoge < 0) bb = -bb;
        cout << a << " " << bb << newl;
        break;
    }

    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,M,P;
pair<pll, ll> abcv[5555];
ll pt[5555];
ll i, j, k, ans;

int main(){
    scanf("%lld%lld%lld", &N,&M,&P);
    fornum(i,0,M){
        ll A, B,C;
        scanf("%lld%lld%lld", &A,&B,&C);
        abcv[i] = {{A, B}, P - C};
    }
    fornum(i,0,N){
        pt[i+1] = 1e9;
    }
    pt[1] = 0;
    i = 0;
    do{
        fornum(j,0,M){
            auto ab = abcv[j].first;
            auto c = abcv[j].second;
            ll npt = pt[ab.first] + c;
            if(npt<pt[ab.second]){
                if(i>=N&&ab.second==N){
                    printf("-1");
                    return 0;
                }
                pt[ab.second] = npt;
            }
        }

    } while (++i<N*2);
    printf("%lld", pt[N] < 0 ? -pt[N] : 0);
}

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

using namespace std;

using ll = long long;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    {
        int num[3] = {A, B, C};
        std::sort(num, num + 3, std::greater<>());
        A = num[0];
        B = num[1];
        C = num[2];
    }

    ll ans = 0;
    ans += A - B;
    C += A - B;

    if ((A - C) % 2 == 0) {
        ans += (A - C) / 2;
    } else {
        ans += (A + 1 - C) / 2 + 1;
    }

    cout << ans << endl;

    return 0;
}


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

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

  vector<int> h(n);
  for (auto&& e : h) {
    cin >> e;
  }

  vector<bool> f(n, true);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    f[a] = f[a] && h[a] > h[b];
    f[b] = f[b] && h[b] > h[a];
  }

  int ans = count_if(begin(f), end(f), [](int x){return x;});
  cout << ans << endl;
}


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

int64_t beki(int64_t n){
 int64_t s,ans;
  s=(n*n)%1000000007;
  ans=(s*n)%1000000007;
  return ans;}

int main() {
int64_t k,a;
  a=0;
  cin>>k;
  vector<int64_t> ans(k);
  ans.at(k-1)=1;
  for(int64_t i=k-2;i>=0;i--){
  ans.at(i)=beki(k/(i+1));
    for(int64_t j=1;(i+1)*j<=k;j++){
    ans.at(i)=ans.at(i)-ans.at((i+1)*j-1);
     }
    ans.at(i)=ans.at(i)+beki(k/(i+1));
  }
  for(int64_t i=0;i<k;i++){a=a+(i+1)*ans.at(i);
  while(a>=1000000007){a=a-1000000007;}}
  cout<<a<<endl;
}  


Measured memory_bytes: 3616
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf
import Debug.Trace

import Control.Monad.ST
import Data.Array.ST.Safe
import Data.STRef

readInt = ( readLn :: IO Int )
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ h, w ] <- readInts
	board <- replicateM h readInts
	let	
		res = solve h w board
	print $ length res
	mapM_ putStrLn $ map ( unwords . map ( show . succ ) ) res

solve h w board' = runST $ do
	board <- newListArray ( ( 0, 0 ), ( h - 1, w - 1 ) ) $ concat board' :: ST s ( STUArray s ( ( Int, Int ) ) Int )
	res <- newSTRef []
	forM_ [ 0 .. h - 1 ] $ \i -> do
		forM_ [ 0 .. w - 2 ] $ \j -> do
			v <- readArray board ( i, j )
			when ( odd v ) $ do
				nv <- succ <$> readArray board ( ( i, j + 1 ) )
				writeArray board ( i, j + 1 ) nv
				modifySTRef res ( [ i, j, i, j + 1 ] : )
		v <- readArray board ( i, w - 1 )
		when ( i + 1 < h && odd v ) $ do
			nv <- succ <$> readArray board ( ( i + 1, w - 1 ) )
			writeArray board ( i + 1, w - 1 ) nv
			modifySTRef res ( [ i, w - 1, i + 1, w - 1 ] : )
	modifySTRef res reverse
	readSTRef res

Measured memory_bytes: 32892
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	double n, m;
	cin >> n >> m;
	double x = 0;
	double ni = 1;
	for (int i = 0; i < m; i++) {
		ni = ni * 0.5;
	}
	double amari = 1.0 - ni;
	double ans = 0;
	for (double i = 1; i < 10000; i++) {
		ans = ans + ni* (100 * (n - m) + 1900 * m)* i;
		ni = ni * amari;
	}
	cout <<ans * 10/10;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string s;
  string t;
  int a;
  int b;
  string u;
  cin>>s;
  cin>>t;
  cin>>a;
  cin>>b;
  cin>>u;
  if(u==s){
    cout<<a-1<<" "<<b<<endl;
  }
  else{
    cout<<a<<" "<<b-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

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

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int k = Integer.parseInt(str[1]);

		int count = 0;
		while (n > 0) {
			n /= k;
			count++;
		}

		System.out.println(count);
	}
}


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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)1e9+1
#define MOD (long long)1e9+7
#define INF64 (long long)1e18+1

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000


int main (void)
{
  llint M,L,A,B;
  llint K[MAX_N];
  bool bool_ans;
  string S;

  vector<char> C;
  llint N;

  cin >> S;
  for(int i=0;;i++) {
    if((S[i] != 'L')&&(S[i] != 'R')) {
      break;
    }
    C.push_back(S[i]);
  }

  N = C.size();
  vector<int> r_l;
  vector<int> l_r;
  vector<llint> ans(N);
  rep(i,0,N) {
    ans[i] = 0;
  }
  rep(i,1,N) {
    if((C[i-1] == 'R') && (C[i] == 'L')) {
      r_l.push_back(i);
    }
  }
  for(int i=N-2;i>=0;i--) {
    if((C[i+1] == 'L') && (C[i] == 'R')) {
      l_r.push_back(i);
    }
  }

  int k=0;
  int kk=0;
  rep(i,0,N) {
    if (C[i] == 'R') {
      for(int j=k;;j++) {
        if (r_l[j]>i) {

          if ((r_l[j]-i)%2 == 0) {
            ans[r_l[j]]++;
          } else {
            ans[r_l[j]-1]++;
          }
          // k=j;
          break;
        }
      }
    } else {

      for(int j=kk;;j++) {
        if(l_r[j]<i) {
          if ((l_r[j]-i)%2 == 0) {
            ans[l_r[j]]++;
          } else {
            ans[l_r[j]+1]++;
          }
          // kk=j;
          break;
        }
      }
    }
  }

  rep(i,0,N-1) {
    cout << ans[i] << " ";
  }
  cout << ans[N-1] << endl;

  return 0;
}


Measured memory_bytes: 2108
program sample
	character(len=5) :: a
    
    read(*,*) a
    
    if (a(1:2)=='AC' .or. a(2:3)=='AC' .or. a(3:4)=='AC' .or. a(4:5)=='AC') then
    	write(*,*) 'Yes'
    else
    	write(*,*) 'No'
    end if
    stop
end program sample


Measured memory_bytes: 2800
a = input().split()
a = [int(i) for i in a]
task = []
for i in range(a[0]):
    temp = input().split()
    temp = [int(i) for i in temp]
    task.append(temp)

lister = []
for i in task:
    if i[1] <= a[1]:
        lister.append(i[0])

if lister == []:
    print ('TLE')
else: 
    print (min(lister))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  n %= k;
  cout << min(n, k-n) << endl;
  return 0;
}

Measured memory_bytes: 256