akhauriyash/Code-Regression huggingface dataset:
n = int(input())
moji = str(input())
alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
lst = list(moji)
for i in range(len(lst)):
  num = alphabet.index(lst[i])
  if num + n >= 26:
    lst[i] = alphabet[num+n-26]
  else:
    lst[i] = alphabet[num+n]
ans = ""
for j in range(len(lst)):
  ans += lst[j]
print(ans)

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

using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    sort(a.begin(),a.end(),greater<>());
    ll m=0;
    for(int i=0;i<n;i++){
        m+=max(a[i]-i,0LL);
    }
    if(n==5){
        for(int i=1;i<=5;i++){
            if(i==5) m++;
            else if(a[i]!=3) break;
        }
        if(a[0]==3){
            for(int i=1;i<=5;i++){
                if(i==5) m++;
                else if(a[i]!=2) break;
            }
        }
    }
    if(n>=4){
        for(int i=0;i<=4;i++){
            if(i==4) m++;
            else if(a[i]!=2) break;
        }
    }
    cout<<m<<endl;
    
    
    return 0;
}


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

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

    long long a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k <= a+b) {
        cout << min(a, k);
        return 0;
    }

    long long rem = k - a - b;
    cout << a - rem;


    return 0;
}


Measured memory_bytes: 3648
X = gets.to_i
result = 0

if (100..105).any? { |a| X % a == 0 }
    result = 1
end

if result == 0
    ((X / 105)..(X / 100)).each do |i|
        n = X - 100 * i
        next if n > 5 * i
  
        5.step(1, -1) do |j|
            next if j > n
            k = n / j
            
            n -= j * k
            i -= k
            
            if n == 0
                result = 1
                break
            end
        end
  
        break if result == 1
    end
end

puts result

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

using namespace std;

int gcd(int a,int b)
{
    if(b == 0 || a == b)
        return a;
    else
        return gcd(b,a%b);
}
int lcm(int a, int b)
{
    int g = gcd(a,b);
    return (a / g) * b;
}

int main() {
    int a,b;
    while (cin >> a >> b) {
        cout << gcd(a,b) << " " << lcm(a,b) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 2984
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int b[1234];
vi vec;
int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
  	int n;
  	cin>>n;
  	int i;
  	f(i,1,n+1){
  		cin>>b[i];
  	}
  	int j,k,flag=0;
  	fd(i,n,1){
  		flag=0;
  		fd(j,i,1){
  			if(b[j]==j){
  				flag=1;
  				vec.pb(j);
  				break;
  			}
  		}
  		if(!flag){
  			cout<<-1<<endl;
  			return 0;
  		}
  		f(k,j,i){
  			b[k]=b[k+1];	
  		}
  	}
  	fd(i,vec.size()-1,0){
  		cout<<vec[i]<<endl;
  	}	

    return 0;   
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

hp = max(l)

l.sort()

while hp > 1 and len(l) != 1:
    a = l[0]
    for i in range(1, len(l)):
        l[i] %= a
    l.sort()
    while l[0] == 0:
        l.remove(0)
    if l[0] < hp:
        hp = l[0]

print(hp)

Measured memory_bytes: 14224
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	map<char, string> s;
	cin >> s['a'] >> s['b'] >> s['c'];
	map<char, int> i;
	i['a'] = 0, i['b'] = 0, i['c'] = 0;
	char turn = 'a';
	while(true) {
		if(i[turn] == s[turn].size()) break;
		i[turn]++;
		turn = s[turn][i[turn] - 1];
	}
	cout << (char)(turn - 'a' + 'A') << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;

//String With Rings
public class Main{

	List<Integer>[] e;
	int res;
	boolean[] v;
	
	void dfs(int k, int d){
		res = Math.max(res, d);
		for(int x:e[k])if(!v[x]){
			v[x] = true;
			dfs(x, d+1);
			v[x] = false;
		}
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		Random rand = new Random(1334259345907L);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			e = new List[101];
			for(int i=1;i<101;i++)e[i]=new ArrayList<Integer>();
			boolean[] u = new boolean[101];
			while(n--!=0){
				int a = sc.nextInt(), b = sc.nextInt();
				u[a] = u[b] = true;
				e[a].add(b); e[b].add(a);
			}
			v = new boolean[101];
			res = 0;
			int[] a = new int[100];
			int id = 0;
			for(int i=1;i<101;i++)if(!e[i].isEmpty())a[id++] = i;
			Set<Integer> U = new HashSet<Integer>();
			for(int i=0;i<=id/3;i++){
				Arrays.fill(v, false);
				int s = rand.nextInt(id);
				while(U.contains(s))s = rand.nextInt(id);
				v[a[s]] = true;
				dfs(a[s], 1);
			}
			System.out.println(res);
		}
	}

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

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

using namespace std;
typedef long long LL;


int n;
struct po
{
	int i;
	int k;
}a[200005];
bool cmp(po x,po y)
{
	return x.k < y.k;
}
bool ccc(po x,po y)
{
	return x.i < y.i;
}


int main()
{
	cin >> n;
	for(int i = 1;i <= n;i++)
	{
		scanf("%d",&a[i].k);
		a[i].i = i;
	}
	sort(a + 1,a + 1 + n,cmp);
	int m1 = a[n / 2 + 1].k;
	int m2 = a[n / 2 ].k;
	sort(a + 1,a + 1 + n,ccc);
		for(int i = 1; i <= n; i++)
	{
		if(a[i].k > m2)
			printf("%d\n", m2);
		else
			printf("%d\n", m1);
	}
}


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

int N;
vector<int> a;

int main () {
  cin >> N;
  a = vector<int>(N);

  int ans = 0;
  rep(i,N) {
    cin >> a[i];
    ans ^= a[i];
  }

  cout << (ans == 0 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

#define INF 0x7fffffff

using namespace std;

struct edge{
	int to, D, E;
	edge(int t, int d, int e){
		to = t;
		D = d;
		E = e;
	}
};


int main(){
	int N, M, L, A, B, D, E;

	while( cin>>N>>M>>L, N|M|L ){
		priority_queue<pair<int, pair<int,int> >,vector<pair<int, pair<int, int> > >,greater<pair<int,pair<int,int> > > > que;
		vector<edge> v[105];
		int dh[105][105];
		for(int i=0; i<M; i++){
			cin >> A >> B >> D >> E;
			v[A].push_back( edge(B, D, E) );
			v[B].push_back( edge(A, D, E) );
		}
		fill(dh[0], dh[0]+105*105, INF);
		
		que.push( make_pair(0, make_pair(1,L)) );
		while( !que.empty() ){
			pair<int, pair<int,int> > P = que.top();
			que.pop();
			int Psf = P.second.first, Pss = P.second.second;
			if( P.first < dh[Psf][Pss] ){
				dh[Psf][Pss] = P.first;
				for(int i=0; i<v[Psf].size(); i++){
					edge e = v[Psf][i];
					que.push( make_pair(P.first + e.E, make_pair(e.to, Pss)) );
					if( e.D <= Pss ){
						que.push( make_pair(P.first, make_pair(e.to, Pss-e.D)) );
					}
				}
			}
		}

		int ans = INF;
		for(int i=0; i<=L; i++)
			ans = min(ans, dh[N][i]);

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

Measured memory_bytes: 11100
#include <iostream>
#include <map>

#define debug(x) cout << #x << "==" << x << endl;

using namespace std;

//??\???

int conv(string s) {
  string hh="", mm="", ss="";
  hh += s[0]; hh += s[1];
  mm += s[3]; mm += s[4];
  ss += s[6]; ss += s[7];

  return stoi(hh) * 60 * 60 + stoi(mm) * 60 + stoi(ss);
}

int main() {
  ios::sync_with_stdio(false);

  int N;
  while(cin >> N) {

    if(N == 0) break;

    map<int,int> imos;
    for(int i = 0; i < N; i++) {
      string s1, s2;
      cin >> s1 >> s2;
      imos[ conv(s1) ] += 1;
      imos[ conv(s2) ] -= 1;
    }

    int mx = 0, num = 0;
    for(map<int,int>::iterator it = imos.begin(); it != imos.end(); it++) {
      num += (it -> second);
      mx = max(mx, num);
    }
    cout << mx << endl;
  }

  return 0;
}

Measured memory_bytes: 4000
#include <iostream>

using namespace std;

int arr[10];

int main() {
  string s;
  cin >> s;
  bool ans = false;
  for (int i = 0; i < 2; ++i) {
    if (s[i] == s[i + 1] && s[i + 1] == s[i + 2]) ans = true;
  }
  if (ans) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int A,B;

    cin >>A >> B;

    Int ans1, ans2, ans3;

    ans1 = A+B;
    ans2 = A-B;
    ans3 = A*B;

    cout << max(ans1,max(ans2,ans3)) << endl;






    return 0;
}

Measured memory_bytes: 256
n,q = map(int, input().split())
s= input()
counter = 0
countlist = [0, 0]

for i in range(1, n):
    if s[i] == "C" and s[i - 1] == "A":
        counter += 1
    countlist += [counter]

for i in range(q):
    l, r = map(int, input().split())
    print(countlist[r] - countlist[l])

Measured memory_bytes: 6096
N = int(input())
H = list(map(int, input().split()))
table = [0 for _ in range(N)]
max_moves = 0

for i in range(-2, -N-1, -1):
    if H[i] >= H[i+1]:
        table[i] = table[i+1] + 1
        max_moves = max(table[i], max_moves)

print(max_moves)


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

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

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

int main(){
  vector<vector<int>> C(3, vector<int>(3));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> C.at(i).at(j);
    }
  }

  vector<int> A(3);
  vector<int> B(3);
  for(int i=0; i<3; i++){
    int it = min(C.at(i).at(0), C.at(i).at(1));
    A.at(i) = min(it, C.at(i).at(2));
  }
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      C.at(i).at(j) -= A.at(i);
    }
  }  
  for(int i=0; i<3; i++){
    int it = min(C.at(0).at(i), C.at(1).at(i));
    B.at(i) = min(it, C.at(2).at(i));
  }
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      C.at(i).at(j) -= B.at(j);
    }
  }

  int sum = 0;
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      sum += C.at(i).at(j);
    }
  }
  
  if(sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  string a;
  cin >> a;
  ll n = a.size();
  

  vector<ll> alph(26, 0);
  ll ans = 0;
  for (int i = n-1; i >= 0; i--){
    ans += (n - 1 - i - alph[a[i]-'a']);
    alph[a[i]-'a']++;
  }

  ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    string s;
    cin >> s;
    int n = s.size();
    int mi = 999999999;
    rep(i, n-2) {
        int x = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
        mi = min(mi, abs(x-753));
    }
    cout << mi;
}



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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b;
    cin>>a>>b;
    int diff = b-a;
    int sum = 0;
    
    for(int i = 0; i < diff; i++)
    {
        sum+=i;
    }
    cout<<sum-a<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
int main(){
    l n,b=1,c=0;
    cin>>n;
    l a[n];
    for(l i=0;i<n;i++){
        cin>>a[i];
        if(i){
            if(a[i]==a[i-1]) b++;
            else{
                c+=b/2;
                b=1;
            }
        }
    }
    c+=b/2;
    cout<<c<<endl;
    return 0;
}
    

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

bool solve(){
    int b, r, g, c, s, t;
    cin >> b >> r >> g >> c >> s >> t;
    if(t==0) return false;
    int ans = 100;
    int bt = b*5+r*3;
    ans += 15*(bt+b+r);
    ans += 7*g+2*c;
    ans -= 2*bt;
    t -= s+bt;
    ans -= t*3;
    cout << ans << endl;
    return true;
}

int main() {
    while(solve());
    return 0;
}



Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
struct edge {
  int to;
  ll cost;
  edge(int to, ll cost) : to(to), cost(cost) {}
};
vector<vector<edge> > G;
vector<bool> vis;
vector<ll> D;
vector<int> leaves;
int N, u, v;
class LCA {
public:
  int V, logV;
  vector<int> depth, len;
  vector<vector<int> > parent; // parent[i][v]: ノードvの(i+1)個上の親
  LCA(int V) {
    this->V = V;
    logV = 0;
    while (V > (1LL<<logV)) logV++;
    this->depth = vector<int>(V);
    this->len = vector<int>(V);
    this->parent = vector<vector<int> >(logV, vector<int>(V));
  }
  void init(int v, int par, int d, int l) {
    depth[v] = d;       // rootからの深さ
    parent[0][v] = par; // 親
    len[v] = l;         // rootからの距離
    for (int i = 0; i < (int)G[v].size(); i++) {
      int w = G[v][i].to;   // 子ノード
      int lc = G[v][i].cost; // 子ノードとの距離
      if (w == par) continue;
      init(w, v, d+1, lc + l);
    }
  }
  void build() {
    for (int k = 0; k + 1 < logV; k++) {
      for (int v = 0; v < V; v++) {
        if (parent[k][v] < 0) parent[k+1][v] = -1;
        else parent[k+1][v] = parent[k][parent[k][v]];
      }
    }
  }
  int query(int u, int v) {
    if (depth[u] > depth[v]) swap(u, v);
    for (int k = 0; k < logV; k++) {
      if ((depth[v] - depth[u]) >> k & 1)
        v = parent[k][v];
    }
    if (u == v) return u;
    for (int k = logV-1; k >= 0; k--) {
      if (parent[k][u] != parent[k][v]) {
        u = parent[k][u];
        v = parent[k][v];
      }
    }
    return parent[0][u];
  }
};
void dfs(int tmp, int par, ll cost) {
  if(!vis[tmp]) {
    if(par != -1) {
      D[tmp] = D[par] + cost;
    }
    vis[tmp] = true;
    for(auto ne: G[tmp])
      dfs(ne.to, tmp, ne.cost);
    if(G[tmp].size()-1==0) leaves.push_back(tmp);
  }
}
int main() {
  cin >> N >> u >> v;
  u--; v--;
  G = vector<vector<edge> >(N);
  vis = vector<bool>(N);
  D = vector<ll>(N);
  vector<int> A(N-1), B(N-1);
  rep(i, N-1) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
    G[A[i]].push_back(edge(B[i], 1));
    G[B[i]].push_back(edge(A[i], 1));
  }
  LCA lca(N);
  lca.init(v, -1, 0, 0);
  lca.build();
  D[v] = 0;
  dfs(v, -1, 0);
  ll ans = 0;
  for(int l: leaves) {
    if(l == v) continue;
    int z = lca.query(u, l);
    if(2 * D[z] - D[u] >= 0) {
      ans = max(D[l]-1, ans);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 20984
W, H, x, y = map(int, input().split())

if (x == 0 and y == 0) or (x == W and y == H) or (x == W and y == 0) or (x == 0 and y == H):
    print('{:.6f} {}'.format(W * H * 0.5, 0))
elif (W == H and x == y) and (x != W / 2 and y != H / 2):
    print('{:.6f} {}'.format(W * H * 0.5, 0))
elif (W == H and x == y) and (x == W / 2 and y == H / 2):
    print('{:.6f} {}'.format(W * H * 0.5, 1))
elif W == H and (x != W / 2 or y != H / 2):
    print('{:.6f} {}'.format(W * H * 0.5, 0))
else:
    x_list = [H * x, H * (W - x)]
    y_list = [y * W, (H - y) * W]

    x_min = min(x_list)
    y_min = min(y_list)

    if x_min > y_min:
        print('{:.6f} {}'.format(x_min, 0))
    elif x_min < y_min:
        print('{:.6f} {}'.format(y_min, 0))
    elif x_min == y_min:
        print('{:.6f} {}'.format(y_min, 1))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define maxN 1000001
#define mod 1000000007
#define maxLL 1000000000000000000
#define PI 3.14159265358979323846264338327950L
typedef long long ll;

bool compared(int a,int b){
	return a < b;
}

int cmp(const void *a,const void *b){
	return(*(int*)b - *(int*)a);
}

int GCD(int a,int b){
	return b?GCD(b,a%b):a;
}

int main(){
	int n,k;
	cin>>n>>k;
	int a[n] = {0};
	for(int i=0;i<k;i++){
		int d;
		cin>>d;
		for(int j=0;j<d;j++){
			int ai;
			cin>>ai;
			a[ai-1] = 1;
		}
	}
	int res = 0;
	for(int i=0;i<n;i++){
		if(a[i] == 0){
			res++;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  ll x;
  cin>>x;
  cout << x / 500 *1000 + (x%500)/5 *5<< endl;
  return 0;
}



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

#define int long long
#define MAX_N (200005)
#define INF (1LL<<60)
#define EPS (1e-7)
#define DEBUG(x) cerr << #x <<":"<< x << endl;
#define DEBUGVC(x) cerr << #x <<": "; for(auto p:(x)) cerr << p <<" "; cerr << endl;
#define DEBUGVCP(x) for(auto p:(x)) cerr << #x <<": "<< p.first <<", "<< p.second << endl;
#define DEBUG2(x, y) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y << endl;
#define DEBUG3(x, y, z) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y <<", "<< #z <<" : "<< z << endl;
const int MOD = (int)1e9+7;

// 約数の列挙O(√n)
vector<int> divisor(int n){
    vector<int> res;
    for(int i=1; i*i<=n; i++){
        if(n%i==0){
            res.push_back(i);
            // n の約数が i の時、n/i も n の約数になる
            if(i!=n/i) res.push_back(n/i);
        }
    }
    return res;
}

signed main() {
    int N;
    cin >> N;

    vector<int> div = divisor(N);

    int ans=0;
    for(int i=0; i<div.size(); i++){
        int d = div[i];
        if((N-d)%d==0){
            int m = (N-d)/d;
            //DEBUG(m);
            if(m==0) continue;
            if(N/m == d){
                ans += m;
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(sc.hasNextLine()){
            String data[] = sc.nextLine().split(",");
            int number = Integer.parseInt(data[0]);
            double weight = Double.parseDouble(data[1]);
            double height = Double.parseDouble(data[2]);
            double bmi = weight / Math.pow(height, 2);
            if(bmi >= 25){
                System.out.println(data[0]);
                
            }
        }
    }
}


Measured memory_bytes: 26148
from bisect import bisect_left

INF = 10 ** 9

N = int(input())
As = list(map(int, input().split()))

adj = [[] for _ in range(N)]
for _ in range(N-1):
    u, v = map(int, input().split())
    adj[u-1].append(v-1)
    adj[v-1].append(u-1)

ans = [0] * N
LIS = [INF] * (N+1)
rewinder = []

parent = [-1] * N
stack = [0]
while stack:
    node = stack.pop()
    for next_node in adj[node]:
        if ans[next_node] == 0:
            parent[next_node] = node
            stack.append(next_node)

    while rewinder and rewinder[-1][0] != parent[node]:
        _, index, prev_value = rewinder.pop()
        LIS[index] = prev_value
    
    index = bisect_left(LIS, As[node])
    rewinder.append((node, index, LIS[index]))
    LIS[index] = As[node]

    ans[node] = bisect_left(LIS, INF)

print(*ans, sep = '\n')

Measured memory_bytes: 155064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
static ll c[(ll)1e7];
int main(void){
    // Your code here!
    ll n;
    cin>>n;
    rep(0,i,n+1)c[i]=0;
    rep(1,i,n+1){
        for(ll j=1;i*j<=n;++j){
            ++c[j*i];
        }
    }
    ll ans=0;
    rep(1,i,n+1){
        //cout<<c[i]<<endl;
        ans+=i*c[i];
    }
    cout<<ans;
}


Measured memory_bytes: 81796
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int A = int.Parse(Console.ReadLine());
		int n = 333;
		int ct = 0;
		while(true){
			//Console.WriteLine(n);
			if(n%10==3 || n%10==5){
				n += 2;
			} else {
				if(n/10%10!=7){
					n += 16;
				} else {
					if(n/100%10!=7){
						n += 156;
					} else {
						if(n/1000%10==0){
							n += 2556;
						} else if(n/1000%10==3 || n/1000%10 == 5){
							n += 1556;
						} else {
							if(n/10000%10==0){
								n += 25556;
							} else if(n/10000%10==3 || n/10000%10 == 5){
								n += 15556;
							} else {
								if(n/100000%10==0){
									n += 255556;
								} else if(n/100000%10==3 || n/100000%10 == 5){
									n += 155556;
								} else {
									if(n/1000000%10==0){
										n += 2555556;
									} else if(n/1000000%10==3 || n/1000000%10 == 5){
										n += 1555556;
									} else {
										if(n/10000000%10==0){
											n += 25555556;
										} else if(n/10000000%10==3 || n/10000000%10 == 5){
											n += 15555556;
										} else {
											if(n/100000000%10==0){
												n += 255555556;
											} else if(n/100000000%10==3 || n/100000000%10 == 5){
												n += 155555556;
											} else {
												n = 1000000000;
											}
										}
									}
								}
							}
						}
					}
				}
			}
			if(n>A){
				break;
			}
			int ct3 = 0;
			int ct5 = 0;
			int ct7 = 0;
			int na = n;
			for(var i=0;i<=9;i++){
				if(na/(int)Math.Pow(10,i)%10==3){
					ct3 += 1;
				}
				if(na/(int)Math.Pow(10,i)%10==5){
					ct5 += 1;
				}
				if(na/(int)Math.Pow(10,i)%10==7){
					ct7 += 1;
				}
			}
			if(ct3>0&&ct5>0&&ct7>0){
				ct += 1;
				//Console.WriteLine(n+"a");
			}
		}
		Console.WriteLine(ct);
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<int>> A(H,vector<int>(W)), B(H,vector<int>(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++){
      cin >> B[i][j];
    }
  }
  vector<vector<int>> D(H,vector<int>(W));
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      D[i][j] = abs(A[i][j]-B[i][j]);
    }
  }
  int m = 80*(H+W+1);
  vector<vector<vector<bool>>> DP(H,vector<vector<bool>>(W,vector<bool>(m+1,false)));
  DP[0][0][D[0][0]]=true;
  for (int i = 1; i < H; i++){
    for (int k = 0; k <= m; k++){
      if (DP[i-1][0][k]){
        if (k+D[i][0]<=m) DP[i][0][k+D[i][0]]=true;
        if (abs(k-D[i][0])<=m) DP[i][0][abs(k-D[i][0])]=true;
      }
    }
  }
  for (int j = 1; j < W; j++){
    for (int k = 0; k <= m; k++){
      if (DP[0][j-1][k]){
        if (k+D[0][j]<=m) DP[0][j][k+D[0][j]]=true;
        if (abs(k-D[0][j])<=m) DP[0][j][abs(k-D[0][j])]=true;
      }
    }
  }
  for (int i = 1; i < H; i++){
    for (int j = 1; j < W; j++){
      for (int k = 0; k <= m; k++){
        if (DP[i][j-1][k]){
          if (k+D[i][j]<=m) DP[i][j][k+D[i][j]]=true;
          if (abs(k-D[i][j])<=m) DP[i][j][abs(k-D[i][j])]=true;
        }
      }
      for (int k = 0; k <= m; k++){
        if (DP[i-1][j][k]){
          if (k+D[i][j]<=m) DP[i][j][k+D[i][j]]=true;
          if (abs(k-D[i][j])<=m) DP[i][j][abs(k-D[i][j])]=true;
        }
      }
    }
  }
  int i = 0;
  while (!DP[H-1][W-1][i]) i++;
  cout << i;
}

Measured memory_bytes: 10880
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	int a, b, k,ans;
	cin >> a >> b >> k;
	int temp = max(a, b);
	
	int count = 0;
	for(int i = temp; i>= 0; i--) {
		if (a%i == 0 && b%i == 0)count++;
		if (count == k) {
			ans = i; break;
		}
	}
	cout << ans << endl;


	system("pause");
	return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 1<<20

using namespace std;

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

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};

char grid[52][52];
int dist[52][52];

bool bfs(int srow, int scol, int erow, int ecol){
	for (int i = 0; i <= erow + 1; ++i){
		for (int j = 0; j <= ecol + 1; ++j){
			dist[i][j] = INF;
		} // end for
	} // end for

	queue<P> que;
	que.push(P(srow, scol));
	dist[srow][scol] = 0;

	while(!que.empty()){
		P curr = que.front(); que.pop();
		int crow = curr.first;
		int ccol = curr.second;
		if (crow == erow && ccol == ecol){
			return true;
		} // end if

		rep (k, 4){
			int nrow = crow + dr[k];
			int ncol = ccol + dc[k];
			if (grid[nrow][ncol] == '#') continue;
			if (dist[nrow][ncol] == INF){
				que.push(P(nrow, ncol));
				dist[nrow][ncol] = dist[crow][ccol] + 1;
			} // end if
		} // end rep	
	} // end while
	return false;
}

void dispGrid(int H, int W){
	for (int i = 1; i <= H; ++i){
		for (int j = 1; j <= W; ++j){
			cerr << grid[i][j];
		} // end for
		cerr << endl;
	} // end for
}

void dispDist(int H, int W){
	for (int i = 1; i <= H; ++i){
		for (int j = 1; j <= W; ++j){
			cerr << setw(2) << dist[i][j];
		} // end for
		cerr << endl;
	} // end for
}

void reversePath(int erow, int ecol){
	int crow = erow;
	int ccol = ecol;
	while(crow != 1 || ccol != 1){
		grid[crow][ccol] = ' ';
		rep (k, 4){
			int nrow = crow + dr[k];
			int ncol = ccol + dc[k];
			if (dist[nrow][ncol] + 1 == dist[crow][ccol]){
				crow = nrow;
				ccol = ncol;
				break;
			} // end if
		} // end rep
	} // end while
	grid[1][1] = ' ';
}

int countPaintBlack(int H, int W){
	int res = 0;
	for (int i = 1; i <= H; ++i){
		for (int j = 1; j <= W; ++j){
			if (grid[i][j] == '.') ++res;
		} // end for
	} // end for
	return res;
}

int main()
{
	memset(grid, 0, sizeof(grid));
	memset(dist, -1, sizeof(dist));
	rep (i, 52) rep (j, 52) grid[i][j] = '#';
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int H, W; cin >> H >> W;
	for (int i = 1; i <= H; ++i){
		for (int j = 1; j <= W; ++j){
			cin >> grid[i][j];
		} // end for
	} // end for

	int srow = 1, scol = 1;
	int erow = H, ecol = W;
	bool ans = bfs(srow, scol, erow, ecol);
	int res = -1;
	if (ans == true){
		reversePath(erow, ecol);
		res = countPaintBlack(H, W);
	} // end if

//	dispGrid(H, W);
//	dispDist(H, W);

	cout << res << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
const int N=2e5+5;
int main()
{
    int a[N],n,dp[N];
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i],dp[i]=0;
    int ma=1;
    for(int i=0;i<n;i++)
    {
        dp[a[i]]=dp[a[i]-1]+1;
        ma=max(ma,dp[a[i]]);
    }
    cout << n-ma << endl;
}


Measured memory_bytes: 1792
N = int(input())
# 仮に青木さん(B)が全て食べたとき、高橋(A)にとっては最悪な状況
# これを打破するためには、自分の得点と相手の得るはずだった得点の和を最大にするようなものについて食べれば良い
# 青木さんも同じことを考えるので、要は幸福度の和をソートして交互に食べていけば、互いに最善の行動を取ることとなる。
# 答えを出す際には、AがBから何点奪ったかだけを考えればよい。
# つまり、Aが最善で何点奪えるか　から　全てBさんが食べたとき　を引けばいい

sum_happiness = []
all_for_B = 0

for i in range(N):
    tmp1, tmp2 = list(map(int, input().split()))
    sum_happiness.append(tmp1 + tmp2)
    all_for_B += tmp2

sum_happiness.sort(reverse=True)


gain_A = 0
for i, h in enumerate(sum_happiness):
    if i % 2 == 0:
        gain_A += h
    # print(gain_A)


print(gain_A - all_for_B)


Measured memory_bytes: 7512
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;



int main(){
    map<pii, int> cnt;
    ll H, W, N;
    cin >> H >> W >> N;
    ll ALL = (H-2) * (W-2);
    int a, b;
    rep(i,N){
        cin >> a >> b;
        repf(x,-2,1){
            repf(y,-2,1){
                if (a+x>=1 && a+x<=H-2 && b+y>=1 && b+y<=W-2){
                    cnt[mp(a + x, b + y)] += 1;
                }
            }
        }
    }
    vector<ll> ans(10);
    ans[0] = ALL;
    for (auto itr = cnt.begin(); itr != cnt.end();itr++){
        pair<pii, int> p = *itr;
        //cout << p.first.first << " " << p.first.second <<" " << p.second<< endl;
        ans[0]--;
        ans[p.second]++;
    }
    rep(i,10){
        cout << ans[i] << endl;
    }
}


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

int main(){
	int n, m;
	cin >> n >> m;
	cout << max(n-m, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
//#include <cmath>
#include <cstdlib>
 
using namespace std;
 
int main(){
 
    string n;
    cin >> n;
 
    int a = 700;
    if(n[0] == 'o')a += 100;
    if(n[1] == 'o')a += 100;
    if(n[2] == 'o')a += 100;
 
    cout << a;
    return 0;
}

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

using namespace std;

int n,m;
char a[55][55],b[55][55];

int cheak(int ni,int nj){

    for(int i = 0;i < m;i++){
        for(int j = 0;j < m;j++){
            if(a[ni+i][nj+j] != b[i][j])return 0;
        }    
    }

    return 1;
}
string func(){
    int ans = 0;

    for(int i = 0;i < n-m+1;i++){
        for(int j = 0;j < n-m+1;j++){
            if(cheak(i,j))return "Yes";
        }    
    }
    return "No";
}
int main(){

    cin >> n >> m;

    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            cin >> a[i][j];
        }    
    }
    for(int i = 0;i < m;i++){
        for(int j = 0;j < m;j++){
            cin >> b[i][j];
        }    
    }

    cout << func() <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    int sum = accumulate(ALL(v),0);
    int m; cin >> m;
    REP(i,m) {
        int p,x;
        cin >> p >> x;
        p--;
        cout << sum - v[p] + x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<string>
#include<algorithm>
#define REP(i,n) for(int i=0; i<int(n); i++)
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	int c = 0;
	for (int i = 0; i < N; i++) {
		if (h[i] >= K) {
			c++;
		}
	}
	cout << c << endl;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		int dimension = sc.nextInt();
		int[][] X = new int[number][dimension];
		int cnt = 0;
		//データを配列に格納
		for(int i =0; i<number ;i++) {
			for(int j =0; j<dimension;j++) {
				X[i][j] = sc.nextInt();			
			}		
		}
		for(int i =0; i<number ;i++) {
			for(int j =i+1; j<number;j++) {
              		int distance =0;
				 for(int k =0;k<dimension;k++)	{
					 int work =Math.abs(X[i][k]-X[j][k]);
					 distance +=work*work;
				 }
				 boolean flag =false;
				 for(int k = 0;k<=distance ;k++) {
					 if(k*k == distance) {
						 //System.out.println(i);
						 //System.out.println(j);
                       flag =true;
					 }
				 }
				 if(flag== true) {
					++cnt;
				 }
			}		
		}
		System.out.println(cnt);

	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
#define first fi;
#define second se;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;

int main(){
  string A,B;
  cin>>A>>B;
  cout<<B<<A<<endl;
}


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

const int INF=1e9;
const int N=1005;
const int X=5005;
int n,x[N],b[N];
vector<int> adj[N];

void dfs(int u){
	for(int v:adj[u])
		dfs(v);
	int m=adj[u].size();
	int dp[m+1][X];
	for(int i=0;i<=m;++i)
		for(int j=0;j<X;++j)
			dp[i][j]=INF;
	dp[0][0]=0;
	for(int i=0;i<m;++i){
		int white=x[adj[u][i]];
		int black=b[adj[u][i]];
		for(int j=0;j<X;++j){
			if(j+white<X) dp[i+1][j+white]=min(dp[i+1][j+white],dp[i][j]+black);
			if(j+black<X) dp[i+1][j+black]=min(dp[i+1][j+black],dp[i][j]+white);
		}
	}
	int best=INF;
	for(int i=0;i<=x[u];++i)
		best=min(best,dp[m][i]);
	if(best==INF)
		exit(puts("IMPOSSIBLE\n")*0);
	b[u]=best;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	for(int i=2;i<=n;++i){
		int v;
		cin>>v;
		adj[v].push_back(i);
	}
	for(int i=1;i<=n;++i)
		cin>>x[i];
	dfs(1);
	cout<<"POSSIBLE\n";
}




Measured memory_bytes: 23196
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(0,n-1):
    if p[i]==i+1:
        x=p[i]
        p[i]=p[i+1]
        p[i+1]=x
        cnt+=1
if p[n-1]==n:
    x=p[n-1]
    p[n-1]=p[n-2]
    p[n-2]=x
    cnt+=1
print(cnt)


Measured memory_bytes: 13880
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll N=2e5+5;
const ll MOD=1e9+7;
const ld pi=3.14159265359;
const ll INF=(1LL<<60);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll n,m,k,sz[N],d[N],x,y,ans[N],de[N];
map<ll,map<ll,bool> > mm;

ll f(ll w){
	return d[w]==w?w:d[w]=f(d[w]);
}

void uni(ll a,ll b){
	a=f(a);b=f(b);
	if(a==b)return;
	if(sz[a]>sz[b]){
		sz[a]+=sz[b];
		d[b]=a;
	}else{
		sz[b]+=sz[a];
		d[a]=b;
	}
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m>>k;
	REP1(i,n)sz[i]=1,d[i]=i;
	REP(i,m)cin>>x>>y,uni(x,y),mm[x][y]=mm[y][x]=1,de[x]++,de[y]++;
	REP1(i,n)ans[i]=sz[f(i)]-de[i];
	REP(i,k){
		cin>>x>>y;
		if(f(x)==f(y)&&!mm[x][y])ans[x]--,ans[y]--;
	}
	REP1(i,n)cout<<ans[i]-1<<" \n"[i==n];
	return 0;
}


Measured memory_bytes: 34304
#include<iostream>
#include<climits>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<list>
#include<string>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int,int>
#define PCC pair<char,char>
#define PCI pair<char,int>
#define PIC pair<int,char>
#define MP make_pair
#define DEBUG(x) cout<<#x<<": "<<x<<endl

class student
{
public:
	vector<int> IN;
	vector<int> OUT;
	bool T[721];
	bool IsDone = false;
	int check(int S,int E)
	{
		if (!IsDone)
		{
			for (int i = 0; i < IN.size(); i++)
			{
				int start = IN[i];
				int end = OUT[i];
				for (int l = start; l < end; l++)
				{
					T[l] = true;
				}
			}
			IsDone = true;
		}
		int ans = 0;
		for(int i=S;i<E;i++)
		{
			if (T[i] == true)ans++;
		}
		return ans;
	}
	void init()
	{
		IN.clear();
		OUT.clear();
		REP(i, 721)T[i] = false;
		IsDone = false;
	}
};
student S[10001];

int main()
{
	while (1)
	{
		int N, M, r;
		cin >> N >> M >> r;
		if (N == 0)break;
		REP(i, r)
		{
			int t, n, m, b;
			cin >> t >> n >> m >> b;
			t -= 540;
			if (b == 1)S[m].IN.push_back(t);
			else  S[m].OUT.push_back(t);
		}
		int q;
		cin >> q;
		REP(i, q)
		{
			int ans = 0;
			int t1, t2, m;
			cin >> t1 >> t2 >> m;
			t1 -= 540;
			t2 -= 540;
			cout << S[m].check(t1, t2) << endl;
		}
		REP(i, M)
		{
			S[i].init();
		}
	}
	return 0;
}

Measured memory_bytes: 10752
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        h: usize,
        w: usize,
        ab: [(usize, usize);n],
    }
    println!("{}", ab.iter().filter(|x| x.0 >= h && x.1 >= w).count());
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    string s;
    cin >> s;

    ll K;
    cin >> K;

    for(int i = 0; i < s.size(); i++){
        int toA = ( 26 - (s[i] - 'a') ) % 26 ;
        //cout << toA << endl;
        if(K - toA >= 0 ){
            s[i] = 'a';
            K -= toA;
        }
    }
    
    char c = ( (s[s.size() - 1] - 'a' ) + (char)(K % 26) ) % 26;
    //cout << c << " " << K << endl;
    s[s.size() -  1] = c + 'a';

    cout << s << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

int main()
{
	int n,m,in,MAX;
	vector<int> P;
	vector<int>::iterator it;
	
	while(scanf("%d%d",&n,&m)&&(n!=0||m!=0)){
		P.clear();
		
		for(int i = 0; i < n; i++){
			scanf("%d",&in);
			P.push_back(in);
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				P.push_back(P[i]+P[j]);
			}
		}
	
		P.push_back(0);
		sort( P.begin(),P.end() );
		MAX = 0;
	
		for(int i = 0; i < P.size(); i++){
			it = upper_bound(P.begin(),P.end(),m-P[i]);
			it--;
			if(P[i] + *it <= m){
				MAX = max(MAX,P[i] + *it);
			}
		}
	
		printf("%d\n",MAX);
	}
	
	return 0;
}

Measured memory_bytes: 5964
N, M = map(int, input().split())

to = [[] for i in range(N+1)]

dist = [100001 for i in range(N+1)]
flug = [1 for i in range(N+1)]

to[0].append(1)
dist[0] = 0
flug[0] = 0

for i in range(M):
    a, b = map(int, input().split())
    to[a].append(b)
    to[b].append(a)

q = []
q.append(0)
while (len(q) != 0):
    i = q.pop(0)
    for j in to[i]:
        if dist[j] == 100001:
            dist[j] = dist[i] +1
            flug[j] = i
            q.append(j)

print("Yes")
for i in range(2,N+1):
    print(flug[i])

Measured memory_bytes: 34652
#include<iostream>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  int ans=0;
  if(x==3) ans+=100000;
  else if(x==2) ans+=200000;
  else if(x==1) ans+=300000;
  
  if(y==3) ans+=100000;
  else if(y==2) ans+=200000;
  else if(y==1) ans+=300000;
  
  if(x==1&&y==1) ans+=400000;
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
vector<T> make_vec(size_t a) { return vector<T>(a, INF); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}
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;
}

signed main() {
    INIT;
    cin >> X;
    if (X >= 12) {
        ans = X / 11 * 2;
        X %= 11;
    }
    if (X > 6) {
        ans += 2;
    } else if (X > 0)
        ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c, d;
  cin >> N ;

  a = N / 1000;
  N = N % 1000;
  b = N / 100;
  N = N % 100;
  c = N / 10;
  d = N % 10;
  
  if( (a == b && b == c) || (b == c) && (c == d) ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;

int main() {
    LL N, M;
    scanf("%lld %lld", &N, &M);
    if (N == 1) return !printf("%lld\n", M);
    LL sq = (LL)sqrt(M);
    LL ans = 1;
    for (int i = 2; i <= sq; i++) {
        int cnt = 0;
        while (M % i == 0) {
              cnt++;
              M /= i;
        }
        ans *= (pow(i, cnt / N));
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256