akhauriyash/Code-Regression huggingface dataset:
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 105
#define PI 3.141592653589793
#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
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, X, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;
ll ans;

int main() {
	go;
    cin >> X >> N;
    fi(i, 0, N, 1) {
    	cin >> arr[i];
    	mp[arr[i]]++;
    }
    ll minDiff = 1e15;
    fei(i, 0, 1000, 1) {
    	if(!mp[i]) {
    		if(abs(i - X) < minDiff) {
    			minDiff = abs(i - X);
    			ans = i;
    		}
    	}
    }
    cout << ans << "\n";
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3732
# -*- coding: utf-8 -*-
import math

def get_dist(x, y, d):
    dist = 0
    for i in range(d):
        dist += (x[i] - y[i]) ** 2

    return math.sqrt(dist)


N, D = map(int, input().split())
X_list = []
for i in range(N):
    X_list.append(list(map(int, input().split())))

cnt = 0
for i in range(N):
    for j in range(i+1, N, 1):
        x = X_list[i]
        y = X_list[j]
        num = get_dist(x, y, D)
        if(num.is_integer()):
            cnt += 1

print(cnt)


Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

int lsone(int n)
{
	return (n&-n);
}

ll pow1(ll a, ll b)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2);
		x *= x;
		x %= mod;
		if (b%2)
		{
			x *= a;
			x %= mod;
		}
		return x;
	}
}

ll h, w, dp[1100][1100], vis[1100][1100];
char grid[1100][1100];

int main()
{
	fastio;		
	cin>>h>>w;

	for (int i = 1; i <= h; i++)
	{
		for (int j = 1; j <= w; j++)
		{
			cin>>grid[i][j];
		}
	}

	queue< pi > q;
	dp[1][1] = 1;
	q.push(mp(1, 1));

	while (!q.empty())
	{
		pi temp = q.front(); q.pop();
		int x = temp.first, y = temp.second;
		//cout<<x<<" "<<y<<" "<<dp[x][y]<<endl;
		if (x+1 <= h and grid[x+1][y] == '.')
		{
			dp[x+1][y] += dp[x][y];
			dp[x+1][y] %= mod;
			if (!vis[x+1][y])
			{
				q.push(mp(x+1, y));
				vis[x+1][y]++;
			}
		}

		if (y+1 <= w and grid[x][y+1] == '.')
		{
			dp[x][y+1] += dp[x][y];
			dp[x][y+1] %= mod;
			if (!vis[x][y+1])
			{
				q.push(mp(x, y+1));
				vis[x][y+1]++;
			}
		}
	}	

	cout<<dp[h][w]<<endl;
	return 0;
}


Measured memory_bytes: 19456
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

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

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k;
  vector<ll> x(n);
  vector<ll> x_cp(n);
  vector<ll> y(n);
  vector<ll> y_cp(n);

  REP(i, n) {
    cin >> x[i] >> y[i];
    x_cp[i] = x[i];
    y_cp[i] = y[i];
  }

  sort(x.begin(), x.end());
  sort(y.begin(), y.end());

  ll ans = 1e19*2;
  REP(xi, n) {
    FOR(xj, xi + 1, n) {
      REP(yi, n) {
        FOR(yj, yi + 1, n) {
          ll sx = x[xi];
          ll tx = x[xj];
          ll sy = y[yi];
          ll ty = y[yj];
          int count = 0;
          REP(m, n) {
            ll nx = x_cp[m];
            ll ny = y_cp[m];
            if((sx <= nx && nx <= tx) && sy <= ny && (ny <= ty)) count++;
          }
          if(count >= k) ans = min(ans, (tx - sx) * (ty - sy));
        }
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main() {
	int N, Z, W; 
	cin >> N >> Z >> W; 
	int A[2019] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
	}
	if(N == 1){cout << abs(A[0] - W) << endl;}
	else{cout << max(abs(A[N-2] - A[N-1]), abs(A[N-1] - W)) << endl;}
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }




int main() {
	mapci val;
	val['I'] = 1; val['V'] = 5; val['X'] = 10; val['L'] = 50; val['C'] = 100; val['D'] = 500; val['M'] = 1000;
	
	string in;
	while (cin>>in) {
		int ans = 0;
		for_(i, 0, (int)in.sz) {
			if (i<(int)in.sz-1) {
				if (val[ in[i] ]<val[ in[i+1] ]) { 
					ans += val[ in[i+1] ] - val[ in[i] ];
					i++;
				} else ans += val[ in[i] ];
			} else {
				ans += val[ in[i] ];
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  ll tmp = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    if (a%2 == 0) {
      if ((a%3 != 0) && (a%5 != 0)) {
        tmp++;
        break;
      }
    }
  }
  if (tmp > 0) {
    cout << "DENIED" << endl;
  } else {
    cout << "APPROVED" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
    int a,b[300],c[300][300],e,d[300],f,t,i,j,k=0,l=0;
    cin>>t>>a>>e;
    for(i=0;i<a;i++){
        cin>>b[i];}
        for(i=0;i<t;i++)
        {
            for(j=0;j<a;j++)
                cin>>c[i][j];
        }
        for(i=0;i<t;i++)
        {
            k=0;
            for(j=0;j<a;j++)
            {
                k+=c[i][j]*b[j];
            }
            k+=e;
            if(k>0)
                l++;
        }
        cout<<l<<endl;
        return 0;
    }


Measured memory_bytes: 256
while True:
    h,w=map(int,input().split())
    if h==0 and w==0:break
    for i in range (0, h):
        if i==0 or i==h-1:
            print('#'*w)
        else:
            putstr = '.'*(w-2)
            print(f'#{putstr}#')

    print()



Measured memory_bytes: 5624
#include <cassert>
#include <iostream>
#include <functional>
#include <iomanip>
#include <set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <deque>
#include <algorithm>
#include  <cstring>
#include <string>
#include <cmath> 
using namespace std;
typedef long long LL;
const int MAX = 110000;
const LL base = 1e9 + 7;


struct Node {
	int x, y, w;
};

LL zv[110];
LL zw[110];

LL dp[MAX];
void solve() {

	LL result = 0;
	LL n, w;

	cin >> n >> w;
	fill(dp, dp + MAX, w + 1);

	dp[0] = 0;

	for (int i = 0; i < n; ++i) {
		cin >> zw[i] >> zv[i];
		for (int j = MAX-100 - zv[i]; j >= 0; --j) {
			int nv = j + zv[i];
			dp[nv] = min(dp[nv], dp[j] + zw[i]);
		}
	}
	for (int i = MAX - 100; i >= 0; --i) {
		if (dp[i] <= w) {
			result = i;
			break;
		}
	}
	cout << result << endl;

}

int main() {
	const int inId = 0;
	const int outId = 0;
	if (inId>0) {
		cerr << "redirect stdin to input " << inId << endl;
		string s = "input";
		s += to_string(inId);
		s += ".txt";
		auto r = freopen(s.c_str(), "r", stdin);
		if (r == nullptr) {
			cerr << "invalid input file " << s;
		}
	}
	if (outId>0) {
		cerr << "redirect stdout to stdout " << outId << endl;
		string s = "stdout";
		s += to_string(outId);
		s += ".txt";
		auto r = freopen(s.c_str(), "w", stdout);
		if (r == nullptr) {
			cerr << "invalid output file " << s;
		}
	}
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // close sync between cout and printf
	cout.precision(10);
	solve();
}


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

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

    int x, n;
    cin >> x >> n;
    if (n == 0){
        cout << x;
        return 0;
    }
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p.at(i);
        //cout << p.at(i);
    }
    int i = 0;
    bool fp, fm;
    while (true)
    {
        fp = false;
        fm = false;
        for (int j = 0; j < n; j++)
        {
            if (!fm && x - i == p.at(j))
            {
                fm = true;
                //cout << i << j << p.at(j) << endl;
            } 
            if (!fp && x + i == p.at(j))
            {
                fp = true;
                //cout << i << j << p.at(j) << endl;
            }
        }
        if (!fm) {
            cout << x - i;
            return 0;
        } else if (!fp) {
            cout << x + i;
            return 0;
        }
        i++;
    }
}

Measured memory_bytes: 3652
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");

    public static void main(String[] args){
        Scanner sc  = new Scanner(System.in);

        int N = sc.nextInt();

        int[] A = new int[N];

        int max = 0;
        int max2 = 0;
        List<Integer> maxIndex = new ArrayList<>();
        for(int i=0; i<N; i++){
            int num = Integer.parseInt(sc.next());
            A[i] = num;
            if(max < num){
                max2 = max;
                max = num;
                if(maxIndex.size() != 0 && maxIndex.get(maxIndex.size()-1) < max) maxIndex.remove(maxIndex.size()-1);
                maxIndex.add(i);
            }else{
                max2 = Math.max(A[i], max2);
            }
        }

        int[] B = new int[N];
        Arrays.fill(B, max);

        for(int index : maxIndex){
            B[index] = max2;
        }


        StringBuffer str = new StringBuffer();
        for(int i=0; i<N; i++){
            str.append(B[i] + br);
        }

        print(str.toString());
    }

    static void println(Object o){
        PrintWriter out = new PrintWriter(System.out);
        out.println(o);
        out.flush();
    }
   static void print(Object o){
       PrintWriter out = new PrintWriter(System.out);
       out.print(o);
       out.flush();
    }
}


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

const int MAX = 1e9;

void out(int x, int y) {
	printf("%d %d ", x, y);
}

int main() {
	long long S;
	scanf("%lld", &S);
	out(0, 0);
	out(MAX, 1);
	int add = (MAX - S % MAX) % MAX;
	out(add, (S + add) / MAX);
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    FastIO;
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i,n){
        cin >> a[i];
        a[i]*=-1;
    } 
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));

    ll ans = 0;
    for(int i = 0; i < n; i++){
        int bi = b[i];
        auto itrA = upper_bound(all(a), -bi);
        if (itrA == a.end()) continue;
        size_t posA = distance(a.begin(), itrA);

        auto itrC = upper_bound(all(c), bi);
        if (itrC == c.end()) continue;
        size_t posC = distance(c.begin(), itrC);

        ll cntA = n-posA;
        ll cntC = n-posC;
        ans += cntA * cntC;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4500
def sumDigit(i):
  if i > 0:
    return sumDigit(i // 10) + i % 10
  else:
    return 0

n = int(input())
ans = n
for a in range(1, n):
  tmp = sumDigit(a) + sumDigit(n - a)
  ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 2940
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

class Node{
	bool[Node] adjnodeset;
	long id;
	long value1 = -1;
	long value2 = -1;
	this(long id){
		this.id = id;
		}
	void add(Node nd){
		this.adjnodeset[nd] = 1;
		nd.adjnodeset[this] = 1;
		}
	void extend1(){
		debug writeln("(", id, ")");
		foreach(nd; adjnodeset.keys){
			if(nd.value1 < 0){
				nd.value1 = this.value1 + 1;
				nd.extend1();
				}
			}
		}
	void extend2(){
		debug writeln("(", id, ")");
		foreach(nd; adjnodeset.keys){
			if(nd.value2 < 0){
				nd.value2 = this.value2 + 1;
				nd.extend2();
				}
			}
		}
	string dump(){
		return id.to!string ~ "[" ~ value1.to!string ~ " " ~ value2.to!string ~ "]";
		}
	}

bool f;

void main(){
	long n = read.to!long;
	
	Node[long] nodes;
	foreach(i; 0 .. n) nodes[i + 1] = new Node(i + 1);
	
	foreach(i; 0 .. n - 1){
		long a = read.to!long;
		long b = read.to!long;
		nodes[a].add(nodes[b]);
		}
	
	nodes[1].value1 = 0, nodes[1].extend1();
	nodes[n].value2 = 0, nodes[n].extend2();
	
	long count;
	foreach(nd; nodes) if(nd.value1 <= nd.value2) count += 1;
	
	string ans;
	if(count > n / 2) ans = "Fennec";
	else ans = "Snuke";
	
	ans.writeln;
	
	debug nodes.values.map!(x => x.dump).join(" ").writeln;
	
	}


Measured memory_bytes: 59452
import java.util.*;
import java.io.*;

class Main {
  static int n;
  public static void main(String[] args) throws IOException {
    int i;
    BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
    n = Integer.parseInt(buffer.readLine());
    Deque<Integer> d = new ArrayDeque<Integer>();
    String[] str;

    for(i=0;i<n;i++) {
        str = buffer.readLine().split(" ");
        switch(str[0]) {
            case "insert":
                d.addFirst(Integer.parseInt(str[1]));
                break;
            case "delete":
                d.remove(Integer.parseInt(str[1]));
                break;
            case "deleteLast":
                d.removeLast();
                break;
            case "deleteFirst":
                d.remove();
                break;
        }
    }
    for(i=d.size();i>0;i--){
      if(i==1){
        System.out.println(d.poll());
        break;
      }
      System.out.print(d.poll()+" ");
    }
  }
}



Measured memory_bytes: 193792
fun main(args: Array<String>) = println(run {
    val (a,b,c,d) = readLine()!!.split(" ").map { it.toLong() }
    fun count(x: Long) = x - x/c - x/d + x/((c*d)/gcd(c,d))
    count(b)-count(a-1)
})

tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)


Measured memory_bytes: 37968
#include <iostream>
#include <algorithm>
int main(){
 int x,n=1,add=1;
 std::cin >> x;
 for(int i=2;i<x+1;i++)
  if(n<x){
   n+=i;
   add++;
  }
  else{
   std::cout << std::min(add,x) << std::endl;
   return 0;
  }
  std::cout << x << std::endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        sc.nextLine();
        Map<Integer,Integer> map = new HashMap<>();
        for(int i = 0;i<m;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            sc.nextLine();
            if(map.get(a) != null){
                map.put(a, map.get(a)+1);
            }else{
                map.put(a,1);
            }
            if(map.get(b) != null){
                map.put(b, map.get(b)+1);
            }else{
                map.put(b,1);
            }
        }
        for(int i = 1;i<n+1;i++){
            if(map.get(i) != null){
                System.out.println(map.get(i));
            }else{
                System.out.println(0);
            }
        }
    }
}

Measured memory_bytes: 21844
#include <stdio.h>

int main(void){
    int a,b,c,tmp;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (a>b){
	    tmp=a;a=b;b=tmp;
    }
	if (b>c){
	    tmp=b;b=c;c=tmp;
    }
	if (a>b){
	    tmp=a;a=b;b=tmp;
    }
	
	printf("%d %d %d\n", a,b,c);
	      
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

	ll a,b,c,k, t; cin >> a >> b >> c  >> k;

	k -= a;
	if (k <= 0) cout << k + a <<endl;
	else {
	  k -= b;
		if (k <= 0) cout << a << endl;
		else {
			k -= c;
			if (k <= 0) cout << a - (k + c) <<  endl;
			else cout << a - c << endl;

		}
	}
}

Measured memory_bytes: 3660
from collections import Counter

N = int(input())
S = []
for _ in range(N):
    S.append(input())

counter = Counter(S)

max_val = max(counter.values())
ans = []
for key, value in counter.items():
    if value == max_val:
        ans.append(key)

ans = sorted(ans)

for s in ans:
    print(s)


Measured memory_bytes: 35572
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int n, m;
    cin >> n >> m;
    int days = 0, dtmp;
    rep(i,m) {
        cin >> dtmp;
        days += dtmp;
    }
    int ans;
    ans = n - days;
    cout << max(-1,ans) << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include<sstream>
#include <string>
int gcd( int m, int n )
{
	// ?????°?????????????????´??????????????????
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ???????????????????????????
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// ?????°?????????????????´??????????????????
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int main() {
  std::string s;
  int a{},b{};
  
  while (std::getline(std::cin, s)) {
    std::stringstream ss;
    ss<<s;
    ss>>a>>b;
    std::cout<<gcd(a,b)<<' '<<lcm(a,b)<<std::endl;
  }
  return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
//typedef long long unsigned int ll;
typedef long long ll;
typedef pair<ll, ll> edge;
//typedef tuple<ll, ll, ll> tp;
const ll INF = 1e18;
const ll mod = 1e9+7;

int main() {
  ll n;
  cin >> n;
  string S[n];
  for (int i=0;i<n;i++){
    cin >> S[i];
    sort(S[i].begin(),S[i].end());
  }
  sort(S,S+n);
  //cout << S[0] << endl;
  //cout << S[1] << endl;
  //cout << S[2] << endl;
  
  string tmp = S[0];
  ll count = 1;
  ll sum = 0;
  for(int i=1;i<n;i++){
    if (tmp != S[i]){
      tmp = S[i];
      if(count != 1) sum += count*(count-1)/2;
      count = 1;
    }
    else count += 1;
  }
  if(count != 1) sum += count*(count-1)/2;
  cout << sum << endl;
}

Measured memory_bytes: 7296
#include<stdio.h>

int main(){
    /*    int m[10];
    int i,j,k;

    for(i = 0; i < 10; i++){
        scanf("%d",&m[i]);
    }

    for(j = 0; j < 9; j++){
        for(k = 0; k < 9-j; k++){
            if(m[k] < m[k+1]){
                int num = m[k+1];
                m[k+1] = m[k];
                m[k] = num;
            }
        }
    }

    for(i = 0; i < 3; i++){
        printf("%d\n",m[i]);
    }
    */

    while(1){

        int x[4],y[4];
        int i,j;
        int hit = 0,blow = 0;
        int res = scanf("%d%d%d%d",&x[0],&x[1],&x[2],&x[3]);
        if(res==EOF) break;

        for(i = 0; i < 4; i++){
            scanf("%d", &y[i]);
        }

        for(i = 0; i < 4; i++){
            if(x[i] == y[i]){
                hit++;
            }
        }
        for(i = 0; i < 4; i++){
            for(j = 0; j < 4; j++){
                if(x[i] == y[j] && i != j){
                    blow++;
                }
            }
        }

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

Measured memory_bytes: 1024
// Problem : A - Kyu in AtCoder
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


#include<bits/stdc++.h>
#define 	ll		    long long
#define 	rep(i,a,n)  for(int i=a;i<n;i++)
#define 	MOD 		1000000007
#define 	vp 			vector<pair<int,int> >
#define 	ff 			first
#define 	ss 			second
#define 	pb 			push_back
#define 	all(x) 		(x.begin(),x.end())
#define 	dg(x)		cerr<<"--- x = "<<x<<"\n"
#define 	endl		"\n"


using namespace std;
const int N = 1e5;
ll ar[N];

void solve(){
	int n ; cin >> n;
	cout <<	(int) ceil((1.0 * (2000-n)) / 200);
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


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

int main() {
    string s;
    ll k,ans=0,tmp=0;
    cin>>s>>k;
    ll n = s.size();
    ll a=1;
    for(int i=0; i<n; i++) {
        if(s[i]==s[i+1]) a++;
        else {
          	if(a == 1) a--;
            ans += a/2;
          	tmp++;
          	a=1;
        }
    }
  if(tmp == 1) cout<<n * k / 2<<endl;
    else if(s.front() == s.back()) {
      	ll fr = 0, ba = 0;
        for(int i=0; i<n; i++) {
            fr++;
            if(s[i] != s[i+1]) break;
        }
        for(int i=n-1; i>=0; i--) {
            ba++;
            if(s[i] != s[i-1]) break;
        }
        cout<<ans * k - (k-1) * ((fr/2) + (ba/2) - (fr+ba)/2)<<"\n";
    }
  	else cout<<ans * k<<endl;
}

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class SearchCombination
    {
        int[,] table;
        int[] memo;

        public SearchCombination()
        {
            table = new int[11, 331];
            memo = new int[10];

            DFS(0, 0);
        }

        public int Count(int n, int s)
        {
            if (n > 10 || s > 330) return 0;

            return table[n, s];
        }

        private void DFS(int depth, int sum)
        {
            table[depth, sum]++;

            for (int i = 0; i < 10; i++)
            {
                if (memo[i] == 0)
                {
                    memo[i] = 1;

                    DFS(depth + 1, sum + i * (depth + 1));

                    memo[i] = 0;
                }
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            SearchCombination SC = new SearchCombination();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] temp = input.Split(' ');
                int n = int.Parse(temp[0]);
                int s = int.Parse(temp[1]);

                sb.AppendLine(SC.Count(n, s).ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9180
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#define sum abs(x)+abs(y)
#define MAXN 100005
using namespace std;
int n,m,t,x,y,lx,ly,lt,tx,ty,tt;
 
int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%d%d%d",&t,&x,&y);
		if((sum)>t) {printf("No\n"); return 0;}
		if(t%2==1)
			if((sum)%2==0){printf("No\n"); return 0;}
		if(t%2==0)
			if((sum)%2==1) {printf("No\n"); return 0;}	
	}
	printf("Yes\n");
	return 0;	
} 

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int H = 0, W = 0;
	while (1){
		scanf("%d %d", &H, &W);

		if (H == 0 && W == 0){
			break;
		}

		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if (j % 2 == 0&&i%2==0){
					printf("#");
				}
				else if (j % 2 == 0 && i % 2 == 1){
					printf(".");
				}
				else if (j % 2 == 1 && i % 2 == 1){
					printf("#");
				}
				else if (j % 2 == 1 && i % 2 == 0){
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}

Measured memory_bytes: 2572
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)


#define INF 100000000
int s[101][101];

int main(){

	while(1){

		int n,k,p,a,b,c,d,e;

		cin >> n >> k;
		if(n==0 && k==0) break;

		REP(i,1,n) REP(j,1,n)
		if(i!=j) s[i][j]=INF;

		rep(i,k){

			 cin >> p;
			 if(p==0){

	            cin >> a >> b;

	    		vector<int>cost,used;

	    		rep(j,n+1){
	    			if(j!=a) cost.push_back(INF);
	    			else cost.push_back(0);
	                used.push_back(0);
	    		}

	            for(;;){

	            	int x; int m=INF;
	            	REP(j,1,n){

	            	if(!used[j] && cost[j]<m){
	            		m=cost[j]; x=j;
	            	}
	            	}

	            	if(x==b || m==INF) break;

	            	used[x]=1;

	            	REP(j,1,n) cost[j]=min(cost[j],cost[x]+s[x][j]);

	            }

	            if(cost[b]==INF) cout << -1 << endl;
	            else cout << cost[b] << endl;

	            cost.clear(); used.clear();

			}


			if(p==1){

				cin >> c >> d >> e;

                if(s[c][d]>e){
				s[c][d]=e; s[d][c]=e;
                }

			}

		}

	}

	return 0;
}

Measured memory_bytes: 1256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	int A,P;
	cin>>A>>P;

	cout<<(3*A+P)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define l long
#define llu unsigned long long
#define f float
int main()
{
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0)
		cout<<1;
	else if(b==0)
		cout<<2;
	else if(c==0)
		cout<<3;
	else if(d==0)
		cout<<4;
	else
		cout<<5;
	return 0;
}

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

bool is_triangle(int a, int b, int c){
    return (a < b+c) && (b < c+a) && (c < a+b);
}

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    int ans = 0;
    for(int i = 0; i <= n-3; i++){
        for(int j = i+1; j <= n-2; j++){
            for(int k = j+1; k < n; k++){
                if(is_triangle(a[i], a[j], a[k])) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math

def is_prime(n):
    if n == 2:
        return True

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

X = int(input())

while 2 <= X <= 100010:
    if is_prime(X) == True:
        print(X)
        break
    X += 1

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

int main() {
  int A = 0, B = 0;
  char op;
  
  cin >> A >> op >> B;
  
  if (op == '+') {
    cout << A + B << endl;
  }
  if (op == '-') {
    cout << A - B << endl;
  }
}


Measured memory_bytes: 256
#conding utf-8
N=int(input())
MOD=10**9+7
dp =[[[[0 for i in range(4)] for i in range(4)] for i in range(4)]for i in range(N+1)]
dp[0][0][0][0]=1

for i in range(1,N+1):
  for j in range(4):
    for k in range(4):
      for l in range(4):
        for m in range(4):
          if k==1 and l==2 and m==3:
            continue
          if k==2 and l==1 and m==3:
            continue
          if k==1 and l==3 and m==2:
            continue
          if j==1 and l==2 and m==3:
            continue
          if j==1 and k==2 and m==3:
            continue
          dp[i][k][l][m] += dp[i-1][j][k][l]
          dp[i][k][l][m] %= MOD

ans=0
for i in range(4):
  for j in range(4):
    for k in range(4):
      ans +=dp[N][i][j][k]
      ans %= MOD
print(ans)

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

using namespace std;

char s[3][3];

int judgeO(){
  for(int i = 0; i < 3; i++){
    if(s[i][0] == 'o' && s[i][1] == 'o' && s[i][2] == 'o') return 1;
  }
  for(int i = 0; i < 3; i++){
    if(s[0][i] == 'o' && s[1][i] == 'o' && s[2][i] == 'o') return 1;
  }
  if(s[0][0] == 'o' && s[1][1] == 'o' && s[2][2] == 'o') return 1;
  if(s[0][2] == 'o' && s[1][1] == 'o' && s[2][0] == 'o') return 1;

  return 0;
}

int judgeX(){
  for(int i = 0; i < 3; i++){
    if(s[i][0] == 'x' && s[i][1] == 'x' && s[i][2] == 'x') return 1;
  }
  for(int i = 0; i < 3; i++){
    if(s[0][i] == 'x' && s[1][i] == 'x' && s[2][i] == 'x') return 1;
  }
  if(s[0][0] == 'x' && s[1][1] == 'x' && s[2][2] == 'x') return 1;
  if(s[0][2] == 'x' && s[1][1] == 'x' && s[2][0] == 'x') return 1;

  return 0;
}


int main(){

  string a;
 
  while(cin >> a){

    int i = 0;


    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++,i++){
	s[j][k] = a[i];
      }
    }

    int x = judgeO();
    int y = judgeX();

    if(x == 1) cout << "o" << endl;
    else if(y == 1) cout << "x" << endl;
    else cout << "d" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
// #include <prettyprint.hpp>
typedef long long ll;
using namespace std;
static const ll mod = 1000000007;

bool is_prime(ll N){
    ll i=2;
    while(i*i<N){
        if(N % i == 0){
            return false;
        }else{
            i ++;
        }
    }
    if(N % i == 0){
        return false;
    }
    return true;
}

template<typename T>
vector<T> divisor(T N){
    vector<T> divisors_list;
    T i = 1;
    for(i = 1;i*i<N;i++){
        if(N % i == 0){
            divisors_list.emplace_back(i);
            divisors_list.emplace_back(N / i);
        }
    }

    if(N % i == 0){
        divisors_list.emplace_back(i);
    }

    return divisors_list;

}

template<typename T>
map<T, T> prime_factor(T N){
    map<T, T> res;
    ll i = 2;
    for(i=2;i*i<=N;i++){
        while(N%i==0){
            ++res[i];
            N /= i;
        }
    }
    if(N!=1){
        res[N] = 1;
    }
    return res;
}


int main(){
    ll N, a, b, c, gcd_num;
    scanf("%lld", &N);
    map<ll, ll> total_res;
    if(N==1){
        printf("1\n");
    }else{
        for(ll i=2;i<=N;i++){
            map<ll, ll> res = prime_factor(i);
            for(auto const &key:res){
                total_res[key.first];
                total_res[key.first] += key.second;
            }
        }
        ll ans =1;
        for(auto const &key:total_res){
            ans *= (key.second + 1);
            ans %= mod;
        }
        printf("%lld\n", ans);

    }


    return 0;
}

Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

p = A[0] if A[0] > 0 else 1
pc = 0 if A[0] > 0 else 1 - A[0]
m = A[0] if A[0] < 0 else -1
mc = 0 if A[0] < 0 else 1 + abs(A[0])

for i in range(1, N):
    p += A[i]
    m += A[i]
    if i % 2 == 0:
        if p <= 0:
            pc += 1 - p
            p = 1
        if m >= 0:
            mc += 1 + m
            m = -1
    else:
        if p >= 0:
            pc += 1 + p
            p = -1
        if m <= 0:
            mc += 1 - m
            m = 1

print(min(pc, mc))


Measured memory_bytes: 14972
#include <cstdio>

using namespace std;
typedef long long llong;

#define MAX 200001
const llong mod = 1000000000 + 7;

llong comb(int n)
{
  return (llong)n * (n - 1) / 2;
}

int main()
{
  int N;
  scanf("%d", &N);
  int A[MAX];
  int cnt[MAX];
  llong total = 0;
  for (int i = 0; i < N; i++)
  {
    cnt[i + 1] = 0;
  }

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

  for (int i = 1; i <= N; i++)
  {
    int j = cnt[i];
    total += comb(j);
  }

  for (int i = 0; i < N; i++)
  {
    int j = cnt[A[i]];
    printf("%lld\n", total - comb(j) + comb(j - 1));
  }

  return 0;
}

Measured memory_bytes: 4276
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;
#define SZ(x)               ((int)(x).size())
#define all(x)              (x).begin(), (x).end()
#define loop(i, n)          for(int i = 0; i < (n); i++)
#define cont(i, n)          for(int i = 1; i <= (n); i++)
#define circ(i, a, b)       for(int i = (a); i <= (b); i++)
#define range(i, a, b, c)   for(int i = (a); ((c) > 0 ? i <= (b) : i >= (b)); i += (c))
#define foreach(it, v)      for(__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define y0          y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1          y1II11II11III11I1III11II111IIII1II1I1
#define pub         push_back
#define pob         pop_back
#define mak         make_pair
typedef long long   ll;
typedef long double lf;
const int   Inf = 0x3f3f3f3f;
const ll    INF = 0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

int n, q;

struct Segtree {
	int dt[1 << 20], wp[1 << 20];
	void inline init() {
		memset(dt, 0x3f, sizeof(dt));
		memset(wp, 0x3f, sizeof(wp));
	}
	void inline pd(int now) {
		if(wp[now] != Inf) {
			dt[now << 1] = min(dt[now << 1], wp[now]);
			dt[now << 1 | 1] = min(dt[now << 1 | 1], wp[now]);
			wp[now << 1] = min(wp[now << 1], wp[now]);
			wp[now << 1 | 1] = min(wp[now << 1 | 1], wp[now]);
			wp[now] = Inf;
		}
	}
	void inline pu(int now) {
		dt[now] = min(dt[now << 1], dt[now << 1 | 1]);
	}
	void inline qmin(int l, int r, int x, int now = 1, int nl = 1, int nr = n) {
		if(nl >= l && nr <= r) {
			dt[now] = min(dt[now], x);
			wp[now] = min(wp[now], x);
			return;
		}
		if(nl > r || nr < l) return;
		pd(now);
		int m = (nl + nr) >> 1;
		qmin(l, r, x, now << 1, nl, m);
		qmin(l, r, x, now << 1 | 1, m + 1, nr);
		pu(now);
	}
	int inline get(int to, int now = 1, int nl = 1, int nr = n) {
		if(nl == nr) return dt[now];
		pd(now);
		int m = (nl + nr) >> 1;
		if(m >= to) return get(to, now << 1, nl, m);
		else return get(to, now << 1 | 1, m + 1, nr);
	}
} sl, su;

set<int> lgl, lgu;

int main() {
	scanf("%d%d", &n, &q);
	sl.init(); su.init();
	sl.qmin(2, n - 1, n);
	su.qmin(2, n - 1, n);
	ll al = (n - 2ll) * (n - 2ll);
	while(q--) {
		int md, p;
		scanf("%d%d", &md, &p);
		if(md == 1) {
			if(lgl.count(p)) continue;
			int bn = sl.get(p);
			al -= bn - 2;
			lgl.insert(p);
			su.qmin(2, bn, p);
		} else {
			if(lgu.count(p)) continue;
			int bn = su.get(p);
			al -= bn - 2;
			lgu.insert(p);
			sl.qmin(2, bn, p);
		}
	}
	printf("%lld\n", al);
	return 0;
}


Measured memory_bytes: 29520
function Main(input) {
	var arr = input.split('');
 
  	var year = String(arr[0] + arr[1] + arr[2] + arr[3]);
  	year = "2018";
  	for(var i = 4; i < 10; i++) {
		var m_d = m_d + arr[i];
    }
  	console.log(year + arr[4] + arr[5] +  arr[6] + arr[7] + arr[8] + arr[9]);
}	
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int num, i, j;
  scanf("%d", &num);

  A = malloc(sizeof(short)*num+1);
  B = malloc(sizeof(short)*num+1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < num; i++ ){
    scanf("%hu", &A[i + 1]);

    C[A[i + 1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= num; j++ ){

    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= num; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8460
import collections
 
N = int(input())
 
g = collections.defaultdict(list)
 
for _ in range(N - 1):
    u, v = map(int, input().split())
    g[u].append(v)
    g[v].append(u)
 
bw = collections.defaultdict(str)
 
bw[1] = 'b'
bw[N] = 'w'
 
q = collections.deque()
q.append(1)
q.append(N)
 
f = 0
s = 0
 
while True:
    if len(q) == 0:
        break
 
    t = q.popleft()
 
    if bw[t] == 'b':
        f += 1
    if bw[t] == 'w':
        s += 1
 
    for succ in g[t]:
        if bw[succ] == '':
            bw[succ] = bw[t]
            q.append(succ)
 
if f > s:
    print('Fennec')
else:
    print('Snuke')

Measured memory_bytes: 39124
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	int m,n;
	cin>> m>> n;
	int max = 0;
	for(int i=0;i<m;i++){
		int a=0;
		for(int j=0;j<n;j++){
			int in;
			cin>> in;
			if(in) a++;
		}
		if(max < a) max = a;
	}
	cout<< max<<endl;

	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1160
//尺取り法

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

int main(){
    // 入力
    int n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n);
    vector<ll> b(m);
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];

    ll t=0;
    rep(i,m) t+=b[i];

    int j=m;
    int ans = 0;
    rep(i,n+1){
        while(j>0&&t>k){
            --j;
            t-=b[j];
        }
        if(t>k) break;
        ans = max(ans,i+j);
        if(i==n) break;
        t+=a[i];
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6412
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n;
  cin>>n;
  vin a(n),b(n),c(n);
  rep(i,0,n)cin>>a[i];rep(i,0,n)cin>>b[i];rep(i,0,n)cin>>c[i];
  sort(all(a));sort(all(b));sort(all(c));reverse(all(c));
  ll ans=0;
  rep(i,0,n){
    int m=b[i];
    //二分探索
    ll acnt=0;
    int ok=-1,ng=n;
    while(ng-ok>1){
      int mid=ok+(ng-ok)/2;
      if(a[mid]<m)ok=mid;
      else ng=mid;
    }
    acnt=ok+1;
    ll ccnt=0;
    ok=-1,ng=n;
  //  cout<<m<<endl;
    while(ng-ok>1){
     // if(m==2)cout<<ok<<" "<<ng<<endl;
      int mid=ok+(ng-ok)/2;
      if(c[mid]>m)ok=mid;
      else ng=mid;
      
    }
    ccnt=ok+1;
   // cout<<acnt<<" "<<ccnt<<endl;
    ans+=acnt*ccnt;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4560
import math
arr = []
tmp = 0
rem = 10
ans = 0
for i in range(5):
    x = int(input())
    arr.append(x)
    if (x%10 < rem) and (x%10 >0):
        rem = x % 10
        tmp = x
for item in arr:
    if item == tmp:
        arr.remove(item)
        arr.append(item)
for item in arr:
    ans+= math.ceil(item/10)*10
print (ans - 10 + rem)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    int a,b,s=0;
    cin>>a>>b;
    if(a>b)
    {
        s+=a;
        a--;
        if(a>b)
            s+=a;
        else
            s+=b;
    }
    else
    {
        s+=b;
        b--;
        if(a>b)
            s+=a;
        else
            s+=b;
    }
    cout<<s<<endl;
    return 0;
}


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

int main() {
	int W, H;
	char WH[50][50];
	cin >> W >> H;
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) {
			cin >> WH[i][j];
		}
	}
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) {
			if (WH[i][j] != '#') {
				for (int k = -1; k < 2; k++) {
					for (int l = -1; l < 2; l++) {
						if (-1 < k + i && k + i < W && -1 < j + l && j + l < H && WH[i + k][j + l] == '#') {
							res++;
						}
					}
				}
				WH[i][j] = '0' + res;
				res = 0;
			}
		}
	}
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) {
			cout << WH[i][j];
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    buf = input()
    buflist = buf.split()
    r = int(buflist[0])
    D = int(buflist[1])
    x2000 = int(buflist[2])
    x = x2000
    for i in range(10):
        x = r * x - D
        print(x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
a=[[[0 for i in range(10)]for j in range(3)]for k in range(4)]
n=int(input())
for i in range(n):
    b,f,r,v=map(int,input().split())
    a[b-1][f-1][r-1]+=v

for i in range(4):
    for j in range(3):
        for k in range(10):
            #print("("+str(i)+","+str(j)+","+str(k)+")",end="")
            print(" "+str(a[i][j][k]),end="")
        print()
    if (i!=3):
        print("####################")
    



Measured memory_bytes: 5624
s = int(input())

l = [s]
i = 0
while True:
    if l[i]%2 == 0:
        l.append(l[i]//2)
    else:
        l.append(3*l[i] + 1)
    i += 1
    if l.count(l[i]) == 2:
        break
        
print(len(l))

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
    int n,a[100],c[8]={0,0,0,0,0,0,0,0},f=0,ans=0;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        if(a[i]<400)c[0]++;
        if(a[i]>=400&&a[i]<800)c[1]++;
        if(a[i]>=800&&a[i]<1200)c[2]++;
        if(a[i]>=1200&&a[i]<1600)c[3]++;
        if(a[i]>=1600&&a[i]<2000)c[4]++;
        if(a[i]>=2000&&a[i]<2400)c[5]++;
        if(a[i]>=2400&&a[i]<2800)c[6]++;
        if(a[i]>=2800&&a[i]<3200)c[7]++;
        if(a[i]>=3200)f++;
    }
    for(int i=0;i<8;i++){
        if(c[i]!=0)ans++;
    }
    cout<<max(ans,1)<<" "<<ans+f<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define n 200000
#define loop(i, a, b) for(int i=a; i<=b; i++)
using namespace std;
int a, b, c, d, e, f;
//int arr[n + 50], arr1[n + 50], arr2[n + 50];
string str, str1, str2;
int main()
{
	string arr[3];
	loop(i, 0, 2)
		cin >> arr[i];
	loop(i, 0, 2)
		cout << arr[i][i];
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main() {
    int h,w,d;
    cin>>h>>w>>d;
    vector<pair<int,int>> zahyou(h*w+1);
    rep(i,0,h){
        rep(j,0,w){
            int a;
            cin>>a;
            zahyou[a]=make_pair(i,j);
        }
    }
    
    map<pair<int,int>,int> cost;
    rep(i,0,d){
        int j=1;
        int total=0;
        while(i+j*d<=h*w){
            int now=i+(j-1)*d,next=i+j*d;
            
            total+=abs(zahyou[now].first-zahyou[next].first);
            total+=abs(zahyou[now].second-zahyou[next].second);
            
            cost[make_pair(i,next)]=total;
            j++;
        }
    }
    
    int q;
    cin>>q;
    vector<int> ans(q);
    rep(i,0,q){
        int l,r;
        cin>>l>>r;
        ans[i]=cost[make_pair(l%d,r)]-cost[make_pair(l%d,l)];
    }
    rep(i,0,q) cout<<ans[i]<<endl;
}


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

int main() {
  string S;
  cin >> S;

  int count = 0;
  stack<char> chars;

  for (int i = 0; i < S.length(); i++) {
    if (chars.empty()) {
      chars.push(S.at(i));
      continue;
    }

    if (chars.top() != S.at(i)) {
      chars.pop();
      count += 2;
    } else {
      chars.push(S.at(i));
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 512