akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	int a,b;
	cin >> a >> b;
	if(a > b) cout << a-1 << endl;
	else cout << a << endl;
	return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<vector<int>> cost(N + 1, vector<int>(3));
  rep(i, 1, N + 1) {
    rep(j, 0, 3) { cin >> cost[i][j]; }
  }
  vector<vector<int>> dp(N + 1, vector<int>(3, 0));
  rep(i, 1, N + 1) {
    rep(j, 0, 3) {
      rep(k, 0, 3) {
        if (j != k)
          chmax(dp[i][j], dp[i - 1][k] + cost[i][k]);
      }
    }
  }
  cout<<*max_element(all(dp[N]))<<endl;

  return 0;
}


Measured memory_bytes: 11264
N = int(input())
A = list(map(int,input().split()))
dp = [[0] * (N+1) for _ in range(N+1)]

#半開区間で考える⇒[i,j)での最適解
for w in range(1,N+1):#区間の残り数
    for l in range(N):# 左端
        r = l + w#右端
        if r > N:
            continue
        elif (N-w) % 2 == 0:#太郎
            dp[l][r] = max(dp[l+1][r] + A[l], dp[l][r-1] + A[r-1])
        elif (N-w) % 2 == 1:#次郎
            dp[l][r] = min(dp[l+1][r] - A[l], dp[l][r-1] - A[r-1])
            
print(dp[0][N])

Measured memory_bytes: 113500
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def array(size, init=0):
    return [[init for j in range(size[1])] for i in range(size[0])]


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())


N, X, T = acinput()

print(int(np.ceil(N/X)*T))


Measured memory_bytes: 27044
#include<iostream>
#include<algorithm>
#include<cassert>
#include<map>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define N 100

const int INF = 1000100; 
int table[N];
int buycost[N];

int solve(int now,vector<int> *make){
  //if ( table[now] != -1)return table[now];
  if(  make[now].size()==0)return table[now]=buycost[now];
  

  int ret = buycost[now],tmp=0;  
  rep(i,make[now].size()){
    tmp+=solve(make[now][i],make);
  }
  
  ret= min(ret,tmp);
  return table[now]=ret; 
}

main(){
  int n;
  while(cin>>n && n){
    map<string,int> M;
    rep(i,n){
      string t;int a;
      cin>>t>>a;
      M[t]=i;
      buycost[i]=a;
      table[i]=-1;
    }
    
    vector<int> make[n];
    cin>>n;
    rep(i,n){
      string a;
      cin>>a;
      int now =M[a],m;
      cin>>m;
      rep(j,m){
	cin>>a;
	make[now].push_back(M[a]);
      }     
    }
    string tmp;
    cin>>tmp;
    int tar=M[tmp];
    cout << solve(tar,make) << endl;
    
  }
  return false;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;

const int N = 1005 ;
const ll MOD = 1e9 + 7;
int h , w;
ll DP[N][N];
char MAT[N][N];
ll calc(int i , int j){
    if (i == h && j == w)return 1;
    if (i > h || j > w || MAT[i][j] == '#')return 0;
    if (DP[i][j] != -1) return DP[i][j];
    ll down,right;
    down = calc(i,j+1);
    right = calc(i+1,j);
    return DP[i][j] = (down + right)%MOD;
}

int main(){
    fastIO;
    cin>>h>>w;
    memset(DP,-1,sizeof DP);
    for(int i = 1 ; i<=h ; i++){
        for(int j = 1 ; j<=w ; j++){
            cin>>MAT[i][j];
        }
    }
    DP[0][0] = 1;
    cout<<calc(1,1);
}


Measured memory_bytes: 12596
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

MOD=10**9+7

n=int(input())
li=[0]*2000

for i in range(1,n+1):
    c=factorization(i)
    #print(c)
    for j in range(len(c)):
        li[c[j][0]]+=c[j][1]

ans=1

for i in range(2,n+1):
    ans=ans*(li[i]+1)
    ans=ans%MOD

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
int main() {
    cin >> n;
    vector<int> a(n, 0);
    for(int i = 0; i < n; ++i) cin >> a.at(i);

    long long mincost = 1e12;
    for(int i = -100; i <= 100; ++i) {
        int check = i;
        long long cost = 0;
        for(int j = 0; j < n; ++j) {
            cost += powl((a.at(j)-check), 2);
        }
        chmin(mincost, cost);
    }
    cout << mincost << endl;
}

Measured memory_bytes: 256
def solve(string):
    n, m, *a = map(int, string.split())
    needs = {i + 1: n for i, n in enumerate(map(int, "2 5 5 4 5 6 3 7 6".split()))}
    if 2 in a and 5 in a or 2 in a and 3 in a:
        a.remove(2)
    if 3 in a and 5 in a:
        a.remove(3)
    if 6 in a and 9 in a:
        a.remove(6)
    b = sorted(a, key=lambda x: needs[x])
    index = 0
    base = str(b[0]) * (n // needs[b[0]])
    n %= needs[b[0]]
    while n > 0:
        use = [_b for _b in b if needs[_b] <= needs[b[0]] + n]
        if len(use) == 1:
            base = base[:-1]
            n += needs[b[0]]
            continue
        flag = max(use) == b[0]
        tmp_n = use[-1] if flag else max(use)
        tmp_c = n // (needs[tmp_n] - needs[b[0]])
        if flag:
            base = base[:-tmp_c] + str(tmp_n) * tmp_c
        else:
            base = base[:index] + str(tmp_n) * tmp_c + base[index + tmp_c:]
            index += tmp_c
        n -= (needs[tmp_n] - needs[b[0]]) * tmp_c
    return base


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
//        Scanner sc = new Scanner(System.in);
//        String S = sc.next();
//
//        String[] strList = {"eraser", "erase", "dreamer", "dream"};
//        for (String str : strList) {
//            S = S.replace(str, "");
//            if (S.isEmpty()) {
//                System.out.print("YES");
//                return;
//            }
//        }
//
//        System.out.print("NO");

        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        S = S.replaceAll("eraser", "-");
        S = S.replaceAll("erase", "-");
        S = S.replaceAll("dreamer", "-");
        S = S.replaceAll("dream", "-");
        S = S.replaceAll("-", "");
        if (S.length() == 0)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

Measured memory_bytes: 30728
# -*- coding: utf-8 -*-
import sys
# from collections import defaultdict, deque
from math import log10, sqrt, ceil
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]

def c(x):
    cnt = 0
    n = x
    while n:
        n //= 10
        cnt += 1
    return cnt

def solve():
    n = int(input())
    o = n
    ans = c(n)
    for i in range(2, int(sqrt(n)) + 3):
        if (n % i == 0):
            a = i
            b = o // a
            ans = min(ans, max(c(a), c(b)))
        if i > n:
            break

    print(ans)
    
        




t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()



"""
1 -> (1, 2) -> (2 ** 3, 3) -> (3, 1)
100000007
"""



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int x, t;
    cin >> x >> t;
    cout << max(0, x - t) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int[][] n = new int[101][101];
		int[][] dp = new int[101][101];
		int l = 0;
		for (int i = 0; sc.hasNext(); i++, l++) {
			String[] line = sc.next().split(",");
			for (int j = 0; j < line.length; j++) n[i][j] = Integer.valueOf(line[j]);
		}

		dp[0][0] = n[0][0];
		for (int i = 1; i < l; i++) {
			for (int j = 0; j < l; j++) {
				if (i > l / 2) {
					dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][j + 1]);
					dp[i][j] += n[i][j];
				} else {
					dp[i][j] = (j == 0) ? dp[i - 1][j] : Math.max(dp[i - 1][j],
							dp[i - 1][j - 1]);
					dp[i][j] += n[i][j];
				}
			}
		}
		System.out.println(dp[l - 1][0]);
	}

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

Measured memory_bytes: 20956
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>

typedef long long int llint;

int main(void){

  int n, k;

  std::cin >> n >> k;

  std::vector<bool> sunuke(n, true);
  
  for(int i=0; i<k; i++){
    int d;
    std::cin >> d;
    for(int j=0; j<d; j++){
      int a;
      std::cin >> a;
      a--;
      sunuke[a] = false;
    }
  }

  int count = 0;
  for(int i=0; i<n; i++){
    if(sunuke[i]) count++;
  }

  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#define maxn 200100
using namespace std;
int   main()
{
	long long a[maxn],n;
	scanf("%lld",&n);
	
	for(int i=0;i<n;i++)
		scanf("%lld",&a[i]);
	double sum=a[0]*1.0;
	for(int i=1;i<n;i++)
		sum=sum*a[i]/(sum+a[i]*1.0);
	printf("%.5lf\n",sum);
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

void enum_prime(int N, vector<bool>& is_p)
{
  is_p.resize(N+1, true);
  is_p[0] = is_p[1] = false;
  for(int i = 2; i*i <= N; i++) {
    if(!is_p[i]) continue;
    for(int j = i+i; j <= N; j+=i) is_p[j] = false;
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  const int MAX_Q = 1000000;

  vector<bool> is_p;
  enum_prime(MAX_Q, is_p);

  int n;
  cin >> n;

  vint q(n);
  rep(i, n) cin >> q[i];

  if(!is_p[q[0]]) {
    cout << 0 << endl;
    return 0;
  }

  vector<vint> dp(2, vint(n+1, 0));
  dp[0][0] = 1;
  dp[1][0] = 0;
  reps(i, 1, n) {
    if(is_p[q[i]]) {
      if(q[i-1] < q[i]) (dp[0][i] += dp[0][i-1]) %= mod;
      if(i>1&&q[i-2] < q[i]) (dp[0][i] += dp[1][i-1]) %= mod;
    }
    (dp[1][i] += dp[0][i-1]) %= mod;
  }
  cout << (dp[0][n-1]+dp[1][n-1])%mod << endl;

  return 0;
}



Measured memory_bytes: 6064
#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)

using ll = long long;
#define INF 1e9

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

int main(){ 
  int N, X;
  cin >> N >> X;
  vector<int> x(N);
  REP(i, N){
    cin >> x[i];
    x[i] = abs(x[i] - X);
  }
  int D = x[0];
  REP(i, N){
    D = gcd(D, x[i]);
  }
  cout << D << endl;



  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int mod= 1e9 + 7;

int main() {
	int n, W;
	cin>>n>>W;
	vector<int>val(n);
	vector<int>wt(n);
	
	for(int i=0;i<n;i++)
		cin>>wt[i]>>val[i];
	
	int i, w; 
	long long int K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max((val[i-1] + K[i-1][w-wt[i-1]]),  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   cout<<K[n][W]; 
}

Measured memory_bytes: 79104
// https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_b

fun main(args: Array<String>) {
    codefestival2016qualcb()
}

fun codefestival2016qualcb() {
    val (n, t) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }.sortedDescending()
    var r = 0
    for (i in a) {
        r = Math.abs(r - i)
    }
    println(if (r > 0) r - 1 else r)
}

Measured memory_bytes: 35988
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<queue>
#include<cmath>
#include<algorithm>
#define N 100010
using namespace std;
inline int read()
{
	int f=0,x=0;char ch=getchar();
	while(!isdigit(ch))f|=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
	return f?-x:x;
}
int n,m,ans,k,t;
int main()
{
	n=read(),m=read(),k=read();
	for(int i=0;i<=n;i++)
	{
		t=m*i;
		for(int j=0;j<=m;j++)
		{
			if(t+(n-(i<<1))*j==k)
			{
				puts("Yes");
				return 0;
			}
		}
	}
    puts("No");
	return 0;
}
/**
*　　┏┓　　　┏┓+ +
*　┏┛┻━━━┛┻┓ + +
*　┃　　　　　　　┃
*　┃　　　━　　　┃ ++ + + +
*  ████━████+
*  ◥██◤　◥██◤ +
*　┃　　　┻　　　┃
*　┃　　　　　　　┃ + +
*　┗━┓　　　┏━┛
*　　　┃　　　┃ + + + +Code is far away from 　
*　　　┃　　　┃ + bug with the animal protecting
*　　　┃　 　 ┗━━━┓ 神兽保佑,代码无bug　
*　　　┃ 　　　　　　 ┣┓
*　　  ┃ 　　　　　 　┏┛
*　    ┗┓┓┏━┳┓┏┛ + + + +
*　　　　┃┫┫　┃┫┫
*　　　　┗┻┛　┗┻┛+ + + +
*/


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

#define MAX_V 10010
struct edge {int to;long long cap;int rev;};
vector<edge> G[MAX_V];	// 最大フロー用の隣接リスト
bool used[MAX_V];
void add_edge(int from,int to,long long cap) {
	G[from].push_back((edge){to,cap,(int)G[to].size()});
	G[to].push_back((edge){from,0,(int)G[from].size()-1});
}
long long dfs(int v,int t,long long f) {
	if(v==t) return f;
	used[v]=true;
	for(int i=0; i<G[v].size(); ++i) {
		edge &e=G[v][i];
		if(!used[e.to]&&e.cap>0) {
			long long 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;
}
long long FordFulkerson(int s,int t, vector<vector<P>>& adj) {
	// adj は通常の隣接リスト（first: to, second: cost）
	for(int i=0; i<(int)adj.size(); i++) {
		for(int j=0; j<(int)adj[i].size(); j++) {
		add_edge(i,adj[i][j].first,adj[i][j].second);
		}
	}
	int flow=0;
	while(1) {
		for(int i=0; i<MAX_V; ++i) used[i]=false;
		long long f=dfs(s,t,INF*INF);
		if(f==0) return flow;
		flow+=f;
	}
}

int main() {
	ios::sync_with_stdio(false);
	ll v,e;
	cin>>v>>e;
	vector<vector<P>> adj(v);
	REP(i,e) {
		ll u,v,c;
		cin>>u>>v>>c;
		adj[u].pb(P(v,c));
	}
	cout<<FordFulkerson(0,v-1,adj)<<endl;
}



Measured memory_bytes: 3512
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int dp[100010][13];
string S; 
int calc(int x, int d) {
    //if(x == 3) cout << x << " " << d << endl;
    if (x >= S.length()) {
        if(d == 5) return dp[x][d] = 1;
        return dp[x][d] = 0;
    }
    
    if(dp[x][d] != -1 && x != 0) return dp[x][d];
    if (S[x] != '?') {
        return dp[x][d] = calc(x + 1, (d * 10 + S[x] - '0') % 13);
    }
    int tmp = 0;
    rep(i, 10) {
        tmp = (tmp + calc(x + 1, (d*10 + i) % 13)) % mod;
    }
    return dp[x][d] = tmp;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S;
    rep(i, 100010) rep(j, 13) dp[i][j] = -1;
    dp[0][0] = 0;
    cout << calc(0, 0) << endl;

    return 0;
}


Measured memory_bytes: 16848
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n;
		int x, y, z, w;
		int ans;
		
		while(true){
			n = scan.nextInt();
			if(n == 0)break;
			
			ans = 0;;
			for(int i = 0; i < n; i++){
				x = scan.nextInt();
				y = scan.nextInt();
				z = scan.nextInt();
				w = scan.nextInt();
				
				if(x + y + z <= 60 && w <= 2)ans += 600;
				else if(x + y + z <= 80 && w <= 5)ans += 800;
				else if(x + y + z <= 100 && w <= 10)ans += 1000;
				else if(x + y + z <= 120 && w <= 15)ans += 1200;
				else if(x + y + z <= 140 && w <= 20)ans += 1400;
				else if(x + y + z <= 160 && w <= 25)ans += 1600;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 65704
#include <bits/stdc++.h>
 
using namespace std;
 
int a, b, k;
 
int main () {
 cin >> a >> b >> k;  
 set <int> s;
 for (int i = a; i <= min(b, a + k - 1); i ++)
  s.insert(i);
 for (int i = b; i >= max(a, b - k + 1); i --)
  s.insert(i);
 for (auto to : s) cout << to << endl;
}

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

prime, i = set(), 1
while i * i <= M:
    if M % i == 0:
        prime.add(i)
        prime.add(M//i)
    i += 1

ans = 0
for i in prime:
    if i * N <= M:
        ans = max(ans, i)
print(ans)


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

int main(){
    int h, w;
    cin >> h >> w;

    char a[h][w + 1];
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }

    bool is_black_h[h];
    for (int i = 0; i < h; i++){
        is_black_h[i] = 0;
        for (int j = 0; j < w; j++){
            if (a[i][j] == '#'){
                is_black_h[i] = 1;
                break;
            }
        }
    }

    bool is_black_w[w];
    for (int j = 0; j < w; j++){
        is_black_w[j] = 0;
        for (int i = 0; i < h; i++){
            if (a[i][j] == '#'){
                is_black_w[j] = 1;
                break;
            }
        }
    }

    for (int i = 0; i < h; i++){
        if (is_black_h[i]){
            for (int j = 0; j < w; j++){
                if (is_black_w[j]){
                    cout << a[i][j];
                }
            }

            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    long result = 0;
    for(int i = 1; i <= x; i++)
    {
      if(i % 3 == 0 && i % 5 == 0)
      {
    	 continue;
      }
      
      if(i % 3 == 0)
      {
    	 continue;
      }
      if(i % 5 == 0)
      {
    	 continue;
      }
      result += i;
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 35444
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  char c;
  cin >> n;
  int d[7];//"J","O","I","JO","JI","OI","JOI";
  int mem[7];
  for(int i=0;i<7;i++) d[i] = mem[i] = 0;
  d[0] = 1;
  for(int i=0;i<n;i++){
    cin >> c;
    if(c=='J') mem[0] = d[0] + d[3] + d[4] + d[6];
    if(c=='O') mem[1] = d[1] + d[3] + d[5] + d[6];
    if(c=='I') mem[2] = d[2] + d[4] + d[5] + d[6];
    if(c=='J'||c=='O') mem[3] = d[0] + d[1] + d[3] + d[4] + d[5] + d[6];
    if(c=='J'||c=='I') mem[4] = d[0] + d[2] + d[3] + d[4] + d[5] + d[6];
    if(c=='O'||c=='I') mem[5] = d[1] + d[2] + d[3] + d[4] + d[5] + d[6];
    mem[6] = d[0] + d[1] + d[2] + d[3] + d[4] + d[5] + d[6];
    for(int i=0;i<7;i++){
      d[i] = mem[i] % 10007;
      mem[i] = 0;
    }
  }
  int ans = 0;
  for(int i=0;i<7;i++) ans += d[i];
  cout << ans % 10007 << endl;
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define BLOCK 700
struct query
{
    int l;
    int r;
    int i;
};
query Q[500001];
int ar[500001],ans[500002];
int fre[500005],cnt=0;
bool comp(query a,query b)
{
    if(a.l/BLOCK!=b.l/BLOCK)
        return a.l/BLOCK<b.l/BLOCK;
    return a.r<b.r;

}
void add(int pos)
{
    fre[ar[pos]]++;
    if(fre[ar[pos]]==1)
        cnt++;
}
void removee(int pos)
{
    fre[ar[pos]]--;
    if(fre[ar[pos]]==0)
        cnt--;
}
main()
{

    int n,q;
    scanf("%d%d",&n,&q);
    for(int i=0; i<n; i++) cin>>ar[i];
    for(int i=0; i<q; i++)
    {
        scanf("%d%d",&Q[i].l,&Q[i].r);
        Q[i].i=i,Q[i].l--,Q[i].r--;
    }
    sort(Q,Q+q,comp);
    int ML=0,MR=-1;
    for(int i=0; i<q; i++)
    {
        int L=Q[i].l;
        int R=Q[i].r;

        while(ML>L)
            ML--,add(ML);
        while(MR<R)
            MR++,add(MR);
        while(ML<L)
            removee(ML),ML++;
        while(MR>R)
            removee(MR),MR--;
        ans[Q[i].i]=cnt;
    }
    for(int i=0; i<q; i++)
        printf("%d\n",ans[i]);

    return 0;

}



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

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> c(n + 1);
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		c[a]++; c[b]++;
	}
	bool f = true;
	for(int i = 1; i <= n; i++){
		if(c[i] % 2 == 1){
			f = false;
			break;
		}
	}
	cout << (f? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 640
//qwq
#include<iostream>
#include<cstdio>
#include<cstring>
#define add(x,y) (ct(x,y),ct(y,x))
#define CT const int&
using namespace std;
const int MAXN = 4e5 + 7;
int n, T, ccnt;
int q[MAXN], home[MAXN], p[MAXN], fa[MAXN],  dep[MAXN],
	deg[MAXN], vis[MAXN], nxt[MAXN], to[MAXN], d[MAXN];

inline void ct(CT u, CT v) {
	++ccnt;
	to[ccnt] = v;
	nxt[ccnt] = home[u];
	home[u] = ccnt;

}

inline int dfs(int u, int F) {
	int res = u, s;
	fa[u] = F;
	dep[u] = dep[F] + 1;
	for(int i = home[u]; i; i = nxt[i]) {
		int v = to[i];
		if(v != F) {
			s = dfs(v, u);
			if(dep[res] < dep[s])res = s;
			//长链剖分/jk
		}
	}
	return res;
}

int main() {
	scanf("%d", &n);
	int rt1, rt2, num, u, v;
	for(int i = 1; i < n; ++i) {
		scanf("%d%d", &u, &v);
		add(u, v);
	}
	rt1 = dfs(1, 0);
	fa[rt1] = 0;
	dep[rt1] = 0;
	rt2 = dfs(rt1, 0);
	// printf("%d %d\n", rt1, rt2);
	for(; rt2; rt2 = fa[rt2])vis[rt2] = 1, d[++T] = rt2;
	// printf("%d \n", T);
	for(int u = 1; u <= n; ++u) {
		if(vis[u])continue;
		bool ans = 0;
		for(int i = home[u]; i; i = nxt[i]) {
			int v = to[i];
			if(vis[v]) {
				deg[v]++;
				ans = 1;
				break;
			}
		}
		if(!ans)return puts("-1"), 0;
	}
	num = 0;
	for(int i = 1; i <= T; ++i) {
		for(int j = 1; j <= deg[d[i]]; ++j) {
			p[num + j] = num + j + 1;
		}
		p[num + deg[d[i]] + 1] = num + 1;
		num += deg[d[i]] + 1;
	}
	num = 0;
	for(int i = T; i >= 1; --i) {
		for(int j = 1; j <= deg[d[i]]; ++j) {
			q[num + j] = num + j + 1;
		}
		q[num + deg[d[i]] + 1] = num + 1;
		num += deg[d[i]] + 1;
	}
	for(int i = 1; i <= n; ++i) {
		if(p[i] != q[i]) {
			if(p[i] < q[i]) {
				for(int j = 1; j <= n; ++j) {
					printf("%d ", p[j]);
				}					puts("");

				return 0;
			} else {
				for(int j = 1; j <= n; ++j) {
					printf("%d ", q[j]);
				}				puts("");

				return 0;
			}
		}
	}
	for(int j = 1; j <= n; ++j) {
		printf("%d ", p[j]);
	}		puts("");

	return 0;
}

Measured memory_bytes: 17536
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	ll a, b;
	cin >> a >> b;

	ll ans = 0;
	llrep(i, 60) {
		ll n = (ll)1 << i;
		ans ^= ((b / (n * 2)*n + max(((b + 1) % (n * 2) == 0 ? (n*2) : (b + 1) % (n * 2)) - n, (ll)0)) & 1) << i;
	}

	if (a != 0) --a;
	llrep(i, 60) {
		ll n = (ll)1 << i;
		ans ^= ((a / (n * 2)*n + max(((a + 1) % (n * 2) == 0 ? (n*2) : (a + 1) % (n * 2)) - n, (ll)0)) & 1) << i;
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    map<int,int> mp;
    rep(i,4) {
        int x; cin >> x;
        mp[x]++;
    }
    if (mp[1] == 1 && mp[7] == 1 && mp[9] == 1 && mp[4] == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3628
import java.util.*;
public class Main{
  public static void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    //System.out.println(line);
    
    char[] ca = line.toCharArray();
    ArrayList<Character> cat = new ArrayList<Character>();
    ArrayList<Integer> cac = new ArrayList<Integer>();
    
    for(int i=0; i<ca.length; i++){
        if(cat.indexOf(ca[i]) == -1){
           cat.add(ca[i]);
           cac.add(1);
        }else{
           int idx = cat.indexOf(ca[i]);
           cac.set(idx, cac.get(idx)+1);
        }
    }
    
    int[] maeakimax = new int[cat.size()];
    int[] usiro = new int[cat.size()];
    for(int i=0; i<maeakimax.length; i++){
      char c = cat.get(i);
      int count = 0;
      for(int j=0; j<ca.length; j++){
          if(ca[j] == c){
             if(maeakimax[i] < count){
                maeakimax[i] = count;
             } 
             usiro[i] = j;
             count = 0;
          }else{
             count++;
          }
      }
    }
    int[] usiroakimax = new int[cat.size()];
    for(int i=0; i<cat.size(); i++){
       usiroakimax[i] = line.length() - usiro[i] - 1;
    }
    
    int anser = 100;
    for(int i=0; i<maeakimax.length; i++){
       int max = Math.max(maeakimax[i], usiroakimax[i]);
       if(anser > max){
          anser = max;
       }
    }

      System.out.println(anser);
  }
}

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

int main(){
	int n;
	string s, t;
	cin >> n >> s >> t;

	rep(i, n) cout << s.at(i) << t.at(i);
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	int digitsum = 0;
	int tmp = N;
	while (tmp > 0) {
		digitsum += tmp % 10;
		tmp /= 10;
	}
	if (N % digitsum == 0)  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;
using ll = long long;
using P = pair<int,int>;

vector<vector<int>> ki(0, vector<int>(0));
vector<vector<int>> ma(0, vector<int>(0));
vector<int> ans(0);
vector<int> it(0);

int main(){
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    int redf = 0;
    int grnf = 0;
    int cou = 0;
    ll ans = 0;

    vector<ll> red(A);
    rep(i, A) cin >> red.at(i);
    sort(red.begin(), red.end());
    vector<ll> grn(B);
    rep(i, B) cin >> grn.at(i);
    sort(grn.begin(), grn.end());
    vector<ll> whi(C);
    rep(i, C) cin >> whi.at(i);
    sort(whi.begin(), whi.end());

    int redi = red.size()-1;
    int grni = grn.size()-1;
    int whii = whi.size()-1;
    while(cou < X+Y){
        ll min = 0;
        int sai = -1;
        if(redf == 0 && grnf == 0 && whii >= 0){
            if(min < red.at(redi)){ min = red.at(redi); sai = 0;}
            if(min < grn.at(grni)){ min = grn.at(grni); sai = 1;}
            if(min < whi.at(whii)){ min = whi.at(whii); sai = 2;}
            if(sai == 0) redi--;
            if(sai == 1) grni--;
            if(sai == 2) whii--;
        }else if(redf == 1 && grnf == 0 && whii >= 0){
            if(min < grn.at(grni)){ min = grn.at(grni); sai = 1;}
            if(min < whi.at(whii)){ min = whi.at(whii); sai = 2;}
            if(sai == 1) grni--;
            if(sai == 2) whii--;
        }else if(redf == 0 && grnf == 1 && whii >= 0){
            if(min < red.at(redi)){ min = red.at(redi); sai = 0;}
            if(min < whi.at(whii)){ min = whi.at(whii); sai = 2;}
            if(sai == 0) redi--;
            if(sai == 2) whii--;
        }else if(redf == 1 && grnf == 1 && whii >= 0){
            if(min < whi.at(whii)){ min = whi.at(whii); sai = 2;}
            if(sai == 2) whii--;
        }else if(redf == 0 && grnf == 0 && whii == -1){
            if(min < red.at(redi)){ min = red.at(redi); sai = 0;}
            if(min < grn.at(grni)){ min = grn.at(grni); sai = 1;}
            if(sai == 0) redi--;
            if(sai == 1) grni--;
        }else if(redf == 1 && grnf == 0 && whii == -1){
            if(min < grn.at(grni)){ min = grn.at(grni); sai = 1;}
            if(sai == 1) grni--;
        }else if(redf == 0 && grnf == 1 && whii == -1){
            if(min < red.at(redi)){ min = red.at(redi); sai = 0;}
            if(sai == 0) redi--;
        }
        if(red.size()-1-redi == X) redf = 1;
        if(grn.size()-1-grni == Y) grnf = 1;
        cou++;
        ans += min;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp105 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int X2 = 0;
            int X4 = 0;

            for (int i = 0; i < N; i++) {
                if (a[i] % 4 == 0) {
                    X4++;
                } else if (a[i] % 2 == 0) {
                    X2++;
                }
            }

            if (N % 2 == 0) {
                Console.WriteLine((X2 + 2 * X4) >= N ? "Yes" : "No");
            } else {
                if (X4 >= 1) {
                    Console.WriteLine((X2 + 2 * X4) >= (N - 1) ? "Yes" : "No");
                } else {
                    Console.WriteLine((X2 >= N ? "Yes" : "No"));
                }
            }

        }
    }
}


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

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

typedef long long int ll;

const ll INF=(ll)1e18;

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

  vector<ll> a(N),b(N);
  vector<ll> c(M),d(M);

  REP(i,N)cin >> a[i] >> b[i];
  REP(i,M)cin >> c[i] >> d[i];

  REP(i,N){
    int ans;
    ll dist = INF;
    REP(j,M){
      ll tmp = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(tmp<dist){
        ans = j;
        dist = tmp;
      }
    }
    cout << ans+1 << endl;
  }
  
}



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

int main()
{
 int N;
 long int K;
 cin >> N >> K;
 map<int,long int> sorted_map;
 vector<int> seen;
 for(int i=0;i<N;i++){
     int a_i,b_i; cin >> a_i >> b_i;
     auto result = find(seen.begin(),seen.end(),a_i);
     if(result==seen.end()){
         sorted_map.insert(make_pair(a_i,b_i));
         seen.push_back(a_i);
     }
     else{
         long int tmp = sorted_map.at(a_i);
         sorted_map.erase(a_i);
         sorted_map.insert(make_pair(a_i,b_i+tmp));
     }
 }
 long int prev = 0;
 long int nxt;
 for(const auto & [key,value] : sorted_map){
     nxt = prev + (long int)value;
     if(prev<K && K<=nxt){
         cout << key << endl;
         break;
     }
     prev = nxt;
 }
 return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];

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

  if (n % 2 == 0) {
    int low = (a[n / 2] + a[n / 2 - 1]);
    int up = (b[n / 2] + b[n / 2 - 1]);
    int ans = up - low + 1;
    cout << ans << '\n';
  } else {
    int low = a[n / 2];
    int up = b[n / 2];
    int ans = up - low + 1;
    cout << ans << '\n';
  }
  return 0;
}



Measured memory_bytes: 4752
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int a,b,c; cin>>a>>b>>c;
    cout<<min(c,b/a)<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
long long int a,b,k;
cin>>a>>b>>k;

if(a+b<k)
	cout<<0<<" "<<0;

else if(a-k>=0)

	cout<<a-k<<" "<<b;

 else{
	b=b-(k-a);
	cout<<0<<" "<<b;
}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
ll num[100];
start{
    int x1,y1,x2,y2;
    x1=read,y1=read,x2=read,y2=read;
    int x3=0,y3=0,x4=0,y4=0;
    /**if(x1==x2&&y1!=y2){
        x3=x1-abs(y2-y1);
        y3=y2;
        x4=x3;
        y4=y1;
    }
    if(y1==y2&&x1!=x2)
    {
        x3=x2;
        x4=x1;
        y3=y2+(x2-x1);
        y4=y3;
    }
    if(x1!=x2&&y1!=y2)
    {
        if(y2>y1)
        {
            int temp=y2-y1;
            printf("temp: %d\n",temp);
            int len=sqrt((x1-x2)*(x1-x2)+temp*temp);
            printf("len: %d\n",len);
            int ask=sqrt(len*len-temp*temp);
            printf("ask: %d\n",ask);
            x4=x1-temp;
            y4=y1+ask;
            y3=y2+ask;
            x3=x2-temp;
        }
    }
    printf("%d %d %d %d\n",x3,y3,x4,y4);**/
    int x=x2-x1,y=y2-y1;
    printf("%d %d %d %d\n",x2-y,y2+x,x1-y,y1+x);
	end;
}


Measured memory_bytes: 764
#include<iostream>
using namespace std;
int main()
{
    int n,G=0,Y=0,W=0,P=0,cnt=0;
    cin>>n;
    char a[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]=='G')
            G=1;
         if(a[i]=='Y')
            Y=1;
         if(a[i]=='P')
            P=1;
         if(a[i]=='W')
            W=1;
    }
    if(G==1)
        cnt++;
    if(Y==1)
        cnt++;
    if(P==1)
        cnt++;
    if(W==1)
        cnt++;
       // cout<<cnt<<endl;
    if(cnt==3)
        cout<<"Three"<<endl;
    else
        cout<<"Four"<<endl;


    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split()) # n = 3, m = 4
a_matrix = [list(map(int, input().split())) for row in range(n)] # [[1, 2, 0, 1], [0, 3, 0, 1], [4, 1, 1, 0]]
b_matrix = [int(input()) for row in range(m)] # [1, 2, 3, 0]

for i in range(n):
	combined = [a * b for (a, b) in zip(a_matrix[i], b_matrix)]
	result = 0
	for x in combined:
		result += x
	print(result)

Measured memory_bytes: 8060
void main()
{
    long n, a, b;
    rdVals(n, a, b);

    long result = modPow(2, n) - 1;
    long fa = 1, fb = 1;

    foreach (i; 0 .. b)
    {
        if(i < a) fa = fa * (n - i) % mod;
        fb = fb * (n - i) % mod;
    }

    long[] finv = new long[b+1];
    long[] inv = new long[b+1];
    finv[0] = 1, finv[1] = 1;
    inv[1] = 1;
    foreach (i; 2 .. b+1) {
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }

    long ca = fa * finv[a] % mod;
    long cb = fb * finv[b] % mod;

    result = (result + mod - ca) % mod;
    result = (result + mod - cb) % mod;

    result.writeln;
}

long modPow(long x, long y)
{
    long result = 1;
    while (y > 0)
    {
        if (y & 1) result = result * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return result;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

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

int main() {
  int a, b;
  std::cin >> a >> b;
  if (a % 2 == 0 || b % 2 == 0) {
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<climits>
using namespace std;
long long dp[101][100005]={0};
int main()
{
  int n,W;
  cin>>n>>W;
  long long arr[n+1][2];
  for(int i=1;i<=n;++i)
  {
      cin>>arr[i][0]>>arr[i][1];
  }
  
  for(int item=1;item<=n;++item)
  {
    for(int weight=1;weight<=W;++weight)   
    {
        if(weight-arr[item][0]>=0) dp[item][weight]=max((long long)dp[item-1][weight],dp[item-1][weight-arr[item][0]]+arr[item][1]);
        else dp[item][weight]=dp[item-1][weight];
    }
  }
  
  cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 78336
import scala.io.StdIn._
object Main{
  def main(args: Array[String]): Unit = {
    val s1 = readLine
    val s2 = readLine
    if(s1.length!=s2.length) return
    for(i <- 0 to s1.length){
      val sa = s1.substring(i)
      val sb = s1.replaceFirst(sa,"")
      if(sa+sb == s2){
        println("Yes")
        return
      }
    }
    println("No")
  }
}


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

int main(){
    string A;
    string X;
    string C;
    cin>> A >>X >>C;
    char x;
    x=X.at(0);
    string answer;
    answer="AxC";
    answer.at(1)=x;
    cout<< answer <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int S=0;
  int M=0;
  cin>>N;
  vector<int>vec(N);
  vector<int>v(N);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
  }
  for(int X=0;X<N;X++){
    cin>>v.at(X);
  }
  for(int X=0;X<N;X++){
    S=0;
    for(int Y=0;Y<=X;Y++){
      S+=vec.at(Y);
    }
    for(int Y=X;Y<N;Y++){
      S+=v.at(Y);
    }
    if(M<S){
      M=S;
    }
  }
  cout<<M<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
ll comb(ll n){
	return n*(n-1)/2;
}
int main()
{
	std::ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	if((n*m)%2==0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;





	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

void get_kurai_vec(int S, vector<int>& store) {
  int shou = S / 10;
  int amari = S % 10;
  store.insert(store.begin(), amari);
  if (shou < 10) {
    if (shou != 0) store.insert(store.begin(), shou);
    return;
  }
  get_kurai_vec(shou, store);
}

int main() {
  int K, N;
  cin >> N >> K;
  vector<int> D(K);
  cin >> D;
  bool break_flag;
  int tmp = N;
  while (1) {
    break_flag = 0;
    vector<int> kurai_vec(0);
    get_kurai_vec(tmp, kurai_vec);
    for (int i = 0; i < kurai_vec.size(); i++) {
      for (int j = 0; j < D.size(); j++) {
        if (kurai_vec[i] == D[j]) {
          break_flag = 1;
          break;
        }
      }
      if (break_flag) break;
    }
    if (!break_flag) {
      cout << tmp << endl;
      return 0;
    }
    tmp++;
  }
  return 0;
}

Measured memory_bytes: 256