akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<map>

#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
#define LL long long
#define INF (2147483647)
#define sqr(x)	((x)*(x))

using namespace std;

inline void read(int &data){
    data=0;
	int w=1; char ch=0;
    while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if (ch=='-') w=-1,ch=getchar();
    while  (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
    data=data*w;
}

inline void write(int x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
} 

inline void read(LL &data){
    data=0;
	int w=1; char ch=0;
    while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if (ch=='-') w=-1,ch=getchar();
    while  (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
    data=data*w;
}

inline void write(LL x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
} 

int main(){	
	int n;read(n);
	int now=0,k=0;
	while (true){
		k+=++now;
		if (k>=n)	break;
	}
	write(now);
} 

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

int main(){

  string s,t;
  cin >> s >> t;

  int len = s.length();
  int ans=0;
  for(int i=0;i<len;i++){
    if(s[i]!=t[i]){
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3920
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    string S;
  cin>>S;
  int num=0;
  rep(i, 4){
    if(S[i]=='+') num++;
    else num--;
  }
  cout<<num<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	string s;
	cin >> s;
	long long n=s.size(),ans=0,cnt_B=0;
	for(long long i=n-1;i>=0;i--){
		if(s[i]=='B'){
			ans+=n-(i+1)-cnt_B;
			cnt_B++;
		}	
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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 H,W;
 int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};
 string s[51];
 int cost[51][51];

int main(int argc, char const *argv[]) {
  cin >> H >> W;
  rep(i,H) cin >> s[i];
  rep(i,H) rep(j,W) cost[i][j]=99999;
  cost[0][0]=0;

  queue<int> que; //y座標x座標の順にqueue保存
  que.push(0); que.push(0);

  while(!que.empty()){
    int y=que.front(); que.pop();
    int x=que.front(); que.pop();
    rep(i,4){
      int nx=x+dx[i];
      int ny=y+dy[i];
      if(nx<0 || ny<0 || nx>=W || ny>=H || s[ny][nx]=='#' || cost[ny][nx]<=cost[y][x]+1) continue;
      cost[ny][nx]=cost[y][x]+1;
      que.push(ny);
      que.push(nx);
    }
  }
  if(cost[H-1][W-1]>=99999){
    cout << "-1" << endl;
    return 0;
  }

  int cnt=0;
  rep(i,H) rep(j,W) if(s[i][j]=='.') cnt++;
  cout << cnt - cost[H-1][W-1] -1 << endl;
  return 0;
}


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

void Main()
{
    int n;
    cin >> n;
    if(n==1) cout << 0 << endl;
    else cout << 1 << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
int main(void)
{
	int i,j,h,w;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0){
			break;
		}
		for(i=0;i<h;i++){
			if(i%2==1){
				for(j=0;j<w;j++){
					if(j%2==1){
						printf("#");
					}
					else{
						printf(".");
					}
				}
			}
			else{
				for(j=0;j<w;j++){
					if(j%2==0){
						printf("#");
					}
					else{
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2092
#include<cstdio>
using namespace std;
const int N=2e5+5;
int n,A[N],l,r=N;
bool Check(int x){
	for(int i=1;i<n;++i){
		if((A[n-i]>=x)==(A[n-i+1]>=x))return A[n-i]>=x;
		if((A[n+i]>=x)==(A[n+i-1]>=x))return A[n+i]>=x;
	}
	return A[1]>=x;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n*2-1;++i)scanf("%d",&A[i]);
	while(l+1<r){
		int mid=(l+r)/2;
		if(Check(mid))l=mid;
		else r=mid;
	}
	printf("%d\n",l);
}

Measured memory_bytes: 1024
# encoding:utf-8

import numpy as np
import random

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

answer = 0
for i in range(N+1):
    n = list(str(i))
    sum = 0
    for j in range(len(n)):
        sum += int(n[j])
    if A <= sum <= B:
        answer += i

print(answer)


Measured memory_bytes: 13360
#include <iostream>                                             
#include <vector>                                               
using namespace std;                                            
                                                                
int main() {                                                    
  int n, m;                                                     
  while (true) {                                                
    cin >> n;                                                   
    if (n==0) {                                                 
      break;                                                    
    }                                                           
    vector<char> from(n);                                       
    vector<char> to(n);                                         
    for (int i=0; i<n; i++) {                                   
      cin >> from[i] >> to[i];                                  
    }                                                           
    cin >> m;                                                   
    vector<char> v(m);                                          
    for (int i=0; i<m; i++) {                                   
      cin >> v[i];                                              
      for (int j=0; j<n; j++) {                                 
        if (v[i]==from[j]) {                                    
          v[i] = to[j];                                         
          break;                                                
        }                                                       
      }                                                         
    }                                                           
    for (int i=0; i<m; i++) {                                   
      cout << v[i];                                             
    }                                                           
    cout << endl;                                               
  }                                                             
  return 0;                                                     
}                                    

Measured memory_bytes: 3160
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int n,a;
	string s;
	cin>>n>>s>>a;
	char ke=s[a-1];
	rep(i,s.size()){
		if(s[i]!=ke)cout<<"*";
		else cout<<ke;
	}
	cout<<endl;
	

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,j;
	int h[100],max,hn;
	for(i=0;i<10;i++)scanf("%d",&h[i]);
	for(i=0;i<10;i++){
		for(j=9;j>0;j--){
			if(h[j]>h[j-1]){
				hn=h[j-1];
				h[j-1]=h[j];
				h[j]=hn;
			}
		}
	}
	printf("%d\n%d\n%d\n",h[0],h[1],h[2]);
	return 0;
}

Measured memory_bytes: 600
n = int(input())
s = input()
res = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            current = 0
            require = [str(i), str(j), str(k)]
            for v in s:
                if v == require[current]:
                    current += 1
                    if current == 3:
                        res += 1
                        break
print(res)


Measured memory_bytes: 42332
'''
def a(b):
    if b <= 1:
        return 1
    return b*a(b-2)
'''
n = int(input())

count = 1

ans = 0
if n%2 == 1:
    print(0)
else:
    for i in range(50):
        kakeru = 10*5**i
        if kakeru <= n:
            ans += n//kakeru
            count *= 10
        else:
            break

    print(ans)


Measured memory_bytes: 2940
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N = int(input())
    a = np.array(list(map(int, input().split())))

    ans = sum((a - min(a)) ** 2)
    for i in range(min(a)+1, max(a)+1):
        ans = min(ans, sum((a - i) ** 2))    
    print(ans)

if __name__ == "__main__":
    main()

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define INF INT_MAX/3
#define N 3
#define LIMIT_TIME 180000
typedef pair<int, int> P;

struct State {
    int g, h;
    string state;
    P blank;
    string path;
    bool operator<(const State &a) const {
        return g + h > a.g + a.h;
    }
};

int d[5] = {-1, 0, 1, 0, -1};
string r[4] = {"D", "R", "U", "L"};
string ans_str = "";
int ans[N][N], puzzle0[N][N], puzzle1[N][N];
set<string> s;
priority_queue<State> next_state;
string path;

bool range(int y, int x) {return 0 <= y && y < N && 0 <= x && x < N;}

int h2() {
    int find = -1;
    while(next_state.size()) {
        State state = next_state.top();
        next_state.pop();
        if (s.count(state.state)) continue; // already search
        s.insert(state.state); // visited

        P blank = state.blank;
        rep(i, 4) {
            int y = d[i] + blank.first, x = d[i + 1] + blank.second; // next blank position
            if (range(y, x)) { // can be replaced
                string tmp = state.state; // next state (string)
                int p = blank.first * N + blank.second, q = y * N + x;
                if (N < 4)  swap(tmp[p], tmp[q]);
                else swap(tmp[2 * p], tmp[2 * q]), swap(tmp[2 * p + 1], tmp[2 * q + 1]);
                if (s.count(tmp)) continue; // already search

                int num;
                if (N < 4) num = state.state[q] - '1';
                else num = stoi(state.state.substr(2 * q, 2)) - 1;
                // calcurate manhattan distance
                int manhattan = state.h - ((abs(num / N - y) + abs(num % N - x)))
                + (abs(num / N - blank.first) + abs(num % N - blank.second));

                if (manhattan == 0) { // answer
                    find = state.g + 1;
                    path = state.path + r[i];
                    break;
                }

                next_state.push(State{state.g + 1, manhattan, tmp, P(y, x), state.path + r[i]});
            }
        }
        if (find != -1) break; // find an answer
    }
    return find;
}

int main(){
    rep(i, N)rep(j, N) cin >> puzzle0[i][j];

    string state = "";
    P blank;
    int manhattan = 0, wrong_place = 0;
    rep(i, N)rep(j, N) {
        // cout << puzzle0[i][j] << ((j % N == N - 1) ? "\n" : "\t");

        if (N * N - 1 > 9 && puzzle0[i][j] < 10) state += "0";
        state += to_string(puzzle0[i][j]);
        if (N * N - 1 > 9 && ans[i][j] < 10) ans_str += "0";
        ans_str += to_string(ans[i][j]);

        if(puzzle0[i][j] == 0) blank = P(i, j);
        else {
            int num = puzzle0[i][j] - 1;
            manhattan += (abs(num / N - i) + abs(num % N - j));
            if (puzzle0[i][j] != ans[i][j]) wrong_place++;
        }
    }

    if (manhattan == 0) { // the answer
        cout << 0 << endl;
    } else {
        s.clear();
        next_state = priority_queue<State>();
        next_state.push(State{0, manhattan, state, blank, ""});
        int steps = h2();
        cout << steps << endl;
    }
    return 0;
}

Measured memory_bytes: 5156
#include<iostream>
#include<cstdio>
#include<complex>
using namespace std;
typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); };
int main() {
	xy_t z[8], p;
	double set[8], s1, s2, s3;
	while (
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf", set, set + 1, set + 2, set + 3, set + 4, set + 5, 

set + 6, set + 7)
		== 8) {
		for (int i = 0; i < 3; i++) {
			z[i] = xy_t(set[i*2], set[i*2 + 1]);
		}
		p = xy_t(set[6], set[7]);
		for (int i = 0; i < 3; i++)
			z[i] -= p;
		s1 = cross_product(z[0], z[1]);
		s2 = cross_product(z[1], z[2]);
		s3 = cross_product(z[2], z[0]);
		if ((s1 > 0 && s2 > 0 && s3 > 0) || (s1 < 0 && s2 < 0 && s3 < 0))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+7;
int n,m,vis[50],ans;
signed main(){
    scanf("%d%d",&n,&m);
    for(int i=1,k;i<=n;i++){
        scanf("%d",&k);
        for(int j=0,x;j<k;j++)
            scanf("%d",&x),vis[x]++;
    }
    for(int i=1;i<=m;i++)if(vis[i] == n)ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
N, K, Q = map(int, input().split())

# print(N)
# print(K)
# print(Q)

scores = []
for i in range(N):
    scores.append(K)

for i in range(Q):
    # print(i)
    A = int(input())
    # print(A)
    
    # for j in range(N):
    #     if j + 1 != A:
    #         scores[j] -= 1
    scores[A - 1] += 1
            
# print(scores)

for i in range(N):
    if scores[i] > K + Q - K:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 6604
#include <iostream>
#define T 13
using namespace std;
int Change(char);

int main(){
  int cnt,c;
  char trump,b;
  string d[4][T]; //nesw
  while(1){
    cin>>trump;
    if(trump=='#') break;
    for(int i=0;i<4;i++)
      for(int j=0;j<T;j++) cin>>d[i][j];
    c=cnt=0;
    for(int i=0;i<T;i++){
      b=d[c][i][1];
      int f=0,ma=0,winner;
      for(int j=0;j<4;j++)
	if(d[j][i][1]==trump){
	  f=1;
	  int v=Change(d[j][i][0]);
	  if(ma<v) ma=v,winner=j;
	}
      if(f){
	if(winner%2) cnt++;
	c=winner;
	continue;
      }
      for(int j=0;j<4;j++){
	if(d[j][i][1]==b){
	  int v=Change(d[j][i][0]);
	  if(ma<v) ma=v,winner=j;
	}
      }
      if(winner%2) cnt++;
      c=winner;
    }
    if(cnt>=7) cout<<"EW "<<cnt-6<<endl;
    else cout<<"NS "<<7-cnt<<endl;
  }
  return 0;
}

int Change(char x){
  int v;
  if('0'<=x&&x<='9') v=x-'0';
  else if(x=='A') v=20;
  else if(x=='K') v=15;
  else if(x=='Q') v=12;
  else if(x=='J') v=11;
  else if(x=='T') v=10;
  return v;
}

Measured memory_bytes: 1188
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

h,w,k = li()
k -= 1
MOD = 10**9 + 7

# 遷移行列
if w > 1:
    matrix = [[0]*w for _ in range(w)]
    for num in range(1 << (w-1)):
        if "11" in bin(num):
            continue

        ex = False
        for i, bit in enumerate(bin(num)[2:].zfill(w-1)):
            if bit == "1":
                ex = True
                matrix[i][i+1] += 1
                matrix[i+1][i] += 1

            elif ex:
                ex = False

            else:
                matrix[i][i] += 1

        if not ex:
            matrix[w-1][w-1] += 1

    # 適用
    dp = [1] + [0]*(w-1)
    for hi in range(h):
        nex = [0]*w
        for wj in range(w):
            for wk in range(w):
                nex[wj] += matrix[wj][wk] * dp[wk]
                nex[wj] %= MOD

        dp = nex

    print(dp[k])

else:
    print(1)

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

int main(){
  int N;
  cin >> N;
  vector<int> L(15);
  for(int i=0;i<N;i++)cin >> L[i];
  int sum=0; int M=L[0];
  for(int i=0;i<N;i++){
    sum+=L[i]; M=max(M,L[i]);
  }
  if(M<sum-M){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<stdlib.h>

using namespace std;


int main(){

	int i,j;
	for(i=1 ; i<10 ; i++){
		for(j=1 ; j<10 ; j++){
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define rrep(i,n) for(ll i=(ll)n-1;i>=0;--i)
#define vin(v,n) rep(i,n)cin>>v[i];
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define sz size()
#define fi first
#define se second
#define pb push_back
#define prqueue priority_queue<ll,vector<ll>,greater<ll>>
#define print(s) cout<<s<<endl;
#define inp(s) cin>>s;
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll a, b, c, d, e,ans,ct,v[100010];
string s, ss;
int main() {
	cin >> s >> ss;
	rep(i, s.size()) {
		string sss = s;
		if (s == ss)break;
		rep(j, s.size()) {
			s[(j+1)%s.size()]=sss[j];
		}
		//cout << s << endl;
		if (s == ss)break;
	}
	print(yn(s == ss));
	return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
def solve(a,b):
    if a%2==0 or b%2==0:
        return a*b//2,a*b//2
    return min(a,b)*(max(a,b)//2),min(a,b)*(1+max(a,b)//2)
ret=h*w
for x in range(1,w):
    mi,ma = solve(h,w-x)
    ret=min(ret,max([ma-mi,ma-h*x,h*x-mi]))
for x in range(1,h):
    mi,ma = solve(w,h-x)
    ret=min(ret,max([ma-mi,ma-w*x,w*x-mi]))
print(ret)


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

class Program {
  static void Main() {
    int n = int.Parse(Console.ReadLine());
    var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    var t = arr[0];
    var a = arr[1];
    Func<int, double> F = x => t - x * 0.006;
    arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int ans = 1;
    double min = 100000;
    for (int i = 0; i < n; i++) {
      var s = Math.Abs(F(arr[i]) - a);
      if (s < min) {
        min = s;
        ans = i + 1;
      }
    }
    Console.WriteLine(ans);
  }
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x, y, b, p;
        cin >> x >> y >> b >> p;
        int ans = x * b + y * p;
        if (b >= 5 && p >= 2) {
            ans *= 4;
            ans /= 5;
        } else {
            int ans1 = x * max(b, 5) + y * max(p, 2);
            ans1 *= 4;
            ans1 /= 5;
            ans = min(ans, ans1);
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 3228
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 300005
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	// WF("output.txt");
	DF("err.txt");

	int l, r;
	scanf("%d %d", &l, &r);
	int rem = 0;
	if (r - l >= 2019) rem = 2019;
	l %= 2019;
	r %= 2019;
	if (l >= r) r += 2019;
	r += rem;
	int res = 2020;
	int ql, qr;
	for (int i = l; i <= r; i++) for (int j = i + 1; j <= r; j++) {
		res = min(res, i * j % 2019);
	}
	printf("%d\n", res);
	return 0;
}

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

int main() {
  int N;
  cin>>N;
  string A,B;
  cin>>A>>B;
  for(int i=0;i<N*2;i++){
    if(i%2==0){
      cout<<A.at(i/2);
    }
    else if(i%2==1){
      cout<<B.at((i-1)/2);
    }
  }
  cout<<endl;
}


Measured memory_bytes: 256
/*  CF_CC
        4U7H0R:_C4551DY */

#include <bits/stdc++.h>

using namespace std;

#define IC ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(im) for(int i=0;i<a;i++)
#define lb lower_bound
#define ll long long
#define pii pair<ll,ll>
#define vec vector<int>
#define fir first
#define sec second
const int mxi=1e7+10;
const int mod=1e9+7;

ll a,b,c;string s1,s2,s3;

int main()
{
    IC
    cin >> s1 >> s2 >> a >> b >> s3;
    if(s3==s1)
        cout << a-1 << " " << b;
    else
        cout << a << " " << b-1;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		int size = sc.nextInt();
		int maxWeight = sc.nextInt();
		long values[] = new long[size];
		int weight[] = new int[size];
		for(int i=0;i<values.length;i++){
			weight[i]=sc.nextInt();
			values[i]=sc.nextLong();
		}
		long dp[][] = new long[values.length+1][maxWeight+1];
		for(int i=0;i<dp.length;i++){
			for(int j=0;j<dp[0].length;j++){
				if(i==0||j==0)dp[i][j]=0;
				else if(weight[i-1]<=j){
					dp[i][j]=Math.max(dp[i-1][j],dp[i-1][j-weight[i-1]]+values[i-1]);
				}else{
					dp[i][j]=dp[i-1][j];
				}
			}
		} 
		System.out.println(dp[values.length][maxWeight]);
	}
}

Measured memory_bytes: 140660
import itertools
n = list(input())
if len(n) <= 2:
    print(0)
    exit()
list3 = [1,3,9]
list2 = [1,2,4]
count = 0
for i in range(3,len(n)):
    list3.append(list3[-1]*3)
    list2.append(list2[-1]*2)
    count += list3[-1]-3*list2[-1]+3
A = ["3","5","7"]
l = list(itertools.product(A,repeat = len(n)))

for i in l:
    if "3" in i and "5" in i and "7" in i:
        if n >= list(i) :
            count += 1
print(count)



Measured memory_bytes: 5492
def main():
    n = int(input())
    h = list(map(int, input().split()))
    for i in range(n - 1, 1, -1):
        if h[i - 1] - 1 > h[i]:
            print("No")
            return
        elif h[i - 1] - 1 == h[i]:
            h[i - 1] -= 1
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 14224
# ABC154A

def f(s, t, a, b, u):
    if u == s:
        print(a - 1, b)
    else:
        print(a, b - 1)

s, t = input().split()
a, b = map(int, input().split())
u = input()

f(s, t, a, b, u)


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

int main(){
  int l,r,d;
  cin >> l >> r >> d;
  int ans=0;
  for(int i=l;i<=r;i++){
    if(i%d==0){
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, h, w;
  cin >> n >> h >> w;
  vector<int> vi(h + 1), vj(w + 1);
  while (n--) {
    int i, j, d;
    cin >> i >> j >> d;
    ++vi[max(i - d, 0)];
    --vi[min(i + d, h)];
    ++vj[max(j - d, 0)];
    --vj[min(j + d, w)];
  }
  for (int i = 0; i < h; ++i) {
    vi[i + 1] += vi[i];
  }
  for (int j = 0; j < w; ++j) {
    vj[j + 1] += vj[j];
  }
  if (all_of(begin(vi), begin(vi) + h, [](int e) { return e; }) or
      all_of(begin(vj), begin(vj) + w, [](int e) { return e; })) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}



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

int main() {
    int N, M; cin >> N >> M;
    vector<int> v(N,0);
    
    for (int i = 0; i < M; i++){
        int a=0, b=0; cin >> a >> b;

        for (int j = 0; j < N; j++){
            if (a == j+1) v.at(j)++; 
            if (b == j+1) v.at(j)++;
        }
    }

    for (int i = 0; i < N; i++) cout << v.at(i) << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int MAX_ANS = 1000000000+7;

long pow_(long x, int n) {
	long ans = 1;
    while (n > 0) {
		if ((n & 1) == 1) {
			ans = (ans * x) % MAX_ANS;
		}
        x = (x * x) % MAX_ANS;
		n >>= 1;
	}
    return ans;
}

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

    long ans = 1; // m=0でans=1
    long xc = 1, xh = 1, y = 1; // yは共通
    for(int m=1; m<min(n, k)+1; m++) {
        xc = (xc * (n-m+1)) % MAX_ANS;
        xh = (xh * (n-m)) % MAX_ANS;
        y = (y * pow_(m, MAX_ANS-2) ) % MAX_ANS;
        long c = (xc * y) % MAX_ANS; // nCm
        long h = (xh * y) % MAX_ANS; // n-mHm = n-1Cm
        ans = (ans + c * h) % MAX_ANS;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

int a[100010], b[100010];
PII p[100010];
int dp[100010];
signed main(void)
{
  int n, h;
  cin >> n >> h;
  int ma = 0;
  REP(i, n) {
    cin >> a[i] >> b[i], p[i] = {b[i], a[i]};
    chmax(ma, a[i]);
  }
  sort(p, p+n);
  REP(i, n) dp[i+1] = dp[i] + p[i].first;
  // REP(i, n+1) cout << dp[i] << " "; cout << endl;

  int ans = INF;
  for(int i=n-1; i>=0; --i) {
    int tmp = max(0LL, h-(dp[n]-dp[i]));
    // cout << i << " " << tmp << endl;

    int ret = (n-i) + tmp/ma + !!(tmp%ma);
    chmin(ans, ret);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int n;
  cin >> n;
  int arr[n];
  vector <int> vec;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    arr[i] -= i + 1;
    vec.push_back(arr[i]);
  }
  sort(vec.begin(), vec.end());
  int p = vec[vec.size() / 2];
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += abs(arr[i] - p);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#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 DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w, a[514][514];
	cin>>h>>w;
	REP(i, h){
		REP(j, w){
			cin>>a[i][j];
		}
	}
	int cnt=0;
	int ans[514514][4];
	REP(i, h){
		REP(j, w){
			if(a[i][j]&1){
				// DEBUG(i);
				// DEBUG(j);
				// DEBUG(cnt);
				if(j!=w-1){
					++a[i][j+1];
					ans[cnt][0]=i;
					ans[cnt][1]=j;
					ans[cnt][2]=i;
					ans[cnt][3]=j+1;
					++cnt;
				}
				else if(i!=h-1){
					++a[i+1][j];
					ans[cnt][0]=i;
					ans[cnt][1]=j;
					ans[cnt][2]=i+1;
					ans[cnt][3]=j;
					++cnt;
				}
			}
		}
	}
	cout<<cnt<<'\n';
	if(cnt){
		REP(i, cnt){
			cout<<ans[i][0]+1<<' '<<ans[i][1]+1<<' '<<ans[i][2]+1<<' '<<ans[i][3]+1<<'\n';
		}
	}
	return 0;
}


Measured memory_bytes: 6912
import qualified Data.Set as Set

f n
  | even n    = n : f (n `div` 2)
  | otherwise = n : f (3 * n + 1)

solve set ((i,x):xs) =
    if Set.member x set
       then i else solve (Set.insert x set) xs

main :: IO ()
main = do
    s <- readLn :: IO Int
    print $ solve Set.empty (zip [1..] (f s))


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
#define pb=push_back
int INF=1e9+7;

int main() {
  int N,M,K;
  cin >> N >> M >> K;
  vi A(N),B(M);
  vl sumA(N+1),sumB(M+1);
  rep(i,N) {
    cin >> A[i];
    sumA[i+1]=sumA[i]+A[i];
  }
  rep(i,M) {
    cin >> B[i];
    sumB[i+1]=sumB[i]+B[i];
  }
  int ans=0;
  rep(i,N+1) {
    if(sumA[i]>K) break;
    int x=upper_bound(sumB.begin(),sumB.end(),K-sumA[i])-sumB.begin();
    ans=max(ans,x+i-1);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 7904
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    string S;
    cin >> S;
    int a = stoi(S.substr(0, 2)), b = stoi(S.substr(2, 2));
    bool ym_flag = true, my_flag = true;
    if (a < 1 || 12 < a) my_flag = false;
    if (b < 1 || 12 < b) ym_flag = false;
    if(ym_flag == my_flag) {
        if(ym_flag) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "NA" << endl;
        }
    } else {
        if(ym_flag) {
            cout << "YYMM" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    }
    return 0;
}

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

using namespace std;

int main() {
 int a, b, c, d;
 cin >> a >> b >> c >> d;
 int turn = 0;
 while(true) {
 	if (turn == 0) {
    	c -= b;
      	if (c <= 0) {
        	cout << "Yes";
          	return 0;
        }
      	turn = 1;
    }
    else {
      a -= d;
      if (a <= 0) {
      	cout << "No";
        return 0;
      }
      turn = 0;
    }
 }
 return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

int n; char mp[55][55];
ll dp[55][55][55]; bool vis[55][55][55];
ll dfs(int l,int mid,int r)
{
	if (vis[l][mid][r]) return dp[l][mid][r];
	vis[l][mid][r]=true;
	if (l==mid&&r==mid) return dp[l][mid][r]=1;
	if (l==mid||r==mid) return dp[l][mid][r]=0;
	
	ll res=0;
	for (int i=l;i<mid;i++)
		for (int j=mid+1;j<=r;j++)
			if (mp[i][j]=='1')
				for (int u=i;u<mid;u++)
					for (int v=mid;v<j;v++)
						res+=dfs(l,i,u)*dfs(u+1,mid,v)*dfs(v+1,j,r);
	return dp[l][mid][r]=res;
}
int main()
{
	//freopen("data.in","r",stdin);
	//freopen("A.out","w",stdout);

	scanf("%d",&n);
	for (int i=1;i<=(n<<1);i++) scanf("%s",mp[i]+1);
	ll ans=0;
	for (int i=2;i<=(n<<1);i++) if (mp[1][i]=='1') ans+=dfs(2,i,(n<<1));
	printf("%lld\n",ans);
	return 0;
}

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

int main(void){
  int a, b; cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) cout << "Possible " << endl;
  else cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main() {
	string S;
	getline(cin, S);
	int size = S.size();
	int ACGT = 0;
	int max = 0;
	for (int i = 0; i < size; i++) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
			ACGT++;
		}
		else {
			if (max < ACGT) { max = ACGT; }
			ACGT = 0;
		}
	}
	if (max < ACGT) { max = ACGT; }
	ACGT = 0;
	cout << max << endl;
}

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

int main()
{
  int64_t K, S, z = 0, ans = 0;
  cin >> K >> S;
  if (S % 3 == 0) // 3つとも同じ数の場合
    ans += 1;
  for (int x = 0; x <= K; x++) // 2つが同じ数の場合
  {
    int64_t z = S - 2 * x;
    if (z == x)
      continue;
    if (0 <= z && z <= K)
      ans += 3;
  }
  for (int x = 0; x <= K - 2; x++)
  {
    for (int y = x + 1; y <= K - 1; y++)
    {
      int64_t z = S - x - y;
      if (z <= y)
        continue;
      if (z <= K)
        ans += 6;
    }
  }
  cout << ans << endl;
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;  
  string s;
  cin >> s;
  int cnt = 0;
  for (auto& c : s) {
    if (c == 'R') {
      cnt++;
    }
  }
  int ans = cnt;
  int cur = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      cur++;
      cnt--;
    }
    int tmp = i + 1 - cur + max(0, cnt - (i + 1 - cur));
    ans = min(ans, tmp);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long
#define mp make_pair
int a,b,c,d;
int ans;
int main()
{
	cin>>a>>b>>c>>d;
	ans=min(a,b)+min(c,d);
	cout<<ans;
    return 0;
}


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

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

class Data {
   public:
    int x, y, count;
    Data() {}
    Data(int x, int y, int count) : x(x), y(y), count(count) {}
};
int main() {
    int h, w, n;
    cin >> h >> w >> n;
    Data start;
    int ans = 0;
    for (int i = 0; i < h; i++) {
        cin >> field[i];
        for (int j = 0; j < w; j++) {
            if (field[i][j] == 'S') {
                start = Data(j, i, 0);
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        queue<Data> Q;
        Q.push(start);
        bool flg[1000][1000] = {{0}};
        while (!Q.empty()) {
            Data d = Q.front(); Q.pop();
            if (field[d.y][d.x] == i + '0') {
                start = Data(d.x, d.y, d.count);
                break;
            }
            if (flg[d.y][d.x]) continue;
            flg[d.y][d.x] = true;
            for (int j = 0; j < 4; j++) {
                int px = d.x + dx[j], py = d.y + dy[j];
                if (px < 0 || py < 0 || px >= w || py >= h) continue;
                if (field[py][px] == 'X') continue;
                Q.push(Data(px, py, d.count + 1));
            }
        }
        ans = start.count;
    }

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

Measured memory_bytes: 5052
#include <iostream>

using namespace std;

typedef long long ll;

ll N;
ll A[100005];
ll MOD=1e9+7;

ll coeff[100005];
ll nf;

ll mod_inv(ll a, ll m) {
        a = a%m;
        ll s0=0,s1=1,s2=m;
        ll t0=1,t1=0,t2=a;
        while (t2 != 0) {
                ll q = s2/t2;
                ll r0=t0,r1=t1,r2=t2;
                t0=s0-q*t0,t1=s1-q*t1,t2=s2-q*t2;
                s0=r0,s1=r1,s2=r2;
        }

        return (s0%MOD + MOD)%MOD;
}

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

        nf = 1;
        for (int i=1; i<=N; i++)
                nf = (i*nf)%MOD;

        coeff[0] = 0;
        for (int i=1; i<=N; i++)
                coeff[i] = (coeff[i-1] + (nf*mod_inv(i,MOD))%MOD)%MOD;

        ll ret=0;
        for (int i=0; i<N; i++) {
                ret += (A[i]*((coeff[i+1] + coeff[N-i] - nf + MOD)%MOD))%MOD;
                ret %= MOD;
        }

        cout << ret << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int k,x;
	cin>>k>>x;
	for(int i=x-k+1;i<x+k;i++){
		cout<<i<<" ";
	}
	cout<<endl;
	return 0;
}



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


int main(){

  int n;
  std::cin>>n;
  double ans=0;
  for(int i=0;i<n;++i){
    double x;
    std::string u;
    std::cin>>x>>u;
    
    if(u=="JPY"){
      ans+=x;
    }else{
      ans+=380000*x;
    }
    
  }
  
  std::cout<<ans<<std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	//6 -> 5 -> 6 ...
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long ans = 0;
		long a = x / 11;
		x -= a * 11;
		ans += a * 2;
		if (x > 0) {
			x -= 6;
			ans++;
		}
		if (x > 0) {
			x -= 5;
			ans++;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 9804
class FenwickTree:
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)
    
    def build(self, lst):
        self.value = lst
        for i, x in enumerate(lst):
            self.add(i + 1, x)
        
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s
    
    def add(self, i, x):
        while i <= self.n:
            self.bit[i] += x
            i += i & -i
    
    def get_sum(self, i, j):
        return self.sum(j) - self.sum(i)

import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
A = list(map(int, input().split()))

bit = FenwickTree(N)
bit.build(A)

for i in range(Q):
    a, b, c = map(int, input().split())
    if a == 0:
        bit.add(b + 1, c)
    else:
        print(bit.get_sum(b, c))


Measured memory_bytes: 127208
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

void Matrix(int *p,int plength){
  int i,j,k,l,q;
  int n=plength-1;
  int m[plength][plength];

  for(i=1;i<=n;i++) m[i][i]=0;
  
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INT_MAX;
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	m[i][j]=(m[i][j]<q ? m[i][j]:q);
      }
    }
  }
  printf("%d\n",m[i][j]);
}

main(){
  int i,n,gomi;
  int *A;

  scanf("%d",&n);

  A=malloc(sizeof(int)*(n+2));

  for(i=1;i<n;i++) scanf("%d%d",&A[i],&gomi);
  scanf("%d%d",&A[i],&A[i+1]);

  Matrix(A,n+2);

  return 0;
}

Measured memory_bytes: 632
#include <iostream>
#include <string>

using namespace std;

void String_Compare(int &cnt, int &cnt_R, std::string buf, unsigned int &i);
void Consecutive_Cnt_Update(int &cnt_max, int &cnt_tmp);

int main()
{
	int cnt = 0;
	int cnt_R = 0;
	
	std::string buf;
	std::cin >> buf;

	for (unsigned int i = 0; i < buf.length(); i++)
	{
		String_Compare(cnt, cnt_R, buf, i);
	}

	std::cout << cnt << std::endl;
	return 0;

}

void String_Compare(int &cnt, int &cnt_R, std::string buf, unsigned int &i)
{
	if ('R' == buf[i])
	{
		cnt_R++;
		Consecutive_Cnt_Update(cnt, cnt_R);
		return;
	}
	if ('S' == buf[i])
	{
		Consecutive_Cnt_Update(cnt, cnt_R);
		cnt_R = 0;
		return;
	}
	cnt_R = 0;
}


void Consecutive_Cnt_Update(int &cnt_max, int &cnt_tmp)
{
	if (cnt_max < cnt_tmp)
	{
		cnt_max = cnt_tmp;
	}
}



Measured memory_bytes: 3600
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int k, x; cin >> k >> x;

	vector<int> ans;
	for (int i = -1000000; i <= 1000000; i++) {
		if (x - k < i && i < x + k) {
			ans.push_back(i);
		}
	}

	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i];

		if (i == (ans.size() - 1)) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
  if(a[i]%2==0):
    if((a[i]%3==0) or (a[i]%5==0)):
      pass
    else:
      print('DENIED')
      sys.exit()
      
print('APPROVED')

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)


#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll n, m;

    cin >> n >> m;

    for(int i=0; i<m; i++)
    {

        ll a;

        cin >> a;

        n-=a;
    }

    if(n<=0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }





    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main()
{
	double a, b, c, d, e, f, x, y;

	while(cin >> a){
		cin >> b >> c >> d >> e >> f;

		x = ((c*e)-(f*b)) / ((a*e)-(b*d));
		y = ((a*f)-(d*c)) / ((a*e)-(b*d));

		if(x == -0)
			x = abs((int)x);
		if(y == -0)
			y *=abs((int)y);
		cout << fixed << setprecision(3);
		cout << x << ' ' << y << endl;
		cout << setprecision(6); // 標準の6桁に戻す
	}

	return 0;
}

Measured memory_bytes: 1284
com_lis = {}
def com(n,k):
    if k == 1:
        if not (n,k) in com_lis:
            com_lis[(n,k)] = 1
        return 1
    if n == 1:
        if not (n,k) in com_lis:
            com_lis[(n,k)] = 1
        return 1
    
    if not (n - 1,k) in com_lis:
        com_lis[(n -1,k)] = com(n - 1,k)
    if not (n ,k - 1) in com_lis:
        com_lis[(n,k -1)] = com(n,k - 1)
        
    
    com_lis[(n,k)] = com_lis[(n - 1,k)] + com_lis[(n,k - 1)]
    return com_lis[(n,k)]

while True:
   
    n,s = map(int,input().split())
    if [n,s] == [0,0]:
        break
    k = int(input())
    for l in range(k):
        p,q = map(int,input().split())
        if p == 1:
            for i in range(q,s+1):
                com_lis[(1,i)] = 0
        if q == 1:
            for j in range(p,n + 1):
                com_lis[(j,1)] = 0
        com_lis[(p,q)] = 0
        
    print(com(n,s))
    com_lis = {}

Measured memory_bytes: 7652
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
    vl A(50), B(50), C(50);
    cin >> A[0] >> B[0] >> C[0];

    int ans = 0;
    bool flag = false;
    for(int i = 0;i < 30;i++){
        if(A[i]%2 != 0 || B[i]%2 != 0 || C[i]%2 != 0){
            flag = true;
            break;
        }
        A[i + 1] = (B[i] + C[i])/2;
        B[i + 1] = (A[i] + C[i])/2;
        C[i + 1] = (A[i] + B[i])/2;
        ans++;
    }

    if(flag) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256