akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
   
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
def main():
    n,m = map(int,input().split())
    U = UnionFind(n)
    for _ in range(m):
        a,b = map(int,input().split())
        U.unite(a-1,b-1)
    
    d = Counter()
    for i in range(n):
        d[U.find(i)]+=1
    
    print(max(d.values()))
main()

Measured memory_bytes: 104476
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef pair<int, int> ii;

void Fastio() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0); 
}

const int mod = 1e9 + 7; 

int n, m, X, Vis[1005]; 
vector<ii> Adj[1005]; 
vector<pair<int, ii> > Edges; 
bool ok[2005]; 

ii p[1005]; 
int dsu[1005]; 
int pw[2005]; 

int Find(int x) {
	return (x == dsu[x] ? x : dsu[x] = Find(dsu[x])); 
}

bool Merge(int u, int v) {
	u = Find(u), v = Find(v); 
	if(u == v) {
		return false; 
	}
	dsu[u] = v; 
	return true; 
}

void dfs(int u) {
	for(auto T : Adj[u]) {
		int v = T.fi, w = T.se; 
		if(v != p[u].fi) {
			p[v] = {u, w}; 
			dfs(v); 
		}
	}
}

signed main()
{
	cin >> n >> m >> X; 
	for(int i = 1; i <= m; i++) {
		int u, v, w; 
		cin >> u >> v >> w;
		Edges.pb({w, {u, v}}); 
	}
	
	for(int i = 1; i <= n; i++) {
		dsu[i] = i; 
		Vis[i] = -1; 
	}
	
	int MST = 0; 
	sort(all(Edges)); 
	for(int i = 0; i < (int)Edges.size(); i++) {
		pair<int, ii> E = Edges[i]; 
		int w = E.fi, u = E.se.fi, v = E.se.se; 
		if(Merge(u, v)) {
			Adj[u].pb({v, w}); 
			Adj[v].pb({u, w}); 
			MST += w; 
			ok[i] = 1; 
		}
	}
	
//	cout << "MST: " << MST << '\n'; 
	
	int D = X - MST, dwn = 0, up = 0, eq = 0; 
	
	p[1] = {0, 0}; 
	dfs(1); 
	 
	for(int i = 0; i < m; i++) {
		if(!ok[i]) {
			int u = Edges[i].se.fi, v = Edges[i].se.se; 
			int w = Edges[i].fi; 
//			cout << u << ' ' << v << '\t'; 
			int mxw = 0; 
			vector<ii> Path;   
			while(u) 
				Vis[u] = i, Path.pb({u, p[u].se}), u = p[u].fi; 
			while(Vis[v] != i) 
				mxw = max(mxw, p[v].se), v = p[v].fi; 
			while(Path.back().fi != v) 
				Path.pop_back(); 
			Path.pop_back(); 
			for(auto T : Path) {
				mxw = max(mxw, T.se); 
			}
			
			int diff = w - mxw; 
			if(diff == D) eq++; 
//			cout << "mxw: " << mxw << ' ' << "diff: " << diff << '\n'; 
			if(diff < D) dwn++; 
			if(diff > D) up++; 
		}
	}
	
//	cout << "D, eq, dwn, up: " << D << ' ' << eq << ' ' << dwn << ' ' << up << '\n'; 
	pw[0] = 1; 
	for(int i = 1; i <= m; i++) {
		pw[i] = pw[i-1] * 2 % mod; 
	}
	
	int ret = 0;  
	if(D < 0) ret = 0; 
	else if(D == 0) {
		ret = (ret + (pw[n - 1] - 2) * pw[m - n + 1]) % mod;
		ret = (ret + 2 * (pw[eq] - 1) * pw[up]) % mod; 
	}
	else ret = 2 * (pw[eq] - 1) * pw[up] % mod; 
	
	cout << ret; 
}


	/*
8 11

100

1 2 1
1 3 4
2 3 7
2 4 3
2 5 6
3 6 5
5 6 2
4 7 8
5 7 4
5 8 5
6 8 3
	*/

Measured memory_bytes: 3856
#include "stdio.h"

int w[1111][1111][3];
int ww[100000][3];

int hen(char a)
{
	if(a == 'J')
	{
		return 0;
	}
	if(a == 'O')
	{
		return 1;
	}
	if(a == 'I')
	{
		return 2;
	}
}

int main()
{
	int m,n;
	int k;

	{
		scanf("%d %d",&m,&n);
		scanf("%d",&k);
	}

	{
		for(int i = 0; i < 1111; i++)
		{
			w[i][0][0] = 0;
			w[i][0][1] = 0;
			w[i][0][2] = 0;
			
			w[0][i][0] = 0;
			w[0][i][1] = 0;
			w[0][i][2] = 0;
		}
	}

	{
		char e[2000];
		for(int i = 1; i <= m; i++)
		{
			scanf("%s",e);
			for(int ii = 1; ii <= n; ii++)
			{
				w[i][ii][0] = w[i - 1][ii][0] + w[i][ii - 1][0] - w[i - 1][ii - 1][0];
				w[i][ii][1] = w[i - 1][ii][1] + w[i][ii - 1][1] - w[i - 1][ii - 1][1];
				w[i][ii][2] = w[i - 1][ii][2] + w[i][ii - 1][2] - w[i - 1][ii - 1][2];
				w[i][ii][hen(e[ii - 1])]++;
			}
		}
	}

	{
		int a,b,c,d;
		for(int i = 0; i < k; i++)
		{
			scanf("%d %d %d %d",&a,&b,&c,&d);
			ww[i][0] = w[c][d][0] + w[a - 1][b - 1][0] - w[c][b - 1][0] - w[a - 1][d][0];
			ww[i][1] = w[c][d][1] + w[a - 1][b - 1][1] - w[c][b - 1][1] - w[a - 1][d][1];
			ww[i][2] = w[c][d][2] + w[a - 1][b - 1][2] - w[c][b - 1][2] - w[a - 1][d][2];
		}
	}

	{
		for(int i = 0; i < k; i++)
		{
			printf("%d %d %d\n",ww[i][0],ww[i][1],ww[i][2]);
		}
	}

	return 0;
}

Measured memory_bytes: 15764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] ns = new long[n];
        long[] ans = new long[n];
        StringBuilder sb = new StringBuilder(2 * n + 1);
        for (int i = 0; i < n; i++) {
            ns[i] = sc.nextLong();
        }
        int end =  n - 1, start = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 2 == 1) {
                ans[start++] = ns[n-i];
            }
            else {
                ans[end--] = ns[n-i];
            }
        }
        for (long l: ans) {
            sb.append(l + " ");
        }
        System.out.println(sb.deleteCharAt(sb.length() - 1).toString());
    }
}


Measured memory_bytes: 97424
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	string a,b;
	getline(cin,a);
	getline(cin,b);
	sort(a.begin(),a.end());
	sort(b.begin(),b.end(),greater<char>());
	if(a<b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
 } 

Measured memory_bytes: 764
from bisect import bisect_left
s=input().split()
n,k=int(s[0]),int(s[1])
s=input().split()
l=[int(s[i]) for i in range(n)]
if min(l)>=0:
    print(l[k-1])
elif max(l)<=0:
    print(-l[-k])
else:
    ind=bisect_left(l,0)
    if l[ind]==0:
        k-=1
        del(l[ind])
    costr=[0]+l[ind:]
    lef=l[:ind]
    costl=[0]+[-lef[-i] for i in range(1,1+len(lef))]
    if k==0:
        print(0)
    else:
        res=10000000000000000000
        for i in range(len(costr)):
            if i>k:
                break
            nowcost=costr[i]*2
            if k-i<len(costl):
                res=min(res,nowcost+costl[k-i])
        for i in range(len(costl)):
            if i>k:
                break
            nowcost=costl[i]*2
            if k-i<len(costr):
                res=min(res,nowcost+costr[k-i])
        print(res)


Measured memory_bytes: 62576
#include<stdio.h>
int main(){
  int i,a,b;
  scanf("%d %d",&a,&b);
  for(i=0;i<=10000;i++){
    if((i*8)/100==a&&(i*10)/100==b){
      printf("%d\n",i);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
    


Measured memory_bytes: 128
using System;

class Program
{
    static void Main(string[] args)
    {
        var abx = Console.ReadLine().Split();
        var a = long.Parse(abx[0]);
        var b = long.Parse(abx[1]);
        var x = long.Parse(abx[2]);
        Console.WriteLine(f(b, x) - f(a - 1, x));
    }

    static long f(long n, long x)
    {
        return n < 0 ? 0 : n / x + 1;
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int m;
    cin >> m;
    cout << 48 - m << endl;
    return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  int count=0;
  for(int i=0;i<n;i++){
    count+=a[i];
  }
  int x=m-count;
  cout << x/a[0]+n << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>

int main() {
  std::vector<int> a(3);
  for (auto& ai: a) {
    scanf("%d", &ai);
    ai &= 1;
  }

  int res = std::accumulate(a.begin(), a.end(), 0);
  puts((res >= 2)? "Hom": "Tem");
}



Measured memory_bytes: 2680
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    int n, m; 
    cin >> n >> m;
    int ans = 0;
   
    for(int i = 1; i < n; i++){
        ans+= i;
    }
    for(int i = 1; i < m; i++){
        ans+=i;
    }

    
    cout << ans << endl;
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    vi x(n);
    rep(i, n) cin >> x[i];
    
    int ans = 0;
    rep(i, n) {
        ans += 2*min(x[i], k-x[i]);
    }
    cout << ans << endl;
}

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

using namespace std;

#define INF 1000007
#define MOD 998244353
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}
signed main()
{
    int A, B;
    cin >> A >> B;
    if (B % A == 0)
    {
        cout << A + B << endl;
    }
    else
    {
        cout << B - A << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct edge{int to,cost;};
typedef pair<int,int> P;
int V;
vector<edge> G[200001];
int mincost[200001],INF=1e9,used[200001]={0};
int prim(){
    priority_queue<P,vector<P>,greater<P> > que;
    fill(mincost,mincost+V,INF);
    mincost[0]=0;
    int res=0;
    que.push(P(0,0));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(used[v]) continue;
        res+=mincost[v];
        used[v]++;
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(mincost[e.to]>e.cost) mincost[e.to]=e.cost,que.push(P(mincost[e.to],e.to));
        }
    }
    return res;
}
int main(){
    int E,a,b,c;
    cin>>V>>E;
    rep(i,E) cin>>a>>b>>c,G[a].push_back({b,c}),G[b].push_back({a,c});
    cout<<prim()<<endl;
}


Measured memory_bytes: 10736
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
  int n, ori_n;
  cin >> n;
  ori_n = n;
  int s = 0;
  while (n > 0) {
    s += (n % 10);
    n /= 10;
  }
  if (ori_n % s == 0) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
typedef long long ll;
ll MOD=(ll)1e9+7;
ll qpow(ll a,ll b){return b?((b&1)?a*qpow(a*a%MOD,b>>1)%MOD:qpow(a*a%MOD,b>>1))%MOD:1;}
ll c(ll n,ll m){
    ll ret=1;
    if(n<m)return 0;
    rep(i,1,m){
        ret*=qpow(i,MOD-2);
        ret%=MOD;
        ret*=n-i+1;
        ret%=MOD;
    }
    return ret;
}
ll p(ll n,ll m){
    ll ret=1;
    if(n<m)return 0;
    rep(i,1,m){
        /* ret*=qpow(i,MOD-2);
        ret%=MOD; */
        ret*=n-i+1;
        ret%=MOD;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    cout<<p(k,n)<<endl;
}


Measured memory_bytes: 3204
#include<stdio.h>

int main(){
    int a, b, c, d;

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

    c = a + b;

    if(c%2){
        printf("IMPOSSIBLE\n");
    }
    else{
        d = c / 2;
        printf("%d\n", d);
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;

int main(){

	int N,Q;
	cin >> N >> Q;
	string S;
	cin >> S;

	vector<int> count(N+1,0);

	for (int i = 1; i < N; i++){
		if(S[i-1] == 'A' && S[i] == 'C'){
				count[i] = count[i-1] + 1;
		}
		else
			count[i] = count[i-1];
	}
	count[N] += count[N-1];


	vector<int> ans(Q,0);
	int l,r;

	for (int i = 0; i < Q; i++){
		cin >> l >> r;
		ans[i] = count[r-1] - count[l-1];
	}

	for (int i = 0; i < Q; i++){
		cout << ans[i] << "\n";
	}
	
	// cout << "count :";

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

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N=1000007,P=998244353;
int fac[N],ifac[N];
void swap(int &a,int &b){a^=b^=a^=b;}
int inc(int a,int b){a+=b;return a>=P? a-P:a;}
int mul(int a,int b){return 1ll*a*b%P;}
int power(int a,int k=P-2){int r=1;for(;k;k>>=1,a=mul(a,a))if(k&1)r=mul(a,r);return r;}
int C(int n,int m){return mul(mul(fac[n],ifac[m]),ifac[n-m]);}
int main()
{
    int i,n,m,ans=0;cin>>n>>m;if(n<m)swap(n,m);
    for(fac[0]=i=1;i<=n+m;++i) fac[i]=mul(fac[i-1],i);
    for(ifac[n+m]=power(fac[n+m]),i=n+m;i;--i) ifac[i-1]=mul(ifac[i],i);
    for(i=1;i<=m;++i) ans=inc(ans,mul(C(i+i,i),C(n+m-i-i,m-i)));
    return !printf("%d\n",inc(n,mul(mul(ans,power(C(n+m,n))),ifac[2])));
}

Measured memory_bytes: 8064
#include <stdio.h>
#define N 100000
#define NOT

int linearSearch(int [],int,int);


int main(){
  int count=0;
  int S[N],T[N],i,j,n,q;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }

  for(j=0;j<q;j++){
    
    if(linearSearch(S,n,T[j]) != 0){
	count++;
     
    }
  }
  
  printf("%d\n",count);

  return 0;
}
  
int linearSearch(int A[ ],int n,int key){
 int i=0;
  A[n] = key;

  while(A[i] != key){
    i++;
  }
  if(i==n) return 0;
  else return 1;

}
 




Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
const int INF=100000000;
bool g[10][10];
int main()
{
  int n,m;cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;a--;b--;
    g[a][b]=g[b][a]=true;
    //cout<<g[a][b]<<" "<<g[b][a]<<endl;
  }
  vector<int>ord(n);
  for(int i=0;i<n;i++)ord[i]=i;
  int res=0;
  do{
    if(ord[0]!=0)break;
    bool ok=true;
    for(int i=0;i+1<n;i++){
      int from=ord[i];
      int to=ord[i+1];
      if(!g[from][to])ok=false;
    }
    if(ok)res++;
  }while(next_permutation(ord.begin(),ord.end()));
  cout<<res<<endl;
}

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


string toUpper(string s){
    string t = s;
    for (int i = 0; i< s.size(); i++){
        t[i]=toupper(s[i]);
    }
    return t;
}

int main(){
    string target,source;
    
    cin >> target;
    target = toUpper(target);
    
    int cou =0;
    
    while(1){
        cin >> source;
        if (source =="END_OF_TEXT") break;
        source = toUpper(source);
        if (target == source) cou++ ;
    }
    
    cout << cou << endl;
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b;
	cin >> a >> b;
	int ans=0;
	if (a <= (a / 100) * 100 + (a / 1000 - (a / 10000) * 10) * 10 + a / 10000) {
		ans++;
	}
	if (b >= (b / 100) * 100 + (b / 1000 - (b / 10000) * 10) * 10 + b / 10000) {
		ans++;
	}
	ans += b / 100 - a / 100-1;
	cout << ans << endl;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
  int N,*A,*ans,M,l[31],count;
  for(int i=0;i<31;i++)l[i]=0;
  scanf("%d",&N);
  A=malloc(sizeof(int)*N);
  ans=malloc(sizeof(int)*N);
  count=0;
  M=0;
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
    if(M<A[i]) M=A[i];
  }
  while(M>0){
    int x=0;
    for(int i=0;i<N;i++) x+=(A[i]>>count&1);
    l[count]=x%2;
    count+=1;
    M=M/2;
  }
  for(int i=0;i<N;i++){
    int a,count;
    a=0;
    count=1;
    for(int j=0;j<31;j++){
      if(l[j]==0){
	if(A[i]>>j&1) a+=count;
      }
      if(l[j]==1){
	if(!(A[i]>>j&1)) a+=count;
      }
      count=count*2;
    }
    ans[i]=a;
  }
  printf("%d",ans[0]);
  for(int i=1;i<N;i++) printf(" %d",ans[i]);
  printf("\n");
  return 0;
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n;
ll a[100005], b[100005];
std::set<ll> s;
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> n;

    for (int i = 0; i <= n; ++i)
        std::cin >> a[i];
    for (int i = 0; i < n; ++i)
        std::cin >> b[i];

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        auto tmp = std::min(a[i], b[i]);
        ans += tmp;
        auto tmp2 = std::min(a[i + 1], b[i] - tmp);
        ans += tmp2;
        a[i + 1] -= tmp2;
    }

    std::cout << ans << std::endl;
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

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

  reverse(s.begin(), s.end());
  vector<int> mods(s.length(), 0);
  mods[0] = s[0] - '0';
  int digit = 10;
  for(int i = 1; i < s.length(); ++i)
  {
    mods[i] = (mods[i - 1] + (s[i] - '0') * digit) % 2019;
    digit *= 10;
    digit %= 2019;
  }
  map<ll, ll> mp;
  mp[0]++;
  for(const auto& v : mods)
  {
    mp[v]++;
  }

  ll ans = 0;
  for(const auto& m : mp)
  {
    ll v = m.second;
    ans += v * (v - 1) / 2;
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4376
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

    ll ans = 0;
    string s;
    ll q;
    cin >> s >> q;

    ll t, mode = 0;
    for (ll i = 0; i < q; i++) {
        cin >> t;
        if (t == 1) {
            mode = (mode+1) % 2;
        } else if (t == 2) {
            ll f;
            string c;
            cin >> f >> c;
            f = ((f-1) + mode) % 2;
            if (f == 0) {
                s.insert(0, c);
            }
            else {
                s.append(c);
            }
        }
    }

    if (mode) reverse(ALL(s));
    cout << s << endl;
}

Measured memory_bytes: 912
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ll long long
#define ld long double
#define fi first
#define se second
#define INF 1e18

const ll mod = 1000000000+7;
const int N = 100000+5;

vector<int> g[N];

ll dp[2][N];

void dfs(int x, int p)
{
	ll ans1 = 1;
	ll ans2 = 1;
	bool flag = true;
	for(auto it : g[x])
	{
		if(it == p)continue;
		dfs(it,x);
		flag = false;
		ans1 *= (dp[1][it] + dp[0][it]);
		ans2 *= (dp[0][it]);
		ans1 %= mod;
		ans2 %= mod;
	}
	dp[1][x] = ans2;
	dp[0][x] = ans1;
}

main()
{ 
	SPEED;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for(int i = 0; i<n-1; i++)
	{
		int u,v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	dfs(1,0);
	cout << (dp[0][1] + dp[1][1]) %mod << endl;
}

Measured memory_bytes: 14208
#include<iostream>
#include <math.h>
using namespace std;
 
int main()
{
    long long n;
    cin>>n;
    long long k=0;
    long long l=(long long)sqrt(n);
    if(n<=2){
      cout<<0;
      return 0;
    }
    for(long long m=1;m<=l;m++){
        if(n%m==0){
        	long long x=n/m;
            if(n%(x-1)!=0 && x*x!=n)k+=x-1;
        }
    	//if(n%m!=0 && n%(m+1)==0)k+=m;
    }
    
    cout <<k << endl;
    return 0;
}

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

using namespace std;

const int maxn=1e2+5;
const int inf=(1<<21);
const int white=0;
const int gray=1;
const int black=2;

int n,m[maxn][maxn];

void dijkstra()
{
    int minv,d[maxn],book[maxn];
    for(int i=0;i<n;i++){
        d[i]=inf;
        book[i]=0;
    }
    d[0]=0;
    while(1){
        minv=inf;
        int u=-1;
        for(int i=0;i<n;i++){
            if(minv>d[i]&&book[i]==0){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1){
            break;
        }
        book[u]=1;
        for(int v=0;v<n;v++){
            if(book[v]==0&&(d[v]>d[u]+m[u][v])){
                    d[v]=d[u]+m[u][v];
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<i<<" "<<(d[i]==inf?-1:d[i])<<endl;
    }
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            m[i][j]=inf;
        }
    }
    int u,k,v,c;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>v>>c;
            m[u][v]=c;
        }
    }
    dijkstra();
    return 0;
}
/*
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3 
*/


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n,k,sum=0;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	cout<<accumulate(a,a+k,sum);
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
// Function to find modulo inverse of a
ll dp[200005];
 ll gcdExtended(ll a, ll b, ll *x, ll *y)
    {
        // Base Case
        if (a == 0)
        {
            *x = 0, *y = 1;
            return b;
        }
 
        ll x1, y1; // To store results of recursive call
        ll gcd = gcdExtended(b%a, a, &x1, &y1);
 
 
        *x = y1 - (b/a) * x1;
        *y = x1;
 
        return gcd;
    }  
    ll modInverse(ll a, ll m)
    {
        ll x, y;
        ll g = gcdExtended(a, m, &x, &y);
 
        ll res = (x%m + m) % m;
        return res;
    }
    ll modularExponentiation(ll x,ll n,ll M)
   {
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

   }
int main()
{
    fastread;
    ll n,i,j,k,l,m;
    m=1000000007;
    cin>>n>>k;
    ll temp=((n%m)*((n-1)%m))%m;
    dp[1]=temp;
    ll sum=temp%m;
    ///cout<<sum<<endl;
    for(i=2;i<=min(n-1,k);i++){
    	ll kola1=(((n-i)%m)*(modInverse(i,m)))%m;
    	ll kola2=(((n-i+1)%m)*(modInverse(i,m)))%m;
    	ll kola=((kola1%m)*(kola2%m))%m;
    	dp[i]=((dp[i-1]%m)*(kola%m))%m;
    	///cout<<dp[i]<<endl;
    	sum=(sum+dp[i])%m;
	}
	cout<<(sum+1)%m;
    return 0;
}

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

int main()
{
  int A,P;cin>>A>>P;
  int kakera=A*3+P;
  
  int i = 0;
  while(2*i<=kakera)
  {
    i++; 
  }
  cout << i-1 << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: i32
    }

    solve(n);
}

fn solve(n: i32) {
    match n % 10 {
        2 => println!("hon"),
        4 => println!("hon"),
        5 => println!("hon"),
        7 => println!("hon"),
        9 => println!("hon"),
        0 => println!("pon"),
        1 => println!("pon"),
        6 => println!("pon"),
        8 => println!("pon"),
        _ => println!("bon"),
    }
}


Measured memory_bytes: 2112
<?php
  $s = trim(fgets(STDIN));
  $cnt = 0;
  for($i=0; $i<strlen($s); $i++){
      if($i > 0){
          if($pre != $s[$i]){
              $pre = $s[$i];
              $cnt++;
          }
      }else{
          $pre = $s[$i];
      }
  }
  echo $cnt;

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, h, j = 0, k = 0;
    bool dead = false;
    cin >> n >> h;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    for (int i = 0; i < n; i++) c[i] = b[n - 1 - i];
    for (int i = 0; i < n; i++)
    {
        if (c[i] < a[n - 1]) break;
        j += c[i];
        k++;
        if (j >= h)
        {
            dead = true;
            cout << k;
            break;
        }
    }
    if (dead == false)
    {
        h -= j;
        if (h % a[n - 1] == 0) cout << k + h / a[n - 1];
        else cout << k + h / a[n - 1] + 1;
    }
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n,k;
  string s;
  cin>>n>>k>>s;
  
 if( s.at(k-1)=='A'){
   s.at(k-1)='a';}
  else if(s.at(k-1)=='B'){
    s.at(k-1)='b';}
  else{s.at(k-1)='c';}
  
  cout<<s<<endl;
}


   
  

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(),B = sc.nextInt();
    int ans = A - B * 2;
    if (ans < 0) ans = 0;
    System.out.println(ans);
  }
}

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

int main(){
	string ss;
	int A=0,B=0,O=0,AB=0;
	while(cin>>ss){
		int cnt=0;
		for(int i=0;i<ss.size();i++){
			if(ss[i]==','){
				cnt=i;
				break;
			}
		}
		if((ss.size()-(cnt+1))>1){
			AB++;
		}else{
			if(ss[ss.size()-1]=='A')A++;
			else if(ss[ss.size()-1]=='B')B++;
			else O++;
		}
	}
	cout<<A<<endl;
	cout<<B<<endl;
	cout<<AB<<endl;
	cout<<O<<endl;
	return 0;
}

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

int compare_int(const void *a,const void *b){
	return *(int*)b - *(int*)a;
}
int main(void){
	int n,i;
	scanf("%d",&n);
	int d[n];
	for(i=0;i<n;i++){
		scanf("%d",&d[i]);
	}
	qsort(d,n,sizeof(int),compare_int);
	int ans = 1;
	for(i=1;i<n;i++){
		if(d[i]!=d[i-1])ans++;
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<p> v(m, {0, 0});
  for (int i = 0; i < m; i++)
  {
    cin >> v[i].first >> v[i].second;
  }

  vector<int> node(n, 0);
  for(int i = 0; i < n; i++) node[i] = i;
  int res = 0;

  do{
    if(node[0] != 0) continue;
    bool flag = true;
    // for(auto a : node)cout << a;
    // cout << endl;
    for (int i = 0; i < n-1; i++)
    {
      for (int j = 0; j < m; j++)
      {
        if((node[i] == v[j].first-1 && node[i+1] == v[j].second-1) || (node[i] == v[j].second-1 && node[i+1] == v[j].first-1))
          break;
        if(j == m-1) flag = false;
      }
    }
    if(flag) {
      res++;
      // for(auto a : node)cout << a;
    }
  } while(next_permutation(all(node)));

  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

int main()
{
	long long X;
	cin >> X;

	boost::multiprecision::cpp_int c = 100;
	int ans = 0;
	while (c < X) {
		c = c * 101 / 100;
		++ans;
	}
	cout << ans << endl;
}


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

int main(int qtd, char* nome[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

	int n;
	cin >> n;
	string ans = "No";
	for(int i=1; i <= 9; i++)
		for(int j = 1; j <= 9; j++)
			if(i*j == n){
				ans = "Yes";
				goto fim;
			}
	fim:
		cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
while 1:
    input_line = input()
    input_list = input_line.split()
    
    x = int(input_list[0])
    y = int(input_list[1])
    
    if x == 0 and y == 0 :
        break
    if x > y:
        print(str(y)+" "+str(x))
    else :
        print(str(x)+" "+str(y))


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 3005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n;

  cout << fixed << setprecision(10) << (ld)((n + 1) / 2) / n << endl;

  return 0;
}

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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int getLargestRectangle(vector<int>& hight) {
    int w = hight.size(),res = 0;
    stack<P> st;
    for (int i = 0;i < w;++i) {
        if (st.empty()) {
            if (hight[i]) st.push(P(hight[i],i));
        } else {
            int t = st.top().first;
            if (t < hight[i]) st.push(P(hight[i],i));
            else if (t > hight[i]) {
                int l = i;
                while (!st.empty() && hight[i] < st.top().first) {
                    P p = st.top();
                    l = p.second;
                    res = max(res,(p.first+1)*(i-l+1));
                    st.pop();
                }
                if (st.empty() || st.top().first < hight[i]) st.push(P(hight[i],l));
            }
        }
    }
    return res;
}

int getLargestRectangle(vector<vector<int>>& grid) {
    int h = grid.size(),w = grid[0].size();
    vector<vector<int>> hight(h,vector<int>(w));
    hight = grid;
    for (int j = 0;j < w;++j) for (int i = 1;i < h;++i) if (hight[i][j]) hight[i][j] += hight[i-1][j];
    for (int i = 0;i < h;++i) hight[i].emplace_back(0);
    int res = 0;
    for (int i = 0;i < h;++i) res = max(res,getLargestRectangle(hight[i]));
    return res;
}

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    vector<vector<int>> t(h-1,vector<int>(w-1,0));
    for (int i = 0;i < h;++i) cin >> s[i];
    for (int i = 0;i < h-1;++i) for (int j = 0;j < w;++j) s[i][j] = (s[i][j] == s[i+1][j] ? '.' : '#');
    for (int i = 0;i < h;++i) for (int j = 0;j < w-1;++j) s[i][j] = (s[i][j] == s[i][j+1] ? '.' : '#');
    for (int i = 0;i < h-1;++i) for (int j = 0;j < w-1;++j) t[i][j] = (s[i][j] == '.');
    int ans = getLargestRectangle(t);
    cout << max(max(h,w),ans) << endl;
    return 0;
}

Measured memory_bytes: 47488
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
#include <stack>
using namespace std;

const int MAXN = 12800;

int a[80][80];
bool dp[80][80][MAXN + 1];



int main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }

    int h, w;
    cin >> h >> w;
    for (int i = 0; i != h; ++i)
        for (int j = 0; j != w; ++j)
            cin >> a[i][j];
    for (int i = 0; i != h; ++i)
        for (int j = 0; j != w; ++j) {
            int b;
            cin >> b;
            a[i][j] = abs(a[i][j] - b);
        }
    dp[0][0][a[0][0]] = true;
    for (int i = 0; i != h; ++i)
        for (int j = 0; j != w; ++j)
            for (int k = 0; k <= MAXN; ++k)
                if (dp[i][j][k]) {
                    if (i < h - 1) {
                        int nv = abs(k - a[i + 1][j]);
                        dp[i + 1][j][nv] = true;
                        int nv2 = k + a[i + 1][j];
                        if (nv2 <= MAXN)
                            dp[i + 1][j][nv2] = true;
                        //cout << i << ' ' << j << ' ' << k << " -> " << i + 1 << ' ' << j << ' ' << nv << ' ' << nv2 << '\n';
                    }
                    if (j < w - 1) {
                        int nv = abs(k - a[i][j + 1]);
                        dp[i][j + 1][nv] = true;
                        int nv2 = k + a[i][j + 1];
                        if (nv2 <= MAXN)
                            dp[i][j + 1][nv2] = true;
                        //cout << i << ' ' << j << ' ' << k << " -> " << i << ' ' << j + 1 << ' ' << nv << ' ' << nv2 << '\n';
                    }
                }
    for (int k = 0; k <= MAXN; ++k)
        if (dp[h - 1][w - 1][k]) {
            cout << k;
            return 0;
        }
    return 0;
}

Measured memory_bytes: 79488
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define DEBUG

int main()
{
    int a;
    char s[10] = {};

    //read
    scanf("%d", &a);
    scanf("%s", s);

    //solve & write
    if(a >= 3200)
    {
        printf("%s\n", s);
    }
    else
    {
        printf("red\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

int x[10],y[10];

double dis (int i, int j){
    int dx = abs(x[i]-x[j]);
    int dy = abs(y[i]-y[j]);

    return  sqrt(dx*dx + dy*dy);
 }
 //あとで取る
 
 
int main(){
    int N;
    cin >> N;

    vector<int>X(N);
    rep(i,N)cin >> X[i];

    int sum = 1000000;
    rep(i,100){
        int hp = 0;
        rep(j,N){
            hp += pow(X[j]-i,2);
        }
        sum = min(sum,hp);

    }
    cout << sum << endl;



 
}

Measured memory_bytes: 3612
import math

a,b,x = map(int,input().split())

if a*a*b == x :
  print(0)
elif a*b/2 >= x/a :
  ax = 2*x/a/b
  print(math.degrees(math.atan(b/ax)))
else : 
  bx = 2*x/a/a - b
  print(90-math.degrees(math.atan(a/(b-bx))))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

const int N = 100'009;

vector<int> g[N];
int d[N][3];
int qv[3 * N];
int qs[3 * N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    g[i].clear();
  }
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    --y;
    g[x].push_back(y);
  }
  int from, to;
  scanf("%d%d", &from, &to);
  --from;
  --to;
  memset(d, -1, sizeof d);
  d[from][0] = 0;
  qv[0] = from;
  qs[0] = 0;
  for (int qh = 0, qt = 1; qh < qt; ++qh) {
    int x = qv[qh];
    int s = qs[qh];
    int ns = (s + 1) % 3;
    for (int y : g[x]) {
      if (d[y][ns] == -1) {
        d[y][ns] = d[x][s] + 1;
        qv[qt] = y;
        qs[qt] = ns;
        ++qt;
      }
    }
  }
  int ans = d[to][0];
  if (ans != -1) {
    ans /= 3;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

vector<int> solve(int N, int A, int B){
  vector<int> ret;

  if(B > N) return vector<int>();
  REP(i,1,B+1){
    ret.push_back(i);
  }
  reverse(ALLOF(ret));

  if(N-B < A-1) return vector<int>();
  if(A-1 == 0){
    if(ret.size() != N) return vector<int>();
    return ret;
  }
  vector<int> tmp(A-1);
  int x = (N-B)/(A-1);
  int y = (N-B)%(A-1);
  rep(i,tmp.size()) tmp[i] = x;
  rep(i,y) tmp[i]++;

  rep(i,tmp.size()){
    if(tmp[i]>B) return vector<int>();
  }
  int pos = N;
  vector<vector<int>> ret2;
  rep(i,tmp.size()){
    vector<int> tmp2;
    rep(j,tmp[i]) tmp2.push_back(pos--);
    ret2.push_back(tmp2);
  }
  reverse(ALLOF(ret2));
  rep(i,ret2.size()){
    rep(j,ret2[i].size()){
      ret.push_back(ret2[i][j]);
    }
  }

  if(ret.size() != N) return vector<int>();
  return ret;
}


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

  vector<int> ret = solve(N, A, B);

  if(ret.size() == 0){
    cout << -1 << endl;
  }else{
    rep(i,ret.size()){
      if(i>0) cout << " ";
      cout << ret[i];
    }
    cout << endl;
  }
  
  return 0;
}


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

typedef long long ll;
typedef long double ld;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
               
	string a,b,c;
	cin>>a>>b;
	
	c=a+b;
//	cout<<c;
	int cnum=0;
	for(int i=0;i<c.size();i++)
	{
		cnum*=10;
		int temp=c[i]-'0';
		cnum+=temp;
	}
	
	for(int i=0;i<2000;i++)
	{
		int n=i*i;
		if(cnum==n)
		{
			cout<<"Yes";
			return 0;
		}
	}
	
	cout<<"No";
		
				
	return 0;
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef vector<string> vs;
typedef vector<vs> vvs;

void chmaxs(string& s, string& t) {
	if(s.size() < t.size()) s = t;
}
 
int main() {
//	cout << fixed << setprecision(15);
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	vvs dp(2, vs(m+1));
	rep(i, n) rep(j, m) {
		int prev = i % 2, next = 1 - prev;
		chmaxs(dp[next][j+1], dp[prev][j+1]);
		chmaxs(dp[next][j+1], dp[next][j]);
		if(s[i] == t[j]) {
			string u = dp[prev][j] + s[i];
			chmaxs(dp[next][j+1], u);
		}
	}
	cout << dp[n % 2][m] << endl;
}


Measured memory_bytes: 8576
#include <iostream>
#include <stdio.h>
#define pi    3.141592653589
using namespace std;

int main(){
	double r, S, l;

	cin>>r;
	S = r * r * pi;
	l = 2 * r * pi;

	printf("%.6lf %.6lf\n", S, l);

	return 0;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {

    string s;
    cin >> s;
    rep(i,s.length()){
        if(i%2==0) cout << s[i];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 512
X = int(input())
a = []
c = []
if X % 2 == 1:
    while a == []:
        for i in range(3,X,2):
            b = X % i
            a.append(b)
        if 0 in a:
            a = []
            X += 1
        else:
            print(X)
elif X == 2:
    print(X)
else:
    X += 1
    while c == []:
        for i in range(3,X,2):
            d = X % i
            c.append(d)
        if 0 in c:
            c = []
            X += 1
        else:
            print(X)

Measured memory_bytes: 10828
x,y = map(int,input().split())
ans = 0
if(y > 0):
    if(x > y):
        ans += 1
        ans += -y +x
        ans += 1
    elif(x >= 0):
        ans += y -x
    elif(x > -y):
        ans += 1
        ans += y + x
    else:
        ans += 1
        ans += -y -x
else:
    if(x > -y):
        ans += 1
        ans += y + x
    elif(x >= 0):
        ans += 1
        ans += -y -x
    elif(x > y):
        ans += 1
        ans += -y +x
        ans += 1
    else:
        ans += y -x

if(x == 0 and y == 0):
    ans = 0
print(ans)
        
        

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip> 
#include <cstring>
#include <queue>
#include <stack> 
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
string s;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes" << endl;
	}else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
main = do
  [x,y] <- map read . words <$> getLine
  let g1 = [1,3,5,7,8,10,12]; g2 = [4,6,9,11]; g3 = [2]
  let gx = map (or . map (==x)) [g1,g2,g3]
  let gy = map (or . map (==y)) [g1,g2,g3]
  putStrLn $ if gx==gy then "Yes" else "No"

Measured memory_bytes: 3904
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	REP(i,N){
		int v=in();
		if(!(v%2)){
			if(v%3 && v%5){
				out("DENIED");
				return 0;
			}
		}
	}
	out("APPROVED");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

#define INF 2000000000
#define MAX_V 10

ll dp[110][110];


void warshall_floyd(ll n) {
    for (ll k = 0; k < n; k++){       // 経由する頂点
    for (ll i = 0; i < n; i++) {    // 始点
        if(dp[i][k]==INF) continue;
      for (ll j = 0; j < n; j++) {  // 終点
        if(dp[k][j]==INF) continue;
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
}

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

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

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    rep(i,110){
        rep(j,110){
            if(i==j) dp[i][j]=0;
            else dp[i][j]=INF;
        }
    }
    
    ll v,e;
    cin>>v>>e;
    rep(i,e){
        ll s,t,d;
        cin>>s>>t>>d;
        dp[s][t]=d;
    }
    warshall_floyd(v);
    rep(i,v) if(dp[i][i]<0){
        cout<<"NEGATIVE CYCLE"<<endl;
        return 0;
    }
    rep(i,v){
        rep(j,v){
            if(dp[i][j]==INF) cout<<"INF";
            else cout<<dp[i][j];
            if(j!=v-1) cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3304
package main

import "fmt"

func main() {
	N, R := read(), read()

	if N >= 10 {
		fmt.Println(R)
		return
	} else {
		fmt.Println(R + 1000 - 100*N)
	}
}

func read() int {
	var v int
	fmt.Scan(&v)
	return v
}


Measured memory_bytes: 512