akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string S, T;
vector<int> dict1[26], dict2[26];

int main() {
  INCANT;
  cin >> S >> T;
  int n = S.size();
  rep(i, n) {
    int s = S[i]-'a';
    int t = T[i]-'a';
    dict1[s].push_back(i);
    dict2[t].push_back(i);
  }

  // i番目の要素に等しいindexの集合がSとTについて同じ
  rep(i, 26) {
    vector<int> svec = dict1[i];
    int sz = svec.size();
    bool ng;
    rep(j, 26) {
      ng = true;
      bool tmp_ok = true;
      vector<int> tvec = dict2[j];
      int tz = tvec.size();
      if (sz!=tz) {
        tmp_ok = false;
        continue;
      }
      rep(k, sz) {
        if (svec[k]!=tvec[k]) {
          tmp_ok = false;
          continue;
        }
      }
      if (tmp_ok) {
        ng = false;
        break;
      }
    }
    if (ng) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << "\n";

  return 0;
}

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

void fff(string s = "") {
	if (s == "1") cin >> s;
	if ((int)s.size() >= 4) {
		freopen(s.c_str(),"r",stdin);
	}
}

struct dsu {
	vector<int> chot;
	int n;
	dsu(int n) : n(n) {
		chot.resize(n + 1,-1);
	}
	int find(int u) {
		return chot[u] < 0 ? u : chot[u] = find(chot[u]);
	}
	bool combine(int u,int v) {
		if ((u = find(u)) != (v = find(v))) {
			if (-chot[u] < -chot[v]) swap(u,v);
			chot[u] += chot[v];
			chot[v] = u;
			return true;
		}
		return false;
	}
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  fff("");
  int n,m;
  cin >> n >> m;
  dsu d(n);
  int ans = n - 1;
  for (int i = 1; i <= m; i++) {
  	int u,v;
  	cin >> u >> v;
  	if (d.combine(u,v)) {
  		--ans;
		}
	}
	cout << ans;
} 

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int i,j,n,a,b,k,sum=0;
    cin>>a>>b>>k;
    for(int i=1;i<=k;i++)
    {
        if(i%2==1){
            if(a%2==1)a -=1;
            a = a/2;
            b +=a;
        }
        else  {
            if(b%2==1)b -=1;
            b = b/2;
            a +=b;
        }

    }
    cout<<a<<" "<<b<<endl;
     return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
struct k{
  int bangou;
  int score;
};
int main(){
  int n;
  int d1,d2,b;
  k id[10001];
  while(  cin >> n,n ){
    for(int i = 0 ; i < n ; i++){
      cin >> b >> d1 >> d2;
      id[i].bangou = b;
      id[i].score = (d1 + d2);
    }
    int max = 0;
    int ans_b; 
    for(int i = 0 ; i < n ; i++){
      if(id[i].score > max){
	max = id[i].score;
	ans_b = id[i].bangou;
      }
    }
    cout << ans_b << " " << max << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
p [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][gets.to_i-1]



Measured memory_bytes: 1916
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = Console.ReadLine().Trim();
            int iN = int.Parse(sS);

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

            // 解析
            string sOut = "ABC";
            if (iN > 999) { sOut = "ABD"; }

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

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

}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll solve(int cost[],int n)
{
	ll dp[n];
	for(int i=0 ; i<n ; i++)
		dp[i]=INT_MAX;
	dp[0]=0;
	for(int i=0 ; i<n ; i++)
	{
		if(i+1<n)
			dp[i+1]=min(dp[i+1],dp[i]+abs(cost[i+1]-cost[i]));
		if(i+2<n)
			dp[i+2]=min(dp[i+2],dp[i]+abs(cost[i+2]-cost[i]));
	}
	return dp[n-1];
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int cost[n];
	for(int i=0 ; i<n ; i++)
		cin>>cost[i];
	long long int ans=solve(cost,n);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4756
N,K=map(int,input().split())
if K%2==1:
    print((N//K)**3)
else:
    T=K//2
    even=0
    odd=0
    for i in range(1,N+1):
        x=T*i
        if x>N:
            continue
        if i%2==0:
            even+=1
        else:
            odd+=1
    print(even**3+odd**3)


Measured memory_bytes: 2940
/*************************************************************************
> File Name: test.cpp
> Author: Akira
> Mail: qaq.febr2.qaq@gmail.com
************************************************************************/
 
#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<cstring>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;
 
#define MaxN 100001
#define MaxM MaxN*4
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9 + 7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x;
int N, M;
struct Edge
{
	int u, v, next;
}edge[MaxM];
int cont;
int head[MaxN];
vector<int> V[MaxN];
void add(int u, int v)
{
	edge[cont].u = u;
	edge[cont].v = v;
	edge[cont].next = head[u];
	head[u] = cont++;
}
void Add(int u, int v) { add(u, v); add(v, u); }
int low[MaxN];
int dfn[MaxN];
int Stack[MaxN], top;
int belong[MaxN];
int vis[MaxN];
int Index, cnt;
void Tarjan(int u)
{
	low[u] = dfn[u] = Index;
	Index++;
	Stack[++top] = u;
	vis[u] = 1;
	for (int i = head[u]; i != -1; i = edge[i].next)
	{
		int v = edge[i].v;
		if (dfn[v] == -1)
		{
			Tarjan(v);
			low[u] = min(low[u], low[v]);
		}
		else if (vis[v])
		{
			low[u] = min(low[u], dfn[v]);
		}
	}
	if (low[u] == dfn[u])
	{
		for (int v=-1; v != u; top--)
		{
			v = Stack[top];
			vis[v] = false;
			belong[v] = cnt;
			V[cnt].push_back(v);
		}
		cnt++;
	}
}
int col[MaxN];
bool BFS(int x)
{
	col[x] = 1;
	queue<int> Q;
	Q.push(x);
	while (!Q.empty())
	{
		int u = Q.front();
		Q.pop();
		for (int i = head[u]; i != -1; i = edge[i].next)
		{
			int v = edge[i].v;
			if (col[v] == col[u]) return false;
			else
			{
				if (col[v] == -1)
				{
					col[v] = col[u] ^ 1;
					Q.push(v);
				}
			}
		}
	}
	return true;
}
bool judge(int x)
{
	MST(col, -1);
	for (int i = 0; i<V[x].size(); i++)
	{
		int node = V[x][i];
		if (col[node] == -1 && !BFS(node)) return false;
	}
	return true;
}
void init()
{
	cont = 0;
	MST(head, -1);
	MST(dfn, -1);
	CLR(low);
	CLR(vis);
	Index = cnt = 1;
	top = 0;
	for (int i = 1; i <= N; i++) V[i].clear();
}
int main()
{
	//std::ios::sync_with_stdio(false);
	while (~scanf("%d%d", &N, &M))
	{
		init();
		while (M--)
		{
			int u, v;
			scanf("%d%d", &u, &v);
			Add(u, v);
		}
		for (int i = 1; i <= N; i++)
			if (dfn[i] == -1) Tarjan(i);
		//cout << cnt << endl;
		LL I = 0, Q = 0, P = 0;
		for (int i = 1; i<cnt; i++)
		{
			if (V[i].size() == 1) I++;
			else
			{
				if (judge(i)) Q++;
				else P++;
			}
		}
		//cout << I << " " << Q << " " << P << endl;
		LL ans = 2 * I*N - I*I + P*P + 2 * P*Q + 2 * Q*Q;
		printf("%lld\n", ans);
	}
	system("pause");
}

Measured memory_bytes: 14448
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

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

int n;
ll a[200000];

int main()
{
	int i, j, k, l;
	cin>>n;
	for(i=0;i<n;i++) scanf("%lld", &a[i]);
	ll ans=0;
	ans+=a[0]-1;
	ll now=1;
	for(i=1;i<n;i++)
	{
		if(a[i] == now+1) now++;
		else if(a[i] > now+1)
		{
			ans+=(a[i]-1)/(now+1);
		}
	}
	cout<<ans<<endl;
	return 0;
}
//*/

Measured memory_bytes: 1152
while True:
    try:
        w = float(input())
        if w <= 48:
            print('light fly')
        elif w <= 51:
            print('fly')
        elif w <= 54:
            print('bantam')
        elif w <= 57:
            print('feather')
        elif w <= 60:
            print('light')
        elif w <= 64:
            print('light welter')
        elif w <= 69:
            print('welter')
        elif w <= 75:
            print('light middle')
        elif w <= 81:
            print('middle')
        elif w <= 91:
            print('light heavy')
        else:
            print('heavy')
    except:
        break

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

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int ans = 0;
	int cnt = 0;
	for (int i = 1; i < n; ++i) {
		if (h[i] <= h[i - 1]) cnt++;
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int total =0;
    for (int i=0; i<N; i++) {
      int l = sc.nextInt();
      int r = sc.nextInt();
      total += r - l + 1;
    }
    System.out.print(total);
  }
}

Measured memory_bytes: 25448
# coding: utf-8
# Your code here!
def main():
    s = input()
    n = len(s)
    s1 = s[:int((n-1)/2)]
    s2 = s[int((n+3)/2)-1:]
    
    for tmp in [s, s1, s2]:
        tmp_rev = tmp[::-1]
        # print(tmp, tmp_rev)
        if tmp != tmp_rev:
            print("No")
            break
    else:
        print("Yes")
    
main()

Measured memory_bytes: 8756
#include <bits/stdc++.h>
using namespace std;
const int N = 210;
int n,a[N],ans;
int main() {
  cin >> n;
  n <<= 1;
  for (int i = 1 ; i <= n ; ++ i)
    cin >> a[i];
  sort(a+1,a+n+1);
  for (int i = n-1 ; i >=1 ; i -= 2)
    ans += a[i];
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    H,W=map(int,input().split())
    print('#'*(W+2))
    for i in range(H):
        print('#'+str(input())+'#')
    print('#' * (W + 2))


resolve()

Measured memory_bytes: 38384
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: 怪文書 / Dubious Document
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int INF = 1 << 30;

/* typedef */

/* global variables */

int cs[26], mincs[26];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < 26; i++) mincs[i] = INF;

  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    memset(cs, 0, sizeof(cs));
    for (int j = 0; j < s.size(); j++) cs[s[j] - 'a']++;
    for (int j = 0; j < 26; j++) mincs[j] = min(mincs[j], cs[j]);
  }

  for (int i = 0; i < 26; i++) {
    char c = 'a' + i;
    for (int j = 0; j < mincs[i]; j++) putchar(c);
  }
  putchar('\n');
  return 0;
}


Measured memory_bytes: 256
import numpy as np

t = np.array([int(input()) for _ in range(5)])
t_wasted = (10 - t % 10) % 10
last = np.argmax(t_wasted)

ans = 0

for i in range(5):
    ans += t[i]

    if i != last:
        ans += t_wasted[i]

print(ans)

Measured memory_bytes: 12496
public class Hello{
    public static void Main(){
        int f = 0;
        int s = 0;
        int t = 0;
        for(int i=0;i<10;i++)
        {
            int height = int.Parse(System.Console.ReadLine());
            if(t < height)
            {
                t = height;
            }
            if(s < height)
            {
                t = s;
                s = height;
            }
            if(f < height)
            {
                s = f;
                f = height;
            }
        }
        System.Console.WriteLine(f.ToString());
        System.Console.WriteLine(s.ToString());
        System.Console.WriteLine(t.ToString());
    }
}

Measured memory_bytes: 5596
n,m,k = map(int,input().split())
mod = 998244353

#色の塗分けのパターンを考える
#n=4,k=0のとき
#m*(m-1)*(m-1)*(m-1)である
#k>0の場合、隣り合う同じ色で塗られた組が1~k個存在する
#隣り合うブロックの個数はn-1個あり、そのうちどこにk個等しくなるか考えると
#Comb(n-1,k)通りとなる。つまり
#1~kのそれぞれの、m*(m-1)^(n-(i+1))*comb(n-1,i)の総和が答え

ans=0
comb=1
for i in range(k+1):
    ans+=m*pow(m-1,n-i-1,mod)*comb
    ans%=mod
    comb*=(n-i-1)*pow(i+1,mod-2,mod)
    comb%=mod
print(ans)

Measured memory_bytes: 9196
num = gets.to_i
arr = gets.strip.split(' ').map(&:to_i)
i = 0
total = 0
while i < num do
  rabbit = i+1
  likeNo = arr[i]
  likeRabbitsLikeNo = arr[likeNo-1]
  if likeRabbitsLikeNo == rabbit
     total+=1
  end
  i+=1
end
 
puts total/2

Measured memory_bytes: 8708
n, m = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    for i in range(m):
        a[0] = a[0] // 2
    print(sum(a))
    exit()

a.sort()
i = 0
while i < m:
    a[n-1] = a[n-1] // 2
    i+=1
    num = len([1 for x in a[:n-1] if x > a[n-1]])
    hoge = min(m-i, num)
    for j in range(hoge):
        a[n-2-j] = a[n-2-j] // 2
    i += hoge
    a.sort()

print(sum(a))


Measured memory_bytes: 14480
def resolve():
    n, k = map(int, input().split())
    sunuke = [0]*n
    man = []
    for i in range(k):
        d = int(input())
        a = list(map(int, input().split()))
        for j in a:
            if sunuke[j-1] == 0:
                sunuke[j-1] = 1
    print(n-sum(sunuke))

resolve()

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

using namespace std;

int main() {
  string s;
  int q;
  cin >> s >> q;
  int rev = 0;
  string pre = "", suf = "";
  for (int i=0; i<q; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      rev = 1 - rev;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        if (rev == 0) pre += c;
        else suf += c;
      } else {
        if (rev == 0) suf += c;
        else pre += c;
      }
    }
  }
  if (rev == 0) {
    reverse(pre.begin(), pre.end());
    cout << pre << s << suf << endl;
  } else {
    reverse(s.begin(), s.end());
    reverse(suf.begin(), suf.end());
    cout << suf << s << pre << endl;
  }
  return 0;
}


Measured memory_bytes: 1088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,m,N) for(int i=m;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int main(){
  int m1,d1,m2,d2;
  cin>>m1>>d1>>m2>>d2;
  if(m1!=m2){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
}


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

using namespace std;

ll gcd(ll a, ll b) {
  if(a < b)
    gcd(b, a);
  ll r;
  while((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

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

int main() {
  int n;
  ll l = 1;
  cin >> n;
  vector<ll> t(n);
  for(int i = 0; i < n; i++) {
    cin >> t.at(i);
    l = lcm(l, t.at(i));
  }
  cout << l << endl;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
can = True
count = 0

while(can):
    for i in range(len(A)):
        if(A[i] % 2 != 0):
            can = False
        else:
            A[i] = A[i] / 2
    if(can):
        count+=1
print(count)


Measured memory_bytes: 9220
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] grid = new char[h][w];
        for(int i = 0; i < h; i++){
            grid[i] = sc.next().toCharArray();
        }
        sc.close();
        boolean res = true;
        for(int j = 0; j < h; j++){
            for(int k = 0; k < w; k++){
                if(grid[j][k] == '.'){
                    continue;
                }else{
                    if(j - 1 >= 0){
                        if(grid[j-1][k] == '#'){
                            continue;
                        }
                    }
                    if(j + 1 < h){
                        if(grid[j+1][k] == '#'){
                            continue;
                        }
                    }
                    if(k - 1 >= 0){
                        if(grid[j][k-1] == '#'){
                            continue;
                        }
                    }
                    if(k + 1 < w){
                        if(grid[j][k+1] == '#'){
                            continue;
                        }
                    }
                    res = false;
                    break;
                }
            }
            if(!res){
                break;
            }
        }
        if(res){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 23252
#include <iostream>
#include <utility>
#include <stdint.h>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
  double A, B, H, M;
  cin >> A >> B >> H >> M;

  H += M/60.0;
  
  double Hx = A*sin(H/12.0*2.0*M_PI), Hy = A*cos(H/12.0*2.0*M_PI);
  double Mx = B*sin(M/60.0*2.0*M_PI), My = B*cos(M/60.0*2.0*M_PI);

  double dx = Hx-Mx, dy = Hy-My;
  
  cout << setprecision(15) << sqrt((dx*dx)+(dy*dy)) << endl;

  return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		
		for (int i = 0; i < n; i++)
			a[i] = Integer.parseInt(sc.next());
		
		Arrays.sort(a);
		
		System.out.println(a[n-1] - a[0]);
		
		sc.close();
	}
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll H,W;
vector<pair<int,int>> V;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>W>>H;
	FOR(i,W) cin>>x, V.push_back({x,0});
	FOR(i,H) cin>>x, V.push_back({x,1});
	
	sort(ALL(V));
	ll ret=0;
	W++;
	H++;
	FORR(r,V) {
		if(r.second==1) ret += W*r.first, H--;
		else ret += H*r.first, W--;
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

int main(){
    int n;
    cin >> n;
    n = n % 10;
    if(n==2 || n==4 || n==5 || n==7 || n==9 ){
        cout << "hon" << endl;
    }
    else if(n==0 || n==1 || n==6 || n==8 ){
        cout << "pon" << endl;
    }
    else{
        cout << "bon" << endl;
    }
    return 0;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;


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

	string S;
	cin >> S;

	int ans = 0;
	for(int i=0; i<S.size(); i++){
		if(S[i] == '2'){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


bool kaibun(string s) {
  int N = s.size();
  for (int i = 0; i < N/2; i++) {
    if (s[i] != s[N-1-i]) return false;
  }
  return true;
}

bool solve(string s) {
  int N = s.size();
  return kaibun(s) && kaibun(s.substr(0, (N-1)/2));
}

int main2() {
  string s; cin >> s;
  bool ans = solve(s);
  cout << (ans ? "Yes":"No") << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
#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 for_t int t;cin>>t;while(t--)
#define MOD 1000000007
#define fi first
#define se second
#define le length
#define debug(n1) cout << n1 << endl
#define set_bits(n) __builtin_popcount(n);
#define rep(i , j , n) for(ll i = j ; i <= n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef map<int, int>mapp;

void func(int arr[], int n, vector<int> &ans) { 
  stack < int > s;
  s.push(0); 
  rep(i,1,n-1){ 
    if (s.empty()){ 
      s.push(i); 
      continue; 
    }
    while (s.empty() == false && arr[s.top()] < arr[i]) 
    {          
        ans[s.top()]=i; 
        s.pop(); 
    } 
    s.push(i); 
  } 
  while (s.empty() == false) { 
    ans[s.top()]=-1; 
    s.pop(); 
  }
}


int main() {
    SPEED;
    ll n;
    cin>>n;
    ll ans = 0;
    ans = ans + n*(n-1);
    ans = ans/2;
    cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		System.out.print(C + " " + A + " " + B);
			
	return;

	}
}

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

int main(){
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	if(H % h == 0 && W % w == 0){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	int arr[H][W];
	fill(arr[0], arr[H], -100000);
	if(H % h) for(int i = 0; i < H; i += h) for(int j = 0; j < W; j++) arr[i][j] = 100000 * h - 100001;
	else for(int i = 0; i < H; i++) for(int j = 0; j < W; j += w) arr[i][j] = 100000 * w - 100001;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(j) cout << ' ';
			cout << arr[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#include<vector>
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define mod 1000000007
using namespace std;

ll ipow(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    } 
    return result; 
} 

int main(){
	fio
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	s[i]='x';
	cout<<s<<endl;
	
return 0;
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

#define int long long


signed main()
{
    int n;
    cin >> n;
    int tmp = 1;
    int ret = 1;
    while(true) {
        if(tmp<=n&&n<=tmp*3) break;
        tmp *= 3;
        ++ret;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3096
// 2020-06-29 23:35:27
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
ll mod;
vector<vector<int>> G;
vector<vector<ll>> dp, dpl, dpr;
ll dfs(int u, int p) {
  dp[u].assign(G[u].size(), 0);
  dpl[u].assign(G[u].size()+1, 0);
  dpr[u].assign(G[u].size()+1, 0);
  ll res = 1;
  rep(i, G[u].size()) {
    int v = G[u][i];
    if(v != p) {
      dp[u][i] = dfs(v, u) % mod;
      res = (res % mod) * (dp[u][i] + 1) % mod;
    }
  }
  return res;
}
void bfs() {
  queue<tuple<int, int, int>> que; // u, p, i
  que.emplace(0, -1, 0);
  while(!que.empty()) {
    auto el = que.front(); que.pop();
    int u = get<0>(el);
    int p = get<1>(el);
    int j = get<2>(el);
    int sz = G[u].size();
    rep(i, sz) {
      int v = G[u][i];
      if(v == p) {
        dp[u][i] = dpl[v][j] * dpr[v][j+1] % mod;
      } else {
        que.emplace(v, u, i);
      }
    }
    dpl[u][0] = dpr[u][sz] = 1;
    rep(i, sz) {
      dpl[u][i+1] = (dpl[u][i] * ((dp[u][i] + 1) % mod)) % mod;
      dpr[u][sz-i-1] = (dpr[u][sz-i] * (dp[u][sz-i-1] + 1) % mod) % mod;
    }
  }
}
void answer() {
  ll n;
  cin >> n >> mod;
  G.resize(n);
  dp.resize(n);
  dpl.resize(n);
  dpr.resize(n);
  rep(i, n-1) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  dfs(0, -1);
  bfs();
  rep(i, n) cout << dpl[i][G[i].size()] % mod << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 30572
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<int,int> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int,pair<int,int> > iii;
#define PI 3.141592653589793
#define mod (ll)(1000*1000*1000+7)
//# define N 300005
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=((ans%m)*(a%m))%m; b/=2; a=((a%m)*(a%m))%m; } return ans%m; }
# define INF (ll)1e18
# define LG 20  
typedef pair<int,pair<int,int> > pii;
# define INF1 (int)1e9+2v
# define maxn 100006

ll sz[maxn];
int par[maxn];
int x[maxn],y[maxn];

void init()
{
	for(int i=0;i<maxn;i++)
	{
		par[i]=i;
		sz[i]=1;
	} 
}

int root(int a)
{
	while(a!=par[a])
	{
		a=par[a];
	}
	return a;
}


bool issame(int a,int b)
{
	a=root(a);b=root(b);
	if(a==b)
		 return true;
	return false;
	
}

void union1(int a,int b)
{
	a=root(a);
	b=root(b);
  if(sz[a]<sz[b])
		swap(a,b);
	sz[a]+=sz[b];
	par[b]=a;
}

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

	for(int i=0;i<n;i++)
		cin >> x[i] >> y[i];

    init();
    vector<pair<ll,int> >xc,yc;

    for(int i=0;i<n;i++)
    {
    	xc.pb(mp(x[i],i));
    	yc.pb(mp(y[i],i));
    }
    sort(xc.begin(),xc.end());
    sort(yc.begin(),yc.end());

    vector<pair<ll,pair<int,int> > >ed;

    for(int i=0;i<xc.size()-1;i++)
    {
    	int f=xc[i].ss;
    	int s=xc[i+1].ss;
    	int d=xc[i].ff-xc[i+1].ff;
    	ed.pb(mp(abs(d),mp(f,s)));
    	f=yc[i].ss;s=yc[i+1].ss;d=abs(yc[i].ff-yc[i+1].ff);
    	ed.pb(mp(d,mp(f,s)));
    }

    sort(ed.begin(),ed.end());
    
    ll ans=0;
    for(int i=0;i<ed.size();i++)
    {
    	int from=ed[i].ss.ff;
    	int to=ed[i].ss.ss;
    	//trace4(from,to,ed[i].ff,issame(from,to));
    	if(!issame(from,to))
    	{
    		union1(from,to);
    		ans+=ed[i].ff;
    		//trace1(issame(from,to));
    	}
    }

    cout << ans;
}

Measured memory_bytes: 11492
L, R = map(int, input().split())
x, y = L % 2019, R % 2019
if (R-L) > 2017 or x>=y:
    print(0)
else:
    m = 2019
    for i in range(x, y + 1):
        for j in range(i + 1, y + 1):
           x = (i * j) % 2019
           m = min(m, x)
           if m == 0:
               break
        if m == 0:
            break
    print(m)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll h,n;
    cin>>h>>n;
    rep(0,i,n){
        ll a;
        cin>>a;
        h-=a;
    }
    if(h>0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 777;
int ed[maxn][maxn];
vector<int> to[maxn];
int c[maxn];
bitset<maxn> f;
bool bad;
pair<int,int> get(int u){
	pair<int,int> res = {0,0};
	if(c[u] == 0) res.first = 1;
	else res.second = 1;
	for(int nxt : to[u]){
		if(c[nxt] == -1){
			c[nxt] = c[u] ^ 1;
			pair<int,int> to = get(nxt);
			res.first += to.first;
			res.second += to.second;
		} else if(c[nxt] == c[u]) bad = true;
	}
	return res;
}
int main(){
	int n, m; cin >> n >> m;
	for(int i = 0; i < m; i++){
		int x, y; cin >> x >> y;
		ed[x][y] = 1;
		ed[y][x] = 1;
	}
	for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) if(i != j && ed[i][j] == 0) to[i].push_back(j);
	f[0] = 1;
	memset(c, -1, sizeof(c));
	for(int i = 1; i <= n; i++) if(c[i] == -1) {
		c[i] = 0;
		pair<int,int> now = get(i);
		if(bad){
			cout << -1 << endl;
			return 0;
		}
		f = (f << now.first) | (f << now.second);
	}
	int best = 1<<30;
	for(int i = n; i >= 0; i--) if(f[i]){
		best = min(best, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
	}
	cout << best << endl;
	return 0;
}


Measured memory_bytes: 3072
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { S: string, T: string} => {
  const S = lines[0]
  const T = lines[1]
  const obj = { S, T }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { S, T } = parseLines(lines)
  let count = 0
  for(let i = 0; i < S.length; i++) {
    if (S[i] === T[i]) {
      count++
    }
  }
  return `${count}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 7628
#include <stdio.h>
static int min(int a, int b)
{
	return a<b?a:b;
}
static int max(int a, int b)
{
	return a>b?a:b;
}
struct {
	int e;
	int (*f)(int,int);
	int xy;
} table[] = {
	{0, max, 0},
	{0, max, 0},
	{0, min, 0},
	{0, max, 0},
	{0, min, 0},
};
void solve(void)
{
	int w, h, n;
	int t, b, l, r;
	scanf("%d %d %d", &w, &h, &n);
	t=h; b=0; l=0; r=w;
	while(n-->0){
		int x,y,a;
		scanf("%d %d %d", &x, &y, &a);
		switch(a){
			case 1:
				l = (l>x?l:x);
				break;
			case 2:
				r = (r<x?r:x);
				break;
			case 3:
				b = (b>y?b:y);
				break;
			case 4:
				t = (t<y?t:y);
				break;
		}
	}
	if(l>r)
		l=r;
	if(b>t)
		b=t;
	printf("%d\n", (r-l)*(t-b));
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


Measured memory_bytes: 128
X = []
n = 0
idx = 0
for i in range(5):
    x = int(input())
    X.append(x)
    m = (10 - x % 10) % 10
    if n < m:
        n = m
        idx = i
res = 0
for i in range(5):
    if i != idx:
        res += (10 - X[i] % 10) % 10 + X[i]
print(res + X[idx])


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

int main()
{
    int n,m,l;cin>>n>>m>>l;
    int a[n][m]={},b[m][l]={};
    long long c[n][l]={};
    for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>a[i][j];
    for(int i=0;i<m;i++)for(int j=0;j<l;j++)cin>>b[i][j];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<l;k++){
                c[i][k]+=a[i][j]*b[j][k];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l-1;j++)cout<<c[i][j]<<" ";
        cout<<c[i][l-1]<<endl;
    }
}


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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

template<class T>bool ch1000000(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


const int MAX = 42;


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

  vector<ll> a(60000, 0);


  for(ll i = 1; i <= 100; i++){
    for(ll j = 1; j <= 100; j++){
      for(ll k = 1; k <= 100; k++){
        ll f = i*i + j*j + k*k + i*j + j*k + k*i;
        a[f]++;
      }
    }
  }

  for(ll i = 1; i <= N; i++) {
    cout << a[i] << endl;
  }

  // cout << setprecision(8) << ans << endl;  // For double
}



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

using namespace std;
#define ll long long
#define mod 1000000007

vector<int> v;
int dp[100001];

int f(int i) {
    if(i == v.size()-1) return 0;
    
    if(dp[i] != -1) return dp[i];

    int ans = abs(v[i] - v[i+1]) + f(i+1);
    if(i+2 < v.size()) ans = min(ans, abs(v[i] - v[i+2]) + f(i+2));

    dp[i] = ans;
    return ans;
}

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

    memset(dp, -1, sizeof(dp));
    int n;
    cin >> n;

    v.resize(n);

    for (int &i : v) {
        cin >> i;
    }

    cout << f(0) << "\n";
}


Measured memory_bytes: 8676
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define for1(i, n) for (int i = 1; i <= (int)n; ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF (1 << 20)

using namespace std;

typedef long long i64;
typedef vector<int> vi;
typedef vector<i64> vi64;
typedef vector<vi> vvi;
typedef vector<vi64> vvi64;
typedef double ld;

int d[100][100];

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  int N, M;
  cin >> N >> M;

  forn(i, 100) forn(j, 100) d[i][j] = INF;
  forn(i, 100) d[i][i] = 0;

  vi a(M), b(M), c(M);
  forn(i, M) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;

    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }

  forn(k, N) {
    forn(i, N) {
      forn(j, N) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
    }
  }

  int ans = 0;
  forn(k, M) {

    bool is_found = false;

    forn(i, N) {
      forn(j, N) {
        if (d[i][a[k]] + c[k] + d[b[k]][j] == d[i][j]) {
          is_found = true;
        }
      }
    }

    if (is_found)
      ans++;
  }

  cout << M - ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int ans=0;
    int p=n;
    while(p){
        ans+=p%10;
        p/=10;
    }
    if(n%ans==0) printf("Yes\n");
    else printf("No\n");
}


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

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

  int N, C;
  int s[100000], t[100000], c[100000];
  cin >> N >> C;
  rep(i, N) cin >> s[i] >> t[i] >> c[i];

  vector<vector<int>> time(32);
  rep(i, 32) time[i].resize(100010);
  rep(i, N) {
    time[c[i]][s[i]]++;
    time[c[i]][t[i]]--;
  }

  vector<int> alltime(100010);
  rep(i, 32) {
    rep(j, 100010) {
      if (time[i][j] < 0) {
        alltime[j+1] += time[i][j];
      } else {
        alltime[j] += time[i][j];
      }
    }
  }

  rep(i, 100000) alltime[i+1] += alltime[i];

  int ans = 0;
  rep(i, 100000) ans = max(ans, alltime[i]);
  cout << ans << endl;
}

Measured memory_bytes: 14336
let n = int(stdin.ReadLine())
let a = stdin.ReadLine().Split(' ') |> Array.mapi (fun i s -> int64(int(s)-i-1))
let b = a |> Seq.sort |> Seq.item (n/2)
a |> Seq.sumBy (fun x -> abs(x-b)) |> stdout.WriteLine


Measured memory_bytes: 31424
#include <iostream>
#include <vector>
#include <set>

using namespace std;

set<int> merge(set<int> a, set<int> b) {
    set<int> ret;
    for (auto x : a) {
        ret.insert(x);
    }
    for (auto x : b) {
        ret.insert(x);
    }
    return ret;
}

set<int> neighbors(set<int> s, vector<set<int>> list) {
    set<int> ret;
    for (auto x : s) {
        for (auto y : list[x]) {
            ret.insert(y);
        }
    }
    return ret;
}

int main() {
    int n, m;
    while(1) {
        scanf("%d", &n);
        scanf("%d", &m);

        if (n == 0 && m == 0) break;

        vector<set<int>> list = vector<set<int>>(n);

        for (int i = 0; i < m; i++) {
            int from, to;
            scanf("%d %d", &from, &to);

            list[--from].insert(--to);
            list[to].insert(from);
        }

        set<int> n0;
        n0.insert(0);

        set<int> n1 = neighbors(n0, list);
        set<int> n2 = neighbors(n1, list);

        int ans = merge(n1, n2).size();
        if (ans == 0) {
            cout << ans << endl;
        } else {
            cout << ans - 1 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 5072
#include <iostream>
using namespace std;
using Int = int64_t;
int main() {
    Int N, M;
    cin >> N >> M;
    if (N == 1) cout << (M == 1 ? 1 : M - 2) << endl;
    else if (M == 1) cout << N - 2 << endl;
    else cout << (N - 2) * (M - 2) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;

#define ll long long int
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)

#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)

#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount



// typedef __int128 bign;


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define MD          1000000007
#define M 			100011
#define LN 			14
#define fftmod      998244353
#define EPS         (double)1e-10

ll md=MD;
ll inf=1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 


inline ll exp(ll a,ll b){ll r=1LL;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}

using cd=complex<double>;
const double PI=acos(-1);

inline ll rand(ll l,ll r){
	return l+rng()%(r-l+1);
}

vii g[M];
ll in[M],out[M];
ll vis[M][3];
ll dp[M][3];
int main(){


    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p,T;string s1,s2;ll qa;ll x,y;
    cin>>n>>m;
    lp(1,m){
        cin>>x>>y;
        g[x].pb(y);
    }
    cin>>x>>y;
    memset(dp,-1,sizeof(dp));
    dp[x][0]=0;
    queue<pii> q;
    q.push({x,0});
    while(!q.empty()){
        pii u=q.front();q.pop();
        vis[u.F][u.S]=1;
        for(auto v:g[u.F]){
            ll nx=u.S+1;nx%=3;
            if(!vis[v][nx]){
                vis[v][nx]=1;
                dp[v][nx]=dp[u.F][u.S]+1;
                q.push({v,nx});
            }

        }


    }
    if(dp[y][0]==-1)cout<<-1<<"\n";
    else cout<<dp[y][0]/3<<"\n";






    return 0;
}


Measured memory_bytes: 12032
#include <iostream>
#include <bits/stdc++.h>
#define  ll long long
using namespace std;
const int N=1e6+10;
char st[]={'a','a','b','c','d','e','f','g','h','i','j'};
int n;
vector<char>s;
void dfs(int step,int num)
{
    if(step==n+1) {
       for(auto v:s) cout<<v;
       cout<<endl;
       return;
    }
    for(int i=1;i<=num;i++){
         s.push_back(st[i]);
         dfs(step+1,max(num,i+1));
         s.pop_back();
    }
}
int main()
{
    cin>>n;
    dfs(1,1);
    return 0;
}


Measured memory_bytes: 1536
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a = list(map(int, input().split()))
    a.sort()
    if a[0]==5 and a[1]==5 and a[2]==7:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

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

int main() {
  int n;cin >> n;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  vector<ll> b(n);
  b=a;
  sort(b.begin(),b.end());
  ll ans1=b[n/2-1];
  ll ans2=b[n/2];
  
  rep(i,n){
    if(a[i]>=ans2){cout << ans1 << endl;continue;}
    if(a[i]<=ans1){cout << ans2 << endl;continue;}
  }
}

Measured memory_bytes: 5376
n = int(input())
a = list(map(int, input().split()))

result = []
while len(a) > 0:
    c = True
    for i in range(len(a)-1, -1, -1):
        if i+1 == a[i]:
            result.append(a[i])
            a.pop(i)
            c = False
            break
    if c:
        result = [-1]
        break

for i in result[::-1]:
    print(i)

Measured memory_bytes: 3064
using System;
    using System.Collections.Generic;
    using System.Linq;

    namespace CF
    {
        class Program
        {
            // https://codeforces.com/contest/ + ContestId
            // ReSharper disable All  d 
            static void Main(string[] args)
            {
                var str  = Console.ReadLine();
                var containstA = false;
                var containsB = false;
                for (var z = 0; z < str.Length; z++)
                {
                    if (str[z] == 'A')
                        containstA = true;

                    if (str[z] == 'B')
                        containsB = true;
                

                }

                if(containstA && containsB)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }



            }
        
        }
    }





Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int x, a;
	cin >> x >> a;
	if (x < a) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}
}

Measured memory_bytes: 256