akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll SIZE=205,INF=1e10;
struct MaxFlow{
	struct edge{
		ll to,cap,rev;
		edge(ll to=0,ll cap=0,ll rev=0):to(to),cap(cap),rev(rev){}
	};
	vector <edge> vec[SIZE];
	ll level[SIZE];
	ll iter[SIZE];
	void add(ll s,ll t,ll c){
		ll S=vec[s].size(),T=vec[t].size();
		vec[s].push_back(edge(t,c,T));
		vec[t].push_back(edge(s,0,S));
	}
	void bfs(ll s){
		memset(level,-1,sizeof(level));
		queue <ll> que;
		level[s] = 0;
		que.push(s);
		while (!que.empty()){
			ll v = que.front();que.pop();
			for(ll i=0;i<vec[v].size();i++){
				edge&e=vec[v][i];
				if (e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	ll flow_dfs(ll v,ll t,ll f){
		if (v==t) return f;
		for(ll &i=iter[v];i<vec[v].size();i++){
			edge &e=vec[v][i];
			if (e.cap>0&&level[v]<level[e.to]){
				ll d=flow_dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap-=d;
					vec[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	ll max_flow(ll s,ll t){
		ll flow = 0;
		while(1){
			bfs(s);
			if (level[t]<0) return flow;
			memset(iter,0,sizeof(iter));
			while (1){
				ll f=flow_dfs(s,t,INF);
				if(f==0) break;
				flow += f;
			}
		}
	}
};
MaxFlow MF;
char a[SIZE][SIZE];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m;cin>>n>>m;
    for(ll i=0;i<n;i++)cin>>a[i];
    ll sx,sy,gx,gy;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(a[i][j]=='S')sx=i,sy=j;
            else if(a[i][j]=='T')gx=i,gy=j;
        }
    }
    if(sx==gx || sy==gy)return cout<<"-1" ,0;
    MF.add(sx,sy+n,INF);
    MF.add(sy+n,sx,INF);
    MF.add(gx,gy+n,INF);
    MF.add(gy+n,gx,INF);
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(a[i][j]!='o')continue;
            MF.add(i,j+n,1);
            MF.add(j+n,i,1);
        }
    }
    cout<<MF.max_flow(sx,gx);
}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

string s, t;

int main()
{
    cin >> s >> t;

    cout << t + s << endl;
}


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

using namespace std;

int i,n,x,y,z,tx,ty,tz;

int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%d%d%d",&tz,&tx,&ty);
		if ((abs(tx-x)+abs(ty-y)<=abs(tz-z)) && (! ((abs(tz-z)-abs(tx-x)-abs(ty-y))&1)))
			x=tx,y=ty,z=tz;
		else
			return puts("No"),0;
	}
	return puts("Yes"),0;
}

Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main{
    public static void main(String[] aaa){
        Scanner sc = new Scanner(System.in);
        int[] count = new int[27];
        String st;
        char m;
        int i,j;
        while(sc.hasNext()){
            st = sc.next();
            for(i=0;i<st.length();i++){
                j=st.charAt(i);
                if(j-'a'>=0&&j-'a'<26)count[st.charAt(i)-'a']++;
                else if(j-'A'<26&&j-'A'>=0)count[st.charAt(i)-'A']++;
            }
        }
        for(i=0;i<26;i++){
            m = (char)('a'+i);
            System.out.println(m+" : "+count[i]);
        }
    }
}



Measured memory_bytes: 26160
n = gets.to_i
base = gets.chomp.split(" ").map(&:to_i)
m = gets.to_i
compare = gets.chomp.split(" ").map(&:to_i)
count = 0

(0..m-1).each do |i|
  left = 0
  right = n-1
  if base[n-1] >= compare[i] then
    while left < right
      mid = ((left+right)/2).floor
      if compare[i] == base[mid] then
        count += 1
        break
      elsif compare[i] < base[mid] then
        right = mid
      else
        left = mid + 1
      end
    end
  end
end

puts (base&compare).size

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, P[55];

bool Judge(){
  for (int i = 0; i < N - 1; i++){
    if (P[i] > P[i+1]) return false;
  }
  return true;
}

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> P[i];
  if (Judge()){
    YES(); return 0;
  }

  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      swap(P[i], P[j]);
      if (Judge()){
        YES(); return 0;
      }
      swap(P[i], P[j]);
    }
  }
  NO();

  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  string s, t;
  cin >> s;
  cin >> t;

  int n = s.length();

  vector<char> st(26, '.');
  for (int i = 0; i < n; i++) {
    if (st[s[i]-'a'] == '.') {
      st[s[i]-'a'] = t[i];
    }
    else if (st[s[i]-'a'] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  swap(s, t);
  st = vector<char>(26, '.');
  for (int i = 0; i < n; i++) {
    if (st[s[i]-'a'] == '.') {
      st[s[i]-'a'] = t[i];
    }
    else if (st[s[i]-'a'] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 916
/*Rajeev Ranjan
  CSE @MNNIT */

#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define S second
#define F first
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
typedef long long int ll;
typedef double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N = 1e5 + 5;


ll a[N],dp[N];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];

    dp[0]=INT_MAX;
    dp[1]=0;

    for(int i=2;i<=n;i++)
    {
        ll x= abs(a[i]-a[i-1]);
        ll y= abs(a[i]-a[i-2]);

        dp[i] = min(y+ dp[i-2],x+ dp[i-1]);
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdint.h>
#include <vector>

using namespace std;

#define MAX_SIZE 1000
#define INF (1LL << 50)

static vector<pair<int64_t, int64_t>> graph[MAX_SIZE];
static int64_t weights[MAX_SIZE];

void init_weights(uint32_t N)
{
  for (uint32_t i = 0; i < N; i++) {
    weights[i] = INF;
  }
  weights[0] = 0;
}

int32_t main()
{
  uint32_t N, M;
  cin >> N >> M;

  init_weights(N);

  for (uint32_t i = 0; i < M; i++) {
    int64_t a, b, c;
    cin >> a >> b >> c;
    graph[a - 1].push_back(make_pair(b - 1, -c));
  }

  uint32_t count = 0;
  for (uint32_t _ = 0; _ < N - 1; _++) {
    for (uint32_t i = 0; i < N; i++) {
      if (weights[i] == INF) continue;
      vector<pair<int64_t, int64_t>> routes = graph[i];
      for (uint32_t j = 0; j < routes.size(); j++) {
        int64_t to = routes[j].first;
        int64_t weight = routes[j].second + weights[i];
        if (weight < weights[to]) {
          weights[to] = weight;
        }
      }
    }
  }

  int64_t ans = -weights[N - 1];

  for (uint32_t _ = 0; _ < N - 1; _++) {
    for (uint32_t i = 0; i < N; i++) {
      if (weights[i] == INF) continue;
      vector<pair<int64_t, int64_t>> routes = graph[i];
      for (uint32_t j = 0; j < routes.size(); j++) {
        int64_t to = routes[j].first;
        int64_t weight = routes[j].second + weights[i];
        if (weight < weights[to]) {
          weights[to] = weight;
        }
      }
    }
  }
  if (ans == -weights[N - 1]) {
    cout << -weights[N - 1] << endl;
  } else {
    cout << "inf" << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,n) for (lint i = 0; i < (n); i++)
#define REP1(i,n) for (lint i = 1; i < (n); i++)
#define REPRE(i,n) for (lint i = N-1; i < 0; i--)
#define REP1RE(i,n) for (lint i = N-1; i < 1; i--)


int main(void){
    // input
    lint N;
    cin >> N;
    vector<lint> X(N),Y;
    REP (i, N) cin >> X[i];
    Y = X;
    sort(Y.begin(), Y.end());

    // output
    REP (i, N) {
        if (X[i] < Y[(N / 2)]) {
            cout << Y[(N / 2)];
        } else {
            cout << Y[(N / 2) - 1];
        }
        cout << endl;
    }
    return 0;
}

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

struct name
{
	int x;
	int y;
	int z;
}list[100005];
int time1[100005];
int s[100005];
int cmp(name a,name b)
{
	if(a.x<b.x)
		return 1;
	else
		if(a.x==b.x)
			return a.z<b.z;
		else
			return 0;
	return a.x<b.x;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d%d",&list[i].x,&list[i].y,&list[i].z);
	}
		sort(list,list+n,cmp);
	int anc=1;
	time1[0]=list[0].y;
	s[0]=list[0].z;
	for(int i=1;i<n;i++)
	{
		int j;
		for(j=0;j<anc;j++)
			if(s[j]==list[i].z)
			{
				time1[j]=list[i].y;
				s[j]=list[i].z;
				break;
			}
			else
			{
				if(time1[j]<list[i].x)
				{
					time1[j]=list[i].y;
					s[j]=list[i].z;
					break;
				}
				
			}
		if(j==anc)
		{	
			time1[anc]=list[i].y;
			s[anc]=list[i].z;
			anc++;
		
			
		}
	}
	
	
	printf("%d\n",anc);
	
	
	
	
	return 0;
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int h,w;
    cin>>h>>w;

    char arr[h][w];
    for(int i=0;i<h;i++) {
        for(int j=0;j<w;j++) {
            cin>>arr[i][j];
        }
    }

    vector<vector<int>> dp(h+1, vector<int>(w+1));
    dp[1][1]=1;

    for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++) {
            if(i==1&&j==1)
                continue;
            if(arr[i-1][j-1]=='#')
                dp[i][j]=0;
            else {
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]%=MOD;
            }
        }
    }

    cout<<dp[h][w];

    return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main() {
	string s;
	while (getline(cin, s)) {
		s += ' ';
		stack<double>stk;
		string str;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == ' ') {
				if (str == "+") {
					int b = stk.top(); stk.pop();
					int a = stk.top(); stk.pop(); 
					stk.push(a + b);
				}
				else if (str == "-") {
					int b = stk.top(); stk.pop();
					int a = stk.top(); stk.pop();
					stk.push(a - b);
				}
				else if (str == "*") {
					int b = stk.top(); stk.pop();
					int a = stk.top(); stk.pop();
					stk.push(a * b);
				}
				else if (str == "/") {
					int b = stk.top(); stk.pop();
					int a = stk.top(); stk.pop();
					stk.push(a / b);
				}
				else stk.push(stoi(str));
				str = "";
			}
			else str += s[i];
		}
		cout << stk.top() << endl;
	}
}

Measured memory_bytes: 3244
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long X = inputArray[0];
			long N = inputArray[1];

			if (N==0) {
				var dummyUketori = retreiveStringArray();
				Console.WriteLine(X);
				return;
			}

			var testArray = retreiveLongArray().ToList();

			for (int i = 0; i < 101; i++) {

				var minusTest = X - i;
				if (!testArray.Contains(minusTest)) {
					Console.WriteLine(minusTest);
					return;
				}

				var plusTest = X + i;
				if (!testArray.Contains(plusTest)) {
					Console.WriteLine(plusTest);
					return;
				}
			}


		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			if (inputArray.Length == 0) {
				return new long[0];
			}

			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 28232
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String sl[] = s.split(" ");
            int a = Integer.parseInt(sl[0]);
            int b = Integer.parseInt(sl[1]);

            System.out.println(a <= b ? a : a - 1);
        }
    }
}


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

struct P{
    int p, l, r;
};

P T[30];

int D[30], H[30];

void depth(int v, int d){
    if(v == -1) return;
    D[v] = d;
    depth(T[v].l, d + 1);
    depth(T[v].r, d + 1);
}
int hight(int v){
    if(v == -1) return -1;
    if(T[v].l == -1 && T[v].r == -1) H[v] = 0;
    return H[v] = (max(hight(T[v].l), hight(T[v].r)) + 1);
}

int sibling(int v){
    if(T[v].p == -1) return -1;
    if(T[T[v].p].l != v) return T[T[v].p].l;
    return T[T[v].p].r;
}

void print(int v){
    printf("node %d: ", v);
    printf("parent = %d", T[v].p);
    printf(", sibling = %d", sibling(v));
    int deg=0;
    if(T[v].l != -1) deg++;
    if(T[v].r != -1) deg++;
    printf(", degree = %d", deg);
    printf(", depth = %d", D[v]);
    printf(", height = %d", H[v]);
    if(T[v].p == -1) printf(", root\n");
    else if(T[v].l == -1&& T[v].r == -1) printf(", leaf\n");
    else printf(", internal node\n");
}

int main(){
    int n, v, l, r, root;
    cin >> n;
    for(int i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = -1;
    for(int i = 0; i < n; i++){
        cin >> v >> l >> r;
        T[v].l = l;
        T[v].r = r;
        if(l != -1) T[l].p = v;
        if(r != -1) T[r].p = v;
    }
    for(int i = 0; i < n; i++){
        if(T[i].p == -1) root = i;
    }
    depth(root, 0);
    hight(root);
    for(int i = 0; i < n; i++) print(i);
     
    
    
  return 0;
}


Measured memory_bytes: 3192
from collections import defaultdict,deque

N = 4
d = defaultdict(list)
for i in range(3):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)


for i in range(1,5):
    dist = [None]*N
    q = deque()
    s = i  # スタート
    q.append(s)
    dist[s-1] = 0

    while len(q)!=0:
        From = q.popleft()
        for To in d[From]:
            if dist[To-1] == None:
                q.append(To)
                dist[To-1] = dist[From-1]+1
    if set(dist)=={0,1,2,3}:
        print("YES")
        exit()
print("NO")

Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int bubble_sort(int *A, int N)
{
    int flag = 1;           // 逆の隣接行列が存在
    int i = 0;              // 未ソート部分列の先頭index
    int exchange_times = 0; // 交換回数

    while (flag)
    {
        flag = 0;
        for (int j = N - 1; j >= i + 1; j--)
        {
            if (A[j] < A[j - 1]) // A[j] <= A[j - 1]だと安定ソートではなくなる
            {
                int tmp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = tmp;
                flag = 1;
                exchange_times += 1;
            }
        }
        i += 1;
    }
    return exchange_times;
}

int main(void)
{
    int N;
    int A[100];
    int times;

    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }

    times = bubble_sort(A, N);
    for (int i = 0; i < N; i++)
    {
        if (i == N - 1)
        {
            printf("%d\n", A[i]);
        }
        else
        {
            printf("%d ", A[i]);
        }
    }
    printf("%d\n", times);

    return 0;
}


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

int main()
{
    string s;
    int a = 0, b = 0;
    cin >> s;
    for(int i=0; i<3; i++){
		if(s[i] == 'A') a++;
		else b++;
    }

    if(a && b) cout << "Yes";
    else cout << "No";

    return 0;
}


Measured memory_bytes: 256
# include <iostream>

using namespace std;


int main()
{
    int x[5];

	for (int i = 0; i < 5; i++)
	{
		cin >> x[i];
	}

	for (int i = 0; i < 5; i++)
	{
		if (x[i] == 0)
		{
			cout << i + 1;
		}
	}

    return 0;
}

Measured memory_bytes: 3584
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, h, w; cin >> n >> h >> w;
  cout << (h <= n && w <= n? (n-h+1)*(n-w+1) : 0) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back

int main() {
    ios
    string str1,str2;
    cin >> str1 >> str2;
    vector <vector <int> > dp (3100 , vector <int> (3100));
    rep(i,0,str1.length()+1)
        rep(j,0,str2.length()+1)
    {
        if(i==0 || j==0)
            dp[i][j]=0;
        else if(str1[i-1]!=str2[j-1])
            dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
        else dp[i][j]=dp[i-1][j-1] +1;
    }
    int res=dp[str1.length()][str2.length()];
//    cout << res << endl;
    int i=str1.length(), j=str2.length();
    string ans;
    while(dp[i][j]!=0)
    {
        if(dp[i][j]==dp[i-1][j])
            i=i-1;
        else if(dp[i][j]== dp[i][j-1])
            j=j-1;
        else{
            ans.pb(str1[i-1]);
            i=i-1;
            j=j-1;
        }
    }
    reverse(ans.begin(),ans.end());
    cout << ans;
    return 0;
}


Measured memory_bytes: 38016
#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>;
#define chmax(x,y) x = max(x,y);
const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll x = 0;
    rep(i,n) {
        if (i%2) x -= a[i];
        else x += a[i];
    }
    vector<ll> ans(n);
    ans[0] = x/2;
    for (int i = 1; i <= n-1; i++) {
        ans[i] = a[i-1] - ans[i-1];
    }
    rep(i,n) ans[i] *= 2;
    rep(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 4544
import std.stdio, std.conv, std.string, std.array, std.algorithm, std.range,
    std.math, std.numeric, std.typecons;

void main()
{
    long a, b;
    readf("%d %d\n", &a, &b);

    long g = gcd(a, b);
    long cnt = 1;
    for (long i = 2; i * i <= g; i++)
    {
        if (g % i == 0)
        {
            cnt++;
            while (g % i == 0)
            {
                g /= i;
            }
        }
    }
    if (g != 1)
    {
        cnt++;
    }
    writeln(cnt);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int a;
  int b;

  cin >> a;
  cin >> b;

  if(a < b)
    cout << "a < b" << endl;
  else if(a > b)
    cout << "a > b" << endl;
  else
    cout << "a == b" << endl;
}

Measured memory_bytes: 3008
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		int sum = 0;
		for (int i = 0; i < s.length(); i++) {
			int d = s.charAt(i) - '0';
			sum += d;
		}
		if (sum % 9 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 40132
//Volume0-0061
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

class Tm implements Comparable<Tm>{
	public final int team;
	public final int crct;
	Tm(int t,int c){
		this.team = t;
		this.crct = c;
	}

	public int compareTo(Tm t){
		return t.crct - this.crct;
	}
}

public class Main {

	public static void main(String[] args) {

		//declare
		ArrayList<Tm> tm = new ArrayList<Tm>();
		Tm T;
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		String[] s;
		int t,c,rank,pre;

        //input
        Scanner sc = new Scanner(System.in);
        while(true){
        	s = sc.nextLine().split(",");
        	t = Integer.parseInt(s[0]);
        	c = Integer.parseInt(s[1]);
        	if(t == 0 && c == 0){break;}
        	tm.add(new Tm(t,c));
        }

    	//calculate
        Collections.sort(tm);

    	pre  = -1;
    	rank =  0;
        for(int i=0;i<tm.size();i++){
        	T = tm.get(i);
        	if(T.crct == pre){
        		map.put(T.team,rank);
        	} else {
        		rank++;
        		map.put(T.team,rank);
        		pre  = T.crct;
        	}
        }

    	//output
        while(sc.hasNext()){
        	System.out.println(map.get(sc.nextInt()));
        }
	}
}

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
static const ll INF = 1LL << 60;
//Write From this Line

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	bool check = true;
	string t = s;
	reverse(t.begin(),t.end());
	if(s != t){
		check = false;
	}
	t = s;
	// sの0から (n - 1) / 2文字を見る
	string s1 = s.substr(0,(n-1)/2);
	string t1 = s1;
	reverse(t1.begin(),t1.end());
	if(s1 != t1){
		check = false;
	}
	string s2 = s.substr((n+1)/2);
	string t2 = s2;
	reverse(t2.begin(),t2.end());
	if(s2 != t2){
		check = false;
	}

	if(check) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort(reverse=True)
    Large=deque([a for a in A if a>=0])
    Small=deque([a for a in A if a<0])
    if not Large:Large.append(Small.popleft())
    if not Small:Small.append(Large.pop())
    ans=[]
    while len(Small)>=2:
        a,b=Large.pop(),Small.pop()
        ans.append((a,b))
        Large.append(a-b)
    small=Small.pop()
    while len(Large)>=2:
        a=Large.pop()
        ans.append((small,a))
        small-=a
    large=Large.pop()
    ans.append((large,small))
    print(large-small)
    for a,b in ans:
        print(a,b)

if __name__=='__main__':
    main()

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

vector<string> stringSplit(const string &str, char sep) {
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep)) {
    v.push_back(buffer);
  }
  return v;
}

int main() {

  string W;
  cin >> W;

  string s;
  map<string, int> mp;

  while (getline(cin, s)) {
    if (s == "END_OF_TEXT") {
      break;
    } else {
      vector<string> v = stringSplit(s, ' ');
      for (int i = 0; i < v.size(); i++) {
        string s_ = "";
        for (int j = 0; j < v[i].size(); j++) {
          int v_ = (int) v[i][j];
          if (65 <= v_ && v_ <= 90) {
            s_ += char(v_ + 32);
          } else if (97 <= v_ && v_ <= 122) {
            s_ += v_;
          }
        }
        mp[s_]++;
      }
    }
  }

  cout << mp[W] << endl;

  return 0;

}


Measured memory_bytes: 3216
alphabets = "abcdefghijklmnopqrstuvwxyz"


n = int(input())

A = []
while True:
    A.append(n % 26)
    n //= 26
    if n == 0:
        break

for i in range(len(A) - 1):
    if A[i] <= 0:
        A[i] += 26; A[i + 1] -= 1

ANS = []
for a in A[::-1]:
    if a == 0:
        continue
    ANS.append(alphabets[a - 1])

print("".join(ANS))


Measured memory_bytes: 9148
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;


int a[10];
int n;

bool dfs(int i,int left, int right){
    if(i==10) return true;
    if(a[i]>left){
        if(dfs(i+1,a[i],right)) return true;
    }
    if(a[i]>right){
        if(dfs(i+1,left,a[i])) return true;
    }
    return false;
}

void solve(){
    for(int i=0;i<10;i++){
        cin>>a[i];
    }
    if(dfs(0,0,0)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return;
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  cout << s[0] << s.length()-2 << s[s.length()-1] << endl;
  return 0;
}


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

int main() {
  ll n, k;
  ll L, R;
  cin >> n >> k >> L >> R;
  ll ans = 0;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll num1 = n / 2, num2 = n - n / 2;
  vector<vector<ll>> a_all(num1 + 1);
  vector<vector<ll>> b_all(num2 + 1);
  for (ll bit = 0; bit < (1 << num1); bit++){
    ll tmp = 0;
    ll tmp_count = __builtin_popcount(bit);
    rep(i,num1){
      if(bit & (1 << i)){
        tmp += a[i];
      }
    }
    a_all[tmp_count].push_back(tmp);
  }
  for (ll bit = 0; bit < (1 << num2); bit++){
    ll tmp = 0;
    ll tmp_count = __builtin_popcount(bit);
    rep(i,num2){
      if(bit & (1 << i)){
        tmp += a[num1 + i];
      }
    }
    b_all[tmp_count].push_back(tmp);
  }
  rep(i, num2 +1){
    sort(b_all[i].begin(), b_all[i].end());
  }
  for (int i = max(0ll, k - num2); i <= num1 && i <= k; i++){
    for(auto v : a_all[i]){
      auto low = lower_bound(b_all[k - i].begin(), b_all[k - i].end(), L - v);
      auto upp = upper_bound(b_all[k - i].begin(), b_all[k - i].end(), R - v);
      if(upp - low <= 0)continue;
      ans += upp - low;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 23312
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
		double ans=0.000000000;
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		 for(int i=1;i<=n;i++){
			    long temp=i;
			    long tri=0;
			    while(temp<k){
			      temp*=2;
			      tri++;
			    }
			    ans+=1.000000000/(n*Math.pow(2,tri));
			 }
		 System.out.println(ans);
	}
}


Measured memory_bytes: 21332
/**
 * 
 */
//package AtCoder;
import java.util.*;
/**
 * @author Shivansh Singh
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int i,j,l1,l2,p;
		String str1,str2;
		str1=sc.next();
		str2=sc.next();
		l1=str1.length();
		l2=str2.length();
		int [][]dp=new int[l2+1][l1+1];
		for (i=0;i<=l1;i++)
			dp[0][i]=0;
		for (i=0;i<=l2;i++)
			dp[i][0]=0;
		for (i=1;i<=l2;i++) {
			for(j=1;j<=l1;j++) {
				if(str1.charAt(j-1)==str2.charAt(i-1))
					dp[i][j]=dp[i-1][j-1]+1;
				else
					dp[i][j]=(int)Math.max(dp[i-1][j],dp[i][j-1]);
			}
		}
		char []sub=new char[dp[l2][l1]];
		i=l2;
		j=l1;
		p=dp[l2][l1]-1;
		while(dp[i][j]!=0) {
			if(dp[i][j]==dp[i-1][j])
				i--;
			else if(dp[i][j]==dp[i][j-1])
				j--;
			else {
				sub[p]=str2.charAt(i-1);
				p--;
				i--;
				j--;
			}	
		}
		for (i=0;i<dp[l2][l1];i++)
			System.out.print(sub[i]);
		sc.close();
	}

}


Measured memory_bytes: 87792
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  if((r*100+g*10+b)%4==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>

#define ll long long

using namespace std;

int main(int argc, char* argv[]){
  char a;
  int ans=0;
  for (int i = 0; i < 4; ++i)
  {
    cin >> a;
    if(a == '+'){
      ans ++;
    }else{
      ans --;
    }
  }

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ABC103C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
        int N = int.Parse(Console.ReadLine());
            string[] input1 = Console.ReadLine().Split(' ');
            int ans = 0;
            for(int i = 0; i < N; i++)
            {
                ans += int.Parse(input1[i]) - 1;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>

int main( void ) {
	int a, b, d, tmp;

	for ( ; scanf( "%d %d", &a, &b ) == 2; printf( "%d\n", d ) ) {
		tmp = a + b;
		for ( d = 1; tmp /= 10; d++ ) ;
	}

	return 0;
}

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

const int N = 2e5 + 5;

map<int, int> mp;

int n, a[N], cnt;

signed main() {
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		cnt += mp[i - a[i]];
		mp[i + a[i]]++;
	}
	printf("%lld\n", cnt);
	return 0;
}

Measured memory_bytes: 27908
#include <stdio.h>

void main(){
int a,b,c,d;
int i;
scanf("%d %d %d %d",&a,&b,&c,&d);
while(a>0 || c>0)
{
c-=b;
if(c<=0){i=0; break;}
a-=d;
if(a<=0){i=1; break;}

}
if(i==0)printf("Yes\n");
if(i==1)printf("No\n");
}




Measured memory_bytes: 1660
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll gcd(ll x, ll y) {
  if (x%y==0) return y;
  return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  ll t = x / gcd(x, y);
  return t * y;
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  --A;
  ll ans = (B - B/C - B/D + B/lcm(C,D)) - (A - A/C - A/D + A/lcm(C, D));
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

vector<LL> A;
vector<LL> AB;
vector<LL> C;
priority_queue<LL,vector<LL>,greater<LL>> pq;

int main()
{
    int X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    _for(i,0,X){
        LL num;
        cin >> num;
        A.PB(num);
    }
    _for(i,0,Y){
        LL num;
        cin >> num;
        _for(j,0,A.size()){
            AB.PB(num + A[j]);
        }
    }

    sort(ALL(AB),greater<LL>());

    _for(i,0,Z){
        LL num;
        cin >> num;
        C.PB(num);
    }

    sort(ALL(C),greater<LL>());

    _for(i,0,Z){
        LL num = C[i];
        _for(j,0,AB.size()){
            LL sum = AB[j] + num;
            if(pq.size() < K) pq.push(sum);
            else{
                if(sum > pq.top()){
                    pq.pop();
                    pq.push(sum);
                }
                else{
                    break;
                }
            }

        }
    }

    vector<LL> ans;

    while(!pq.empty()){
        ans.PB(pq.top());
        pq.pop();
    }

    reverse(ALL(ans));

    _for(i,0,ans.size()){
        printf("%lld\n",ans[i]);

    }

    return 0;
}

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

using namespace std;

typedef long long ll;



 
const int mx = 105;
const int mx1 = 1000001;
const ll mod = 1000000007;


// void adds(int &a, int b){
//     a+= b;
//     if(a >= mod)
//      a-=mod;
// }

// void subs(int &a, int b){
//     a-= b;
//     if(a < 0)
//      a+=mod;
// }

int main(){
   ll n, i, j, l, r, k;

   cin>>n;
   vector<ll> a(n);

   for(i = 0;i < n;i++)
    cin>>a[i];

   ll dp[n][n]; 
   memset(dp, 0 ,sizeof(dp));

   ll pre[n];
   pre[0] = a[0];
   for(i = 1;i < n;i++){
       pre[i] = a[i]+pre[i-1];
   }

   for(i =0 ;i < n;i++){
       for(j = 0;j < n;j++)
        dp[i][j] = -1;
   }
   for(l = n-1;l >= 0;l--){
       for(r = l;r < n;r++){
           if(r-l+1 == 1){
               dp[l][l] = 0;
           }
           else if(r-l+1 == 2){
               dp[l][r] = a[l]+a[r];
              // cout<<l<<" "<<r;
           }
           else{
                ll te = pre[r] - ((l-1 >= 0) ? pre[l-1]:0);

              //  cout<<te<<" "<<r<<" "<<l<<"\n";

               for(k = l;k < r;k++){
                   if(dp[l][r] == -1 || dp[l][k] + dp[k+1][r] + te < dp[l][r])
                   dp[l][r] = dp[l][k] + dp[k+1][r] + te;
               }
           }
       }
   }

   
   cout<<dp[0][n-1];

} 


Measured memory_bytes: 1536
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (int, int, int) {
	n, a, b := scanInt(sc), scanInt(sc), scanInt(sc)
	return n, a, b
}

func resolve(n, a, b int) int {
	sum := 0
	for i := 1; i <= n; i++ {
		if s := digitSum(i); a <= s && s <= b {
			sum += i
		}
	}
	return sum
}

func digitSum(n int) (sum int) {
	for cur := n; cur > 0; cur /= 10 {
		sum += cur % 10
	}
	return sum
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#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, n0, ax, ay, h, f;
    cin >> n;
    vector<vector<int>> za(n, vector<int>(3));
    rep(i, n) cin >> za.at(i).at(0) >> za.at(i).at(1) >> za.at(i).at(2);
    rep(i, n){
        if(za.at(i).at(2) != 0){ n0 = i; break;}
    }
    rep(x, 101){
        rep(y, 101){
            h = abs(za.at(n0).at(0)-x) + abs(za.at(n0).at(1)-y) + za.at(n0).at(2);
            f = 0;
            rep(i, n){
                if(max(h-abs(za.at(i).at(0)-x)-abs(za.at(i).at(1)-y), 0) != za.at(i).at(2)){
                    f = 1;
                    break;
                }
            }
            if(f == 0){
                ax = x;
                ay = y;
                break;
            }
        }
        if(f == 0) break;
    }
    cout << ax << ' ' << ay << ' ' << h << endl; 
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

X,N = map(int, input().split())
if N==0:
    print(X)
    quit()
PList=list(map(int, input().split()))
List=[]
for k in range(102):
    List.append(k)

i=0
while i<N:
    if PList[i] in List:
        List[List.index(PList[i])]=100000
    i+=1

#print(List)


ANS=1000
j=0
KOTAE=1000
while j<102:
    if List[j]!=100000:
        SA=abs(X-List[j])
        if SA<ANS:
            ANS=SA
            #print("ands",ANS)
            KOTAE=List[j]
            #print(KOTAE)
        #print(ANS)
    j+=1
print(KOTAE)

Measured memory_bytes: 9224
import heapq

H, W = [int(i) for i in input().split()]
maze = [list(input()) for _ in range(H)]

ans = 0
for h in range(H):
    for w in range(W):
        visited = [[False] * W for _ in range(H)]
        queue = [(0, h, w)]
        max_move = 0
        while queue:
            move, nh, nw = heapq.heappop(queue)
            if not (0 <= nh < H and 0 <= nw < W):
                continue
            if visited[nh][nw]:
                continue
            if maze[nh][nw] == "#":
                continue
            visited[nh][nw] = True
            max_move = max(max_move, move)
            heapq.heappush(queue, (move + 1, nh + 1, nw))
            heapq.heappush(queue, (move + 1, nh - 1, nw))
            heapq.heappush(queue, (move + 1, nh, nw + 1))
            heapq.heappush(queue, (move + 1, nh, nw - 1))
        ans = max(ans, max_move)
print(ans)


Measured memory_bytes: 82908
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int H, W;
    cin >> H >> W;
    char a[H][W];
    rep(i, H){
        rep(j, W) cin >> a[i][j];
    }
    vector<int> iw;
    vector<int> jw;
    rep(i, H){
        bool is_w = true;
        rep(j, W) if(a[i][j] == '#') is_w = false;
        if(is_w) iw.push_back(i);
    }
    rep(j, W){
        bool is_w = true;
        rep(i, H) if(a[i][j] == '#') is_w = false;
        if(is_w) jw.push_back(j);
    }
    rep(i, H){
        if(count(iw.begin(), iw.end(), i) == 0){
            rep(j, W){
                if(count(jw.begin(), jw.end(), j) == 0) cout << a[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  map<int, ll> mp;
  int n, q, now, b, c;
  ll sum  = 0;
  cin >> n;
  rep(i, n) {
    cin >> now;
    mp[now]++;
    sum += now;
  }
  cin >> q;
  while(q--) {
    cin >> b >> c;
    if(!mp[b]) {
        cout << sum << endl;
        continue;
    }
    sum -= mp[b] * b;
    sum += mp[b] * c;
    mp[c] += mp[b];
    mp[b] = 0;
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 9228
#include <stdio.h>

int main()
{
    int n, m, i, j;
    
    scanf("%d %d", &n, &m);
    
    int A[n][m];
    int b[m];
    int c[n];
    
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            A[i][j] = 0;
            if(i == 0){
                b[j] = 0;
            }
        }
        c[i] = 0;
    }
    
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            scanf("%d", &A[i][j]);
        }
    }
    
    for(j=0; j<m; j++){
        scanf("%d", &b[j]);
    }
    
    for(i=0; i<n; i++){
        for(j=0; j<m; j++){
            c[i] += A[i][j] * b[j];
        }
        printf("%d\n", c[i]);
    }
    
    return 0;
    
}

Measured memory_bytes: 640
N = int(input())
p = list(map(int, input().split(" ")))
q = [i for i in range(1,N+1)]

count = 0
for i in range(N):
	if p[i]!=q[i]:
		count += 1
if count == 0 or count == 2:
	print('YES')
else:
	print('NO')


Measured memory_bytes: 3060
import math

X = int(input())

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

i = X
while True:
    if is_prime(i):
        print(i)
        break
    i += 1

Measured memory_bytes: 3060
#include <cstdio>

int main(){
    
    for(;;){
        int x,y;
        scanf("%d%d",&x,&y);
        if(x == 0 && y == 0){
            break;
        }
        if(x <= y){
            printf("%d %d\n",x,y);
        }else if(x > y){
            printf("%d %d\n",y,x);
        }
    }
    return 0;
}


Measured memory_bytes: 2556
#include<bits/stdc++.h>
#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()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, Q;
vector<int> E[201010];
int val[201010];
//---------------------------------------------------------------------------------------------------
void dfs(int cu, int pa = -1) {
	fore(to, E[cu]) if(pa != to) {
		val[to] += val[cu];
		dfs(to, cu);
	}
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> Q;
	rep(i, 0, N - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}

	rep(q, 0, Q) {
		int p, x; cin >> p >> x;
		p--;
		val[p] += x;
	}

	dfs(0);

	rep(i, 0, N) {
		if (i) printf(" ");
		printf("%d", val[i]);
	}
	printf("\n");
}







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

using namespace std;



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, t;
  cin >> s >> t;
  bool ans = false;
  for (int i = 0; i < (int)s.size(); ++i) {
    ans |= s==t;
    rotate(t.begin(), t.begin()+1, t.end());
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
  
import fractions
a=A[0]
for i in range(1, N):
    a=a*A[i]//fractions.gcd(a,A[i])
a-=1
ans=0
for i in A:
  ans+=a%i
print(ans)

Measured memory_bytes: 5176
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {
	static long ans = 1;
	static int n, k;
	static int mod = 1000000007;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		n = Integer.parseInt(sa[0]);
		k = Integer.parseInt(sa[1]);
		Map<Integer, List<Integer>> map = new HashMap<Integer, List<Integer>>();
		map.put(-1, new ArrayList<Integer>());
		map.put(0, new ArrayList<Integer>());
		for (int i = 0; i < n - 1; i++) {
			sa = br.readLine().split(" ");
			int a = Integer.parseInt(sa[0]) - 1;
			int b = Integer.parseInt(sa[1]) - 1;

			List<Integer> list1 = map.get(a);
			if (list1 == null) {
				list1 = new ArrayList<Integer>();
				map.put(a, list1);
			}
			list1.add(b);

			List<Integer> list2 = map.get(b);
			if (list2 == null) {
				list2 = new ArrayList<Integer>();
				map.put(b, list2);
			}
			list2.add(a);
		}
		br.close();

		int[] cnt = new int[100005];
		dfs(map, 0, -1, 2, cnt);
		System.out.println(ans);
	}

	static void dfs(Map<Integer, List<Integer>> map, int c, int p, int dep, int[] cnt) {
		int x = Math.min(cnt[dep - 2], 1) + Math.min(cnt[dep - 1], 1) + cnt[dep] + cnt[dep + 1];
		int y = Math.max(k - x, 0);
		ans *= y;
		ans %= mod;
		cnt[dep]++;

		List<Integer> list = map.get(c);
		for (int i : list) {
			if (i != p) {
				dfs(map, i, c, dep + 1, cnt);
			}
		}
		dep--;
		cnt[dep + 2] = 0;
	}
}


Measured memory_bytes: 81784
#include<cstdio>
using namespace std;

int main() {
	int n, k;
	char s[100005];
	scanf("%d %d", &n, &k);
	scanf("%s", s);
	int flips = 0;
	int start = -1;
	for (int i = 1; i < n; i++) {
		if (start < 0 && s[i] != s[0]) {
			start = i;
		}
		if (start > 0 && s[i] == s[0]) {
			start = -1;
			if (k > 0) {
				k--;
			}
			else {
				flips += 2;
			}
		}
	}
	if (start > 0) {
		if (k > 0) {
			k--;
		}
		else {
			flips += 1;
		}
	}
	printf("%d\n", n - 1 - flips);
	return 0;
}


Measured memory_bytes: 888
N = int(input())
h = [int(_) for _ in input().split()]

optimal_cost = [0]
optimal_cost.append(abs(h[1] - h[0]))

for i in range(2, N):
    cost = min(abs(h[i] - h[i - 1]) + optimal_cost[i - 1],
               abs(h[i] - h[i - 2]) + optimal_cost[i - 2])
    optimal_cost.append(cost)

print(optimal_cost[-1])


Measured memory_bytes: 13928
A,B = map(int,input().split())
coin = 0

if A > B :
    coin = coin + A
    A = A-1
    if A > B:
        coin = coin +A
    else : 
        coin = coin + B
elif B >=A :
    coin = coin + B
    B = B-1
    if A > B:
        coin = coin + A
    else :
        coin = coin + B
    
print(coin)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  vector<int>x(m),dx(m-1);
  rep(i,m)cin>>x[i];
  sort(all(x));
  rep(i,m-1)dx[i]=x[i+1]-x[i];
  sort(all(dx));
  int summ=0;
  rep(i,m-n)
  {
    summ+=dx[i];
  }
  cout<<summ<<endl;


  return 0;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
int i[1111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e,f;
  cin >>a>>b;
  if(a>12) d=b;
  if(a<=12&&a>=6) d=b/2;
  cout <<d<<'\n';
  return (0);
}


Measured memory_bytes: 256