akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define trav(a, b) for(auto& a: b)
#define all(a) a.begin(), a.end()
#define gottagofast ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int gcd(int a, int b, int c) {
	return __gcd(a, __gcd(b, c));
}

int main() {
	gottagofast;
	int k;
	ll ans = 0;
	cin >> k;
	for(int a = 1; a <= k; ++a) {
		for(int b = 1; b <= k; ++b) {
			for(int c = 1; c <= k; ++c) {
				ans += gcd(a, b, c);
			}
		}
	}
	cout << ans;
	return 0;

}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k,i,j,l,d,p;
    cin>>n>>k;
    //p=n;

    vector<long long int>v,v1,v2;

    d=min(n%k,k-((n%k)%k));
    cout<<d<<endl;

    return 0;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main ()
{
   char ch;
   cin>>ch;
   if(ch=='A')
    cout<<"T"<<endl;
   else if(ch=='T')
    cout<<"A"<<endl;
   else if (ch=='G')
    cout<<"C"<<endl;
   else if(ch=='C')
   cout<<"G"<<endl;
    return 0;
}


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

int main()
{
  char a, b;
  cin >> a >> b;
  if (a == 'H' && b == 'H') cout << 'H' << endl;
  else if (a == 'D' && b == 'D') cout << 'H' << endl;
  else cout << 'D' << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> step(n + 1, true);
  for(int i = 0; i < m; ++i){
    int a;
    cin >> a;
    step[a] = false;
  }
  vector <long long int> ans(n + 1);
  ans[0] = 1;
  for(int now = 0; now < n; ++now){
    for(int next = now + 1; next <= min(n, now + 2); ++next ){
      if(step[next]){
        ans[next] += ans[now];
        ans[next] %= 1000000007;
      }
    }
  }
  cout << ans[n] << endl;
}

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

int main(){
  int n,k;cin>>n>>k;
  string s;
  cin>>s;
  if(s[k-1]=='A')s[k-1]='a';
  else if(s[k-1]=='B')s[k-1]='b';
  else s[k-1]='c';
  cout<<s;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 点数取得
	long long llPoint;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%lld", &llPoint);

	// 必要回数
	long long llCnt = llPoint / (long long)11 * (long long)2;

	// 端数
	int liMod = llPoint % (long long)11;
	if (liMod > 0) {
		llCnt++;
		if (liMod > 6) {
			llCnt++;
		}
	}

	// 結果セット
	sprintf(lc1Out, "%lld\n", llCnt);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
    
using namespace std;
int N, M;

int main( ) {
    cin>>N>>M;
    int A[M];
    int total=0;
    int ans;
    for(int i=1;i<=M;i++){
        cin>>A[i];
        total=total+A[i];
    }
    if(N-total>=0){
        cout<<N-total;
    }
    else{
        cout<<"-1";
    }
    
    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n,k; scanf("%d%d",&n,&k);
    string s; cin>>s;
    int cnt=0;
    rep(i,0,n-1)if(s[i]!=s[i+1])cnt++;
    printf("%d\n",min(n-1,n-1-cnt+2*k));
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

int a[10][10];

int calc_msu(int x) {
  while (x >= 10) {
    x /= 10;
  }
  return x;
}

int solve(int n) {
  for (int i = 1; i <= n; ++i) {
    int msu = calc_msu(i);
    int lsu = i % 10;
    ++a[msu][lsu];
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int msu = calc_msu(i);
    int lsu = i % 10;
    ans += a[lsu][msu];
  }
  return ans;
}

int main() {
  int n;
  std::cin >> n;
  std::cout << solve(n) << std::endl;
  return 0;
}


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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "H"
#define FALSE__ "D"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

int n;

signed main()
{
	init();
	solve();
}

void init()
{
	cin >> n;
}

void solve()
{
	int res = 0;
	int i;
	for (i = 1; res < n; i++) res += i;
	cout << i - 1 << endl;
}


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

using namespace std;

vector <int> gr[100010];
int h[100010];
int a[100010];
int k;
int ans = 0;

void dfs(int v) {
    h[v] = 0;
    for (int i = 0; i < gr[v].size(); ++i) {
        dfs(gr[v][i]);
        h[v] = max(h[v], h[gr[v][i]] + 1);
    }
    if (h[v] == k - 1 && a[v] != 1) {
        ++ans;
        a[v] = 1;
        h[v] = -1;
    }
}

int main() {
    int n;
    cin >> n >> k;
    cin >> a[1];
    for (int i = 2; i <= n; ++i) {
        cin >> a[i];
        gr[a[i]].push_back(i);
    }
    dfs(1);
    if (a[1] != 1) {
        ++ans;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 11136
import java.math.BigInteger;
import java.util.*;
public class Main {





public static void main(String[] args)
{
	Scanner sc=new Scanner(System.in);
			int a=sc.nextInt();
			int b=sc.nextInt();
			int c=sc.nextInt();
			if(2*b==(a+c)) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
}
}

class pair{
	int x,y;
	pair(int x,int y){
		this.x=x;
		this.y=y;
	}
}


Measured memory_bytes: 35648
H, W = list(map(int, input().split()))
s = [input() for i in range(H)]
a = "#"
Ans = "Yes"
for i in range(H):
  for j in range(W):
    if s[i][j] == a:
      if i - 1 >= 0 and s[i - 1][j] == a: continue
      if i + 1 <= H - 1 and s[i + 1][j] == a: continue
      if j - 1 >= 0 and s[i][j - 1] == a: continue
      if j + 1 <= W - 1 and s[i][j + 1] == a: continue
      Ans = "No"
      break

print(Ans)

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

using namespace std;

int main(){
  int N;
  int num = 1;
  double dec = 0;

  cin >> N;

  double A[N];
  for(int i = 0;i < N;i++){
    cin >> A[i];
    num = num*A[i];
  }

  for(int i = 0;i<N;i++){
    dec += (double)(num)/(A[i]);
  }

  cout << num/dec << endl;
  return 0;

}



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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, k;
    cin >> n >> k;
    int cnt = 0;

    rep(i, n)
    {
        int h;
        cin >> h;
        if (h >= k)
            cnt++;
    }

    OP(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    ll sum=0;
    for(ll x=2;x*x<=n;x++){
        ll cnt=0;
        while(n%x==0){cnt++;n/=x;}
        if(cnt>0){
            ll i=1;
            while(cnt>0){cnt-=i;i++;sum++;}
            if(cnt<0)sum--;
        }
    }
    if(n>1)sum++;
    cout<<sum<<"\n";
}


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

int main(){
  int n;
  cin >> n;
  
  vector<int64_t> Lucas(n+1);
  Lucas.at(0) = 2LL;
  Lucas.at(1) = 1LL;
  for(int i=2; i<=n; i++){
    Lucas.at(i) = Lucas.at(i-1) +Lucas.at(i-2);
  }
  cout << Lucas.at(n);
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
	int N;cin>>N;
  vector<ll> a(3*N);
  FOR(i,0,3*N)cin>>a[i];
  priority_queue<ll,vector<ll>,greater<ll>> f;
  priority_queue<ll> b;
  vector<ll> sumf(N+1,0LL),sumb(N+1,0LL);
  FOR(i,0,N){
  	f.push(a[i]);
    sumf[0]+=a[i];
  }
  FOR(i,0,N){
  	ll tmp=f.top();
    if(a[i+N]>tmp){
    	f.pop();
      	f.push(a[i+N]);
        sumf[i+1]=sumf[i]+a[i+N]-tmp;
    }else{
    	sumf[i+1]=sumf[i];
    }
  }
  FOR(i,0,N){
  	b.push(a[3*N-1-i]);
    sumb[0]+=a[3*N-1-i];
  }
  FOR(i,0,N){
  	ll tmp=b.top();
    if(a[2*N-1-i]<tmp){
    	b.pop();
      b.push(a[2*N-1-i]);
      sumb[i+1]=sumb[i]+a[2*N-1-i]-tmp;
    }else{
    	sumb[i+1]=sumb[i];
    }
  }
  ll res =-INF;
  FOR(i,0,N+1){
    res=max(res,sumf[i]-sumb[N-i]);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 6516
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int N, A, B, C;
int ans = 0;

void dfs(vector<int> &l, int i, int mp, int l1, int l2, int l3) {
  if (i == N) {
    if (l1 == 0 || l2 == 0 || l3 == 0) return;
    ans = min(ans, abs(A - l1) + abs(B - l2) + abs(C - l3) + mp);
    return;
  }
  if (l1 != 0)
    dfs(l, i + 1, mp + 10, l1 + l[i], l2, l3);
  else
    dfs(l, i + 1, mp, l1 + l[i], l2, l3);

  if (l2 != 0)
    dfs(l, i + 1, mp + 10, l1, l2 + l[i], l3);
  else
    dfs(l, i + 1, mp, l1, l2 + l[i], l3);

  if (l3 != 0)
    dfs(l, i + 1, mp + 10, l1, l2, l3 + l[i]);
  else
    dfs(l, i + 1, mp, l1, l2, l3 + l[i]);

  dfs(l, i + 1, mp, l1, l2, l3);
  return;
}

int main() {
  cin >> N >> A >> B >> C;
  vector<int> l(N);
  for (int i = 0; i < N; i++) cin >> l[i];
  ans = 1000000;
  dfs(l, 0, 0, 0, 0, 0);
  cout << ans << endl;
  return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> G(n,-1);
	vector<vector<int>> vs(n);
	int u,k,v;
	for(int loop=0;loop<n;loop++){
		cin >> u >> k;
		for(int loop2=0;loop2<k;loop2++){
			cin >> v;
			vs[u-1].push_back(v-1);
		}
	}
	queue<pair<int,int>> Q;
	Q.push(make_pair(0,0));
	G[0]=0;
	int lk,dist;
	while(!Q.empty()){
		lk = Q.front().first;
		dist = Q.front().second;
		Q.pop();
		for(int loop=0;loop<vs[lk].size();loop++){
			if(G[vs[lk][loop]]==-1){
				G[vs[lk][loop]]=dist+1;
				Q.push(make_pair(vs[lk][loop],dist+1));
			}
		}
	}
	for(int loop=0;loop<n;loop++){
		cout << loop+1 << " " << G[loop] << endl;
	}
	return 0;
}


Measured memory_bytes: 3176
/* Elementary data structures - Stack */

#include <stdio.h>
#include <stdlib.h>

int stack[200];
int l = 0;

void push( int x )
{
  stack[l++] = x;
}

int pop()
{
  return stack[--l];
}

int main( void )
{
  char c;
  int a, b, numberp;
  while ( 1 ) {
    scanf( "%c", &c );
    if ( c == '\n' ) break;

    switch( c ){
    case ' ':
      numberp = 0;
      break;
    case '+':
      push( pop() + pop() );
      numberp = 0;
      break;
    case '-':
      a = pop();
      b = pop();
      push( b - a );
      numberp = 0;
      break;
    case '*':
      push( pop() * pop() );
      numberp = 0;
      break;
    default:
      if ( numberp )
        push( 10 * pop() + c - 48 );
      else
        push( c - 48 );
      numberp = 1;
    }
  }

  printf( "%d\n", pop() );

  return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    ll n,k,s;
    cin >> n >> k >> s;
    ll x = n-k;
    rep(i,k){
        cout << s << " ";
    }
    rep(i,x){
        cout << 1000000000-1 <<" ";
    }
    cout << endl;


}



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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    int N; cin >> N;
    vi a(N);
    int cnt=0;
    for(int i=0; i<N; i++){
        cin >> a[i];
        if(i%2 == 0 && a[i]%2 == 1){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3580
S=input()
s=[0 for i in range(len(S))]

for i in range(len(S)):
    s[i]=int(S[i])
CHECK=[0 for i in range(2021)]
ans=0
temp=0
for i in range(1,len(s)+1):
    #print(s[-i])
    temp=(temp+s[-i]*pow(10,i-1,2019)+2019*2)%2019
    #print(i,temp)
    #print(temp)
    CHECK[temp]+=1
for i in CHECK:
    ans+=i*(i-1)//2

ans+=CHECK[0]
 
print(ans)

Measured memory_bytes: 10956
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265358979323846264338327950L
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

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

  cout << round((a + b) / 2) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;

  static class Solution {
    void solve() throws IOException {
      while (true) {
        int m = in.nextInt();
        int f = in.nextInt();
        int r = in.nextInt();
        char grade = 'F';
        int tmp = m + f;
        
        if (m == -1 || f == -1 ) {
          if (m == -1 && f == -1 &&  r == -1) {
            break;
          } 
        } else if (tmp >= 80) {
          grade = 'A';
        } else if (tmp >= 65) {
          grade = 'B';
        } else if (tmp >= 50) {
          grade = 'C';
        } else if (tmp >= 30) {
          grade = 'D';
          
          if (r >= 50) {
            grade = 'C';
          } 
        } 
        
       
        
        out.println(grade);
      }
      
//      End solve()
    }
//    End Solution
}

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }


  }

}

Measured memory_bytes: 24312
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

int main()
{
  string s[3];
  for (int i = 0; i < 3; i++)
    cin >> s[i];

  int count = 0;

  for (;;)
  {
    char tmp = s[count][0];
    //cout << tmp << " " << s[count] << endl;

    if (s[count].size() == 0)
      break;
    if (tmp == 'a')
    {
      s[count].erase(0, 1);
      count = 0;
    }
    else if (tmp == 'b')
    {
      s[count].erase(0, 1);
      count = 1;
    }
    else if (tmp == 'c')
    {
      s[count].erase(0, 1);
      count = 2;
    }
  }
  char ans;
  for (int i = 0; i < 3; i++)
  {
    if (count == i)
    {
      ans = 'A' + i;
      cout << ans << endl;
      break;
    }
  }
}


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

int main(){
  int n;
  cin >> n;
  cout << (1000-n%1000)%1000 << endl;

  return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;

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

}


/* きょむ〜 */


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

typedef long long int ll;
const int maxn = 1e5 + 10;
void solved(){
	ll x;cin>>x;
	for(ll i = -1000; i <= 1000; i++){
		for(ll j = -1000; j <= 1000; j++){
			if(pow(i,5) - pow(j,5) == x){
				cout<<i<<" "<<j<<endl;return;
			}
		}
	}
}
int main(){
	solved();
	return 0;
} 

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
int main () {
  int N, M;
  cin >> N >> M;
  dsu d(N);
  int a, b;
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    a--;
    b--;
    d.merge(a, b);
  }
  map<long, long> mp;
  for(int i = 0; i < N; i++)mp[d.leader(i)];
  cout << mp.size() - 1<< endl;
  return 0;
}

Measured memory_bytes: 8968
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int a,b;
int main(){
	cin>>a>>b;
	int a1,a2,a3;
	a1=a+b;
	a2=a-b;
	a3=a*b;
	cout<<max(a1,max(a2,a3))<<endl;
	return 0;
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
#define deg_to_rad(deg) (((long double)(deg)/360.0)*2*M_PI)
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;
#define PI 3.14159265358979323846264338327950L

int main() {

    int a, b, h, m;
    scanf("%d%d%d%d", &a, &b, &h, &m);

    long double rad = PI * 2 * (
    (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);

    long double rsq = (long double)(a * a + b * b) - (long double)(2 * a * b) *cosl(rad);

    printf("%20.20Lf\n", sqrtl(rsq));

    return 0;
}

/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



Measured memory_bytes: 4188
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


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

	vector<int> A(M);

	int cnt = 0;

	rep(i, M) {
		cin >> A[i];
		cnt += A[i];
	}

	if (N - cnt < 0) {
		cout << "-1" << endl;
	}
	else if (N - cnt >= 0) {
		cout << N - cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        long INF = (long)1e18;
        FastScanner sc = new FastScanner(Console.OpenStandardInput());
        int N = sc.nextInt();
        long[] A = sc.longArray(N);
        if (A.Contains(0))
        {
            Console.WriteLine(0);
            return;
        }
        long ans = 1L;
        foreach (var Ai in A)
        {
            if (INF / ans < Ai)
            {
                Console.WriteLine(-1);
                return;
            }
            ans *= Ai;
        }
        Console.WriteLine(ans);
    }
}

// FastScanner start
public class FastScanner
{
    public readonly Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof = false;
    public FastScanner(Stream stream)
    {
        str = stream;
    }
    private T[] enumerate<T>(int n, Func<T> f)
    {
        var a = new T[n];
        for (int i = 0; i < n; ++i) a[i] = f();
        return a;
    }
    public char nextChar()
    {
        byte b = 0;
        do
        {
            b = read();
        }
        while ((b < 33 || 126 < b) && !isEof);
        return (char)b;
    }
    public int nextInt()
    {
        return (isEof) ? int.MinValue : (int)nextLong();
    }
    public long nextLong()
    {
        if (isEof)
        {
            return long.MinValue;
        }
        long ret = 0;
        byte b = 0;
        var ng = false;
        do
        {
            b = read();
        }
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-')
        {
            ng = true;
            b = read();
        }
        for (; true; b = read())
        {
            if (b < '0' || '9' < b)
            {
                return ng ? -ret : ret;
            }
            else ret = ret * 10 + b - '0';
        }
    }
    public int[] intArray(int n)
    {
        return enumerate(n, nextInt);
    }
    public long[] longArray(int n)
    {
        return enumerate(n, nextLong);
    }
    public char[] charArray(int n)
    {
        return enumerate(n, nextChar);
    }
    public string Scan()
    {
        var sb = new StringBuilder();
        for (var b = nextChar(); b >= 33 && b <= 126; b = (char)read())
        {
            sb.Append(b);
        }
        return sb.ToString();
    }
    private byte read()
    {
        if (isEof)
        {
            return 0;
        }
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = str.Read(buf, 0, 1024)) <= 0)
            {
                isEof = true;
                return 0;
            }
        }
        return buf[ptr++];
    }
}
// FastScanner end

Measured memory_bytes: 28344
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC094_A();
        }

        static void ABC094_A()
        {
            var ABX = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            Console.WriteLine(ABX[0] > ABX[2] || ABX[0] + ABX[1] < ABX[2] ? "NO" : "YES");
        }
    }
}

Measured memory_bytes: 11220
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = Integer.parseInt(scan.next());
		int b = Integer.parseInt(scan.next());	
		System.out.println(a*b+" "+ 2*(a+b));
		scan.close();
	}
}

Measured memory_bytes: 17124
#include<bits/stdc++.h>
#define LiangJiaJun main
#define ll long long
using namespace std;
int n,W;
ll f[100004];
int a[104],b[104];
int w33ha(){
    memset(f,0,sizeof(f));
    for(int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]);
    for(int i=1;i<=n;i++){
        for(int j=W;j>=a[i];j--){
            f[j]=max(f[j],f[j-a[i]]+b[i]);
        }
    }
    printf("%lld\n",f[W]);
    return 0;
}
int LiangJiaJun(){
    while(scanf("%d%d",&n,&W)!=EOF)w33ha();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n+1];
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[i] < i && a[a[i]]==i) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

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


Measured memory_bytes: 3640
var
  s:string;
  l:longint;
begin
  readln(s);
  l:=length(s);
  if s[1]=s[l] then
   begin
     if l mod 2=0 then writeln('First')
                  else writeln('Second');
   end
  else
   begin
     if l mod 2=1 then writeln('First')
                  else writeln('Second');
   end;
end.

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

using namespace std;

char num[8]={'a','d','g','j','m','p','t','w'};
int size[8]={3,3,3,3,3,4,3,4};
int main(void){
	string str;
	int n;
	scanf("%d",&n);
	for(int ddd=0;ddd<n;ddd++){
		int cnt=0;
		string res;
		cin >> str;
		for(int i=0;i<str.size();i++){
			if(i==0){
				if(str[i]!='0')cnt++;
			}else{
				if(str[i]!='0')cnt++;
				if(str[i]=='0'){
					if(str[i-1]=='0')continue;
					if(str[i-1]=='1'){
						cnt=(cnt+4)%5;
						if(cnt==0)res+='.';
						if(cnt==1)res+=',';
						if(cnt==2)res+='!';
						if(cnt==3)res+='?';
						if(cnt==4)res+=' ';
					}else res+=num[str[i-1]-'0'-2]+(cnt-1+size[str[i-1]-'0'-2])%size[str[i-1]-'0'-2];
					cnt=0;
				}
			}
		}

		cout << res << endl;
	}
	return 0;
}

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

int main(){
	
	int n, h[100010], dp[100010];
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++){
		scanf(" %d", &h[i]);
		
		if(i <= 1) dp[i] = abs(h[i] - h[0]);
		else dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	
	printf("%d\n", dp[n - 1]);
	return 0;
}


Measured memory_bytes: 4564
#include<stdio.h>

int num[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 
 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 
int main() 
{
	int n;
	scanf("%d",&n);
	printf("%d",num[n]);
	return 0;
}



Measured memory_bytes: 128
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
import heapq
INF = float("inf")
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

def custom_round(number, ndigits=0):
  if type(number) == int: #整数ならそのまま返す
    return number
  d_point = len(str(number).split('.')[1]) #小数点以下が何桁あるか定義
  if ndigits >= d_point:#求める小数点以下の値が引数より大きい場合はそのまま返す
    return number
  c = (10 ** d_point) * 2
    #小数点以下の桁数分元の数に0を足して整数にして2倍するための値(0.01ならcは200)
  return round((number * c + 1) / c, ndigits)
    #元の数に0を足して整数にして2倍して1を足して2で割る。元の数が0.01なら0.015にしてroundを行う

N, M = mi()

ans = 0
ans += (N - M) * 100 + M * 1900
ans *= (2 ** M) 

print(ans)

Measured memory_bytes: 38384
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int result = 0;

        result = a + (a * a) + (a * a * a);

        PrintWriter out = new PrintWriter(System.out);
        out.println(result);

        sc.close();
        out.flush();
    }
}

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

#define int long long int
#define pb push_back
#define mp make_pair

int32_t main()
{
     
     int n;
     
     cin>>n;
     
     if(n==1)
     {
          cout<<"Hello World";
     }
     else
     {
          int a,b;
          
        cin>>a>>b;
        
        cout<<a+b;
     }
     
     
     return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  	public static void main (String [] args){
		Scanner scanner = new Scanner (System.in);
        String in = scanner.next();
        String out = "";
        for (int i = 0; i < in.length(); i+=2){
            out = out + in.charAt(i);
        }
        System.out.println(out);
    }
}

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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n;
    cin >> n;

    ll a[n], b[n], c[n];
    rep(i, n)cin >> a[i] >> b[i] >> c[i];

    ll dp[n+1][3] = {};
    
    rep(i, n){
        dp[i+1][0] = max(dp[i][1], dp[i][2]) + a[i];
        dp[i+1][1] = max(dp[i][0], dp[i][2]) + b[i];
        dp[i+1][2] = max(dp[i][0], dp[i][1]) + c[i];
    }

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

Measured memory_bytes: 4992
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>

using namespace std;

typedef long long ll;
const ll nmax = 1e9 + 7;
const ll mod = 998244353;
const double PI = 2 * asin(1);

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

  int ans = 0, now = 0;
  for (int i = 0; i < N; i++){
    if (now <= H[i]){
      ans++; now = H[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        String s = input[0];
        String t = input[1];
        StringBuilder ans = new StringBuilder();
        
        for(int i = 0; i < n; i++){
            ans.append(s.charAt(i));
            ans.append(t.charAt(i));
        }
        
        out.println(ans);
        out.close();
        
    }
}

Measured memory_bytes: 32948
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main() {
	int n;
	cin >> n;
	int sum = 800 * n;
	int sum2 = 200 *( n/15);
	cout << sum - sum2 << endl;
}


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

using namespace std;
 
typedef long long ll;
 

int main(){
    int n;

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

}

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define LOCAL
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound
#define lowbit(x) x&(-x)
#define testbit(x,i) x&(1<<i)

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

string s;

int main() 
{
	#ifndef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>s;
    if(s == "ABC") {
    	cout<<"ARC"<<endl;
	}else {
		cout<<"ABC"<<endl;
	}
    /* end code */
	return 0;
}

Measured memory_bytes: 3652
// B - Bingo
// https://atcoder.jp/contests/abc157/tasks/abc157_b
#include <iostream>
#include <bits/stdc++.h>
#include <map>
#include <queue>
#include <set>
#include <string> 
#include <vector>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair<int, int> PII;
const ll mxsize = 3e5 + 5;
const ll linf = 1e9;
const long double inf = 10000000000.0;
#define fastIO                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
const ll mod = 1e9 + 9;
#define clr(x) memset(x , 0 , sizeof(x));
 
/******************************************** CODE STARTS FROM HERE *************************************************/ 

int main()
{
  fastIO;
  vector < vector < int > > A(3 , vector < int > (3));
  for(int i = 0 ; i < 3 ; i++)
  {
    for(int j = 0 ; j < 3 ; j++)
    {
      cin >> A[i][j];
    }
  }
  int n;
  cin >> n;
  vector < vector < bool > > visited(3 , vector < bool >(3 , false));
  while(n--)
  {
    int a;
    cin >> a;
    for(int i = 0 ; i < 3 ; i++)
    {
      for(int j = 0 ; j < 3 ; j++)
      {
        if(A[i][j] == a) visited[i][j] = true;
      }
    }
  }
  for(int i = 0 ; i < 3 ; i++)
  {
    int cnt = 0;
    for(int j = 0 ; j < 3 ; j++)
    {
      if(visited[i][j] == true) cnt++;
    }
    if(cnt == 3)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  for(int i = 0 ; i < 3 ; i++)
  {
    int cnt = 0;
    for(int j = 0 ; j < 3 ; j++)
    {
      if(visited[j][i] == true) cnt++;
    }
    if(cnt == 3)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(visited[0][0] && visited[1][1] && visited[2][2])
  {
    cout << "Yes" << endl;
    return 0;
  }
  if(visited[0][2] && visited[1][1] && visited[2][0])
  {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

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

using namespace std;
int main(void){
    int n,a;
    cin>>n>>a;
    do{
        n-=500;
    }while(n>=0);
    if(n+500>a)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int check(int a,int b,int c)
{
	if(a+b>=c&&a+c>=b&&b+c>=a)
		return 1;
	return 0;
}
int main(void)
{
	long long n;
	scanf("%lld",&n);
	long long arr[n][n];
	int mark[n][n];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			scanf("%lld",&arr[i][j]);
			mark[i][j]=0;
		}
	}
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			for(int k=j+1;k<n;k++)
			{
				if(!check(arr[i][j],arr[i][k],arr[j][k]))
				{
					printf("-1\n");
					return 0;
				}
				if(arr[i][j]==arr[i][k]+arr[j][k])
					mark[i][j]=1;
				if(arr[i][k]==arr[i][j]+arr[j][k])
					mark[i][k]=1;
				if(arr[j][k]==arr[i][j]+arr[i][k])
					mark[j][k]=1;
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(mark[i][j]==0)
				ans+=arr[i][j];
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1280
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
import math
import string

def intinput():
    return int(input())

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

def splitintinput():
    return map(int,input().split())

N = intinput()
tmp = N
divs = 0

while tmp:
    divs += tmp % 10
    tmp = int(tmp/10)

if N % divs == 0:
    print('Yes')
else:
    print('No')
    


Measured memory_bytes: 3832
from itertools import groupby


def main():

    S = input()
    K = int(input())
    a = [len(tuple(s)) for _, s in groupby(S)]
    ans = 0

    if S[0] == S[-1] and K > 1:
        if len(a) == 1:
            ans = a[0] * K // 2
        else:
            ans = a[0] // 2 + a[-1] // 2 + (a[0] + a[-1]) // 2 * (K - 1)
            ans += sum(n // 2 for n in a[1:-1]) * K

    else:
        ans += sum(n // 2 for n in a) * K

    print(ans)


if __name__ == "__main__":
    main()

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

#define ll long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define vi vector < int >
#define pii pair < int, int >

const int N = 1e6 + 7;
const int INF = 1e9 + 7;

ll dp[200][N];
int w[N], c[N];
int n, cp;

main(){
    scanf("%d%d", &n, &cp);
    for (int i = 1; i <= n; i++){
        scanf("%d%d", &w[i], &c[i]);
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= cp; j++){
            dp[i][j] = dp[i - 1][j];
            if (w[i] <= j)
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + c[i]);
        }
    }
    printf("%lld", dp[n][cp]);
}


Measured memory_bytes: 289024
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let _: usize = read();
    let a: Vec<i32> = read_vec();
    let mut ans= 4000001;
    for i in -100..101 {
        let t = a.iter().fold(0, |s, &x| s + (i - x) * (i - x));
        if t < ans { ans = t; }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int a = in.nextInt();
        int b = in.nextInt();

        BigInteger ai = new BigDecimal(a).toBigInteger();
        BigInteger bi = new BigDecimal(b).toBigInteger();
        out.println(
                ai.multiply(bi).divide(
                        ai.gcd(bi)
                ).toString()
        );
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21332
program answer
  implicit none
  integer(8) :: i, N, d, count
  integer(8), allocatable :: x(:), y(:)
  read(*,*) N, D
  allocate(x(n))
  allocate(y(n))
  do i = 1, n
     read(*,*) x(i), y(i)
  end do

  count=0

  do i = 1, n
     if(x(i)**2+y(i)**2<=D*D) then
        count=count+1
     end if
  end do

  write(*,*) count
  stop
 end program answer
  

Measured memory_bytes: 5988
N,Y=map(int,input().split())
flag=0
ten_key=int(Y/10000)
one_key=int(Y/1000)
if N<ten_key or one_key<N:
    print(-1,-1,-1)

else:
    amari=Y-(ten_key*10000)
    five_key=int(amari/5000)
    if N-ten_key<five_key:
        print(-1,-1,-1)
    
    else:
        for i in range(ten_key+1):
            if flag==1:
                break
            amari=Y-(i*10000)
            five_key=int(amari/5000)
            for j in range(five_key+1):
                one_max=N-i-j
                amari=Y-((i*10000)+(j*5000))
                one_key=int(amari/1000)
                if one_key+i+j==N:
                    print(i,j,one_key)
                    flag=1
                    break
        if flag==0:
            print(-1,-1,-1)


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

void solve() {
    int N;
    string S;
    cin >> N >> S;
    for(int i = 0; i < S.size(); ++i) {
        S[i] += N;
        if(S[i] > 'Z') S[i] -= 'Z' - 'A' + 1;
        cout << S[i];
    }
}

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


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(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; }

typedef pair <ll,ll> P;

bool pairCompareF(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}

bool pairCompareS(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main()
{
    string s;
    cin >> s;
    for (ll i = 0; i < s.length(); ++i) {
        if (i + 1 < s.length()) {
            if (s[i] == s[i+1]) {
                cout << i + 1 << " " << i + 2 << endl;
                return 0;
            }
        }
        if (i + 2 < s.length()) {
            if (s[i] == s[i+2]) {
                cout << i + 1<< " " << i + 3 << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}


Measured memory_bytes: 512
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
 

counter =0
for i in range(0,len(B),1):
  if A[i] >= B[i]:
    counter +=B[i]
    A[i] -= B[i]
    B[i] = 0
    continue
  else:
    counter += A[i]
    B[i] -= A[i]
    A[i] =0
    if A[i+1] >= B[i]:
      counter +=B[i]
      A[i+1] -= B[i]
      B[i] =0
      continue
    else:
      counter += A[i+1]
      B[i] -= A[i+1]
      A[i+1] =0

print(counter)

Measured memory_bytes: 19004