akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc168_b solver = new abc168_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc168_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int K = in.nextInt();
            String S = in.next();
            String dash = "";
            if (S.length() > K) {
                dash = "...";
                out.print(S.substring(0, K));
            } else {
                out.print(S);
            }
            out.println(dash);
        }

    }
}



Measured memory_bytes: 35820
#include <iostream>

using namespace std;

int main()
{
    int inputMonth, inputDay;
    cin >> inputMonth >> inputDay;

    int testMonth = 1, testDay = 1, takahashiDays = 1;
    while(true) {
        testDay ++;
        testMonth++;
        takahashiDays++;
        if (testMonth > inputMonth) {
            takahashiDays--;
            break;
        }

        if (testMonth == inputMonth) {
            if (testDay > inputDay) {
                takahashiDays--;
                break;
            }
        }
    }

    cout << takahashiDays;
    return 0;
}


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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    int N, A;
    cin >> N;
    vector<int> B(N);
    rep(i, N) {
        cin >> A;
        A--;
        B[A] = i + 1;
    }
    rep(i, N) {
        cout << B[i];
        if (i < N - 1) cout << " ";
        else cout << endl;
    }
}

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

int main() {
    while (1) {
        int A, B;
        string op;
        cin >> A >> op >> B;
        if (op == "?") break;

        if (op == "+") cout << A + B << endl;
        else if (op == "-") cout << A - B << endl;
        else if (op == "*") cout << A * B << endl;
        else if (op == "/") cout << A / B << endl;
    }
}


Measured memory_bytes: 3140
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
import numpy as np
from collections import Counter

N, X, Y = map(int, input().split())
F = [[0 for i in range(N)] for j in range(N)]

for i in range(N - 1):
    F[i][i + 1] = 1
    F[i + 1][i] = 1
F[X - 1][Y - 1] = 1
F[Y - 1][X - 1] = 1

G = csgraph_from_dense(F, null_value=0)
d = dijkstra(G)

# print(F)
# print(d)

# print(np.count_nonzero(d == 1))
s = Counter(d.flatten().astype(np.int64))
# print(s)
for i in range(1, N):
    if i in s:
        print(s[i] // 2)
    else:
        print(0)

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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 2e5 + 123;                                          
const int M = mod;
const int pri = 997;
const int Magic = 2101;

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

int n, a[N], k;
int gcd;

int main () {
    cin >> n >> k;
    For (i, 1, n) cin >> a[i], gcd = __gcd(gcd, a[i]);
    For (i, 1, n) {
        if (a[i] >= k && (a[i] - k) % gcd == 0) {
            puts("POSSIBLE");
            exit(0);
        }
    }
    puts("IMPOSSIBLE");
    return Accepted;
}

// Coded By OB

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

using namespace std;

int main()
{
    int H, W;
    string a, b;
    cin >> H >> W;
	
   for(int i = 0; i < W + 2; i++){
  	cout << "#";
  }
  	cout << "" << endl;
  
    for (int i = 0; i < H; i++)
    {
        cin >> a;
        cout << "#" << a << "#" << endl;
    }
  
  for(int i = 0; i < W + 2; i++){
  	cout << "#";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int max = 0;
  int now = 0;
  rep(i, n){
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      now++;
    }
    else {
      now = 0;
    }
    if (now > max)
      max = now;
  }
  cout << max << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define ld long double
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define pll pair<ll,ll>
    #define ff first
    #define ss second
    #define pb push_back
    #define deb(x) cout<<#x<<" : "<<x<<endl;
    #define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
    #define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
    #define deb4(w,x,y,z) cout<<#w<<" : "<<w<<"\t"<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define printv(a)  for(ll i=0;i<a.size();i++)  cout<<a[i]<<" ";
   
   
    const int mod=998244353.;
    const int N=1e6+5; 
   
    bool sortbysec(const pair<pair<ll,ll>,ll> &a, 
                      const pair<pair<ll,ll>,ll> &b) 
        { 
            return (a.second > b.second); 
        } 
        ll powermod(ll x, ll y, ll p)
        {
            ll res = 1;
            x = x % p;
            while (y > 0)
            {
                if (y & 1) res = (res*x) % p;
                y = y>>1;
                x = (x*x) % p;
            }
            return res;
        }
       
        bool isprime(int n) 
        { 
            if (n <= 1)  return false; 
            if (n <= 3)  return true; 
            if (n%2 == 0 || n%3 == 0) return false; 
            for (int i=5; i*i<=n; i=i+6) 
                if (n%i == 0 || n%(i+2) == 0) 
                   return false; 
           return true; 
        }
        ll n;
        void dfs(string s,char mx)
        {
            if(s.size()==n)
            cout<<s<<"\n";
            else
            {
                for(char c='a';c<=mx;c++)
                {
                    dfs(s+c,((c==mx)?char(mx+1):mx));
                }
            }
        }
        
    int main()
    {
        FAST;
       
       cin>>n;
       dfs("",'a');
 return 0;
    }

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = (1LL << 59);
const int iINF = (1 << 31)-1;
const double dINF = 1000000000000000000.0;
const int MAX_N = 1 << 17;

int main(){
	int n, a; cin >> n >> a;
	n %= 500;
	if (n <= a)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
#define PB push_back
#define mkp make_pair
#define F first
#define S second

typedef vector<int> vint;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<int,int> pii;

void do_normal(int l,int r);
void do_while(int l,int r);
void do_if(int l,int r);
void do_action(char t);

int h,w;
vector<string> v;
string s;

pii pos;
pii goal;
int d=0;
bool used[55][55][4][1010];
int ans = -1;
int cnt = 0;
bool ok = true;

int dd[]={-1,0,1,0,-1};

bool do_check(char t){
	if(t=='T') return true;
	if(t=='C'){
		if(v[pos.F+dd[d]][pos.S+dd[d+1]]=='#') return true;
		return false;
	}
	if(t=='N') return d==0;
	if(t=='E') return d==1;
	if(t=='S') return d==2;
	if(t=='W') return d==3;
}

bool is_used(int x){
	if(used[pos.F][pos.S][d][x]){
		ok=false;
		return false;
	}
	used[pos.F][pos.S][d][x]=true;
	return true;
}

void do_action(char t){
	cnt++;
	if(t=='^'){
		if(do_check('C')) return;
		else{
			pos.F+=dd[d];
			pos.S+=dd[d+1];
		}
	}
	else if(t=='>'){
		(d+=1)%=4;
	}
	else if(t=='v'){
		(d+=2)%=4;
		if(!do_check('C')){
			pos.F+=dd[d];
			pos.S+=dd[d+1];
		}
		(d+=2)%=4;
	}
	else if(t=='<'){
		(d+=3)%=4;
	}
	else{
		cout<<t<<endl;
		assert(0);
	}
	// cout<<"action "<<pos.F<<" "<<pos.S<<" "<<d<<endl;
}

void do_while(int l,int r){
	// cout<<"while "<<s.substr(l,r-l+1)<<" "<<do_check(s[l+1])<<endl;
	if(pos==goal) return;
	if(!ok) return;
	if(!is_used(l)) return;
	if(s[l]=='~'&&do_check(s[l+1])) return;
	else if(s[l]!='~'&&!do_check(s[l])) return;
	int ll = l+1;
	// cout<<"while hoge"<<endl;
	if(s[l]=='~') ll++;
	do_normal(ll,r);
	if(!ok) return;
	if(pos==goal) return;
	do_while(l,r);
}

void do_if(int l,int r){
	// cout<<"if "<<s.substr(l,r-l+1)<<endl;
	if(pos==goal) return;
	if(!ok) return;
	if(!is_used(l)) return;
	if(s[l]=='~'&&do_check(s[l+1])) return;
	else if(s[l]!='~'&&!do_check(s[l])) return;
	int ll = l+1;
	if(s[l]=='~') ll++;
	do_normal(ll,r);
	if(!ok) return;
	if(pos==goal) return;
}

void do_normal(int l,int r){
	// cout<<"normal "<<s.substr(l,r-l+1)<<endl;
	reep(i,l,r+1){
		// cout<<i<<" "<<s[i]<<endl;
		if(pos==goal) return;
		if(!ok) return;
		if(!is_used(i)){
			// cout<<i<<endl;
			return;
		}
		// while
		if(s[i]=='{'){
			int aa = 0;
			int bb = 0;
			int p = i;
			while(1){
				if(s[p]=='{') aa++;
				if(s[p]=='}') bb++;
				if(aa==bb) break;
				p++;
			}
			do_while(i+1,p-1);
			i=p;
		}
		// if
		else if(s[i]=='['){
			int aa = 0;
			int bb = 0;
			int p = i;
			while(1){
				if(s[p]=='[') aa++;
				if(s[p]==']') bb++;
				if(aa==bb) break;
				p++;
			}
			do_if(i+1,p-1);
			i=p;
		}
		else{
			do_action(s[i]);
		}
	}
}


int main(){
	cin>>h>>w;
	v.assign(h,"");
	rep(i,h) cin>>v[i];
	cin>>s;
	rep(i,h){
		rep(j,w){
			if(v[i][j]=='s') pos=pii(i,j);
			if(v[i][j]=='g') goal=pii(i,j);
		}
	}
	do_normal(0,s.size()-1);
	if(ok&&pos==goal) cout<<cnt<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 12468
import copy as cp
N = int(input())
H = list(map(int, input().split()))
H2 = cp.copy(H)
H.insert(0, 0)

count = 0
mx = 0
i = 0
for h1, h2 in zip(H, H2):
    if h1 >= h2:
        count += 1
    else:
        if (mx < count):
            mx = count
        count = 0
if (mx < count):
    mx = count
print(mx)

Measured memory_bytes: 14764
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
using Graph = vector<vector<ll> >;
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; }
const ll INF = 1e18;

int main(){
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    bool two = false;
    if(k>=(1e18/d))two=true;
    if(x-k*d<0)two=true;
    if(!two){
        cout << x-k*d << endl;
    }
    else{
        ll cnt = x/d;
        ll nokori = k-cnt;
        if(nokori%2==0){
            ll p = x%d;
            cout << abs(p) << endl;
        }
        else{
            ll m = x%d-d;
            cout << abs(m) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N, M;
vector<int> a, f;

int main() {
  cin >> N >> M;
  a.resize(M), f.resize(M, 0);

  rep(i, M) {
    int b;
    cin >> a[i] >> b;
    rep(j, b) {
      int c;
      cin >> c;
      f[i] |= (1 << (c - 1));
    }
  }

  int K = (1 << N);
  const int INF = 1e9;
  vector<vector<int>> dp(M + 1, vector<int>(K, INF));
  dp[0][0] = 0;
  rep(i, M) rep(k, K) {
    dp[i + 1][k] = min(dp[i + 1][k], dp[i][k]);
    dp[i + 1][k | f[i]] = min(dp[i + 1][k | f[i]], dp[i][k] + a[i]);
  }

  cout << (dp[M][K - 1] == INF ? -1 : dp[M][K - 1]) << endl;
  return 0;
}


Measured memory_bytes: 16384
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=1e3+3;
int vis[N][N];
string s[N];
int dx[]= {0,0,-1,1};
int dy[]= {1,-1,0,0};
int main()
{
    ft
    int t,i,j,n,m,l,r,s1,s2,d1,d2;
    cin>>n>>m>>s1>>s2>>d1>>d2;
    for(i=0; i<n; i++)
    {
        cin>>s[i];
        for(j=0; j<m; j++)
        {
            vis[i][j]=INT_MAX;
        }
    }
    priority_queue<pair<int,pi>>q;
    q.push({0,{s1-1,s2-1}});
    vis[s1-1][s2-1]=0;
    while(!q.empty())
    {
        int val=-q.top().F;
        pi f=q.top().S;
        q.pop();
        for(i=0; i<4; i++)
        {
            int x=f.F+dx[i];
            int y=f.S+dy[i];
            if(x>=0 && x<n && y>=0 && y<m && vis[x][y]>val && s[x][y]=='.')
            {
                vis[x][y]=val;
                q.push({-vis[x][y],{x,y}});
            }
        }
        for(i=f.F-2; i<=f.F+2; i++)
        {
            for(j=f.S-2; j<=f.S+2; j++)
            {
                if(i>=0 && i<n && j>=0 && j<m && vis[i][j]>val+1 && s[i][j]=='.')
                {
                    vis[i][j]=val+1;
                    q.push({-vis[i][j],{i,j}});
                }
            }
        }
    }
    if(vis[d1-1][d2-1]==INT_MAX)
    {
        vis[d1-1][d2-1]=-1;
    }
    cout<<vis[d1-1][d2-1]<<"\n";
    return 0;
}



Measured memory_bytes: 8696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    string s; cin >> s;
    bool ok = false;
    rep(i, 2) {
        if(s[i]==s[i+1] && s[i+1]==s[i+2]) ok = true;
    }
    if(ok) Yes();
    else No();
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
x = na()

z = sum(x)
Z = z/n

p = round(Z)

ans = 0
for i in x:
  ans += (i-p)**2
  
print(ans)

Measured memory_bytes: 9196
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int N = sc.nextInt();
		int [] x = new int[N];
		int [] y = new int[N];
		int [] a = new int[N];
		for(int i = 0 ; i < N ; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			a[i] = sc.nextInt();
		}
		int xmin = 0, xmax = W, ymin = 0, ymax = H;
		for(int i = 0 ; i < N ; i++) {
			if(a[i] == 1) {
				xmin = Math.max(xmin, x[i]);
			} else if(a[i] == 2) {
				xmax = Math.min(xmax, x[i]);
			} else if(a[i] == 3) {
				ymin = Math.max(ymin, y[i]);
			} else if(a[i] == 4) {
				ymax = Math.min(ymax, y[i]);
			}
		}
		if(xmax - xmin < 0 || ymax - ymin < 0) {
			System.out.println(0);
		} else {
			System.out.println((xmax - xmin) * (ymax - ymin));
		}
	}
}


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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector < int > pos, neg;
    for(int i = 0 ; i < n ; ++i){
        int x;
        cin >> x;
        if(x >= 0) pos.push_back(x);
        else neg.push_back(x);
    }
    vector < pair < int, int > > ops;
    sort(pos.begin(), pos.end());
    sort(neg.rbegin(), neg.rend());
    if((int)pos.size() == 0){
        ops.push_back({neg[0], neg[1]});
        pos.push_back(neg[0] - neg[1]);
        neg.erase(neg.begin(), neg.begin() + 2);
    }
    if((int)neg.size() == 0 && (int)pos.size() != 1){
        ops.push_back({pos[0], pos[1]});
        neg.push_back(pos[0] - pos[1]);
        pos.erase(pos.begin(), pos.begin() + 2);
    }
    int i = 0, j = 0;
    if((int)neg.size() > 0){
        long long sm = neg[0];
        for(int i = 0 ; i < (int)pos.size() - 1 ; ++i){
            ops.push_back({sm, pos[i]});
            sm -= pos[i];
        }
        if((int)pos.size() > 0){
            ops.push_back({pos.back(), sm});
            sm = pos.back() - sm;
        }
        
        for(int i = 1 ; i < (int)neg.size() ; ++i){
            ops.push_back({sm, neg[i]});
            sm -= neg[i];
        }
    }
    cout << ops.back().first - ops.back().second << '\n';
    for(auto op : ops)
        cout << op.first << ' ' << op.second << '\n';
    return 0;

}

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

void solve(){
    int n,k;
    cin>>n>>k;

    if(n == 1){
        cout<<0<<endl;
        return;
    }
    
    vector<int> a(n);
    
    vector<int> dp(n,INT_MAX);
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    
    dp[0]=0;
    
    for(int i=1 ; i<n; i++){
        for(int j=1 ; j<=k ; j++){
            if(i-j >=0 ){
                dp[i] = min(dp[i] , dp[i-j]+abs(a[i]-a[i-j]));
            }
            else{
                break;
            }
        }
    }
    
    cout<<dp[n-1]<<endl;
    

return;

}
int main() {
	// your code goes here
        solve();
    
    return 0;
}


Measured memory_bytes: 4028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105+5,M=2e3+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int jg[N][N],vis[N],cnt,pre[N],h[N],d[N];
struct edge{
	int  to,nt,w;
}e[M];
void add(int u,int v,int w){
	e[++cnt]={v,h[u],w},h[u]=cnt;
	e[++cnt]={u,h[v],w},h[v]=cnt;
}
void spfa(int st){
	queue<int>q;
	mst(vis,0);
	mst(pre,-1);
	mst(d,0x3f);
	q.push(st);vis[st]=1,d[st]=0;
	while(!q.empty()){
		int u=q.front();q.pop();vis[u]=0;
		for(int i=h[u];i;i=e[i].nt){
			int v=e[i].to,w=e[i].w;
			if(d[v]>d[u]+w){
				d[v]=d[u]+w;
				pre[v]=u;
				if(!vis[v]) vis[v]=1,q.push(v);
			}
		}
	}
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		add(u,v,w);
	}
	for(int i=1;i<n;i++){
		spfa(i);
		for(int j=i+1;j<=n;j++){
			int u=j;
			while(u!=i){
				jg[u][pre[u]]=jg[pre[u]][u]=1;
				u=pre[u];
			}
		}
	}
	int ans=m;
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++){
			if(jg[i][j]||jg[j][i]) ans--;
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3832
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int N = sc.nextInt();
		int a[][] = new int[H][W];
		for (int i=0;i<N;i++) {
			int x= sc.nextInt();
			int y= sc.nextInt();
			int b=sc.nextInt();
			if (b==1) {
				for (int k=0;k<H;k++) {
					for (int j=0;j<x;j++) {
						a[k][j]++;
					}
				}
			} else if (b==2) {
				for (int k=0;k<H;k++) {
					for (int j=x;j<W;j++) {
						a[k][j]++;
					}
				}
			} else if (b==3) {
				for (int k=0;k<y;k++) {
					for (int j=0;j<W;j++) {
						a[k][j]++;
					}
				}
			} else {
				for (int k=y;k<H;k++) {
					for (int j=0;j<W;j++) {
						a[k][j]++;
					}
				}
			}
		}
		int count=0;
		for (int i=0;i<H;i++) {
			for (int j =0;j<W;j++) {
				if (a[i][j]==0) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
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;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b;
	cin>>a>>b;
	cout<<a*b-b-a+1<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair  
#define fi first
#define se second
#define pii pair<int,int> 
#define vi vector<int>
#define vpii vector<pii> 
#define vvpii vector<vetcor<pii>>
#define sz(V) ((int)V.size())
#define zeros(arr) memset(arr,0,sizeof(arr))
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define n1 "\n"
const int maxx  = 1e5+10 , limit = 1e17 , M=1e9+7 , max1 = 1e6;
#define PI 3.14159265
int pow(int x,int n){ if(n==0) return 1;  int res=pow(x,n/2); res=(res*res)%M;  if(n&1) res= (res*x)%M; return res;}
int calcInverse(int x,int n){ int res=1; while(n>0) { if(n&1)res=(res*x)%M;  x=(x*x)%M; n=n/2;} return res;}
#define test int t; cin>>t; while(t--)

int32_t main(){
    IOS       
    int x;cin>>x;
    if(x>=30)
      cout<<"Yes";
    else 
      cout<<"No";
    return 0;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
	char s[4];
	scanf("%s",s);
	if(s[0]!=s[1]&&s[0]!=s[2]&&s[1]!=s[2]){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1660
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class nikkei2019_2_qual_e {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int n, k;
        cin >> n >> k;
        vector<int> v1(n), v2(n);

        int idx = 0;
        REP(i, n) {
            if (idx >= n) idx = 1;
            v1[idx] = k + i;
            idx += 2;
        }

        idx = 1;
        REP(i, n) {
            if (idx >= n) idx = 0;
            v2[idx] = k + i + n;
            idx += 2;
        }

        REP(i, n) {
            if (v1[i] + v2[i] > k + 2 * n + i) {
                cout << -1 << endl;
                return;
            }
        }
        REP(i, n) {
            cout << v1[i] << " " << v2[i] << " " << k + 2 * n + i << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    nikkei2019_2_qual_e solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int k[n];
  int a[n][m];
  for(int i=0;i<n;i++){
      cin >> k[i];
      for(int j=0;j<k[i];j++){
          cin >> a[i][j];
      }
  }

bool flag;
int count=0;
for(int j=1;j<=m;j++){
    for(int i=0;i<n;i++){
        for(int p=0;p<k[i];p++){
            if(j==a[i][p]){
                flag=true;
                break;
            }
            else flag=false;
        }
        if(!flag) break;
    }
    if(flag) ++count;
}
cout << count << endl;
return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
#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; }

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

ll lcm(ll a, ll b){
    return a/gcd(a,b)*b;
}

int main(){
    ll n; cin>>n;
    ll t1=1, t2;
    rep(i,n){
        cin>>t2;
        ll t=lcm(t1,t2);
        t1=t;
    }
    cout<<t1<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG    //空コンテナ操作禁止　Clang環境では#define _LIBCPP_DEBUG 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int color = 1;
  for( int i=1; i<N; i++ ){
    if( S.at(i-1) != S.at(i) ) color++;
  }
  
  cout << color;
  return 0;
}

Measured memory_bytes: 512
// D.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e5 + 200;

int n, m, q, mem[MAX_N], siz[MAX_N];

struct clue
{
	int a, b, c;
} clues[MAX_N];

int find(int x) { return mem[x] == x ? x : mem[x] = find(mem[x]); }

int main()
{
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 1; i <= n; i++)
		mem[i] = i;
	for (int i = 1; i <= q; i++)
	{
		scanf("%d%d%d", &clues[i].a, &clues[i].b, &clues[i].c);
		clues[i].a++, clues[i].b++;
		if (clues[i].c == 0 && find(clues[i].a) != find(clues[i].b))
			mem[find(clues[i].a)] = find(clues[i].b);
	}
	int component = 0, c1 = 0;
	for (int i = 1; i <= n; i++)
		component += find(i) == i;
	for (int i = 1; i <= q; i++)
		if (clues[i].c == 1)
		{
			c1++;
			int u = find(clues[i].a), v = find(clues[i].b);
			if (u == v)
				puts("No"), exit(0);
		}
	long long lft = c1 ? max(3, component) : component - 1, rig = 1LL * component * (component - 1) / 2;
	puts((lft <= m - (n - component) && m - (n - component) <= rig) ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 5316
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m,r;
	cin>>n>>m>>r;
	vvi cost(n,vi(n,inf));
	vi in(r);
	rep(i,r)cin>>in[i];
	rep(i,r)in[i]--;
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;a--;b--;
		cost[a][b]=cost[b][a]=c;
	}
	rep(k,n)rep(i,n)rep(j,n)cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
	sort(all(in));
	int out=inf;
	do{
		int sum=0;
		rep(i,r-1)sum+=cost[in[i]][in[i+1]];
		out=min(out,sum);
	}while(next_permutation(all(in)));
	cout<<out<<endl;
}






Measured memory_bytes: 512
/*
    TOP GUN: MAVERICK!!
                                */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli mod=998244353;
lli INF=1e17;
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y-x)>>(31))&(x^y))^y; }
int fmi(int x, int y) { return (((y-x)>>(31))&(x^y))^x; }
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,q,z,y,k,m;
const double pi1=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
//lli tot=0;
vector<lli> pf(string s) {
    int n = (int)s.length();
    vector<lli> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n>>m;
    multiset<lli,greater<lli>> ml;
    for(int i=1;i<=n;i++)
    {
        lli x;
        cin>>x;
        ml.insert(x);
    }
    for(int i=1;i<=m;i++)
    {
        lli d=*ml.begin();
        d/=2ll;
        ml.erase(ml.begin());
        ml.insert(d);
    }
    lli ss=0;
    for(auto &i: ml)
    ss+=i;
    cout<<ss;
}

Measured memory_bytes: 5632
#include <cstdio>
#include <algorithm>
using namespace std;
#define INF (1<<29)

int main(void) {
    int N, W, ans = 0;
    scanf("%d %d", &N, &W);
    int v[N], w[N], t[W+1];
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &v[i], &w[i]);
    }

    for (int i = 0; i <= W; i++) t[i] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = W - w[i]; j >= 0; j--) {
            t[j + w[i]] = max(t[j + w[i]], t[j] + v[i]);
            ans = max(ans, t[j + w[i]]);
        }
    }

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

    return 0;
}

Measured memory_bytes: 1064
import collections

n = int(input())
a = list(map(int, input().split()))

count = collections.Counter(a)
sum = 0

# 全体の選び方をカウント
for x in count.values():
    sum += x * (x - 1) // 2

for k in a:
    print(sum - count[k] + 1)

Measured memory_bytes: 26780
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

class UnionFindTree
{
  public:
	int treeCnt; //ツリーの数
	vi rank, p;  //rank => 根の高さ, p => 親
	vi num;		 //木の要素数
	vi diff_weight;
	UnionFindTree() {}
	UnionFindTree(int size)
	{
		rank.resize(size, 0);
		p.resize(size, 0);
		num.assign(size, 1);
		treeCnt = 0;
		REP(i, size)
		{
			makeset(i);
		}
	}

	void makeset(int x)
	{
		p[x] = x;
		rank[x] = 0;
		treeCnt++;
	}

	//同じ木に属しているか判定
	bool isSame(int x, int y)
	{
		return root(x) == root(y);
	}

	//xとyが属している木をつなぐ
	void unite(int x, int y)
	{
		link(root(x), root(y));
	}

	//木と木を繋ぐ処理をする。
	void link(int x, int y)
	{
		if (!isSame(x, y))
		{
			if (rank[x] > rank[y])
			{
				p[y] = x;
				num[x] += num[y];
			}
			else
			{
				p[x] = y;
				if (rank[x] == rank[y])
				{
					rank[y]++;
				}
				num[y] += num[x];
			}
			treeCnt--;
		}
	}

	//xが属している木の根を探る
	int root(int x)
	{
		if (p[x] == x)
			return x;
		else
			return p[x] = root(p[x]);
	}

	int countTree()
	{
		return treeCnt;
	}

	int getNum(int a)
	{
		return num[root(a)];
	}
};

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vi P(M, -1);
	UnionFindTree utf(N);
	REP(i, N)
	{
		int K;
		cin >> K;
		REP(j, K)
		{
			int L;
			cin >> L;
			L--;
			if (P[L] == -1)
			{
				P[L] = i;
			}
			else
			{
				utf.unite(P[L], i);
			}
		}
	}
	if (utf.countTree() == 1)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
def isdigit(s):
  return all(c in '0123456789' for c in s)

def check(s, a, b):
  if len(s) != a + b + 1:
    return False
  
  if not isdigit(s[:a]):
    return False
  
  if s[a] != '-':
    return False
  
  if not isdigit(s[-b:]):
    return False
  
  return True
  
a, b = map(int, input().split())
s = input()
if check(s, a, b):
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    vector<LL> a(n);
    rep(i, n) cin >> a[i];
    deque<int> dq;

    rep(i, n) {
        if (i % 2 == 0) {
            dq.push_back(a[i]);
        } else {
            dq.push_front(a[i]);
        }
    }
    if (n % 2 != 0) reverse(dq.begin(), dq.end());
    for (auto &e: dq) {
        cout << e << " ";
    }
    cout << endl;
}


Measured memory_bytes: 4480
n = gets.to_i
vols = gets.split.map(&:to_i)

m_vols = [0] * n
diffs = vols.zip(vols.rotate(1)).map{|a, b| (b - a) * 2}

(0..(n - 2)).step(2).each{|i| m_vols[i + 2] = m_vols[i] + diffs[i]}
m_vols[1] = m_vols.last + diffs.last
(1..(n - 3)).step(2).each{|i| m_vols[i + 2] = m_vols[i] + diffs[i]}

diff = (vols.inject(:+) - m_vols.inject(:+)) / n
puts m_vols.map{|v| v + diff}.join(" ")


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

int main(void) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int s1 = a * b;
    int s2 = c * d;
    if (s1 <= s2) cout << s2;
    else cout << s1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int N, K; cin >> N >> K;
	vector<int>x(N);
	rep(i, 0, N)cin >> x[i];
	int cnt = 0;
	rep(i, 0, N) {
		cnt += min(x[i] * 2, abs(K - x[i]) * 2);
	}
	cout << cnt << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
void solve(){
  int table[200][200] = { 0 };

  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      scanf("%d", &table[i][j]);
      table[n][j] += table[i][j];
      table[i][n] += table[i][j];
    }
  }
  for (int i = 0; i < n; i++){
    table[n][n] += table[i][n];
  }
  for (int i = 0; i < n + 1; i++){
    int j = 0;
    printf("%5d", table[i][0]);
    for (j = 1; j < n + 1; j++){
      printf("%5d", table[i][j]);
    }
    printf("\n");
  }
}

int main(){
  while (scanf("%d", &n), n)solve();
  return 0;
}

Measured memory_bytes: 1360
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 1001000
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    ll n;cin>>n;
    //3
    ll n3=n/3;
    ll s3=(n3*(2*3+(n3-1)*3))/2;
    //5
    ll n5=n/5;
    ll s5=(n5*(2*5+(n5-1)*5))/2;
    //15
    ll n15=n/15;
    ll s15=(n15*(2*15+(n15-1)*15))/2;
    ll totSum=(n*(n+1))/2;
    ll cutSum=s3+s5-s15;
    cout<<totSum-cutSum<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
    int N,M;
    cin >> N >> M;
    
    string ans = "No";
    if (N == M) ans = "Yes";
    
    // 出力
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long  a,b,k;
    cin>>a>>b>>k;
    if(a>=k){
        cout<<a-k<<" "<<b<<endl;
    }else if(a+b>=k){
        cout<<0<<" "<<b-k+a<<endl;        
    }else{
        cout<<0<<" "<<0<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 100005

const int INF = 1e16 + 7;
const int MOD = 1e9 + 7;

set<int> a[ARRAY_MAX];

int main() {

	ll N;
	cin >> N;

	for (ll n = 1; n <= 3500; n++)
	{
		for (ll w = 1; w < 3500; w++)
		{
			ll down = 4 * n*w - N * w - n * N;//分子
			ll over = N * n*w;//分母
			if (down <= 0)
			{
				continue;
			}
			if (over % down == 0)
			{
				cout << over / down << " " << n << " " << w << endl;
				return 0;
			}
		}
	}


	return 0;
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    int arr[] = {A,B,C};
    for(int i = 0; i < 2; i++)
    {
        if(arr[i] > arr[i+1])
            {
                int temp = arr[i];
                arr[i] = arr[i+1];
                arr[i+1] = temp;
            }
    }

    cout << 10*arr[2] + arr[1] + arr[0];
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

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

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  bool ok = true;

  for(int i = 0; i < n; i++) {
    int a; cin >> a;
    if(a % 2 == 1) continue;
    if(a % 5 == 0 or a % 3 == 0) continue;
    ok = false;
    break;
  }

  if(ok) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		long t = System.currentTimeMillis();
		new Main().run();
		System.err.println(System.currentTimeMillis() - t);
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		System.out.println(N*(N-1)/2+M*(M-1)/2);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll s, c; cin >> s >> c;
	ll ans = 0;

	{
		ll g = min(s, c / 2);
		ans += g;
		s -= g;
		c -= 2 * g;
	}

	{
		ll g = c / 4;
		ans += g;
		c -= 4 * g;
	}

	cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF = 1e9;

int main() {
  ld l, ans = 0;
  cin >> l;
  ld t, y, o;
  t = l / 3.0;

  printf("%.10Lf\n", t * t * t);
  return 0;
}


Measured memory_bytes: 256
s = list(input())
n = len(s)
s_1 = s[0:(n-1)//2]
s_2 = s[(n+1)//2:n]


def kaibunn(l):
    a = 1
    m = len(l)
    for i in range(m):
        if l[i] != l[m-1-i]:
            a = 0
            break
    return a

if kaibunn(s)==1 and kaibunn(s_1)==1 and kaibunn(s_2)==1:
    print("Yes")
else:
    print("No")


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BCountBalls solver = new BCountBalls();
        solver.solve(1, in, out);
        out.close();
    }

    static class BCountBalls {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long a = in.nextLong();
            long b = in.nextLong();
            long ans = (n / (a + b)) * a;
            if (n % (a + b) > a) {
                ans += a;
            } else {
                ans += n % (a + b);
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int a[6]={0,9,0,900,0,90000};
	int ans=0,sint=0,p=1;
	int len=s.size();
	for(int i=1;i<len;i++)
		ans+=a[i];
	for(int i=0;i<len;i++)
	{
		sint=10*sint+s[i]-'0';
		p*=10;
		}	
	if(len%2)
		ans=ans+sint-p/10+1;
	cout<<ans;
	return 0;
	
 } 

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())

cnt=0
for i in range(0,a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            if 500*i+100*j+50*k==x:
                cnt+=1
print(cnt)

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

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));

		int n = sc.nextInt();
		int[] c = new int[n];
		int[] s = new int[n];
		int[] f = new int[n];
		int[] ans = new int[n];
		Arrays.fill(c, 0);
		Arrays.fill(s, 0);
		Arrays.fill(f, 0);
		Arrays.fill(ans, 0);
		
		for (int i = 0; i < n-1; i++) {
			c[i] = sc.nextInt();
			s[i] = sc.nextInt();
			f[i] = sc.nextInt();
		}
		
		for (int i = 0; i < ans.length; i++) {
			int total = 0;
			for (int j = i; j < ans.length-1; j++) {
				if (total<s[j]) {
					total = s[j];
				}else if (total%f[j]==0) {
					// nothing to do
				}else{
					int sub = f[j] - (total%f[j]);
					total += sub;
				}
				total += c[j];
			}
			ans[i] = total;
		}
		
		for (int i = 0; i < ans.length; i++) {
			out.println(ans[i]);
		}
		out.close();
	}

	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		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;
		}

	}
	//--------------------------------------------------------

}



Measured memory_bytes: 22996