akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

    void solve() throws IOException {
        int n = ni(), m = ni();
        int[] a = nia(m);

        out.println(n - m - 1);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 24444
#include <iostream>

using namespace std;

#define int long long

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);    
  int d, t, s;
  cin >> d >> t >> s;
  if (s * t >= d) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}


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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back
#define t top()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo 1e17
#define int long long

const int N = 4e2 + 5;
int n;
int a[N] , sum[N];
int dp[N][N];

/// dp[i][j] là tổng nhỏ nhất khi kết hợp hết các slime trong đoạn [i][j].

main()
{
    //freopen("N.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    FOR(i , 1 , n)
    {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    FOR(r , 1 , n)
        FORD(l , r - 1 , 1)
        {
            dp[l][r] = 1e15;
            FOR(k , l , r + 1)
                dp[l][r] = min(dp[l][r] , sum[r] - sum[l - 1] + dp[l][k - 1] + dp[k][r]);
        }
    cout << dp[1][n] << "\n";
}


Measured memory_bytes: 1536
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

a=gets.to_i
b=gets.to_i
h=gets.to_i
puts (a+b)*h/2

Measured memory_bytes: 1788
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;


int H,W;
ll res=0,m[10][10];


int main()
{
	scanf("%d%d",&H,&W);
	for(int i=0;i<10;i++)
		for(int j=0;j<10;j++)
			scanf("%lld",&m[i][j]);

	for(int k=0;k<10;k++)
		for(int i=0;i<10;i++)
			for(int j=0;j<10;j++)
				m[i][j]=min(m[i][j],m[i][k]+m[k][j]);

	for(int i=0;i<H;i++)
		for(int j=0;j<W;j++)
		{
			int t;
			cin>>t;
			if(t!=-1&&t!=1)
				res+=m[t][1];
		}
	cout<<res<<endl;
}


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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;

  int ans = 0;
  ans += min(a,k);
  k-=a;
  if(k>0){
    k-=b;
  }
  if(k>0){
    ans -= min(c,k);
  }
  cout << ans << endl;
}

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

using namespace std;

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.14159265;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' '; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
//double d;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n >> m;
	if (n==1&&m==1) {
    	cout << 0; return 0;
    } else {
    	cout << (n*(n-1))/2+(m*(m-1))/2;
    }

    //cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

struct dice {
	int area[6];
};

int main() {
	struct dice dice1;
	char order[101];
	int i, temp;

	scanf("%d %d %d %d %d %d", &dice1.area[0], &dice1.area[1], &dice1.area[2], &dice1.area[3], &dice1.area[4], &dice1.area[5]);
	scanf("%s", order);

	for (i = 0; order[i] != '\0'; i++) {
		if (order[i] == 'N') {
			temp = dice1.area[0];
			dice1.area[0] = dice1.area[1];
			dice1.area[1] = dice1.area[5];
			dice1.area[5] = dice1.area[4];
			dice1.area[4] = temp;
		}
		else if (order[i] == 'W') {
			temp = dice1.area[0];
			dice1.area[0] = dice1.area[2];
			dice1.area[2] = dice1.area[5];
			dice1.area[5] = dice1.area[3];
			dice1.area[3] = temp;
		}
		else if (order[i] == 'E') {
			temp = dice1.area[0];
			dice1.area[0] = dice1.area[3];
			dice1.area[3] = dice1.area[5];
			dice1.area[5] = dice1.area[2];
			dice1.area[2] = temp;
		}
		else if (order[i] == 'S') {
			temp = dice1.area[0];
			dice1.area[0] = dice1.area[4];
			dice1.area[4] = dice1.area[5];
			dice1.area[5] = dice1.area[1];
			dice1.area[1] = temp;
		}
	}

	printf("%d\n" , dice1.area[0]);

	return 0;
}


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

def ans120(A:int, B:int, K:int):
    l=sorted([A,B])
    ans_list=[]
    for i in range(1,l[1]+1):
        if A%i==0 and B%i==0:
            ans_list.append(i)
    return ans_list[-K]

print(ans120(A,B,K))

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    vector<int> ma(3,0);
    REP(i,3)cin>>ma[i];
    int ans=INT32_MAX;
    REP(i,3)REP(y,3)if(i!=y)ans=min(ans,ma[i]+ma[y]);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
h,w,d = map(int,input().split())
branch = dict()
for i in range(1,h*w+1):
	branch[i] = []
for i in range(h):
	atemp = list(map(int,input().split()))
	for k in range(w):
		branch[atemp[k]].append(i+1)
		branch[atemp[k]].append(k+1)

q = int(input())
l = []
r = []
for i in range(q):
	ltemp,rtemp = map(int,input().split())
	l.append(ltemp)
	r.append(rtemp)

calc = dict()
for i in range(d):
	calc[i+1] = []
for i in range(1,d+1):
	now = i
	calc[i].append(0)
	k = 0
	while now+d <= h*w:
		calc[i].append(calc[i][k]+abs(branch[now][0]-branch[now+d][0])+abs(branch[now][1]-branch[now+d][1]))
		now = now+d
		k += 1

for i in range(q):
	div = l[i]//d
	if l[i]%d != 0:
		sur = l[i]%d
	else:
		sur = d
	ansdiv = r[i]//d
	if sur == d:
		print(calc[sur][ansdiv-1]-calc[sur][div-1])
	else:
		print(calc[sur][ansdiv]-calc[sur][div])

Measured memory_bytes: 51252
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x = max(x)
y = min(y)

if (x < y) and (X < y) and (Y >= y):
    print("No War")
else:
    print("War")

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

using namespace std;

using int64 = long long;

const int mod = 1e9 + 7;

string K;
int D;

int64 dp[10000][100][2];

int64 rec(int idx, bool free, int sum) {
  if(idx == K.size()) return sum == 0;
  if(~dp[idx][sum][free]) return dp[idx][sum][free];
  int64 ret = 0;
  for(int i = free ? K[idx] - '0' : 9; i >= 0; i--) {
    ret += rec(idx + 1, free & (i == K[idx] - '0'), (sum + i) % D);
    ret %= mod;
  }
  return dp[idx][sum][free] = ret;
}

int main() {
  memset(dp, -1, sizeof(dp));
  cin >> K >> D;
  cout << (rec(0, true, 0) + mod - 1) % mod << endl;
}



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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

const int N = 100003;

bitset<100> bt[N];
int dp[N];

void solve() {
	int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
	cin >> n >> m;
	int w[n + 1], v[n + 1];
	for (i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for (j = 0; j < N - 1; j++) {
		if (dp[j] == dp[N - 1]) continue;
		for (i = 1; i <= n; i++) {
			if (j + v[i] >= N) continue;
			if (bt[j][i]) continue;
			ans = dp[j] + w[i];
			if (ans > m) continue;
			if (ans < dp[j + v[i]]) {
				dp[j + v[i]] = ans;
				bt[j + v[i]] = bt[j];
				bt[j + v[i]][i] = 1;
			}
		}
	}
	for (i = 0; i < N; i++) {
		if (dp[i] != dp[N - 1]) ans = i;
	}
	cout << ans;
	return ;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
typedef long long ll;
using namespace std;

const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main() {
  int N;
  cin >> N;
  map<string, ll> m;
  string s;
  for (int i = 0; i < N; i++) {
    cin >> s;
    sort(s.begin(), s.end());
    m[s]++;
  }
  ll v = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    ll t = it->second;
    v += t * (t - 1) / 2;
  }
  cout << v << "\n";
  return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef long long ll;

int w, h;
int sx, sy;
int lastTime;
int dc[10][102];

char t[22][22];

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

int dp[2][20][20][1<<10];

void solve(){
  memset(dp, -1, sizeof(dp));
  dp[0][sy][sx][0] = 0;

  int to = (1 << 10);

  for(int I = 0; I < lastTime; I++){
    int i = I % 2;
    int ni = (i + 1) % 2;

    for(int y = 0; y < h; y++){
      for(int x = 0; x < w; x++){
        for(int j = 0; j < to; j++){
          dp[ni][y][x][j] = -1;
        }
      }
    }

    for(int y = 0; y < h; y++){
      for(int x = 0; x < w; x++){
        if(t[y][x] != '.') continue;

        for(int j = 0; j < to; j++){
          if(dp[i][y][x][j] == -1) continue;

          int ncost = dp[i][y][x][j];
          int nj = j;

          for(int k = 0; k < 4; k++){
            int nx = x + dx[k];
            int ny = y + dy[k];
            if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
            if(t[ny][nx] == '.') continue;

            int id = t[ny][nx] - '0';

            if(nj & (1 << id)) continue;
            if(dc[id][I] == -1) continue;

            ncost += dc[id][I];
            nj |= (1 << id);
          }

          for(int k = 0; k < 4; k++){
            int nx = x + dx[k];
            int ny = y + dy[k];
            if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
            if(t[ny][nx] != '.') continue;

            dp[ni][ny][nx][nj] = max(dp[ni][ny][nx][nj], ncost);
          }
        }
      }
    }
  }

  int ans = 0;

  for(int y = 0; y < h; y++){
    for(int x = 0; x < w; x++){
      for(int j = 0; j < to; j++){
        ans = max(ans, dp[lastTime % 2][y][x][j]);
      }
    }
  }

  cout << ans << endl;
}

int main(){
  while(cin >> w >> h, w || h){
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        cin >> t[i][j];

        if(t[i][j] == 'P'){
          t[i][j] = '.';
          sx = j;
          sy = i;
        }
      }
    }

    lastTime = 0;
    memset(dc, -1, sizeof(dc));

    int n;
    cin >> n;

    while(n--){
      int g, d, s, e;
      cin >> g >> d >> s >> e;
      lastTime = max(lastTime, e);

      for(int i = s; i < e; i++){
        dc[g][i] = d;
      }
    }

    solve();
  }
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n;
    while(cin>>n){
        ll ans=0;
        string s;
        map<string, int> mp;
        for(int i=0; i<n; ++i){
            cin>>s;
            scanf("%d",a+i);
            mp[s]=i;
        }
        string x;
        cin>>x;
        for(int i=mp[x]+1; i<n; ++i){
            ans+=a[i];
        }
        
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  double pi = acos(-1);
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double hangle = double(H*60+M)/720*2*pi;
  double mangle = double(M)/60*2*pi;
  double angle = abs(hangle-mangle);
  double ans1 = A*A+B*B-2*A*B*cos(angle);
  double ans = sqrt(ans1);
  printf("%.10f\n", ans);
}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
 
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}
 
void solve() {
	int N;
	cin >> N;
	vector<double> A(N);
	for (int i = 0; i < N; i++) {
	    cin >> A[i];
	}

	sort(all(A));

	double now = A[0];
	for (int i = 1; i < N; i++) {
	    now = (now + A[i]) / 2;
	}
	cout << now << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600123456789

int main(){
  int n,k;
  cin>>n>>k;
  vector<long> vec(n);
  rep(i,n) cin>>vec[i];

  long ans = INF;
  rep(mask,1<<n) if(__builtin_popcount(mask)>=k){
    long prev = 0;
    long cost = 0;
    rep(i,n){
      if(mask&(1<<i)){
        if(i>0) cost += max<long>(prev+1-vec[i], 0);
        prev = max(prev+1, vec[i]);
      } else {
        prev = max(prev, vec[i]);
      }
    }
    ans = min(ans, cost);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import collections as c
N = int(input())
a = list(map(int,input().split()))
ue = a[0::2]
sita = a[1::2]
dictue = c.defaultdict(int)
dictsita = c.defaultdict(int)
for i in ue:
    dictue[i] += 1
for i in sita:
    dictsita[i] += 1
ue = list(dictue.items())
ue.sort(key=lambda x:x[1])
sita = list(dictsita.items())
sita.sort(key=lambda x:x[1])
m = ue[len(ue)-1]
n = sita[len(sita)-1]
if m[0] == n[0]:
    if len(ue) == 1:
        if len(sita) == 1:
            print(N//2)
        else:
            print(N-m[1]-sita[len(sita)-2][1])
    else:
        if len(sita) == 1:
            print(N-n[1]-ue[len(ue)-2][1])
        else:
            print(min(N-n[1]-ue[len(ue)-2][1],N-m[1]-sita[len(sita)-2][1]))
else:
    print(N-m[1]-n[1])

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

int main(){
	vector <int> a(4);
	vector <int> b(4);
	int sum	= 0;
	for (int i =0;i<5;i++){
		cin >> a[i];
		(a[i]%10)? b[i] = a[i]%10: b[i]=10;
		(a[i]%10)? sum+=(a[i]/10 + 1)*10 : sum+= a[i];
		}
	
	cout << sum - 10  + *min_element(b.begin(),b.end()) << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back
#define sz size

using namespace std;

int n;

string s;

double ans,x;

int main()
{
    cin >> n;
    for (int i=0;i<n;i++)
    {
        cin >> x >> s;
        if (s=="JPY")ans+=x;
        else ans+=x*(380000);
    }
    cout << fixed << setprecision(5) << ans << endl;
    return 0;
}


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

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()

int main()
{
	string s;
	cin >> s;
	rep(i, 4)
	{
		cout << s[i];
	}
	cout << " ";
	repi(i, 4, s.size())
	{
		cout << s[i];
	}
	cout << endl;
	return 0;
}

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

int main(void){
    long long  n;
    cin >> n;
    for(long long i=(long long)sqrt(n);i>0;i--){
        if(n%i==0){
            long long j=n/i;
            cout << i+j-2 << endl;
            return 0;
        }
    }
}

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

using namespace std;

typedef long long ll;

const int maxn = 110000;

int a[maxn];

int main(int argc, char * argv[])
{
	int n;
	scanf("%d", &n);
	for (int i = 1;i <= n;++i) scanf("%d", &a[i]);
	ll lower = 2, upper = 2;
	for (int i = n;i >= 1;--i)
	{
		ll mini = ((lower - 1) / a[i] + 1)*a[i];
		ll maxi = upper / a[i] * a[i];
		if (mini > upper)
		{
			printf("-1\n");
			return 0;
		}
		lower = mini;
		upper = maxi + a[i] - 1;
	}
	printf("%lld %lld\n", lower, upper);
	return 0;
}

Measured memory_bytes: 512
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
//#define rz(x) resize(x)
//#define rz(x,y) resize(x,y)



void mymain(){
    string a;
    cin >> a;
    string s(a.size(),'x');
    cout << s << endl;
}

signed main(){
//IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;
for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


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


using namespace std;


#ifdef zxc

#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-10;
const ll MOD = 1e9 + 7;
const ld PI = 3.141592653589793;
const int maxn = 200001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

signed main() {
#ifdef zxc
    mt19937 mt(228);
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
//            freopen("", "r", stdin);
//        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(10);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    int a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0) {
        cout << "Zero";
        return 0;
    }
    if (b < 0) {
        if ((b - a + 1) % 2 == 0) {
            cout << "Positive";
        } else {
            cout << "Negative";
        }
        return 0;
    }
    cout << "Positive";
    auto end = chrono::steady_clock::now();
    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int f[51][51][51];
int a, b, c, x, ans;
int main() {
	cin >> a >> b >> c >> x;
	
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (i * 500 + j * 100 + k * 50 == x) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;


signed main(){
  int N,H,ans=0;
  cin >> N >> H;
  vector<ll> a(N),b(N);
  FOR(i,0,N){
    cin >> a[i] >> b[i];
  }
  sort(ALL(a));
  sort(ALL(b));
  REP(i,0,N){
    if(a[N-1] < b[i]){
      H -= b[i];
      ans++;
    }
    if(H <= 0){
      cout << ans << endl;
      return 0;
    }
  }
  debug(ans);
  cout << ans + (H+a[N-1]-1)/a[N-1] << endl;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, k;
    cin >> n >> k;
    vector<ll> p(n);
    for(auto& i : p) cin >> i;

    vector<ll> sum(n+1, 0);
    REP(i, n) sum[i+1] = sum[i] + p[i];


    ll ma = -inf, s = 0;
    REP(i, n - k + 1){
        if(sum[i+k] - sum[i] > ma){
            ma = sum[i+k] - sum[i];
            s = i;
        }
    }

    double ans = 0.0;
    REP(i, k){
        ans += (double) (1 + p[i+s]) / 2;
    }

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (ll i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
    ll n,d;cin>>n>>d;
    int cnt=0;
    rep(i,n){

        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3616
n, k = map(int, input().split())
a = list(map(int, input().split()))
ball = {}

for i in a:
    if i in ball:
        ball[i] += 1
    else:
        ball[i] = 1

ball = sorted(ball.items(), key=lambda x: -x[1])

ans = 0
if len(ball) > k:
    for i in range(k):
        ans += ball[i][1]
    ans = n - ans
print(ans)


Measured memory_bytes: 98376
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back

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

const int maxn = 5e3+2;
char s[maxn], ans[maxn];
int slen, anslen;
int k;

bool found(int len, int start)
{
  for (int i = 0; i < len; ++i)
    if (s[start+i] != ans[i])
      return false;
  return true;
}
bool found(int len)
{
  for (int i = 0; i+len <= slen; ++i)
    if (found(len, i))
      return true;
  return false;
}
void dfs(int len, int &left)
{
  for (char c = 'a'; c <= 'z'; ++c)
    {
      ans[len] = c;
      ans[len+1] = 0;
      if (found(len+1))
        {
          --left;
          if (!left)
            {
              puts(ans);
              exit(0);
            }
          dfs(len+1, left);
        }
    }
}
int main()
{
  scanf("%s %d", s, &k);
  slen = strlen(s);
  dfs(0, k);
}




Measured memory_bytes: 256
import java.util.*;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int[][] am = new int[N + 1][N + 1];
        List<int[]> edges = new ArrayList<>();
        for (int i : IntStream.range(0, M).toArray()) {
            int a = scan.nextInt();
            int b = scan.nextInt();
            am[a][b] = 1;
            am[b][a] = 1;
            edges.add(new int[]{a, b});
        }
        int count = 0;
        for(int[] edge : edges) {
            int start = edge[0];
            int goal = edge[1];
            am[start][goal] = 0;
            am[goal][start] = 0;
            Set<Integer> toured = new HashSet<>();
            Set<Integer> next = new HashSet<>();
            Set<Integer> tmp = new HashSet<>();
            next.add(start);
            while (!next.isEmpty()) {
                toured.addAll(next);
                for(int nn: next) {
                    for (int i = 1; i <= N; i++) {
                        if(am[nn][i] == 0) {
                            continue;
                        }
                        if(toured.contains(i)) {
                            continue;
                        }
                        tmp.add(i);
                    }
                }
                if (toured.contains(goal)) {
                    count--;
                    break;
                }
                next = tmp;
                tmp = new HashSet<>();
            }
            count++;
            am[start][goal] = 1;
            am[goal][start] = 1;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 28628
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define PI            3.14159265
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),v.rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>
#define msi           map<string,int>

int solve(){
   int n; cin>>n;
   vc<pii> v;
   for (int i = 0; i < n; ++i)
   {
       int a,b; cin>>a>>b;
       v.pb(mp(b,a));
   }
   sort(all(v));
   for (int i = 1; i < n; ++i)
   {
       v[i].sc+=v[i-1].sc;
   }
   for (int i = 0; i < n; ++i)
   {
       if(v[i].fr<v[i].sc){
        cout<<"No";
        return 0;
       }
   }
   cout<<"Yes";
}

signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 6128
a = list(input()) #aca
b = list(input()) #accc
c = list(input()) #ca

win = False 
run = a

while win != True:
  if run[0] == "a":
    run.pop(0)
    run = a
    if len(run) == 0:
        print("A")
        win = True
        
  elif run[0] == "b":
    run.pop(0)
    run = b
    if len(run) == 0:
        print("B")
        win = True
  else:
    run.pop(0)
    run = c
    if len(run) == 0:
        print("C")
        win = True

Measured memory_bytes: 9032
#include<bits/stdc++.h>
#define N 200050
#define M 200
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
#define ll long long
#define SIZE N

using namespace std;
int ar[N],tot;

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	char c; cin>>c;
	if(c>='a'&&c<='z')c='a';
	else c = 'A';
	cout<<c;
}


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

#define ll long long
#define N 110
#define M 100010
#define pii pair <int, int>
#define fi first
#define se second
const ll p = 1e9 + 7;
int n, k;
ll f[N][M];
pii g[M]; 
map <int, int> mp;

int main() {
	while (scanf("%d%d", &k, &n) != EOF) {
		memset(f, 0, sizeof f);
		mp.clear();
		int m = 0;
		for (int i = 1, j; i <= k; i = j + 1) {
			j = k / (k / i);
			g[++m] = pii(j, j - i + 1);
			mp[j] = m;
		}
		for (int i = 1; i <= m; ++i) {
			f[1][i] = (f[1][i - 1] + g[i].se) % p; 
		}
		for (int i = 2; i <= n; ++i) {
			for (int j = 1; j <= m; ++j) {
				f[i][j] = (f[i][j - 1] + 1ll * g[j].se * f[i - 1][mp[k / g[j].fi]] % p) % p;
			}
		}
		printf("%lld\n", f[n][m]);
	}
	return 0;
}

Measured memory_bytes: 93116
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')
def Z(f):
    if f:
        print('Yay!')
    else:
        print(':(')
def ispow(n):
    if int(n**.5)**2==n:
        return True
    return False

n = int(input())

if n % 2 == 1:
    print(0)
    exit()

def f(n):
    if n == 0:
        return 0
    return f(n // 5) + (n % 5)

n //= 2

print((n - f(n)) // 4)

Measured memory_bytes: 5044
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}


int main(){
  ll i,j,N,M,cnt=0,x;
  cin>>N;
  rep1(i,N+1){
    cin>>x;
    if(x!=i)cnt++;
  }
  if(cnt<3){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main() {
	int N;
	cin >> N;
	string s;
	cin >> s;
	int maxi = 0, now = 0;
	for (int i = 0; i < N; i++) {
		if (s[i] == ')') {
			++now;
		} else {
			--now;
		}
		maxi = max(maxi, now);
	}
	now = 0;
	int m = 0;
	for (int i = N-1; i >= 0; --i) {
		if (s[i] == '(') {
			++now;
		} else {
			--now;
		}
		m = max(m, now);
	}
	for (int i = 0; i < maxi; i++)
		cout << "(";
	cout << s;
	for (int i = 0; i < m; i++)
		cout << ")";
	cout << endl;
	return 0;
}


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

int gcd(int a, int b)
{
  int max = a > b ? a : b;
  int n = 2;

  for (; n <= max; n++)
  {
    if (a % n == 0 && b % n == 0)
    {
      return n * gcd(a / n, b / n);
    }
  }

  return 1;
}

int main()
{
  int a, b;
  cin >> a >> b;

  int common = gcd(a, b);
  cout << common << endl;

  return 0;
}



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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  long X, Y;
  cin >> X >> Y;
  if (X % Y == 0)
    cout << -1 << endl;
  else
    cout << X << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{

    int a;
    int b;

    int c;
    int d;


    scanf("%d", &a);
    scanf("%d", &b);

    if(b%2==1){
        printf("No\n");
        return 0;
    }

    c = b - 2 * a;
    if (c<0)
    {
        printf("No\n");
        return 0;
    }
    d = c / 2;

    if(d>a){
        printf("No\n");
        return 0;
    }

    printf("Yes\n");
}

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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define vrep(v, i) for(int i = 0; i < (v).size(); i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
#define dump(a, n) for(int i = 0; i < n; i++)cout << a[i] << "\n "[i + 1 != n];
#define dump2(a, n, m) for(int i = 0; i < n; i++)for(int j = 0; j < m; j++)cout << a[i][j] << "\n "[j + 1 != m];
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef complex<double> cd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int solve(int N){
		for(int X = 1 ; X <= N ; ++X){
			double Xd = X * 1.08;
			int Xi = (int)Xd;
			if(N == Xi){
				return X;
			}
		}
		return -1;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int S = solve(N);
		if(S < 0){
			System.out.println(":(");						
		}else{
			System.out.println(S);			
		}
	}
}


Measured memory_bytes: 23124
#include<stdio.h>
#define N 1000
#define M 100

int main(void){
  int i,n,j,jj;
  char x[N][M],y[N][M],sum[M];
  int xdigi,ydigi,ldigi;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",&x[i]);
    scanf("%s",&y[i]);
  }
  for(i=0;i<n;i++){
    for(j=0;;j++){
      if(x[i][j]==0){
        xdigi=j;
        break;
      }
    }
    for(j=0;;j++){
      if(y[i][j]==0){
        ydigi=j;
        break;
      }
    }
    if(xdigi>=ydigi){
      ldigi=xdigi;
    }else{
      ldigi=ydigi;
    }
    if(ldigi>80){
      printf("overflow\n");
    }else{
      for(j=0;j<=ldigi;j++){
        sum[j]=0;
      }
      for(j=xdigi-1,jj=0;j>=0;j--,jj++){
        sum[jj]+=x[i][j]-'0';
      }
      for(j=ydigi-1,jj=0;j>=0;j--,jj++){
        sum[jj]+=y[i][j]-'0';
      }
      for(j=0;j<ldigi;j++){
        if(sum[j]>=10){
          if(j==ldigi-1){
            ldigi++;
          }
          sum[j+1]++;
          sum[j]%=10;
        }
      }
      if(ldigi>80){
        printf("overflow\n");
      }else{
        for(j=ldigi-1;j>=0;j--){
          printf("%c",sum[j]+'0');
        }
        printf("\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <iostream>
using namespace std;

#define MAX_W 8
#define MOD 1000000007

typedef pair<int, int> P;
int pat[MAX_W + 1];

int getPattern(int i) {
    return i < 0 ? 1 : pat[i];
}

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    K--;

    if (W == 1) {
        cout << 1 << endl;
        return 0;
    }

    pat[0] = 1;
    pat[1] = 1;
    pat[2] = 2;
    for (int i = 0; i < MAX_W + 1; i++) {
        if (i > 2) pat[i] = pat[i - 1] + pat[i - 2];
    }

    long int count[H+1][W];

    count[0][0] = 1;
    for (int i = 1; i < W; i++) {
        count[0][i] = 0;
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 0; j < W; j++) {
            count[i][j] = 0;
            if (j > 0) count[i][j] += count[i-1][j-1] * getPattern(j - 1) % MOD * getPattern(W - j - 1) % MOD;
            count[i][j] += count[i-1][j] * getPattern(j) % MOD * getPattern(W - j - 1) % MOD;
            if (j < W - 1) count[i][j] += count[i-1][j+1] * getPattern(j) % MOD * getPattern(W - j - 2) % MOD;
            count[i][j] = count[i][j] % MOD;
        }
    }

    cout << count[H][K] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

//WA なんでだかよくわからない

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};

int imod(int i, int j){
  return i % j + (i % j < 0 ? j : 0);
}

int main(){
    while(1){
        int n;
        cin >> n;
        if(!n) break;

        vector<int> ans;
        while(n!=0){
            ans.push_back(imod(n, 10));
            n -= imod(n, 10);
            n /= -10;
        }
        for(int i=ans.size()-1;i>=0;i--)cout << ans[i];
        cout << endl;
    }

    return 0;
}

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

int main(){
    
    int N, K;
    cin >> N >> K;
    vector<int> X(N);
    
    for(int i=0;i<N;i++){
        cin >> X[i];
    }
    
    int count=0;
    for(int i=0;i<N;i++){
        count+=2*min(abs(X[i]),abs(K-X[i]));
    }
    
    cout << count << endl;
    
}

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

int main()
{
    int H, W, D, Q;
    cin >> H >> W >> D;
    vector<array<int,2>> A(H*W);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int k;
            cin >> k;
            A[k-1] = array<int, 2>{i, j};
        }
    }
    vector<vector<int>> cost(D);
    for(int i=0;i<D;i++){
        cost[i].push_back(0);
        for(int j=i; j+D<H*W; j+=D){
            auto x1 = A[j];
            auto x2 = A[j+D];
            auto c = abs(x1[0] - x2[0]) + abs(x1[1] - x2[1]);
            cost[i].push_back(c + cost[i].back());
        }
    }

    cin >> Q;
    int R, L;
    vector<int> res(Q);
    for(int i=0;i<Q;i++){
        cin >> L >> R;
        R--; L--;
        res[i] = cost[R%D][R/D] - cost[L%D][L/D];
    }
    for(auto v : res) cout << v << endl;

    return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;

ll n, k;
ll f[128];

int main(){
  cin >> n >> k;
  for(ll i=0;i<k;i++){
    ll c; cin >> c;
    for(ll j=0;j<c;j++){
      ll d; cin >> d; f[d] = 1;
    }
  }
  ll ans = 0;
  for(ll i=1;i<=n;i++) if (f[i]==0) ans++;
  cout << ans << endl;
  
  return 0;
}
  

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cstdlib>
// #include <fstream>

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;
long long int act[100010][3];
long long int dp[100010][3];


int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    
    std::cin >> n;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<3; j++)
        {
            std::cin >> act[i][j];
        }
    }
    
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<3; j++)
        {
            for(int k=0; k<3; k++)
            {
                if(j==k) continue;
                chmax(dp[i+1][k], dp[i][j]+act[i][k]);
            }
        }
    }

    std::cout << std::max({dp[n][0], dp[n][1], dp[n][2]}) << std::endl;

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int INF = 1e9;

string s;
int main(){
  cin>>s;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]=='A' && s[i+1]=='C'){cout<<"Yes"<<endl;return 0;}
  }
  cout<<"No"<<endl;
  return 0;
}


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

yakusuu = []
for i in range(1, int((M + 1)**(1/2)+1)):
    if M % i == 0:
        yakusuu.append(i)
        yakusuu.append(int(M/i))
yakusuu.sort()
yakusuu.reverse()


for i in yakusuu:
    if M / i >= N:
        print(i)
        break


Measured memory_bytes: 39024
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		new Main();
	}

	public Main() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine().trim();
		int n = Integer.parseInt(line);
		br.close();

		call(n);
	}

	void call(int n) {
		int i = 1;

		do {
			int x = i;
			if (x % 3 == 0) {
				System.out.print(" " + i);
			} else {
				do {
					if (x % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					x /= 10;
				} while (x != 0);
			}
		} while (++i <= n);

		System.out.println();
	}
}

Measured memory_bytes: 26892
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]";
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int N = 3;
    vector<int> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    sort(ALL(A));

    int diffSum = 0;
    FOR(i, 1, N){
        diffSum += A[i] - A[i-1];
    }

    p(diffSum);

    return 0;
}

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

int main() {
  int n = 0;
  cin >> n;
  vector <int> arr(n);
  for(int i = 0; i < n; i++){
    cin >> arr[i];
  }
  int sum = 0;
  sort(arr.begin(),arr.end());
  for(int i = 0; i < n-1; i++){
    sum = sum + arr[i];
  }
  if(arr[n-1] < sum){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256