akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, int, hash<int>> ht; // while using, comment #define int long long  */

void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
using namespace std;
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("in6.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int T = 1;
    // cin >> T;
    
    FOR1(tt, T){
        // cout << "Case #" << tt << ": ";
        int n; cin >> n;
        vector<pii> pts;
        FOR(i, n){
            int x, y;
            cin >> x >> y;
            pts.emplace_back(x, y);
        }
        // https://leetcode.com/problems/maximum-of-absolute-value-expression/discuss/339968/JavaC%2B%2BPython-Maximum-Manhattan-Distance
        int ans = 0, smallest, cur;
        for (int p : {1, -1}) {
            for (int q : {1, -1}) {
                smallest = p * pts[0].ff + q * pts[0].ss;
                for (int i = 1; i < n; ++i) {
                    cur = p * pts[i].ff + q * pts[i].ss;
                    ans = max(ans, cur - smallest);
                    smallest = min(smallest, cur);
                }
            }
        }
        cout << ans;
        cout << '\n';
    }
    return 0;
}


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

typedef pair<int, int> T;
int N, K;
vector<T> G[2010];
vector<T> E;

int dfs(int v, int p){
  int s = 1;
  for(int i = 0; i < G[v].size(); i++){
    int u = G[v][i].first;
    if( u == p ) continue;
    G[v][i].second = dfs( u, v );
    s += G[v][i].second;
  }
  return s;
}

bool used[2010];
int solve_even(int v){
  int ret = N;
  for(int i = 0; i < G[v].size(); i++){
    fill(used, used + 2010, false);
    int t = 0;

    queue<T> Q;
    Q.push( T( v, 0 ) );
    used[v] = true;
      
    while( !Q.empty() ){
      int u = Q.front().first;
      int d = Q.front().second; Q.pop();
      if( d == K / 2 ){
	for(int j = 0; j < G[u].size(); j++){
	  if( used[ G[u][j].first ] ) continue;
	  t += G[u][j].second;
	}
      }else{
	for(int j = 0; j < G[u].size(); j++){
	  if( used[ G[u][j].first ] ) continue;
	  Q.push( T( G[u][j].first, d + 1 ) );
	  used[ G[u][j].first ] = true;
	}
      }
    }
    ret = min(ret, t);
  }
  return ret;
}

int solve_odd(int e){
  int ret = 0;
  fill(used, used + 2010, false);
    
  queue<T> Q;
  Q.push( T( E[e].first, 0 ) );
  Q.push( T( E[e].second, 0 ) );
  used[ E[e].first ] = true;
  used[ E[e].second ] = true;

  while( !Q.empty() ){
    int u = Q.front().first;
    int d = Q.front().second; Q.pop();
    if( d == K / 2 ){
      for(int j = 0; j < G[u].size(); j++){
	if( used[ G[u][j].first ] ) continue;
	ret += G[u][j].second;
      }
    }else{
      for(int j = 0; j < G[u].size(); j++){
	if( used[ G[u][j].first ] ) continue;
	Q.push( T( G[u][j].first, d + 1 ) );
	used[ G[u][j].first ] = true;
      }
    }
  }
  
  return ret;
}

int main(){
  cin >> N >> K;
  for(int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back( T(b, 0) );
    G[b].push_back( T(a, 0) );
    E.push_back( T(a, b) );
  }

  for(int v = 0; v < N; v++){
    dfs( v, -1 );
  }

  int ans = N;
  if( K % 2 == 0 ){
    for(int v = 0; v < N; v++)
      ans = min( ans, solve_even(v) );
  }else{
    for(int e = 0; e < N - 1; e++){
      ans = min( ans, solve_odd(e) );
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>


bool diff(int a[5], int k ){
  for(int i=0; i<5; i++){
    for(int j=i+1; j<5; j++){
      if ( !(std::abs(a[i] - a[j]) <= k) ) return false;
    }
  }
  return true;
}

int main (void){
  int x[5];
  for(int i=0; i<5; i++){
    std::cin >> x[i] ;
  }

  int k; std::cin >> k;

  if ( diff(x, k) ) std::cout << "Yay!" << std::endl;
  else std::cout << ":(" << std::endl;

  return 0;
}

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

int main() {
  int N;
  cin >> N;
  long long res = 1;
  int mod = 1e9 + 7;

  for (int i = 1; i <= N; ++i) {
    res *= i;
    res %= mod;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import math

INF = 1e12
n = int(input())
cnt = INF
m = math.sqrt(n)

for i in range(1, math.ceil(m) + 1):
  if n % i == 0:
    j = n // i
    cnt = min(cnt, i + j - 2)
  else:
    continue

print(cnt)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

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

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	int D, G;
	cin >> D >> G;
	P.resize(D);
	C.resize(D);
	rep(i, 0, D) {
		cin >> P[i] >> C[i];
	}


	ll ans = 1 << 29;


	rep(bit, 0, 1 << D) {
		ll sum = 0;
		ll num = 0;

		rep(i, 0, D) {
			if (bit & (1 << i)) {
				sum += C[i] + P[i] * 100 * (i + 1);
				num += P[i];
			}
		}
			if (sum >= G) {
				ans = min(ans, num);
			}
			else {
				rrep(i, D - 1, 0) {
					if (bit & (1 << i)) {
						continue;
					}
					rep(j, 0, P[i]) {
						if (sum >= G) {
							break;
						}
						sum += 100 * (i + 1);
						num++;
					}
				}
				ans = min(ans, num);

			}

		
	}
	



	cout << ans << endl;

















	/*cin >> D >> G;
	P.resize(D);
	C.resize(D);
	rep(i, 0, D) {
		cin >> P[i] >> C[i];
	}

	ll res = 1 << 29;
	rep(bit, 0, (1 << D)) {
		ll sum = 0;
		ll num = 0;
		rep(i, 0, D) {
			if (bit & (1 << i))sum += C[i] + P[i] * 100 * (i + 1), num += P[i];
		}
		if (sum >= G) {
			res = min(res, num);

		}
		else {
			rrep(i, D - 1, 0) {
				if (bit & (1 << i))continue;
				rep(j, 0, P[i]) {
					if (sum >= G)break;
					sum += 100 * (i + 1);
					num++;
				}
			}
			res = min(res, num);

		}

	}
	
	cout << res << endl;*/


}
	

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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


int main(void) {
    string s;
    cin >> s;

    if(s.at(0)!='A') {
        cout << "WA" << endl;
        return 0;
    }

    int ccnt=0, ccntkeep;
    for(int in=2;in<s.size()-1;in++) {
        if(s.at(in)=='C') { 
            ccnt++;
            if(ccnt==1) ccntkeep=in;
        }
        //cout << ccntkeep << endl;
    }
    if(ccnt!=1) {
        cout << "WA" << endl;
        return 0;
    }

    for(int in=1;in<s.size();in++) {
        if(ccntkeep==in) continue;
        if(s.at(in)-'a'<0||25<s.at(in)-'a') {
            cout << "WA" << endl;
            //cout << 'a';
            //cout << s.at(in);
            return 0;
        }
    }

    cout << "AC" << endl;

    return 0;
}


Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v) { cout << v << endl; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

int main() {
  int n, k; in(n),in(k);
  vector<ll> A(n);
  loop(i,0,n) in(A[i]);
  ll prod = 1;
  loop(i,0,k) prod *= A[i];
  loop(i,k,n) {
    if (A[i-k] < A[i]) print("Yes");
    else print("No");
  }
  return 0;
}


Measured memory_bytes: 4840
N = int(input())
A = list(map(int, input().split()))
#A = [int(x) for x in input().split()]
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
A = [-float('inf')] + A + [float('inf')]
B.sort()
C.sort()
C = [-float('inf')] + C + [float('inf')]

total = 0

for i in range(N):
    low = 0
    high = N + 1
    while high - low > 1:
        mid1 = (low + high) // 2
        if A[mid1] < B[i]:
            low = mid1
        else:
            high = mid1
    mid1 = low
    low = 0
    high = N + 1
    while high - low > 1:
        mid2 = (low + high) // 2
        if C[mid2] <= B[i]:
            low = mid2
        else:
            high = mid2
    mid2 = high
    total += mid1 * (N + 1 - mid2)

print(total)

Measured memory_bytes: 23328
A,B,K=map(int,input().split())

cnt=0
while K:
  if cnt%2==0:
    if A%2==1:
      A-=1
    B+=A//2
    A//=2
  else:
    if B%2==1:
      B-=1
    A+=B//2
    B//=2  
  K-=1
  cnt+=1
  
print(A,B)

Measured memory_bytes: 9192
#!/usr/bin/env python3
import sys


def solve(A: int, P: int):
    ret = (3 * A + P) // 2
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    solve(A, P)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int[] b = new int[m];
		for(int i = 0 ; i < m ; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		Map<Integer, Integer> endMap = new HashMap<>();
		Map<Integer, Integer> stMap = new HashMap<>();
		for(int i = 0 ; i < m ; i++) {
			if(a[i] == 1) {
				endMap.put(b[i], 1);
			}
			if(b[i] == n) {
				stMap.put(a[i], 1);
			}
		}
		for(int key : endMap.keySet()) {
			if(stMap.containsKey(key)) {
				System.out.println("POSSIBLE");
				return;
			}
		}
		System.out.println("IMPOSSIBLE");
	}
}


Measured memory_bytes: 95920
let s = readLine()!
let mod = 2019

func pow(_ a: Int, _ n: Int, _ mod: Int? = nil) -> Int {
  var a = a
  var n = n
  var result: Int = 1
  if let unwrappedMod = mod {
    while n > 0 {
      if n & 1 == 1 { result = result * a % unwrappedMod }
      n >>= 1
      a = a * a % unwrappedMod
    }
    return result
  } else {
    while n > 0 {
      if n & 1 == 1 { result *= a }
      n >>= 1
      a *= a
    }
    return result
  }
}

var tmp = 0
var remainders: [Int: Int] = [0: 1]
for (i, char) in s.reversed().enumerated() {
  let num = Int(String(char))!
  tmp += num * pow(10, i, mod)
  tmp %= mod
  if tmp < 0 { tmp += mod }
  if let v = remainders[tmp] {
    remainders[tmp] = v + 1
  } else {
    remainders[tmp] = 1
  }
}

var result = 0
for v in remainders.values {
  result += v * (v - 1) / 2
}

print(result)


Measured memory_bytes: 8260
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = mapint()
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
Cs = list(mapint())
Cs.sort(reverse=True)

from collections import deque
Q = deque([0])
idx = 1
ans = 0
allocation = [-1]*N
allocation[0] = Cs[0]
while Q:
    v = Q.pop()
    for nx in graph[v]:
        if allocation[nx]==-1:
            ans += Cs[idx]
            allocation[nx] = Cs[idx]
            Q.append(nx)
            idx += 1

print(ans)
print(*allocation)
    

Measured memory_bytes: 76520
#B問題
S = list(str(input()))
N = len(S)
flag = 0
for i in range(N):
    if i%2 == 0:
        if S[i] == "L":
            flag = 1
            break
    else:
        if S[i] == "R":
            flag = 1
            break
            
if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		int a,b,c,i,j=0;
		Scanner br= new Scanner(System.in);
		a=br.nextInt();
		b=br.nextInt();
		c=br.nextInt();
		for(i=a;i<=b;i++){
			if(c%i==0){
				j++;
			}
		}
		System.out.println(j);
	}
}

Measured memory_bytes: 26224
n = int(input())

ans = float("inf")
for a in range(1,n):
	b = n-a
	sa = str(a).rjust(6,"0")
	sb = str(b).rjust(6,"0")
	cnt = 0
	for i in range(6):
		cnt += int(sa[i]) + int(sb[i])

	ans = min(ans, cnt)

print(ans)

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

int main(){
  int A, B, count = 0;
  
  cin >> A >> B;
  
  for(int i = A;i < B + 1;i ++){
    if((i%10 == i/10000) && ((i%100)/10 == (i/1000)%10)){
      count ++;
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
import sys
X = int(input())
ans = 1
# temp = [0,0] 
judge1=True
judge2 =True
# while i < X+1:
for i in range(1,X+1):
    judge1 =True
    j = 2
    while judge1 and j <X:
        if  i**j > X:
            if j-1 >1:
                if ans <= i**(j-1) <X :
                    ans = i**(j-1)
                    # print("a")
                    # temp = [i,j]
                # print("{0} {1}".format(i,j))
            judge1 =False
        elif i**j == X:
            if ans <= i**j:
                ans = i**j
            judge1 =False
        # print("{0} {1}".format(i,j))
                # temp=[i,j]
        j += 1        
print(ans)

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

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

def solve():
    n = int(stdin.readline().rstrip())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    if n%9==0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9212
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main()
{
    string S;
    cin >> S;
    map<char, ll> mp;

    for (ll i = 0; i < S.size(); i++)
    {
        mp[S[i]] += 1;
    }
    
    bool ok = true;
    for (auto &&e : mp)
    {
        if (e.second > 1) {
            ok = false;
        }
    }
    cout << (ok ? "yes" : "no") << endl;
}

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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> c(n);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		c[a]++;
		c[b]++;
	}
	for (auto&& ci : c) cout << ci << endl;
	return 0;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  string s;
  cin >> s;
  int N = s.size();
  if ((N % 2 == 0) ^ (s[0] == s[N - 1]))
    cout << "Second" << endl;
  else
    cout << "First" << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n;
    cin >> n;
    string s,t;
    cin >> s;
    cin >> t;
    string ans;
    for(int i = 0;i < n;i++){
        ans.push_back(s.at(i));
        ans.push_back(t.at(i));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

#define MAX_V 102
#define INF 1000000000000000
struct edge { int to, cap, rev; };
vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}

int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    REP(i, G[v].size()){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    while(true){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}


signed main(){

    int N;
    cin >> N;
    vector<int> a(N + 1);
    int psum = 0;
    REP(i, N){
        cin >> a[i + 1];
        psum += max((int)0, a[i + 1]);
    }

    int s = 0, t = N + 1;

    FOR(i, 1, N + 1){
        if(a[i] >= 0){
            //割ることで生じる損失
            add_edge(i, t, a[i]);
        }else{
            //割らないことで生じる損失
            add_edge(s, i, -1 * a[i]);
        }
        for(int j = i + i; j <= N; j += i){
            add_edge(i, j, INF);
        }
    }

    int mincut = max_flow(s, t); 

    int ans = psum - mincut;

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
class CellularPhone
{
	//tips C#???????????????????????????????????????????????????
	class Button {
		protected string m_code;
		public Button(){m_code = " ";}
		
		public char push(int i) { //i = ??????????????£?¶????????????????????????°
			int input = (i - 1) % m_code.Length;
			return m_code[input];
		}
	}
	class Button_1 : Button{ public Button_1() {m_code = ".,!? ";}};
	class Button_2 : Button{ public Button_2() {m_code = "abc"  ;}};
	class Button_3 : Button{ public Button_3() {m_code = "def"  ;}};
	class Button_4 : Button{ public Button_4() {m_code = "ghi"  ;}};
	class Button_5 : Button{ public Button_5() {m_code = "jkl"  ;}};
	class Button_6 : Button{ public Button_6() {m_code = "mno"  ;}};
	class Button_7 : Button{ public Button_7() {m_code = "pqrs" ;}};
	class Button_8 : Button{ public Button_8() {m_code = "tuv"  ;}};
	class Button_9 : Button{ public Button_9() {m_code = "wxyz" ;}};
	
	private Button[] m_button;
	
	private int m_inputNum;
	private int m_inputCount;
	private string m_translatedStr;
	
	private void flushInputStr()
	{
		if (0 != m_inputCount) m_translatedStr += m_button[m_inputNum].push(m_inputCount);
		m_inputCount = 0;
	}
	
	public CellularPhone() {
		m_inputNum = 0;
		m_inputCount = 0;
		m_translatedStr = "";

		m_button = new Button[10];
		m_button[0] = new Button();   m_button[1] = new Button_1(); 
		m_button[2] = new Button_2(); m_button[3] = new Button_3();
		m_button[4] = new Button_4(); m_button[5] = new Button_5();
		m_button[6] = new Button_6(); m_button[7] = new Button_7();
		m_button[8] = new Button_8(); m_button[9] = new Button_9();
	}
	public void push(int i) {
		if ((i == 0) || (m_inputNum != i)) {// 0??????????????\?????¨??°??????????????\???????????????
			flushInputStr();
		}
		if (i != 0) {
			m_inputNum = i;
			++m_inputCount;
		}
	}
	
	public string echoStr() 
	{
		System.Console.WriteLine(m_translatedStr);
		return m_translatedStr;
	}
	public void clearStr() { m_translatedStr = "";}
};

class KeitaiMessage
{
	public static void Main()
	{
		CellularPhone myPhone = new CellularPhone();
		int inputCount = int.Parse(System.Console.ReadLine());
		
		for (int i = 0; i < inputCount; ++i) {
			string inputStr = System.Console.ReadLine();
			for (int index = 0; index < inputStr.Length; ++index) {
				myPhone.push(inputStr[index] - '0'); // ??°????????????
			}
			myPhone.echoStr();
			myPhone.clearStr();
		}
	}
};

	
	

Measured memory_bytes: 8976
#include<bits/stdc++.h>
//#define int long long
#define il inline 
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;
const int MAXN=2e6+1e1;
const int Mod=1e9+7;

lint fac[MAXN];
lint inv[MAXN];

int r1,c1,r2,c2;

lint Ans1,Ans2;

lint qpow(lint A,int B)
{

	lint res=1;

	while(B>0)
	{
		if(B&1) (res*=A)%=Mod;
		(A*=A)%=Mod;
		B>>=1;
	}

	return res;

}

lint C(int A,int B)
{

	return ( A<B ? 0 : (((fac[A]*inv[B])%Mod)*inv[A-B])%Mod );

}

inline int read()
{
	register char cc = getchar(); register int cn(0), flus(1);
	while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus;
}

signed main(void)
{
	r1 = read(), c1 = read(), r2 = read(), c2 = read();
	
	int n=max(c1,c2)+r2+2;

	fac[0]=inv[0]=1;

	for(int i=1;i<=n;i++) fac[i]=(fac[i-1]*i)%Mod;

	inv[n]=qpow(fac[n],Mod-2);

	for(register int i=n;i;i--) inv[i-1]=(inv[i]*i)%Mod;

	rep(i, r1, r2) (Ans1+=C(i+c2+1,i+1))%=Mod;

	rep(i, r1, r2) (Ans2+=C(i+c1,i+1))%=Mod;

	printf("%lld\n",(Ans1-Ans2+Mod)%Mod);

	return 0;

}


Measured memory_bytes: 31488
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
    string s;
    cin >> s;
    int result[26] = {};
    for(int i = 0; i < s.length(); i++){
        int tmp = s[i] - 'a';
        result[tmp]++;
    }
    bool ans = true;
    for(int i = 0; i < 26; i++){
        if(result[i] % 2 == 1){
            ans = false;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

M = N - 1
flg = 1
R = (N-1) * (N-2) // 2
edge_list = []
for i in range(2, N+1):
    edge_list.append([1, i])

if K > R:
    flg = -1
elif K == R:
    pass
else:
    for i in range(2, N):
        for j in range(i+1, N+1):
            edge_list.append([i, j])
            M += 1
            R -= 1
            if K == R:
                break
        if K == R:
            break

if flg == -1:
    print(-1)
else:
    print(M)
    for edge in edge_list:
        p, q = edge
        print(str(p), str(q))


Measured memory_bytes: 42864
#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()
{
  ll N,A,B; cin >> N >> A >> B;
  ll ans = N / (A+B) * A;
  ll tmp = N % (A+B);
  ans += min(tmp,A);
  cout << ans << endl;
}

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

using namespace std;

int main(){

	char c;	int sum = 0;

	while(1){

		c = getchar();

		if(c=='\n') break;

		sum += c-'0';

	}

	if(sum%9==0) printf("Yes");

	else printf("No");

	return 0;

}

Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<stdio.h>
#include<vector>
using namespace std;

int main(){
  string S;
  cin >> S;
  bool flag  = false;
  if(S[0] == S[1] && S[2] == S[3] && S[0] != S[2]){
    flag = true;
  }else if(S[0] == S[2] && S[1] == S[3] && S[0] != S[1]){
    flag = true;
  }else if(S[0] == S[3] && S[1] == S[2] && S[0] != S[1]){
    flag = true;
  }

  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
    int N; cin >> N;
    int A[210000];
    bool isDifferent = true;
    rep(i, N) {
        cin >> A[i];
    }
    sort(A,A+N);
    rep(i,N) {
        if(i < N -1) {
            if(A[i] == A[i+1]) {
                isDifferent = false;
            }
        }
    }
    if(isDifferent) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N;
    std::cin >> N;
    std::vector<int> A(N);
    REP(i, N) {
        std::cin >> A[i];
    }

    string ans = "second";
    REP(i, N) {
        if(A[i] % 2 == 1) {
            ans = "first";
            break;
        }
    }
    std::cout << ans << std::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 REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;


int main(){
  ll n; cin>>n;
  ll res=0;
  map<int,ll> mp;
  REP(i,n){
    ll a; cin>>a;
    mp[a]++;
  }
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    ll a=itr->first;
    ll b=itr->second;
    if(a!=b){
      if(a>b)res+=b;
      else res+=b-a;
    }
  }
  cout<<res<<endl;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n); for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main(){
    string s,t;
    cin >> s >> t;
    int i = 0;
    while(i < t.size()-1){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        } 
        i++;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
long long dp[2001];
int main()
{
	int n;
	cin>>n;
	dp[3]=1;
	for(int i=4;i<=n;i++)
	dp[i]=(dp[i-1]+dp[i-3])%1000000007;
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 3580
import math
a,b,v=map(int,input().split())
theta1=0
theta2=math.pi/2
ans=10**9
if a*a*b-v==0:
    print(0)
    exit()
if a*a*b/2>=v:
    while 1:
        tmp=math.tan((theta1+theta2)/2)-2*v/(a*b*b)
        if abs(tmp)<=10**(-6):
            ans=(theta1+theta2)/2
            break
        else:
            if tmp>0:
                theta2=(theta1+theta2)/2
            else:
                theta1=(theta1+theta2)/2
else:
    while 1:
        tmp=math.tan((theta1+theta2)/2)-(a**3)/(2*(a*a*b-v))
        if abs(tmp)<=10**(-6):
            ans=(theta1+theta2)/2
            break
        else:
            if tmp>0:
                theta2=(theta1+theta2)/2
            else:
                theta1=(theta1+theta2)/2
print(90-math.degrees(ans))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    const int MAX_N = 100000;
    const int MAX_V = 1000000000;
    vector<int> x(MAX_N);
    vector<int> l(MAX_N);
    for(int i = 0; i < n; i++) cin >> x[i] >> l[i];
    pair<int, int> ps[MAX_N];
    for(int i = 0; i < n; i++){
        ps[i] = pair<int, int>(x[i]+l[i], x[i]-l[i]);
    }
    sort(ps, ps+n);
    int cur = -MAX_V;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(cur <= ps[i].second){
            ans++;
            cur = ps[i].first;
        }
    }
    cout << ans;
}


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

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

    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ri register int
using namespace std;
typedef long long ll;
#define pb push_back
#define rez resize
#define ppp pop_back
template <typename T> inline void exgcd(T a, T b, T &x, T &y) {
  if (!b) { x = 1, y = 0; return; }
  exgcd(b, a - a / b * b, y, x), y -= a / b * x;
}
namespace modular {
  const int mod = 998244353;
  int ret;
  inline int add(int a, int b) { return a < mod - b ? a + b : a - mod + b; }
  inline int dec(int a, int b) { return a < b ? a - b + mod : a - b; }
  inline int mul(int a, int b) { return (ll) a * b % mod; }
  inline void Add(int &a, int b) { a = a < mod - b ? a + b : a - mod + b; }
  inline void Dec(int &a, int b) { a = a < b ? a - b + mod : a - b ; }
  inline void Mul(int &a, int b) { a = (ll) a * b % mod; }
  inline int ksm(int a, int p) { for (ret = 1; p; p >>= 1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1); return ret; }
  inline int fix(int x) {
    x <= -mod || x >= mod ? x %= mod : 0;
    return x < 0 ? x + mod : x;
  }
  inline int Inv(int a) {
    static int x, y;
    return exgcd(a, mod, x, y), fix(x);
  }
}  using namespace modular;
const int N = 3e5 + 5;
int n, m;
char s[N];
int R = 0, G = 0, B = 0, RG = 0, GB = 0, BR = 0;
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  scanf("%d%s", &n, s + 1), m = 3 * n;
  int res = 1;
  for (ri i = 1; i <= m; ++i) {
    if (s[i] == 'R') {
      if (GB) Mul(res, GB), --GB;
      else {
        int ad = 0;
        if (G) ad += G, ++RG, --G; 
        if (B) ad += B, ++BR, --B;
        if (ad) Mul(res, ad);
        else ++R;
      }
    }
    if (s[i] == 'B') {
      if (RG) Mul(res, RG), --RG;
      else {
        int ad = 0;
        if (G) ad += G, ++GB, --G; 
        if (R) ad += R, ++BR, --R;
        if (ad) Mul(res, ad);
        else ++B;
      }
    }
    if (s[i] == 'G') {
      if (BR) Mul(res, BR), --BR;
      else {
        int ad = 0;
        if (R) ad += R, ++RG, --R; 
        if (B) ad += B, ++GB, --B;
        if (ad) Mul(res, ad);
        else ++G;
      }
    }
  }
  for (ri i = 1; i <= n; ++i) Mul(res, i);
  cout << res;
  return 0;
}

Measured memory_bytes: 3960
#!/mnt/c/Users/moiki/bash/env/bin/python
H,W,D = map(int, input().split())
M = [ list(map(int, input().split())) for _ in range(H)]
Q = int(input())
pos = {}
from itertools import accumulate

for h in range(H):
    for w in range(W):
        pos[M[h][w]] = (h,w)
        

accd = [ [0] for _ in range(D)]

distance = lambda p,np: abs(p[0]-np[0])+abs(p[1]-np[1])

for i in range(1,D+1):
    p = pos[i]
    amari = i % D

    tmp = i + D

    while tmp <= H*W:
        nextp = pos[tmp]
        accd[amari].append( accd[amari][-1] + distance(p,nextp) )

        tmp += D
        p = nextp

# print(accd)
# exit(0)

for i in range(Q):
    L,R = map(int, input().split())
    ans = 0

    if not L == R:
        if R%D == 0:
            ans = accd[L%D][(R-R%D)//D-1] - accd[L%D][(L-L%D)//D-1]
        else:
            ans = accd[L%D][(R-R%D)//D] - accd[L%D][(L-L%D)//D]


    print(ans)
    


Measured memory_bytes: 70108
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,s1;
    cin>>s;
    cin>>s1;
    s=s+s1[s1.length()-1];
    if(s==s1)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  ll N; cin >> N;
  ll M; cin >> M;
  vector<ll> A(M); for (ll i = 0; i < M; i++) cin >> A[i];
  ll sum = 0;
  for (ll i = 0; i < M; i++) {
    sum += A[i];
  }
  ll ans = -1;
  if (N >= sum) ans = N - sum;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int p, q, a, n;
int gcd(int a, int b){
   if(a < b) swap(a, b);
   if(b == 0) return a;
   return gcd(b, a % b);
}

int calc(int np, int nq, int na, int nn, int last){
    int res = 0;
    if(nn > n) return 0;
    int g = gcd(np, nq);
    np /= g; nq /= g;
    if(np == 1){
        if(last <= nq && na * nq <= a) res++;
    }
    // cout << np << " " << nq << " " << na << " " << nn << " " << last << endl;        
    for(int i = last; i * i * na <= a; i++){
        int nxtp = np * i - nq;
        int nxtq = nq * i;
        if(nxtp <= 0) continue;
        g = gcd(nxtp, nxtq);
        nxtp /= g; nxtq /= g;
        res += calc(nxtp, nxtq, na * i, nn + 1, i);
    }
    return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(1){
        cin >> p >> q >> a >> n;
        if(p + q + a + n == 0) break;
        int ans = calc(p, q, 1, 1, 1);
        cout << ans << endl;    
    }
}


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

int a[102][102];
int dp[102][102];

inline int area(int y1, int x1, int y2, int x2){
	int ret = dp[y2][x2];
	if(y1 - 1 >= 0)ret -= dp[y1-1][x2];
	if(x1 - 1 >= 0)ret -= dp[y2][x1-1];
	if(y1 - 1 >= 0 && x1 - 1 >= 0)ret += dp[y1-1][x1-1];
	return ret;
}
int main(){
	int n;
	cin >> n;

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

	dp[0][0] = a[0][0];

	for(int i=1;i<n;i++){
		dp[i][0] = dp[i-1][0] + a[i][0];
	}
	for(int j=1;j<n;j++){
		dp[0][j] = dp[0][j-1] + a[0][j];
	}

	for(int i=1;i<n;i++){
		for(int j=1;j<n;j++){
			dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + a[i][j];
		}
	}

	int ret = -(1 << 30);
	for(int y1=0;y1<n;y1++)for(int x1=0;x1<n;x1++){
		for(int y2=y1;y2<n;y2++)for(int x2=x1;x2<n;x2++){
			int tmp = area(y1, x1, y2, x2);
			ret = max(ret, tmp);
		}
	}


	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1240
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> ss(n); cin >> ss;
    vector<int> ts(m); cin >> ts;
    vector<int> dp[2] = {vector<int>(m + 1, 1), vector<int>(m + 1)};
    // vector<vector<int>> dp(2, vector<int>(m + 1, 1));
    for(int i = 0; i < n; i++){
        int i1 = i & 1, i2 = !i1;
        dp[i2][0] = 1;
        int* num = &dp[i2][0];
        int* num2 = &dp[i1][0];
        for(int j = 0; j < m; j++){
            num++;
            num2++;
            if(ss[i] == ts[j]){
                *num = *(num - 1) + *num2;
                if(*num >= M){
                    *num -= M;
                }
            }else{
                *num = *(num - 1) + *num2 - *(num2 - 1);
                if(*num >= M){
                    *num -= M;
                }else if(*num < 0){
                    *num += M;
                }
            }
        }
    }
    printde(dp);
    cout << dp[n & 1][m] << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
char s[150];
int main()
{
	bool a=0;
	scanf("%s",s);
	for(int i=0;i<strlen(s);i++)
	{
		if(s[i]=='C')
		a=1;
		else
		if(s[i]=='F'&&a==1)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  itn int
using ll=int64_t;
#define rep(i,n) for (int i = 0; i < (int) (n); i++)
using vi = vector<int>;
using vll = vector<ll>;
/*//再帰関数木構造定型
int complete_time(vector<vector<int>> &children, int x) {
  // ベースケース
  if (children.at(x).size() == 0) {
    return 1;  // 子組織が無いような組織について、報告書が揃う時刻は0
  }// 再帰ステップ
  int receive_maisuu = 1;  // 受け取った時刻の最大値
  // x番の組織の子組織についてループ
  for (int c : children.at(x)) {receive_maisuu  += complete_time(children, c) ;}
  return  receive_maisuu ;
}*/


// 組織の関係から2次元配列を作る
//二次元配列入力定型
/*
vector<vector<int>> children(N);  // ある組織の子組織の番号一覧
  for (int i = 1; i < N; i++) {
    int parent = p.at(i);  // i番の親組織の番号
    children.at(parent).push_back(i);  // parentの子組織一覧にi番を追加
  }

  // num個分のスペースからなる文字列を返す (字下げに用いる)
  string space(int num) {
    string ret = "";
    for (int i = 0; i < num; i++) {
      ret += " ";
    }
    return ret;
  }*/


int main(){
int a,b;
cin>>a>>b;
cout<<a*b;
  
  

  
  

}


Measured memory_bytes: 3676
#include <cstdio>
#include <algorithm>
#include <map>
#define ll long long
using namespace std;
ll c[405][4],h[405],v[4];
map<ll,int> mp;
void upd(ll x,int d){
    for(int i=0;i<4;i++,x=((x&1023ll)<<30ll)|(x>>10ll)){
    	mp[x]+=d;
	}
    return;
}
ll Hash(ll *a){
    ll ret=0;
    for(int i=0;i<4;i++){
    	ret|=(a[i]<<(i*10ll));
	}
    return ret;
}
int main(){
	int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld%lld%lld",c[i],c[i]+1,c[i]+2,c[i]+3);
        h[i]=Hash(c[i]);
        upd(h[i],1);
    }
    ll ans=0,res;
    for(int i=1;i<=n-5;i++){
        upd(h[i],-1);
        for(int j=i+1;j<=n;j++){
            upd(h[j],-1);
            for(int k=0;k<4;k++){
                res=1;
                for(int l=0;l<4;l++){
                    ll tmp[]={c[i][(l+1)&3],c[i][l],c[j][(3-l+k)&3],c[j][(6-l+k)&3]};
                    v[l]=Hash(tmp);
                    if(!mp.count(v[l])){
                    	goto to;
					}
                }
                for(int l=0;l<4;l++){
                    res*=mp[v[l]];
                    upd(v[l],-1);
                }
                ans+=res;
                for(int l=0;l<4;l++){
                	upd(v[l],1);
				}
                to:;
            }
            upd(h[j],1);
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main() {
    long long N;
    cin >> N;
    string res = "";
    while (N) {
        --N;
        res += (char)('a' + (N % 26));
        N /= 26;
    }
    reverse(res.begin(), res.end());
    cout << res << endl;
}

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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

 
void dfs(Graph& g, ll v,Array& c) {
	bool flag = true;
	for (auto e : g[v]) {
		if (c[e.to] == -1) {
			c[e.to] = !c[v];
			dfs(g, e.to, c);
		}
	}
}

void solve(){
	ll n;
	cin>>n;
	Graph g(n);
	REP(i,n-1){
		ll a,b;
		cin>>a>>b;
		a--;b--;
		add_edge(g,a,b,1,true,1);
	}
	Array ans(n,0);
	Array c(n, -1);
	c[0] = 0;
	dfs(g, 0, c);
	ll con = 0;
	for (auto i : c)if (i == 0) con++;
	if(con<=n/3){
		Array used(n+1,false);
		ll num=3;
		REP(i,n){
			if(c[i]==0){
				ans[i]=num;
				used[num]=true;
				num+=3;
			}
		}
		num=1;
		REP(i,n){
			if(c[i]!=0){
				ans[i]=num;
				used[num]=true;
				num++;
				while(used[num]) num++;
			}
		}
	}else if(n-con<=n/3){
		Array used(n+1,false);
		
		ll num=3;
		REP(i,n){
			if(c[i]!=0){
				ans[i]=num;
				used[num]=true;
				num+=3;
			}
		}
		num=1;
		REP(i,n){
			if(c[i]==0){
				ans[i]=num;
				used[num]=true;
				num++;
				while(used[num]) num++;
			}
		}
	}else{
		Array used(n+1,false);
		ll num1=1;
		ll num2=2;
		REP(i,n){
			if(c[i]!=0){
				ans[i]=num1;
				used[num1]=true;
				num1+=3;
				if(num1>n) num1=3;
			}
		}
		REP(i,n){
			if(c[i]==0){
				ans[i]=num2;
				used[num2]=true;
				num2+=3;
				if(num2>n) num2=num1;
			}
		}
	}

	for(auto i:ans) cout<<i<<" ";
	cout<<en;
}

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

	solve();
    return 0;
}

Measured memory_bytes: 24192
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
int main()
{
		int a, b;
		scanf("%d%d", &a,&b);
		if (a > b)printf("a > b\n");
		else if (a == b)printf("a == b\n");
		else if (a < b)printf("a < b\n");
	return 0;
}



Measured memory_bytes: 2604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int[][] A=new int[N][N];
		long sum=0;
		for(int i=0;i<N;i++)
			for(int j=0;j<N;j++){
				A[i][j]=sc.nextInt();
				sum+=A[i][j];
			}
		sum/=2;
		
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				for(int k=0;k<N;k++){
					if(i==k||j==k) continue;
					if(A[i][j]>A[i][k]+A[k][j]){
						System.out.println(-1);
						return;
					}
					if(A[i][j]==A[i][k]+A[k][j]){
						sum-=A[i][j];
						break;
					}
				}
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 50408