akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#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, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define MAX_N 100

int N;
vector<pii> R, B;

int match[MAX_N * 2];
vector<int> G[MAX_N * 2];
bool used[MAX_N * 2];

bool dfs(int v) {
    used[v] = true;
    for (auto u : G[v]) {
        int m = match[u];
        if (m < 0 || (!used[m] && dfs(m))) { 
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

int main() {
    cin >> N;
    int x, y;
    REP(i, N) {
        cin >> x >> y;
        R.push_back({x, y});
    }
    REP(i, N) {
        cin >> x >> y;
        B.push_back({x, y});
    }
    REP(i, N) {
        REP(j, N) {
            if (R[i].first < B[j].first && R[i].second < B[j].second) {
                G[i].push_back(j + N);
                G[j + N].push_back(i);
            }
        }
    }

    int ans = 0;
    fill(match, match + N * 2, -1);
    REP(i, N) {
        if (match[i] < 0) {
            fill(used, used + N, 0);
            if (dfs(i)) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
target_word = raw_input()
text = ''
while True:
    raw = raw_input()
    if raw == "END_OF_TEXT":
        break
    text += raw.strip('.') + ' '

# ans = 0
print(text.lower().split().count(target_word))
# for word in text.lower().split():
#     if word == target_word:
#         ans += 1
# print(ans)

Measured memory_bytes: 6336
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int n;
int a[MAXN];
long long l[MAXN], r[MAXN];

int main() {

  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  for (int i = 0; i < n; i++) {
    if (i == 0) {
      l[i] = abs(a[i]);
    } else {
      l[i] = l[i - 1] + abs(a[i] - a[i - 1]);
    }
  }

  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1) {
      r[i] = abs(a[i]);
    } else {
      r[i] = r[i + 1] + abs(a[i] - a[i + 1]);
    }
  }

  for (int i = 0; i < n; i++) {
    long long cur = 0;
    if (i == 0) {
      cur = r[i + 1] + abs(a[i + 1]);
    } else if (i == n - 1) {
      cur = l[i - 1] + abs(a[i - 1]);
    } else {
      cur = l[i - 1] + r[i + 1] + abs(a[i + 1] - a[i - 1]);
    }
    printf("%lld\n", cur);
  }

  return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

const int maxN = 300000;

int LtoR[maxN];
int RtoL[maxN];
int result[maxN];

int main()
{
	int N;
	string str;
	cin >> N >> str;

	LtoR[0] = RtoL[N - 1] = 0;
	for (int i = 0; i < N - 1; i++) {
		if (str[i] == 'W') {
			LtoR[i + 1] = LtoR[i] + 1;
		} else {
			LtoR[i + 1] = LtoR[i];
		}
	}

	for (int i = N - 1; i > 0; i--) {
		if (str[i] == 'E') {
			RtoL[i - 1] = RtoL[i] + 1;
		} else {
			RtoL[i - 1] = RtoL[i];
		}
	}

	for (int i = 0; i < N; i++) {
		result[i] = LtoR[i] + RtoL[i];
	}

	cout << *min_element(result,result + N) << endl;

	return 0;
}

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

int main() {
  int s;
  cin>>s;
  if(s/100==0&&s%100==0){
    cout<<"NA"<<endl;
  }
  else if(s/100==0&&s%100>0&&s%100<13){
    cout<<"YYMM"<<endl;
  }
  else if(s/100==0&&s%100>12){
    cout<<"NA"<<endl;
  }
  else if(s/100>0&&s/100<13&&s%100==0){
    cout<<"MMYY"<<endl;
  }
  else if(s/100>0&&s/100<13&&s%100>0&&s%100<13){
    cout<<"AMBIGUOUS"<<endl;
  }
  else if(s/100>0&&s/100<13&&s%100>12){
    cout<<"MMYY"<<endl;
  }
  else if(s/100>12&&s%100==0){
    cout<<"NA"<<endl;
  }
  else if(s/100>12&&s%100>0&&s%100<13){
    cout<<"YYMM"<<endl;
  }
  else if(s/100>12&&s%100>12){
    cout<<"NA"<<endl;
  }
  
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(){
  int n, *S, q;
  int i, j, in, count=0;

  // input data
  scanf("%d",&n);
  S = (int *)malloc(sizeof(int) * n);
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&in);
    for(j=0; j<n; j++){
      if(in == S[j]){
        count ++;
        break;
      }
    }
  }

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

  return 0;
}



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

m=99
for i in A:
  tmpi = i
  c = 0
  while True:
    if tmpi % 2== 0:
      tmpi//=2
      c+=1
    else:
      break
  m = min(c,m)
  if m == 0:
    break
print(m)
  

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

int main(){
	int n,m;
	bool flag=true;
	cin >> n >> m;
	int buf[n];
	for(int i=0; i < n;i++) buf[i] = -1;
	for(int i=0; i < m;i++){
		int s,c;
		cin >> s >> c;
		if(buf[s-1] == -1 || buf[s-1]==c) buf[s-1] = c;
		else flag = false;
	}
	if(flag){
		if(buf[0] == 0 && n !=1) cout << "-1" << endl;
		else{
			for(int i = 0; i < n; i++){
				if(buf[i] == -1){
					if(i == 0 && n > 1) buf[i] = 1;
					else buf[i] =0;
				}
			}
			int buf1 = 0;
			for(int i=0; i < n ; i++){
				buf1 += buf[i] * (int)pow(10.0, n-1-i);
			}
			cout << buf1 << endl;
		}
	}else{
		cout << "-1" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 5e5 + 120;
 
int main(){FAST;    
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a ,a + 3);
    cout << abs(a[0]  - a[1]) + abs(a[1] - a[2]);
        
    
    return 0;
}
 










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

using namespace std;
const int nmax=305;
vector< pair<int,int> > ap[5][5],offsets;
int col[2][2*nmax][2*nmax];
int n,d1,d2,i,j,k;
void dfs(int wh,int li,int ci)
{
    int lf,cf;
    for(int i=0;i<offsets.size();i++)
    {
        lf=li+offsets[i].first;
        cf=ci+offsets[i].second;
        if(lf>=0&&lf<2*n&&cf>=0&&cf<2*n&&(!col[wh][lf][cf]))
       {
          col[wh][lf][cf]=(3-col[wh][li][ci]);
          dfs(wh,lf,cf);
       }
    }
}
void solve(int wh,int d)
{
    offsets.clear();
    for(i=-2*n;i<=2*n;i++)
        for(j=-2*n;j<=2*n;j++)
           if(i*i+j*j==d)
               offsets.push_back({i,j});
    for(int i=0;i<2*n;i++)
        for(int j=0;j<2*n;j++)
         if(!col[wh][i][j])
            {
                col[wh][i][j]=1;
                dfs(wh,i,j);
            }
}
int main()
{
   // freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n>>d1>>d2;
    solve(0,d1);
    solve(1,d2);
    for(i=0;i<2*n;i++)
        for(j=0;j<2*n;j++)
         ap[col[0][i][j]][col[1][i][j]].push_back({i,j});
    for(i=1;i<=2;i++)
        for(j=1;j<=2;j++)
          if(ap[i][j].size()>=n*n)
    {
        for(k=0;k<n*n;k++)
            cout<<ap[i][j][k].first<<' '<<ap[i][j][k].second<<'\n';
        return 0;
    }
    return 0;
}


Measured memory_bytes: 29272
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int pop(void);
void push(int );
int isEmpty(void);
int isFull(void);


int stack[101];
int top=0;

int main(){
  int x;
  int sum=0,sub,sub1,multi=1;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      sum+=pop();
      // printf("%d",sum);
      sum+=pop();
      //   printf("%d",sum);
      push(sum);  
      //printf("%d",sum);
      sum=0;
    } else if ( s[0] == '-' ){
      sub1=pop();
      sub=pop();
      sub-=sub1;

      push(sub);
      sub=0;

    } else if ( s[0] == '*' ){
      multi*=pop();
      multi*=pop();


      push(multi);
      multi=1;

    } else {
      x = atoi(s);
      // printf("%d\n",x);
      push(x);
    }
  }
  printf("%d\n",stack[1]);
  return 0;
}

int pop(){
 
  if(isFull()>101)exit(0);
 
  top--;
  return stack[top+1];
}


void push(int c){
   
  if(0>isEmpty())exit(1);
 
  top++;
  stack[top]=c;
 
}



int isEmpty(){
  return top==0;
}

int isFull(){
  return top >= 200-1;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
 
int main() {
	ll k,x;
	cin>>k>>x;
	ll MIN=x-k+1;
	ll MAX=x+k-1;
	for(ll i=MIN;i<=MAX;i++){
		cout <<i << " ";
	}
}

Measured memory_bytes: 256
using System;
using System.IO;

class MainClass {
    static void Main() {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


        string line;
        line = Console.ReadLine();

        string[] t = line.Split(' ');
        long N = long.Parse(t[0]);
        long D = long.Parse(t[1]);

        long counter = 0;

        for(long i = 0;i<N; i++){

            line = Console.ReadLine();
            string[] tokens = line.Split(' ');
            long x = long.Parse(tokens[0]);
            long y = long.Parse(tokens[1]);

            double dis = Math.Sqrt(x*x + y*y);


            //Console.WriteLine("{0} {1} {2} {3}", x, y, dis, (dis >= D));

            if(dis <= D){
                counter++;
            }
        }

        Console.WriteLine(counter);
        Console.Out.Flush();
    }
}


Measured memory_bytes: 40584
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

#define REP(i, n) for(int i = 0;i < n;i++)

using namespace std;

const int INF = 100000000;

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

  return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000003

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll fac[1000010];
ll fp[1000010];

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

  fac[0]=1;
  rep(i,1000004)fac[i+1]=fac[i]*(i+1)%mod;

  ll Q;
  cin>>Q;
  while(Q--){
    ll x,d,n;
    cin>>x>>d>>n;
    if(d==0){
      cout<<mod_pow(x,n)<<endl;
      continue;
    }
    if(x==0){
      cout<<0<<endl;
      continue;
    }

    ll i=x*mod_pow(d,mod-2)%mod;
    ll j=i+n-1;
    if(j>=mod){
      cout<<0<<endl;
      continue;
    }
    cout<<(mod_pow(fac[i-1],mod-2)*fac[j]%mod)*mod_pow(d,j-i+1)%mod<<endl;

  }

  return 0;
}


Measured memory_bytes: 10368
import sys
import os
import itertools
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

    X,Y=map(int, input().split())

    x=Y/2-X
    y=2*X-Y/2

    if x>=0 and y>=0 and x.is_integer() and y.is_integer():
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9460
#include <iostream>
#include <set>

using namespace std;

int main() {
    int s;
    cin >> s;
    set<int> st;
    int ans=1;
    while(1) {
        if(st.find(s)!=st.end()) {
            break;
        }
        
        st.insert(s);
        
        if(s%2==0) {
            s /= 2;
        } else {
            s *= 3;
            s += 1;
        }
        ans++;
    }

    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 1e5 + 5;

int main(){
	IOS
	string satu="", dua="";
	char a, b;
	cin >> a >> b;
	int c=a-'0';
	int d=b-'0';
	while(c--){
		satu=satu+b;
	} 
	while(d--){
		dua=dua+a;
	}
	cout << min(satu, dua) << '\n'; 
}


Measured memory_bytes: 3624
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 
#define rep(i,a,n) for(int i=a;i<n;i++)
const int MAX = 500001; 

// structure to store queries 
struct Query 
{ 
  int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
  return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
  for (; idx <= n; idx += idx&-idx) 
    bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
  int sum = 0; 
  for (; idx>0; idx-=idx&-idx) 
    sum += bit[idx]; 
  return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
  // initialising bit array 
  int bit[n+1]; 
  memset(bit, 0, sizeof(bit)); 

  // holds the rightmost index of any number 
  // as numbers of a[i] are less than or equal to 10^6 
  int last_visit[MAX]; 
  memset(last_visit, -1, sizeof(last_visit)); 

  // answer for each query 
  int ans[q]; 
  int query_counter = 0; 
  for (int i=0; i<n; i++) 
  { 
    // If last visit is not -1 update -1 at the 
    // idx equal to last_visit[arr[i]] 
    if (last_visit[arr[i]] !=-1) 
      update (last_visit[arr[i]] + 1, -1, bit, n); 

    // Setting last_visit[arr[i]] as i and updating 
    // the bit array accordingly 
    last_visit[arr[i]] = i; 
    update(i + 1, 1, bit, n); 

    // If i is equal to r of any query store answer 
    // for that query in ans[] 
    while (query_counter < q && queries[query_counter].r == i) 
    { 
      ans[queries[query_counter].idx] = 
          query(queries[query_counter].r + 1, bit, n)- 
          query(queries[query_counter].l, bit, n); 
      query_counter++; 
    } 
  } 

  // print answer for each query 
  for (int i=0; i<q; i++) 
    cout << ans[i] << endl; 
} 

// driver code 
int main() 
{ 
    #ifndef ONLINE_JUDGE
         freopen("input.txt" , "r" , stdin);
         freopen("output.txt" , "w" , stdout);
         #endif
  int n,q;
  cin >>n>>q;
  int a[n];
  rep(i,0,n)
  cin >> a[i];
  
  Query queries[q]; 
  rep(i,0,q){
    int x,y;

    cin >> x >>y;
    x--;
    y--;
  queries[i].l = x; 
  queries[i].r = y; 
  queries[i].idx = i; 
  
}
  sort(queries, queries+q, cmp); 
  answeringQueries(a, n, queries, q); 
  return 0; 
} 


Measured memory_bytes: 17464
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

    bool ans = false;
    while(n!=0) {
        ans |= n%10 == 7;
        n /= 10;
    }
    cout << (ans? "Yes" : "No") << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  int n_max = pow(2, n);
  multiset<int> s;
  for (int i = 0; i < n_max; i++) {
    int tmp;
    cin >> tmp;
    s.insert(-tmp);
  }
  
  vector<int> x;
  x.emplace_back(*s.begin());
  s.erase(s.begin());
  
  for (int i = 1; i <= n; i++) {
    sort(x.begin(), x.end());
    int loop_end = x.size();
    for (int j = 0; j < loop_end; j++) {
      auto it = s.upper_bound(x.at(j));
      if (it == s.end()) {
        cout << "No\n";
        return 0;
      }
      x.emplace_back(*it);
      s.erase(it);
    }
  }
  
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 17048
#include<cstdio>
using namespace std;
const int maxn=505;
int n,m;char mp[maxn][maxn];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",mp[i]+1);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++)
		if(mp[i][j]=='#') putchar('#');
		else putchar(j==1||(i&1)&&j<m?'#':'.');
		putchar('\n');
	}
	putchar('\n');
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++)
		if(mp[i][j]=='#') putchar('#');
		else putchar(j==m||!(i&1)&&j>1?'#':'.');
		putchar('\n');
	}
	return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  map<string, int> m;
  int ma = 0;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    m[s]++;
    ma = max(ma, m[s]);
  }
  for (auto &i : m) {
    if (i.sc == ma) cout << i.fi << '\n';
  }
}


Measured memory_bytes: 19224
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    ll ans = 0;
    for(ll i = 1; i <= N; i++) {
        ll cnt = N/i;
        ans += i*cnt*(cnt+1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <algorithm>
#include <cctype>
#include <cstring>
using namespace std;
typedef long long int64;
inline int64 read(int f = 1, int64 x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
int n, a[N];
int64 ans1, ans2;
int main()
{
    n = read();
    for(int i = 1; i <= n; ++i) a[i] = read();
    ans1 = ans2 = 2;
    for(int i = n; i; --i)
    {
        if(ans1%a[i]) ans1 = ans1/a[i]*a[i]+a[i];
        ans2 = ans2/a[i]*a[i]+a[i]-1; 
    }
    if(ans1 < ans2) printf("%lld %lld\n", ans1, ans2);
    else puts("-1");
    return 0;
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private static int[] dp = null;

    //https://atcoder.jp/contests/dp/tasks/dp_b
    public static void main( String[] args ) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        dp = new int[n + 1];
        Arrays.fill(dp, -1);

        int val = solveTopDown(n - 1, arr, k);
        System.out.println(val);
    }

    private static int solveTopDown( int i, int[] arr, int k ) {
        if (dp[i] != -1) {
            return dp[i];
        }

        if (i == 0) { //if one element left
            dp[i] = 0;
            return dp[i];
        }

        int min = Integer.MAX_VALUE;

        //for each stone frog want to Jump K steps..
        for (int p = k; p >= 1; p--) {

            //if frog can jump at-least one stone..using zero bcz we are using zero based indexing
            if (i - p >= 0) {
                min = Math.min(min, solveTopDown(i - p, arr, k) + Math.abs(arr[i] - arr[i - p]));
            }
        }

        return dp[i] = min;
    }
}

Measured memory_bytes: 61328
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    vector<int> up(N+1), down(N+1);
    for (int i = 1; i <= N; i++) {
        int A; cin >> A;
        up[i] = up[i-1] + A;
    }
    for (int i = 1; i <= N; i++) {
        int A; cin >> A;
        down[i] = down[i-1] + A;
    } 
    
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int tmp = 0;
        tmp += up[i] + (down[N] - down[i-1]);
        ans = max(ans, tmp);
    }

    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    solve();

    return 0;
}

Measured memory_bytes: 3632
fun main(args: Array<String>) {
    var (d, n) = readLine()!!.split(" ").map(String::toInt)
    if (n == 100) n++
    if (d == 0) {
        println(n)
    } else if (d == 1) {
        println(n * 100)
    } else {
        println(n * 10000)
    }
}



Measured memory_bytes: 37824
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define ctoi(x) (x - '0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int t;

int main() {
	FOR(i, 5) {
		cin >> t;
		if (t == 0) cout << i + 1;
	}
}

Measured memory_bytes: 3524
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#define gc getchar()
#define N 103
#define sint short
#define upd(x,y) (x=max(x,(short)(y)))
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
sint s[N][N],dp[N][N][N][N];char str[N][N];
inline sint S(int a,int b,int c,int d)
{
	if(a>c) swap(a,c);if(b>d) swap(b,d);
	return (short)(s[c][d]+s[a-1][b-1]-s[a-1][d]-s[c][b-1]);
}
int main()
{
	int n=inn(),m=inn(),x=0,y=0;sint ans=0;
	for(int i=1;i<=n;i++) scanf("%s",str[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(str[i][j]=='E') x=i,y=j;
			else s[i][j]=(str[i][j]=='o');
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
		s[i][j]=(short)(s[i][j]+s[i-1][j]+s[i][j-1]-s[i-1][j-1]);
	for(int a=x;a;a--) for(int b=y;b;b--)
		for(int c=x;c<=n;c++) for(int d=y;d<=m;d++)
		{
			ans=max(ans,dp[a][b][c][d]);int L=d-y+1,R=m-y+b,U=c-x+1,D=n-x+a;
			if(a>U) upd(dp[a-1][b][c][d],dp[a][b][c][d]+S(a-1,max(b,L),a-1,min(d,R)));
			if(b>L) upd(dp[a][b-1][c][d],dp[a][b][c][d]+S(max(a,U),b-1,min(c,D),b-1));
			if(c<D) upd(dp[a][b][c+1][d],dp[a][b][c][d]+S(c+1,max(b,L),c+1,min(d,R)));
			if(d<R) upd(dp[a][b][c][d+1],dp[a][b][c][d]+S(max(a,U),d+1,min(c,D),d+1));
		}
	return !printf("%d\n",(int)ans);
}

Measured memory_bytes: 215296
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  string s;
  unordered_map<string,int>m;
  cin>>n;
  for(int i=0;i<n;i++){
  cin>>s;
    int c=0;
    m[s]=c++;
    
  }
cout<<m.size();
  
}

Measured memory_bytes: 17724
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>

using ll = long long;

int main()
{
    int N;
    std::cin >> N;
    if (N == 1)
    {
        std::cout << "Hello World" << std::endl;
    }
    else
    {
        int A, B;
        std::cin >> A >> B;
        std::cout << A + B << std::endl;
    }
}

Measured memory_bytes: 256
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str, T: str):
    if S == T[:len(S)]:
        print(YES)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

struct point {
	double x;
	double y;
};

// n:古文書の行数
point get_treasure_point(int n) {
	point p = { 1.0, 0.0 };

	for (int i = 0; i < n - 1; i++) {
		double rad = atan2(p.y, p.x) + M_PI / 2.0;
		p.x += cos(rad);
		p.y += sin(rad);
	}
	return p;
}

int main(void) {
	int n;

	while (cin >> n) {
		if (n == -1) {
			break;
		}
		point trasure_point = get_treasure_point(n);

		printf("%f\n%f\n", trasure_point.x, trasure_point.y);
	}
}

Measured memory_bytes: 1272
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
typedef long long ll;
using namespace std;

int main(void) {
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    ans += (r - l + 1);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int N, K;
int A[100000];
int main() {
  cin >> N >> K;
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  
  int lng = -1;
  for(int i = 1; i < N; ++i) {
    if(A[i - 1] + A[i] >= K) lng = i - 1;
  }
  if(lng == -1) {
    cout << "Impossible" << endl;
  } else {
    cout << "Possible" << endl;
    
    for(int i = 0; i < lng; ++i) {
      cout << i + 1 << endl;
    }
    for(int i = N - 2; i > lng; --i) {
      cout << i + 1 << endl;
    }
    cout << lng + 1 << endl;
  }
    
  
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

vector<int> SCC(vector<vector<int>> &g) {
    int n=SZ(g);
    vector<vector<int>> rg(n);
    REP(i,n) FORE(x,g[i]) rg[x].push_back(i);
    priority_queue<pii> pq;
    vector<bool> vis(n,false);
    int cnt=0;
    function<void(int,int)> dfs1=[&](int v,int p) {
        vis[v]=1;
        FORE(x,g[v]) if(x!=p && !vis[x]) dfs1(x,v);
        pq.push({cnt++,v});
    };
    REP(i,n) {
        if(!vis[i]) dfs1(i,-1);
    }

    cnt=0;
    vector<int> ret(n,-1);
    function<void(int,int)> dfs2=[&](int v,int p) {
        ret[v]=cnt;
        FORE(x,rg[v]) if(x!=p && ret[x]==-1) dfs2(x,v);
    };
    while(!pq.empty()) {
        int v=pq.top().second;
        pq.pop();
        if(ret[v]!=-1) continue;
        dfs2(v,-1);
        cnt++;
    }
    return ret;
}
signed main() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>> g(n);
    REP(i,m) {
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
    }
    vector<int> scc=SCC(g);
    int Q;
    cin>>Q;
    while(Q--) {
        int a,b;
        cin>>a>>b;
        cout<<(scc[a]==scc[b])<<endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    string s;
    cin >> s;

    int one = count(s.begin(), s.end(), '1');
    vector<int> modP(N), modM(N);
    int powP = 1, powM = 1;
    int modPP = 0, modMM = 0;
    for (int i=N-1; i>=0; --i) {
        modP[i] = powP;
        modM[i] = powM;
        if (s[i] == '1') {
            (modPP += modP[i]) %= (one + 1);
            if (one > 1) (modMM += modM[i]) %= (one - 1);
        }
        (powP *= 2) %= (one + 1);
        if (one > 1) (powM *= 2) %= (one - 1);
    }

    for (int i=0; i<N; ++i) {
        if (s[i] == '0') {
            int mod = one + 1;
            int res = 1;
            int cur = (modPP + modP[i] + mod) % mod;
            while (cur > 0) {
                cur %= __builtin_popcount(cur);
                ++res;
            }
            cout << res << '\n';
        } else {
            if (one == 1) {
                cout << 0 << '\n';
                continue;
            }
            int mod = one - 1;
            int res = 1;
            int cur = (modMM - modM[i] + mod) % mod;
            while (cur > 0) {
                cur %= __builtin_popcount(cur);
                ++res;
            }
            cout << res << '\n';
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){

    i64 n;
    cin >> n;

    unordered_map<int,i64> m;
    m[0] = 0;
    m[1] = 1;

    function<i64(i64)> g = [&](i64 x){
        if(m.find(x) != m.end())
            return m[x];

        if(x & 1){
            return m[x] = (2 * g(x >> 1) + g((x >> 1) + 1)) % MOD;
        }else{
            return m[x] = (2 * g(x >> 1) + g((x >> 1) - 1)) % MOD;
        }
    };

    cout << g(n + 1) << endl;
    return 0;

}


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

int main(){
	int x,y;
	cin >> x >> y;
	while(!(x==0&&y==0)){
		if(x<y) cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
		cin >> x >> y;
	}
	return 0;
}



Measured memory_bytes: 3040
let read_int_array n = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x))

let n = read_int()

let a = read_int_array (n - 1)

let b = Array.make n 0

let () =
  Array.iter (fun i -> b.(i - 1) <- b.(i - 1) + 1) a;
  Array.iter (fun i -> Printf.printf "%d\n" i) b


Measured memory_bytes: 9224
import java.util.*;
 
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();

        long ans = 0;
        for(long i=1; i<=N; i++){
            if(i%3!=0 && i%5!=0){
                ans += i;
        }
}
         System.out.println(ans);

}
}


Measured memory_bytes: 35776
void main()
{
    long n = rdElem;
    Point[] p = n.rdCol!Point;

    double total = 0.0;
    foreach (i; 0 .. n)
    {
        foreach (j; 0 .. n)
        {
            if (i == j) continue;
            total += p[i].dist(p[j]);
        }
    }

    writefln("%.15f", total / n);
}

alias Point = Vector2D!double;

struct Vector2D(T)
{
    T x, y;

    this(T x, T y)
    {
        this.x = x, this.y = y;
    }

    Vector2D!T opBinary(string op, T)(Vector2D!T that)
    if ((op == "+") & isNumeric!T)
    {
        return Vector2D!T(this.x + that.x, this.y + that.y);
    }

    Vector2D!T opBinary(string op, T)(Vector2D!T that)
    if ((op == "-") & isNumeric!T)
    {
        return Vector2D!T(this.x - that.x, this.y - that.y);
    }

    Vector2D!T opBinary(string op, T)(T that)
    if ((op == "*") & isNumeric!T)
    {
        return Vector2D!T(this.x * that, this.y * that);
    }

    Vector2D!T opBinaryRight(string op, T)(T that)
    if ((op == "*") & isNumeric!T)
    {
        return opBinary!(op)(that);
    }

    Vector2D!T opBinary(string op, T)(T that)
    if ((op == "/") & isNumeric!T)
    {
        return Vector2D!T(this.x / that, this.y / that);
    }

    T dot(Vector2D!T that)
    {
        return this.x * that.x + this.y * that.y;
    }

    T cross(Vector2D!T that)
    {
        return this.x * that.y - this.y * that.x;
    }

    T quadrance()
    {
        return dot(this);
    }

    double norm()
    {
        return dot(this).to!double.sqrt;
    }

    double dist(Vector2D!T that)
    {
        return sqrt((this.x - that.x)^^2 + (this.y - that.y)^^2);
    }
}

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

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

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

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

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

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

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

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

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

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

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

using namespace std;

int main(){
    int n;
    cin >> n;
    set<string> s;

    string prev_word = "";
    bool success = true;

    for (int i = 0; i < n; i++) {
        string word;
        cin >> word;
        if (i == 0) {
            prev_word += word[0];
        }
        if (s.find(word) != s.end() || prev_word.back() != word[0]) {
            success = false;
        }
        prev_word = word;
        s.insert(word);
    }
    if (success) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
def main():
    N = int(input())
    X = list(map(int, input().split()))
    X.sort()
    ans = float('inf')
    for i in range(1, max(X)+1):
        d = 0
        for j in range(N):
            d += pow((i - X[j]), 2)
        ans = min(ans, d)
    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

#define int ll
signed main()
{
    int N; cin >> N;
    vector<int> A(N); cin >> A;

    int ans = 0;

    map<ll,int> sum, diff;
    for (int i = 0; i < N; i++) {
        sum[i + A[i]]++;
        diff[i - A[i]]++;
    }

    for (auto it = sum.begin(); it != sum.end(); it++) {
        ll s = it->first;
        int cnt_s = it->second;
        int cnt_d = diff[s];
        ans += cnt_s * cnt_d;
    }

    cout << ans << endl;
}


Measured memory_bytes: 38984
n, m = map(int, input().split())
h = []
a = []
b = []
dic_target = {}
dic_exclude = {}

counter = 0

h = list(map(int, input().split()))

for i in range(m):
  _a, _b = map(int, input().split())
  #print(_a, _b)
  h_a = h[_a - 1]
  h_b = h[_b - 1]
  if _a in dic_target:
    dic_target[_a] = max(dic_target[_a], h_a, h_b)
  else:
    dic_target[_a] = max(h_a, h_b)
  if _b in dic_target:
    dic_target[_b] = max(dic_target[_b], h_a, h_b)
  else:
    dic_target[_b] = max(h_a, h_b)
  if h_a == h_b:
    if _a in dic_exclude:
      dic_exclude[_a] = max(dic_exclude[_a], h_a, h_b)
    else:
      dic_exclude[_a] = max(h_a, h_b)
    if _b in dic_exclude:
      dic_exclude[_b] = max(dic_exclude[_b], h_a, h_b)
    else:
      dic_exclude[_b] = max(h_a, h_b)

for i in range(n):
  if i + 1 not in dic_target:
    counter += 1
  elif i + 1 in dic_target and h[i] == dic_target.get(i + 1):
    if i + 1 not in dic_exclude or h[i] != dic_exclude.get(i + 1):
      counter += 1
print(counter)



Measured memory_bytes: 20112
import sys
sys.setrecursionlimit(10000)

x,y = map(int,input().split())


if y == x:
    print(1)
    exit()

asn = 0
def dfs(x,y,n):
    
    n += 1
    ans = x*2**n
    if ans > y:
        return n
    else:
        return dfs(x,y,n)

a = dfs(x,y,1)

print(a)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

using ll = long long int;

int arr[60];

int main() {

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;

		arr[a]++;
		arr[b]++;
	}

	for (int i = 1; i <= n; i++) {
		cout << arr[i] << endl;
	}

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

int main() {
    int K,A,B;
    
    cin >> K >> A >> B;

    for(int i = A; i <= B; i++){
        if(i % K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>
int main(void){
	int i,k,r,c,sum;
	scanf("%d %d",&r,&c);
	int hyo[r][c];
	for(i=0;i<r;i++){
		for(k=0;k<c;k++){
			scanf("%d",&hyo[i][k]);
		}
	}
	int gyo[r],retu[c];
	for(i=0;i<r;i++){
		sum=0;
		for(k=0;k<c;k++){
			sum+=hyo[i][k];
		}
		gyo[i]=sum;
	}
	for(i=0;i<c;i++){
		sum=0;
		for(k=0;k<r;k++){
			sum+=hyo[k][i];
		}
		retu[i]=sum;
	}
	for(i=0;i<r;i++){
		for(k=0;k<c;k++){
			printf("%d ",hyo[i][k]);
		}
		printf("%d\n",gyo[i]);
	}
	for(i=0;i<c;i++){
		printf("%d ",retu[i]);
	}
	sum=0;
	for(i=0;i<r;i++){
		for(k=0;k<c;k++){
			sum+=hyo[i][k];
		}
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(LL i=(l);i<(r);i+=(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009 
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,int m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
typedef struct fac { LL n, exp; }F;
LL fact(LL n,F*a){LL x,i,j,c=0;x=n;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
//snippet
//overflow...char 1e6



#define N 100009

typedef struct lr {
	int l, r;
}LR;
int upr(const LR* a, const LR* b) { return a->r < b->r ? -1 : a->r > b->r ? 1 : 0; }

int main() {
	int n, x, l;
	LR f[N];
	scanf("%d", &n);
	rep(i, n) {
		scanf("%d%d", &x, &l);
		f[i].l = x - l;
		f[i].r = x + l;
	}
	qsort(f, n, sizeof(LR), upr);

	int ans = 0, M = -2*MOD;
	rep(i, n) {
		if (M <= f[i].l) {
			ans++;
			M = f[i].r;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)
        cout<<(n-2)*(b-a)+1<<endl;else
        cout<<0<<endl; 
 } 

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

using namespace std;

vector<int> adj[100100];
int n, m;
int dp[100100];

int cal(int u) {
    if (!dp[u]) {
        for (int v : adj[u]) {
            dp[u] = max(dp[u], cal(v));
        }
        dp[u]++;
    }
    return dp[u];
}

int main() {
    cin >> n >> m;
    while (m--) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) ans = max(ans, cal(i));
    cout << ans - 1 << '\n';
}

Measured memory_bytes: 7424
n, x = (int(i) for i in input().split())
a = [int(i) for i in input().split()]

ret = 0
sm = sum(a)

if sm < x:
    ret = len(a) - 1
elif sm == x:
    ret = len(a)
else:
    a.sort()
    c = 0
    for i in a:
        c += i
        if c <= x:
            ret += 1

print(ret)

Measured memory_bytes: 3064
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var output = N;
            for (var A = 1; A < N; A++)
            {
                var B = N - A;
                var total = SumOfDigits(A) + SumOfDigits(B);
                output = Math.Min(total, output);
            }

            Console.WriteLine(output);
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 13140
import java.io.*;
import java.util.*;
import java.lang.Math.*;
public class Main {
    private static MyScanner scanner;

    public static void main (String[] args){
        Main instance = new Main();
        scanner = instance.new MyScanner();
        instance.solve();
    }

    private void solve() {
        try {
            Long counter = 0l;
            Long N = scanner.nextLong();
            Long M = scanner.nextLong();
            Long amari;
            if (M > 2*N) {
                counter += N;
                M -= 2*N;
            } else {
                counter += M / 2;
                M -= (M / 2) * 2;
            }
            if (M > 3) {
                counter += M / 4;
            }
            System.out.println(counter);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String line = br.readLine();
            while (line.equals("")) {
                line = br.readLine();
            }
            s = line.split(reg, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 23124
# D

N = int(input())

d = [0] * (10**6 + 1) 
A = list(map(int, input().split()))

for a in A:
  d[a] += 1

ans = 0
maxa = max(A) + 1
for i in range(1,maxa):
  if d[i] == 1:
    ans += 1

  if d[i] > 0:
    # d[i]の倍数は含めない
    for j in range(i*2,maxa,i):
      d[j] = 0

print(ans)



Measured memory_bytes: 40220
n = int(input())
A = [*map(int, input().split())]
mx = max(A)
c = [0]*(mx+1)
for a in A:
    for i in range(a, mx+1, a): c[i] += 1
ans = 0
for a in A:
    if c[a] == 1: ans += 1
print(ans)


Measured memory_bytes: 32248
import heapq
n,m=map(int,input().split())
A=list(map(int,input().split()))

q=[]
for a in A:
  heapq.heappush(q,-a)
  
for _ in range(m):
  p=-heapq.heappop(q)//2
  heapq.heappush(q,-p)
print(-sum(q))


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

struct edge{
    int to,cost;
    edge(){
        to = 0; cost = 0;
    }
    edge(int t,int c){
        to = t;
        cost = c;
    }
};

int n;
vector<pair<int,int> > G[100001];
bool visited[100001];
long long int d[100001];

const long long int INF = 1000000000000;

long long int  prim(){

    priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > que;

    long long int res = 0;

    fill(d,d+n,INF);
    fill(visited,visited+n,false);

    que.push(make_pair(0,0));

    while(!que.empty()){
        pair<int,int> p = que.top(); que.pop();

        int v = p.second, cst = p.first;
        if(visited[v]){
            continue;
        }
        visited[v] = true;
        res += cst;
        for(int i=0; i<G[v].size(); i++){
            //edge e = G[v][i];
            //que.push(make_pair(e.to, e.cost));
            que.push(make_pair(G[v][i].first, G[v][i].second));
        }

    }

    return res;

}

int main() {

    cin >> n;

    int ed;

    cin >> ed;

    int a, b, c;

    for (int i = 0; i < ed; i++) {
        scanf(" %d %d %d", &a, &b, &c);
        //G[a].push_back(edge(b, c));
        G[a].push_back(make_pair(c, b));
        G[b].push_back(make_pair(c, a));
    }

    cout << prim() << endl;

    return 0;
}

Measured memory_bytes: 10096