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

using namespace std;
using ll = long long;

int main() {
	ll n;
	cin >> n;
	string s;
	ll t(1);
	if (n == 0) {
		cout << 0 << endl;
		return 0;
	}
	while (n != 0) {
		ll a = abs(n % 2);
		s = to_string(a) + s;
		n -= a * t;
		n /= 2;
		t *= -1;
	}
	cout << s << endl;
}


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

int main() {
  string s, t = "CODEFESTIVAL2016";
  cin >> s;

  int ans = 0;
  for (int i = 0; i < t.size(); ++i)
    if (s[i] != t[i])
      ++ans;
  cout << ans << endl;
}

Measured memory_bytes: 768
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.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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);
        BStringsWithTheSameLength solver = new BStringsWithTheSameLength();
        solver.solve(1, in, out);
        out.close();
    }

    static class BStringsWithTheSameLength {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            char[] first = sc.next().toCharArray(), second = sc.next().toCharArray();
            char[] print = new char[n * 2];
            for (int i = 0, j = 0; i < n; i++) {
                print[j++] = first[i];
                print[j++] = second[i];
            }
            for (char c : print)
                pw.print(c);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

    }
}



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

int main(){
  int a,b;
  int max;

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

  max = a + b;
  if(max < a - b) max = a - b;
  if(max < a*b) max = a*b;

  printf("%d\n", max);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int dijkstra(int n,int s,int g,vector<vector<pair<int,int>>>&pas){
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>q;
    q.push({0,s});
    int d[n];
    for(int i=0;i<n;i++)d[i]=1000000000;
    d[s]=0;
    while(q.size()){
        int p=q.top().second;
        if(p==g){
            return q.top().first;
        }
        q.pop();
        for(int i=0;i<pas[p].size();i++){
            if(d[p]+pas[p][i].second<d[pas[p][i].first]){
                d[pas[p][i].first]=d[p]+pas[p][i].second;
                q.push({d[pas[p][i].first],pas[p][i].first});
            }
        }
    }
}
int main(){
    int n,m,r;
    scanf("%d%d%d",&n,&m,&r);
    int t[r],a[m],b[m],c[m];
    int turn[r];
    for(int i=0;i<r;i++){
        scanf("%d",&t[i]);
        t[i]--;
        turn[i]=i;
    }
    vector<vector<pair<int,int>>>pas(n);
    for(int i=0;i<m;i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        pas[a[i]-1].push_back({b[i]-1,c[i]});
        pas[b[i]-1].push_back({a[i]-1,c[i]});
    }
    int shortest_way[r][r];
    for(int i=0;i<r-1;i++){
        for(int j=i+1;j<r;j++){
            shortest_way[i][j]=dijkstra(n,t[i],t[j],pas);
        }
    }
    int mi=1000000000;
    do{
        if(turn[0]>turn[r-1])continue;
        int dist=0;
        for(int i=0;i<r-1;i++){
            dist+=shortest_way[min(turn[i],turn[i+1])][max(turn[i],turn[i+1])];
            if(dist>=mi){
                break;
            }
        }
        mi=min(mi,dist);
    }while(next_permutation(turn,turn+r));
    printf("%d\n",mi);
    return 0;
}

Measured memory_bytes: 896
n = int(input())
h = [0]
for i in input().split(): h.append(int(i))
def cost(i,j): return abs(h[i]-h[j])

#dp[i]:= 足場iにたどり着く為の最小コスト
#dp[0]:= 0
#dp[1]:= 0
#dp[2]:= abs(h[1]-h[2])
dp = [0 for _ in range(n+1)]
dp[2] = cost(1,2)
for i in range(3,n+1):
    dp[i] = min(dp[i-1]+cost(i,i-1),dp[i-2]+cost(i,i-2))

print(dp[n])

Measured memory_bytes: 52848
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int main() {
  ios::sync_with_stdio(false);
 string a;
 cin>>a;
 int x=a.size();
 if(a[x-1]=='s'){
   a+="es";
 }else a+="s";
 cout<<a<<endl;
  return 0;
}

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

int main(){
	string a,b;
	cin>>a>>b;
	if(a[1]==b[1] && a[0] == b[2] && a[2]==b[0]){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}
	return 0;
}

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

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

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

    int c = a;
    for (int i = 0; i < n-1; ++i) {
        cin >> a;
        c = gcd(c, a);
    }

    cout << c << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N,K;

int fact(int n){
    int res=1ll;
    for(int i=1;i<=n;++i)res=(res*i)%mod;
    return res;
}

int f_pow(int x,int n){
    int ans=1ll;
    while(n>0){
        if((n&1)==1){
            ans=(ans*x)%mod;
        }
        x=(x*x)%mod;
        n=n>>1ll;
    }
    return ans;
}

int comb(int n,int k){
    return ((fact(n)*f_pow(fact(k),mod-2)%mod)*f_pow(fact(n-k),mod-2))%mod;
}

signed main(){
    cin>>N>>K;
    for(int i=1;i<=K;++i){
        if(N-K+1<i)cout<<0<<endl;
        else cout<<(comb(K-1,i-1)*comb(N-K+1,i))%mod<<endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 100005;
struct Edge { int next, to; } e[maxn << 1];
int head[maxn], tot;
void Add(int u, int v) {
	e[++tot] = (Edge){head[u], v}; head[u] = tot;
}
int N, sg[maxn];
int dfs(int x, int y) {
	for(int i = head[x]; i; i = e[i].next) {
		int to = e[i].to;
		if(to == y) continue;
		sg[x] ^= dfs(to, x) + 1;
	}
	return sg[x];
}
int main() {
	scanf("%d", &N);
	for(int i = 1, u, v; i < N; ++i) {
		scanf("%d%d", &u, &v);
		Add(u, v); Add(v, u);
	}
	puts(dfs(1, -1) ? "Alice" : "Bob");
	return 0;
}

Measured memory_bytes: 7168
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int a;
	cin >> a;
	if (a < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int n,c[101][2][7],z,Z,x;
	
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		for(int t=0;t<6;t++){
			scanf("%d",&c[i][1][t]);
			c[i][0][t]=t;
		}
	}
	
	for(int p=0;p<n-1;p++){
		for(int s=p+1;s<n;s++){
			
			///c[p][1][]??¨????????????????????????///
			
			for(int i=0;i<6;i++){
				
				///??????c[s][1][i]?????????///
				
				for(int t=0;i!=c[s][0][0];t++){
					if(t==4) break;
					z=c[s][0][0];
					Z=c[s][1][0];
					c[s][0][0]=c[s][0][4];
					c[s][1][0]=c[s][1][4];
					c[s][0][4]=c[s][0][5];
					c[s][1][4]=c[s][1][5];
					c[s][0][5]=c[s][0][1];
					c[s][1][5]=c[s][1][1];
					c[s][0][1]=z;
					c[s][1][1]=Z;
				}
				if(i!=c[s][0][0]){
					for(int t=0;i!=c[s][0][0];t++){
						if(t==4) break;
						z=c[s][0][0];
						Z=c[s][1][0];
						c[s][0][0]=c[s][0][2];
						c[s][1][0]=c[s][1][2];
						c[s][0][2]=c[s][0][5];
						c[s][1][2]=c[s][1][5];
						c[s][0][5]=c[s][0][3];
						c[s][1][5]=c[s][1][3];
						c[s][0][3]=z;
						c[s][1][3]=Z;
					}
				}
				///a[]??¨????????????????????´??¢?????????///
				
				for(int t=0;t<4;t++){
					x=0;
					for(int t=0;t<6;t++){
						if(c[p][1][t]!=c[s][1][t]){
							x++;
						}
					}
					//printf("%d\n",x);
					if(x==0) break;
					
					Z=c[s][1][1];
					c[s][1][1]=c[s][1][3];
					c[s][1][3]=c[s][1][4];
					c[s][1][4]=c[s][1][2];
					c[s][1][2]=Z;
				}
				if(x==0) break;
			}
			if(x==0) break;
		}
		if(x==0) break;
	}
	if(x==0){
		printf("No\n");
	}
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 2684
const main = (input) => {
  input = input.split(' ');
  const A = parseInt(input[0], 10);
  const B = parseInt(input[1], 10);
  
  if ((A+B)%3===0){
    console.log("Possible");
  }else if(A%3===0){
    console.log("Possible");
  }else if(B%3===0){
    console.log("Possible");
  }else{
    console.log("Impossible");
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
r,c=map(int, input().split())
mat = []
for y in range(r):
	mat.append(list(map(int,input().split())))
	
cols = [0]*c

for row in mat:
	print(" ".join(list(map(str, row))), end=" ")
	print(sum(row))
	for i in range(c):
		cols[i] += row[i]

print(" ".join(list(map(str, cols))), end=" ")
print(sum(cols))

	



Measured memory_bytes: 5704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int n;
    cin >> n;
    int ans=mod;
    rep(i,n+1){
        int cnt=0;
        int mon6=i;
        int mon9=n-i;
        while(mon6){
            cnt+=mon6%6;
            mon6/=6;
        }
        while(mon9){
            cnt+=mon9%9;
            mon9/=9;
        }
        chmin(ans,cnt);
    }
    cout << ans;

    


}

/*



 */



Measured memory_bytes: 256
N, D = map(int, input().split())
XY = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(N):
    if (XY[i][0]**2 + XY[i][1]**2)**0.5 <= D:
        ans += 1
print(ans)

Measured memory_bytes: 45832
class Unionfind():
    def __init__(self, progsize):
        self.table = [-1 for _ in range(progsize)]
        self.size = [1 for _ in range(progsize)]

    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x

    def union(self, x, y):
        xl = self.find(x)
        yl = self.find(y)
        if xl != yl:
            if self.table[xl] <= self.table[yl]:
                self.table[yl] = xl
                self.table[xl] -= 1
                self.size[xl] += self.size[yl]
            else:
                self.table[xl] = yl
                self.table[yl] -= 1
                self.size[yl] += self.size[xl]

n, m = [int(x) for x in input().split()]
b =  [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
b.reverse()
r = []
t = n*(n-1)//2
ds = Unionfind(n)
for q, p in b:
  r.append(t)
  qq, pp = ds.find(p), ds.find(q)
  if pp != qq:
    t -= ds.size[pp] * ds.size[qq]
  ds.union(p, q)
for x in reversed(r):
  print(x)

Measured memory_bytes: 23276
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(ReadLine());
        }

        public static long[] Reads()
        {
            return ReadLine().Split().Select(long.Parse).ToArray();
        }

        
         public static long gcd(long x, long y)
        {
            if (x < y) gcd(y, x);
            while (y != 0)
            {
                var z = x;
                x = y;
                y = z % y;
            }
            return x;
        }

        public static long lcm(long x, long y)
        {
            return x * y / gcd(x, y);
        } 

        public static long C(long n, long k)
        {
            long x = 1;
            for (long i = 1; i <= k; i++)
            {
                x *= n - i + 1;
                x /= i;
            }
            return x;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var q=Reads();
            var h = q[0];
            var w = q[1];
            var t = 0;
            for (int i = 0; i <h ; i++)
            {
                var c = ReadLine();
                for (int j = 0; j <c.Length ; j++)
                {
                    if (c[j] == '#') t++;
                }
            }
            if (t == h + w - 1) WriteLine("Possible");
            else WriteLine("Impossible");


            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 18904
n, m = map(int, input().split())
C = list(map(int, input().split()))
INF = 10**5
dp = [INF for _ in range(n+1)]
dp[0] = 0
for i in range(n):
    for c in C:
        if i + c <= n:
            dp[i+c] = min(dp[i+c], dp[i]+1)
print(dp[n])


Measured memory_bytes: 7380
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int32_t main() {
    IOS;

        ll n;
        cin>>n;
        int md=0;
       	rep(i,1,1e6){
       		md=(md*10+7)%n;
       		//db1(md[i]);
       		if(md==0){
       			cout<<i;
       			return 0;
       		}	
   	    }
        cout<<"-1";



        cout<<'\n';
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        A[i]--;
    }
    set<ll> path_set;
    vector<ll> path_vec(n + 1, -1);
    ll point = 0LL;
    path_set.insert(point);

    ll idx = 0LL;
    path_vec[idx] = point;

    ll ans;
    while (true) {
        point = A[point];
        // cout << "point: " << point << endl;
        if (path_set.find(point) == path_set.end()) {
            point = point;
            path_set.insert(point);
            idx++;
            path_vec[idx] = point;
        } 
        // detect loop
        else {
            auto vec_iter = std::find(path_vec.begin(), path_vec.end(), point);
            // for (auto p: path_vec) {
            //     cout << p;
            // }
            ll offset = distance(path_vec.begin(), vec_iter);
            ll length = path_set.size() - offset;

            // cout << "offset: " << offset << ", length: " << length << endl;
            if (k < offset) {
                ans = path_vec[k];
            } else {
                ans = path_vec[(k - offset) % length + offset];
            }
            break;
        }        
    }
    cout << (ans + 1LL) << endl;
    return 0;
}

Measured memory_bytes: 15668
#include <bits/stdc++.h>
using namespace std;
int L,R,n,m;priority_queue<int>q;
struct nod{int l,r;friend bool operator <(nod a,nod b){if(a.l!=b.l) return a.l<b.l;return a.r>b.r;}}a[200005];
int main()
{
	scanf("%d%d",&n,&m);R=m+1;
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].l,&a[i].r);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) if(a[i].l>L&&L<m) L++;else q.push(a[i].r);
	while(!q.empty())
	{
		if(R-L==1) break;
		int x=q.top();q.pop();
		if(R>x) R--;
	}
	printf("%d\n",n-(L+(m-R+1)));
}

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

using namespace std;

int n;
string s;

int calc(string s, string t)
{
	int cnt[26], cnt2[26];
	for(int i = 0; i < 26; i++) cnt[i] = cnt2[i] = 0;
	for(int i = 0; i < s.size(); i++) cnt[s[i]-'a']++;
	for(int i = 0; i < t.size(); i++) cnt2[t[i]-'a']++;
	int ret = 0;
	for(int i = 0; i < 26; i++) ret += (cnt[i] && cnt2[i]);
	return ret;
}

int main(void)
{
	cin >> n;
	cin >> s;
	
	int ans = 0;
	for(int i = 1; i < s.size(); i++){
		ans = max(ans, calc(s.substr(0, i), s.substr(i)));
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#include <iostream>

int main()
{
    
    int x, y;
    cin >> x >> y;
    if (y >= x * 2 && y <= x * 4 && y % 2 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
        
}

Measured memory_bytes: 3132
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) const { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) const { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};

int64_t const MOD = 1e9+7;
typedef mod_int<MOD> mint;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  std::string L; std::cin >> L;
  std::vector<mint> dpN(L.size()), dpT(L.size());
  dpN[0] = 1;
  dpT[0] = 2;
  for(int i = 1; i < L.size(); ++i) {
    if(L[i] == '0') {
      dpT[i] = dpT[i-1];
      dpN[i] = dpN[i-1]*3;
    } else {
      dpT[i] = dpT[i-1]*2;
      dpN[i] = dpT[i-1] + dpN[i-1]*3;
    }
  }
  mint ans = dpT[L.size()-1] + dpN[L.size()-1];
  fin(ans.v_);
  return 0;
}


Measured memory_bytes: 2000
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int> x(N);
  for(int i=0;i<N;i++){
    cin>>x.at(i);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(x.at(i)<=K-x.at(i)){
      ans+=2*x.at(i);
    }
    else{
      ans+=2*(K-x.at(i));
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		
		//?????¨?¨????????????????????????????
		String s  = sc.nextLine();
		String [] ary = s.split(" ");
		int height = Integer.parseInt(ary[0]);
		int width = Integer.parseInt(ary[1]);
		
		//?????±????????????????´???????
		int [][] data = new int[height][width];
 		for(int i = 0; i < height; i++) {
			String strData  = sc.nextLine();
			String[] dataAry = strData.split(" ");
			for(int j = 0; j < width; j++) {
				data[i][j] = Integer.parseInt(dataAry[j]);
			}
		}
 		
 		//??\?????????????????±?????¨?????????
 		int sumG = 0;
 		for(int i = 0; i < data.length; i++) {
 			int sum = 0;
 			for(int j = 0; j <data[i].length; j++) {
 				System.out.print(data[i][j] + " ");
 				sum += data[i][j];
 			}
 			System.out.println(sum);
 		}
 		
 		//????¨??????¨?????????
 		for(int i = 0; i < width; i++) {
 			int sum = 0;
 			for(int j = 0; j < height; j++) {
 				sum += data[j][i];
 			}
 			sumG += sum;
 			System.out.print(sum + " ");
 		}
 		System.out.println(sumG);
 		
	}

}

Measured memory_bytes: 33504
#include <cstdio>
#include <algorithm>
using std::max;
const int MAXN=2000;
int cnt=0;
struct Edge {
	int v,nxt;
}ed[MAXN<<1];
int first[MAXN];
inline void add(int x,int y) {
	static int cnt=0;
	ed[++cnt].v=y;
	ed[cnt].nxt=first[x];
	first[x]=cnt;
}
void dfs(int x,int fa,int dep) {
//	printf("(%d,%d,%d)\n",x,fa,dep);
	++cnt;
//	printf("cnt %d\n",cnt);
	if(!dep) return;
	for(int i=first[x];i;i=ed[i].nxt) {
		int v=ed[i].v;
		if(v==fa) continue;
		dfs(v,x,dep-1);
	}
}
int edge[MAXN][2];
int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	int in1,in2;
	for(int i=1;i<n;++i) {
		scanf("%d%d",&in1,&in2);
		edge[i][0]=in1;
		edge[i][1]=in2;
		add(in1,in2);
		add(in2,in1);
	}
	int ans=0;
	if(k&1) {
		for(int i=1;i<n;++i) {
		//    printf("id %d now\n",i);
			cnt=0;
		//	printf("first\n");
			dfs(edge[i][0],edge[i][1],k/2);
		//	printf("second\n");
			dfs(edge[i][1],edge[i][0],k/2);
		//	printf("cnt %d now\n",cnt);
			ans=max(ans,cnt);
		}
	} else {
		for(int i=1;i<=n;++i) {
		//    printf("id %d now\n",i);
			cnt=0;
			dfs(i,-1,k/2);
		//	printf("cnt %d now\n",cnt);
			ans=max(ans,cnt);
		}
	}
	printf("%d",n-ans);
	return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> pll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pf           push_front
#define pi           acos(-1)
#define all(x)       x.begin(),x.end()
ll t;


int main()
{
    int a,b,c,d,e,f,g,i,j;
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	char [][] list;
	int xpos;
	int ypos;

	private void setList(int x, int y, int n, int dis){
		//上
		if(dis == 0){
			for(int i=0; i < n; i++){
				list[y - i][x] = '#';
				xpos = x;
				ypos = y-i;
			}
		}
		//右
		else if(dis == 1){
			for(int i=0; i < n ;i++){
				list[y][x+i] = '#';
				xpos = x+i;
				ypos = y;
			}
		}
		//↓
		else if(dis == 2){
			for(int i=0; i < n; i++){
				list[y+i][x] = '#';
				xpos = x;
				ypos = y+i;
			}
		}
		//左
		else if(dis == 3){
			for(int i=0; i < n; i++){
				list[y][x - i] = '#';
				xpos = x-i;
				ypos = y;
			}
		}

	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n-- > 0){
			int m = sc.nextInt();
			list = new char[m][m];
			for(int i=0; i < m ;i++){
				Arrays.fill(list[i], ' ');
			}
			xpos = 0;
			ypos = m-1;
			setList(xpos, ypos, m, 0);
			int len = m;
			for(int i=1; len >= 2 ; i++){
				setList(xpos, ypos, len, i % 4);
				i++;
				if(len != 2){
					setList(xpos, ypos, len, i % 4);
				}
				len -= 2;
			}
			//print
			for(int i=0; i < m; i++){
				for(int j=0; j < m; j++){
					System.out.print(list[i][j]);
				}
				System.out.println("");
			}
			if(n != 0){
				System.out.println("");
			}

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

Measured memory_bytes: 12000
import java.io.*;

public class Main {
	public static void main(String[] args) {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		try {
			String line;
			int n;
			
			while(true){
				line=r.readLine();
				n = Integer.parseInt(line);
				if(n==0){
					break;
				}
				
				int[][] m = new int[n][n];
				boolean[][] left = new boolean[n][n];
				boolean[][] right = new boolean[n][n];
				
				//create matrix
				for(int row=0;row<n;row++){
					line=r.readLine();
					String[] temp = line.split(" ");
					for(int column=0;column<n;column++){
						int t = Integer.parseInt(temp[column]);
						m[row][column] = t;
						left[row][column] = false;
						right[row][column] = false;
					}
				}

				//look for the shortest index for each row
				for(int row=0;row<n;row++){
					int shortest = m[row][0];
					for(int column=1;column<n;column++){
						if(m[row][column]<shortest){
							shortest=m[row][column];
						}
					}
					for(int column=0;column<n;column++){
						if(m[row][column]==shortest){
							left[row][column]=true;
						}
					}
				}
				//look for the tallest student in each column
				for(int column=0;column<n;column++){
					int tallest = m[0][column];
					for(int row=1;row<n;row++){
						if(m[row][column]>tallest){
							tallest=m[row][column];
						}
					}
					for(int row=0;row<n;row++){
						if(m[row][column]==tallest){
							right[row][column]=true;
						}
					}
				}
				
				int res = 0;
				
				for(int row=0;row<n;row++){
					for(int column=0;column<n;column++){
						if(left[row][column]&&right[row][column]){
							res = m[row][column];
							break;
						}
					}
					if(res!=0){
						break;
					}
				}
				System.out.println(res);
				
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

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

using namespace std;

#define ll long long
#define ull unsigned long long

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

    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < k; i++) {
        int pre, pp = -1;
        vector<int> dp(3, 0);
        for (int j = i; j < n; j += k) {
            if (t[j] == 's') {
                if (pp != 0) {
                    dp[0] = max({dp[0], dp[1], dp[2]}) + r;
                    pp = 0;
                }
                else {
                    dp[0] = max(dp[0], max(dp[1], dp[2]) + r);
                    pp = -1;
                }
            }
            if (t[j] == 'p') {
                if (pp != 1) {
                    dp[1] = max({dp[0], dp[1], dp[2]}) + s;
                    pp = 1;
                }
                else {
                    dp[1] = max(dp[1], max(dp[0], dp[2]) + s);
                    pp = -1;
                }
            }
            if (t[j] == 'r') {
                if (pp != 2) {
                    dp[2] = max({dp[0], dp[1], dp[2]}) + p;
                    pp = 2;
                }
                else {
                    dp[2] = max(dp[2], max(dp[0], dp[1]) + p);
                    pp = -1;
                }
            }
        }
        ans += max({dp[0], dp[1], dp[2]});
    }
    cout << ans << '\n';
}

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

int main() {
  string s;
  cin>>s;
  int n=s.size()-1;
  bool even = true;
  for(int i=0;i<s.size();i++){
    even=true;
    if(n%2==0){
      for(int j=0;j<n/2;j++){
        if(s[j]!=s[j+n/2])
          even=false;
        
      }
      if(even==false)
          n=n-2;
    }
    else {n-=1;even=false;}
    if(even)break;
  }
  cout<<n;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int h,w;
	char f[602][602];
	rep(i,602)rep(j,602)f[i][j] = '.';
	scanf("%d%d",&h,&w);
	rrep1(y,h){
		scanf("\n");
		rep1(x,w)scanf("%c",&f[x][y]);
	}
	h ++; w ++;
	
	multiset<pair<ld,int>> S;
	rep1(x,w)rep1(y,h-1){
		if(f[x][y] != f[x][y+1]){
			S.insert(pair<ld,int>(y/(ld)x+1e-9,1));
			if(x != 1)S.insert(pair<ld,int>(y/(ld)(x-1)-1e-9,-1));
		}
	}
	rep1(y,h)rep1(x,w-1){
		if(f[x][y] != f[x+1][y]){
			S.insert(pair<ld,int>((y-1)/(ld)x+1e-9,1));
			S.insert(pair<ld,int>(y/(ld)x-1e-9,-1));
		}
	}
	
	int ret = 0;
	int cnt = 0;
	for(pair<ld,int> p: S){
		cnt += p.sc;
		ret = max( ret , cnt );
		//cout << p.fr << " " << p.sc << " " << cnt << endl;
	}
	cout << 1+(ret+1)/2 << endl;
}




Measured memory_bytes: 59576
N = int(input())
X = (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)

print(X[N-1])


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

signed main(){
  int s,t,p,q,M,y;cin>>s>>t>>p>>q>>M>>y;
  /*
  int now=y,pre=0;
  for(int i=1;i<=1e8;i++){
    int a=pre*p+q;a%=M;
    now^=a;pre=a;
  }
  cout<<now<<endl;
  */
  cout<<(t^s^y)<<endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long 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 = 1LL << 60;

int main() {
    int N, K;
    cin >> N >> K;
    
    long double win = 0.0L;
    for (int i = 1; i <= N; i++) {
        if (i >= K) {
            win += 1.0L / N * (N - K + 1);
            break;
        }
        int mul = 1;
        int x = i;
        while (x < K) {
            x *= 2;
            mul *= 2;
        }
        win += 1.0L / mul / N;
    }

    printf("%.10Lf\n", win);

    return 0;
}

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

int main() {
	int n, m; cin >> n >> m;
	vector<string> a(n), b(m); 
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, m) cin >> b[i];

	string ans = "No";
	rep(i, 0, n - m + 1) {
		rep(j, 0, n - m + 1) {
			vector<string> c(m);
			rep(k, 0, m) {
				c[k] = a[i + k].substr(j, m);
			}
			if (b == c) ans = "Yes";
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n, c, z, a[33], b[33], dp[33][65555], pcnt[65555];
int main() {
	for (int i = 0; i < 16; i++) {
		for (int j = 1 << i; j < (1 << i) << 1; j++) {
			pcnt[j] = pcnt[j - (1 << i)] + 1;
		}
	}
	while (scanf("%d%d", &n, &c), n | c) {
		for (int i = 0; i < n; i++) {
			a[i] = 0;
			for (int j = 0; j < 16; j++) {
				scanf("%d", &z);
				if(z) a[i] += (1 << j);
			}
		}
		a[n] = 0;
		for (int i = 1; i <= c; i++) {
			b[i] = 0;
			for (int j = 0; j < 16; j++) {
				scanf("%d", &z);
				if (z) b[i] += (1 << j);
			}
		}
		for (int i = 0; i <= n; i++) {
			fill(dp[i] + 0, dp[i] + 65536, -999999999);
		}
		dp[0][a[0]] = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 65536; j++) {
				if (dp[i][j] == -999999999) continue;
				for (int k = 0; k <= c; k++) {
					dp[i + 1][(j & ~b[k]) | a[i + 1]] = max(dp[i + 1][(j & ~b[k]) | a[i + 1]], dp[i][j] + pcnt[j & b[k]]);
				}
			}
		}
		printf("%d\n", *max_element(dp[n], dp[n] + 65536));
	}
	return 0;
}

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

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int64_t Q=998244353;
  vector<vector<int64_t>> dp(C+2,vector<int64_t>(D+2));
  dp.at(A).at(B)=1;
  for(int i=A;i<C;i++){
    dp.at(i+1).at(B)=(dp.at(i).at(B)*B)%Q;
  }
  for(int i=B;i<D;i++){
    dp.at(A).at(i+1)=(dp.at(A).at(i)*A)%Q;
  }
  for(int i=A;i<C;i++){
    for(int j=B;j<D;j++){
      dp.at(i+1).at(j+1)=(dp.at(i).at(j+1)*(j+1)+dp.at(i+1).at(j)*(i+1)-dp.at(i).at(j)*i*j+Q*i*j)%Q;
    }
  }
  cout<<dp.at(C).at(D)<<endl;    
}

Measured memory_bytes: 73680
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll, ll> lltpl;



/******************************************************************************************/


const int IINF = 1e9 + 7;
const ll LINF = 1e18 + 7;
const ll MOD = 1e9 + 7;



template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	

	int n;
	cin >> n;
	if (n % 2 == 0) {
		printf("%.9f\n", (n / 2)/(double)n);
	}
	else
	{
		printf("%.9f\n", (n / 2+1) / (double)n);
	}







	

}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();

		if(n%2 == 1) {
			System.out.println("No");
			return;
		}

		String s1 = s.substring(0, n/2);
		String s2 = s.substring(n/2,n);

		if(s1.equals(s2)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22864
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    int n, m; cin >> n;
    VI a(n);
    REP(i, n) cin >> a[i];
    cin >> m;
    VI b(m);
    REP(i, m) cin >> b[i];
    VI res;
    set_symmetric_difference(ALL(a), ALL(b), inserter(res, res.end()));
    REP(i, res.size()){
        cout << res[i] << "\n";
    }
    return 0;
}



Measured memory_bytes: 6500
from collections import deque
h,w=map(int,input().split())
dist=[[-1]*(w+2) for _ in range(h+2)]
dist[1][1]=1
maze=[]
maze.append(['#' for _ in range(w+2)])
for i in range(h):
    maze.append(['#']+list(input())+['#'])
maze.append(['#' for _ in range(w+2)])
cnt=0
for i in range(h+2):
    for j in range(w+2):
        if maze[i][j]=='#':
            cnt+=1

d=[[-1,0],[1,0],[0,-1],[0,1]]
q=deque()
q.append([1,1])
while q:
    x,y=q.popleft()
    for dx,dy in d:
        if (0<=x+dx<=h+1) and (0<y+dy<w+1):
            if maze[x+dx][y+dy]==".":
                if dist[x+dx][y+dy]==-1 or dist[x+dx][y+dy]>dist[x][y]+1:
                    q.append([x+dx,y+dy])
                    dist[x+dx][y+dy]=dist[x][y]+1
if dist[h][w]==-1:
    print(-1)
else:
    print((h+2)*(w+2)-cnt-dist[h][w])

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 998244353;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
istream& operator>>(istream& is, const mint& a){ return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

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

    vector<int> A(N);
    for (auto &i : A) cin >> i;

    vector<mint> dp(S+1);
    dp[0] = 1;
    mint ans = 0;
    rep(i, N) {
        repr(j, S+1) {
            int nj = j + A[i];
            if (nj <= S) dp[nj] += dp[j];
        }
        ans += dp[S];
        dp[0] += 1;
    }

    cout << ans << endl;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int inf = 1e9;

int add(int x, int y) {
    return (1ll * x + 1ll * y) % mod;
}

int del(int x, int y) {
    return ((1ll * x - 1ll * y) % mod + mod) % mod;
}

int mul(int x, int y) {
    return (1ll * x * 1ll * y) % mod;
}
const int N = 1e5 + 5;
long long sum = 0;
int n, m;
ii a[N];

multiset<int> mst;
multiset<int>::iterator it;

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        cin >> a[i].fi >> a[i].se;
    sort(a + 1, a + 1 + n);
    int pt = 1;
    for(int i = 1; i <= m; i++) {
        int j = pt;
        while(j <= n && a[j].fi <= i) {
            mst.insert(a[j].se);
            j++;
        }
        pt = j;
        if(mst.size() != 0) {
            it = mst.end(); it--;
            sum += (*it);
            //cout << sum << " " << i << "\n";
            mst.erase(it);
        }
    }
    cout << sum;
}



Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

int main(void) {
    int i,n;
    vector<int> m;
    for(i=0; i<10; i++){
        cin >> n;
        m.push_back(n);
    }
    sort(m.begin(),m.end(),greater<int>());
    for(i=0; i<3; i++) {
        cout << m[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
Option Explicit On
Option Strict On

Module Module1

    Sub Main()

        Dim tmp As String() = Split(Console.ReadLine(), " ")

        If tmp(0) = tmp(1) Then
            If tmp(0) <> tmp(2) Then
                Console.WriteLine("Yes")
            Else
                Console.WriteLine("No")
            End If
        Else
            If tmp(0) = tmp(2) Or tmp(1) = tmp(2) Then
                Console.WriteLine("Yes")
            Else
                Console.WriteLine("No")
            End If
        End If


    End Sub

End Module



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

int main(){
  long long n,a,b;
  long long sum=0;
  cin>>n>>a>>b;
  long long tmp;
  tmp=n/(a+b);
  sum+=tmp*a;
  n=n-tmp*(a+b);
  if(n>=a){
    sum+=a;
  }else{
    sum+=n;
  }
  cout<<sum<<endl;
}


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	long long int n, a, b; cin>>n>>a>>b;
	a = n * a;
	cout<<min(a, b)<<endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v) reverse(v.begin(),v.end())
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }

void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define P pair<int,int>
#define Pll pair<ll,ll>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

struct UnionFind{
	vector<int> par; //データiが属する親の番号
	vector<int> sizes; //根ノードiの木に含まれるデータの数

	// 最初は全てのデータiがグループiに存在するものとして初期化
	UnionFind(int n):par(n),sizes(n, 1){
		REP(i,n) par[i] = i;
	}

	// 根を張り替えながら再帰的に根ノードを探す
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;  // sizes[y]は無意味な値となるため
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};
int gcd(int n,int m){
	if(m>n) return gcd(m,n);
	if(m==0) return n;
	else return gcd(m,n%m);
}

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

	int x,y,sum;
	sum=0;
	cin>>x>>y;

	switch(x){
		case 1:
			sum+=300000;
			break;
		case 2:
			sum+=200000;
			break;
		case 3:
			sum+=100000;
			break;
	}
	switch(y){
		case 1:
			sum+=300000;
			break;
		case 2:
			sum+=200000;
			break;
		case 3:
			sum+=100000;
			break;
	}
	if(x==1 && y==1) sum+=400000;

	print(sum);
	return 0;
}


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

using namespace std;

int main(){
    int N,Z,W;
    cin>>N>>Z>>W;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin>>a[i];

    int score = -1;

    if(N==1) score = abs(a[N-1]-W);
    else score = max(abs(a[N-1]-W),abs(a[N-2]-a[N-1]));

    cout<<score<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
	ios::sync_with_stdio(0), cin.tie(0);
	ll a, b, c;
	ll cnt = 0;
	cin >> a >> b >> c;
	ll k;
	cin >> k;
	while (b <= a) {
		b *= 2;
		cnt ++;
	}
	while (c <= b) {
		c *= 2;
		cnt ++;
	}
	cout << (cnt <= k ? "Yes" : "No");
}

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

int main() {
  int x;
  cin >> x;
  if(x <= x/100*100+x/100*5) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iX = int.Parse(sS[0]);
            int iT = int.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = iX - iT;
            if (iOut < 0) { iOut = 0; }

            //出力
            Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

int main() {
  int d;
  while (cin >> d) {
    int sum = 0;
    for (int i = 0; i < 600 / d; i++) {
      int x = i * d;
      sum += x * x * d;
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 0
from collections import Counter as C
n = int(input())
l = [input() for _ in range(n)]
c = C(l)
for k in ['AC', 'WA', 'TLE', 'RE']:
  if k not in c:
    print('{} x 0'.format(k))
  else:
    print('{} x {}'.format(k, c[k]))

Measured memory_bytes: 16624
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
long long T[200001];
/*
int ABS(int n){
	if(n<0) return (-1)*n;
	else return n;
}
*/
int main(){
	int N;
	long long add_all = 0;
	long long min_p = 1000000000000000000LL;
	
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> T[i];
		add_all += T[i]; 
	}
	long long left = 0;
	for(int i = 0; i <= N-2; i++){
		left += T[i];
		long long tmp = add_all-left-left;
		if(min_p > abs(tmp)) min_p = abs(tmp);

	}

	cout << min_p << endl;
}

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

int n,A[50];

int solve(int i, int m){
    if(m==0) return 1;
    if(i>=n) return 0;
    int res = solve(i+1,m) || solve(i+1,m-A[i]);
    //cout<<i<<","<<m<<":"<<res<<endl;
    return res;
}

int main(){
    int q,M,i;
    cin>>n;
    for(i=0;i<n;i++) cin>>A[i];
    cin>>q;
    for(i=0;i<q;i++){
        cin>>M;
        if(solve(0,M)) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
}


Measured memory_bytes: 3104