akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

void helper(vector<vector<int>> &res, int i, int w)
{
	while(i>=0 && res[i][w-1]==0)
	{
		for(int j=0;j<w;j++)
		{
			res[i][j] = res[i+1][j];
		}

		i--;
	}
}

void helper2(vector<vector<int>> &res, int h, int w)
{	int i = h-1;
	while(res[i][w-1]==0)
	{
		i--;
	}

	for(;i<h-1;i++)
	{
		for(int j=0;j<w;j++)
		{
			res[i+1][j] = res[i][j];
		}
	}
}

void fill(vector<vector<int>> &res, int h, int w, int k)
{	
	
	for(int i=0;i<h;i++)
	{	
		int last=0;
		for(int j=0;j<w;j++)
		{	
			if(res[i][j]!=0)
			{	
				last = res[i][j];
				for(int k=j-1; k>=0; k--)
				{
					if(res[i][k] != 0) break;
					res[i][k] = res[i][j];
				}
			}
		}

		int k = w-1;
		if(res[i][k]==0 && last!=0)
		{
			while(k>=0)
			{
				if(res[i][k]!=0) break;
				res[i][k] = last;
				k--;
			}
		}

		if(i>0 && res[i][w-1]!=0 && res[i-1][w-1]==0)
		{
			helper(res,i-1,w);
		}
	}

	if(res[h-1][w-1]==0)
		helper2(res,h,w);
}

int main()
{
	int h,w,k;
	cin>>h>>w>>k;

	vector<vector<int>> res(h,vector<int>(w,0));
	int count=1;
	char ch;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>ch;
			if(ch=='#')
			{
				res[i][j] = count;
				count++;
			}
		}
	}

	fill(res,h,w,k);
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cout<<res[i][j]<<" ";
		}
		cout<<"\n";
	}

	return 0;

}

Measured memory_bytes: 1152
n = int(input())
a = input().split()
A = [int(s) for s in a]
B = len([i for i in A if i < 0])
ABS = list(map(abs, A))
small = min(ABS)
if small == 0 or B % 2 ==0:
    print(sum(ABS))
else:
    print(sum(ABS) - 2 * small)

Measured memory_bytes: 18164
#include <queue>
#include <cstdio>
#include <vector>

int n,m,Ans,t,x,y;
std::vector<int> v[200005];
std::priority_queue<int> q;

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)scanf("%d%d",&x,&y),v[x].push_back(y);
    for(int i=m;i>=0;--i)
    {
        for(auto j:v[i])q.push(j);
        if(i&&!q.empty())q.pop(),++t;
    }
    Ans=t,y=m;
    while(!q.empty())
    {
        x=q.top(),q.pop();
        if(x<=y&&y>t)++Ans,--y;
    }
    printf("%d\n",n-Ans);
    return 0;
}

Measured memory_bytes: 8832
#include<iostream>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 1; i < 10; ++i) {
        if (N % i) continue;
        if (N / i >= 10) continue;
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
// All Heil Fire Lord Zuko

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

#define F first
#define S second
#define PB push_back
#define debug(x) cerr << #x << " = " << x << endl

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;

const int N = 2 * 100 * 1000 + 19;

int32_t main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int x, y;
    cin >> x >> y;
    int a[] = {1, 3, 5, 7, 8, 10, 12};
    int b[] = {4, 6, 9, 11};
    int c[] = {2};
    int ans = 0;
    if (x == 2 || y == 2)
      return cout << "No", 0;
    for (int i = 0; i < 7; i ++) {
        if (x == a[i])
            ans ++;
        if (y == a[i])
            ans ++;
    }
    if (ans == 1)
        ans = 0;
    else if (ans == 2)
        return cout << "Yes", 0;
    for (int i = 0; i < 4; i ++) {
        if (b[i] == x)
            ans ++;
        if (b[i] == y)
            ans ++;
    }
    if (ans == 1)
        cout << "No";
    else if (ans == 2)
        cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  int i,t,a[50]={0};
  char w[101];
  scanf("%s",w);
  for(i=0;i<strlen(w);i++)a[w[i]-97]++;
  for(i=0;i<50;i++)t+=a[i]%2;
  puts(t?"No":"Yes");
  return 0;
}

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

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    int ans;
    if (n <= k) {
        ans = x * n;
    }
    else {
        ans = x * k + y * (n - k);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

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

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

const ll MOD = 1000000007;
const ll INF = 10000000;


int main(void){

    string s, t;

    cin >> s >> t;

    bool flag = false;

    int sz = s.size();
    
    for (int i = 0; i < sz; i++){
        string w;
        for (int j = 0; j < sz; j++){
            w += s[(i + j) % sz];
        }
        if (w == t) flag = true;
    }


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b)* h / 2 << endl;
}

Measured memory_bytes: 256
mod = 998244353
def comb(n, r):
    if n < r:return 0
    if n < 0 or r < 0:return 0
    return fa[n] * fi[r] % mod * fi[n - r] % mod
n, m, k = map(int, input().split())
fa = [1] * (n + 1)
fi = [1] * (n + 1)
for i in range(1, n + 1):
    fa[i] = fa[i - 1] * i % mod
    fi[i] = pow(fa[i], mod - 2, mod)
ans = 0
for i in range(k + 1):
    ans += pow(m - 1, n - i - 1, mod) % mod * comb(n - 1, i) * m % mod
    ans %= mod
print(ans)

Measured memory_bytes: 79600
#include <iostream>
#include <list>
#include <queue>

#define pb push_back

const int MAXN = 200100;
using namespace std;

int d[MAXN];
list <int> adj[MAXN];

void bfs(int s)
{
	queue <int> Q;
	Q.push(s);
	
	while(!Q.empty())
	{
		int u = Q.front();
		Q.pop();
		
		for(auto v : adj[u])
		{
			if(d[v] == 0 && v != 1)
			{
				d[v] = d[u] +1;
				Q.push(v);
			}
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, m;
	cin >> n >> m;
	
	while(m--)
	{
		int u, v;
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	
	bfs(1);
	
	if(d[n] == 2)
		cout << "POSSIBLE\n";
	
	else
		cout << "IMPOSSIBLE\n";
		
	return 0;
}

Measured memory_bytes: 17152
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

  ll N, A, B;
  cin >> N >> A >> B;

  ll X[100010] = {};
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }

  ll ma = 0;
  for (int i = 1; i < N; i++) {
    ma += min((X[i] - X[i - 1]) * A, B);
  }

  cout << ma << endl;
  return 0;
}


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

class Program {
    static long f(long A, long B, long C){
        long dc = C - 2*(C/2);
        return dc*A*B;
    }
    static void Main(string[] args){
        string[] str = Console.ReadLine().Split(' ');
        long A = long.Parse(str[0]);
        long B = long.Parse(str[1]);
        long C = long.Parse(str[2]);
        
        
        long ans = f(A,B,C);
        ans = Math.Min(ans, f(C,B,A));
        ans = Math.Min(ans, f(A,C,B));
        
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
    
using namespace std;
    
#define endl "\n"
#define ll unsigned long long
#define int long long int
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define vi vector <int >
#define vvi vector < vi > 
#define vii vector < pii >
#define viii vector < piii >
#define vll vector <ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define double long double
#define a first
#define b second

int32_t main(){

    int n, m, k;
    scanf("%lld%lld",&n,&m);
    vi arr(m);
    vvi a(m);
    vi ax(m);
    forn(i, m){
        scanf("%lld%lld",&arr[i],&k);
        a[i].resize(k);
        ax[i] = 0;
        forn(j, k){
            scanf("%lld",&a[i][j]);
            a[i][j]--;
            ax[i] = ax[i]|(1 << a[i][j]);
        }
    }

    vi dp((1 << n) + 5);
    dp[0] = 0;
    for(int i = 1; i < (1 << n); i++){
        dp[i] = INT_MAX;
        forn(j, m){
            if(!(i&ax[j])) continue;
            int aux = i;
            for(auto z:a[j]){
                if(aux&(1 << z)){
                    aux = aux^(1 << z);
                }
            }
            dp[i] = min(dp[i], arr[j] + dp[aux]);
        }
    }
    int bitmask = (1 << n) - 1;

    if(dp[bitmask] >=INT_MAX){
        printf("-1\n");
    }else{
        printf("%lld\n",dp[bitmask]);
    }


    return 0;
}


Measured memory_bytes: 384
import sys
from collections import deque
from collections import defaultdict
import copy

n, m = map(int, sys.stdin.readline().split())
adj = [[] for _ in range(n+1)]
radj = [[] for _ in range(n+1)]
for _ in range(m):
    a, b = map(int, sys.stdin.readline().split())
    adj[a].append(b)
    radj[b]


def searchRoute(i):
    global adj
    nexts = deque()
    route = [i]
    visited = set()
    result = []
    for x in adj[i]:
        if x < i:
            continue
        nroute = copy.copy(route)
        nexts.append((x, nroute))
    while len(nexts) > 0:
        error = False
        found = False
        x, xroute = nexts.popleft()
        xroute.append(x)
        visited.add(x)
        for y in adj[x]:
            if y < i:
                continue
            if y == i:
                found = True
                break
            if y in visited:
                break
            yroute = copy.copy(xroute)
            nexts.append((y, yroute))
        if found:
            result = xroute
            break
    return result

heiro = []
for i in range(1, n+1):
    res = searchRoute(i)
    if len(res) > 0:
        heiro = res
        break

if len(heiro) == 0:
    print(-1)
    exit()
while True:
    visited = set()
    bp = [-1, -1]
    rt = defaultdict(int)
    for i in range(len(heiro)):
        visited.add(heiro[i])
        rt[heiro[i]] = i
        for j in adj[heiro[i]]:
            if j in visited and not (i == len(heiro) - 1 and j == heiro[0]):
                bp = [i, rt[j]]
                break
        if bp[0] != -1:
            break
    if bp[0] == -1:
        print(len(heiro))
        for i in heiro:
            print(i)
        exit()
    heiro = heiro[bp[1]:bp[0]+1]



Measured memory_bytes: 42736
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;

map<Pair, int> edge_n;
map<Pair, int> edge_c;
vector<vector<int>> g;

void dfs(int from, int current, int node_color) {
  int color = 0;
  for(const auto next :g[current]) {
    if(next == from) continue;
    if(color == node_color) color++;
    edge_c[{current, next}] = color;
    edge_c[{next, current}] = color;
    dfs(current, next, color++);
  }
}

signed main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  vector<ll> cum(n+1);
  REP(i, n) cum[i+1] = cum[i] + a[i];
  ll ans = 0;
  REP(i, n) cum[i+1] = (cum[i+1] - i - 1 + k) % k;
  map<int, int> m;
  REP(i, n+1) {
    if(i >= k) {
      m[cum[i-k]] -= 1;
    }
    ans += m[cum[i]];
    m[cum[i]]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12800
import Data.List
import Data.Char
import qualified Data.ByteString.Char8 as BS8

main :: IO ()
main = do
    [n] <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine
    pi <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine
    let ideal = [(x, x) | x <- [1..n]]
        p = zip [1..n] pi
        result = ideal \\ p

    putStrLn $ if (length result) <= 2
        then "YES"
        else "NO"


Measured memory_bytes: 636
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main{
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		//InputStream in = new FileInputStream("src/input.txt");
		InputStream in = System.in;
		//PrintStream out = new PrintStream("src/output.txt");

		//System.setOut(out);

		sc = new Scanner(in);

		String S = sc.next();

		if(S.length() <= 3){
			System.out.println("No");
			return;
		}
		if(S.charAt(0) == 'Y' && S.charAt(1) == 'A' && S.charAt(2) == 'K' && S.charAt(3) == 'I'){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}


		//out.close();
	}
}

Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

bool used[100010];

int main()
{
	int n,m;cin >> n >> m;
	vector<vector<int> > v(n);
	deque<int> dq;
	int ans = 2;
	REP(i,m)
	{
		int a,b;cin >> a >> b;a--;b--;
		v[a].PB(b);v[b].PB(a);
		if(i == 0){dq.push_back(a);dq.push_back(b);used[a] = used[b] = true;}
	}
	
	while(1)
	{
		int flag = -1;
		int now = dq.front();
		REP(i,v[now].size())
		{
			if(!used[v[now][i]])
			{
				flag = v[now][i];
			}
		}
		if(flag == -1)break;
		dq.push_front(flag);
		used[flag] = true;
		ans++;
	}
	
	while(1)
	{
		int flag = -1;
		int now = dq.back();
		REP(i,v[now].size())
		{
			if(!used[v[now][i]])
			{
				flag = v[now][i];
			}
		}
		if(flag == -1)break;
		dq.push_back(flag);
		used[flag] = true;
		ans++;
	}
		
	cout << ans << endl;
	for_each(ALL(dq),[](int x){cout << x+1 << ' ';});cout << endl;
	
	
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main() {
    char c;
    cin >> c;
    cout << (char)((int)c + 1) << endl;
}

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

using namespace std;
const int N = 1e6+100;
const long long INF = 999999999999;
long long dis[N][3];
vector<int> G[N];
bool vis[N][3];
struct node{
    int id;
    long long dis;
};
bool operator<(node a,node b){
    return a.dis>b.dis;
}
int n,m,S,T;
priority_queue<node> q;
void dijkstra(int S){
    for(int i=1;i<=n+100;i++){
        for(int j=0;j<3;j++) dis[i][j]=INF,vis[i][j]=0;
    }
    dis[S][0]=0;
    q.push({S,0});
    while(!q.empty()){
        node rt=q.top();q.pop();
        int u=rt.id;
        int L=rt.dis;
        for(auto v:G[u]){
            int nowL=(L+1)%3;
            if(dis[v][nowL]>dis[u][L]+1){
                dis[v][nowL]=dis[u][L]+1;
                q.push({v,nowL});
            }
        }
    }
}
int main(){
    cin>>n>>m;
    int u,v;
    for(int i=1;i<=m;i++){
        cin>>u>>v;
        G[u].push_back(v);
    }
    cin>>S>>T;
    dijkstra(S);
    //cout<<dis[T][0]<<endl;
    if(dis[T][0]==INF) puts("-1");
    else cout<<dis[T][0]/3<<endl;
    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int a[n];
    int cnt[n+1];
    for(int i=1; i<=n; i++){
        cnt[i]=0;
    }
    for(int i=1; i<n; i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    for(int i=1; i<=n; i++){
        cout<<cnt[i]<<endl;
    }
}


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

using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  
  vector<vector<int>> a(h, vector<int>(w, 0));
  for(int i = 0; i < h; i++){
    bool o = false;
    for(int j = 0; j < w; j++){
      int in;
      cin >> in;
      if((in & 1) == 1){
        a[i][j] = o ? -1 : 1;
        o = o ? false : true;
      }
    }
    for(int j = 1; j < w; j++){
      a[i][j] += a[i][j - 1];
    }
  }
  
  vector<pair<int, int>> man;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w - 1; j++){
      if(a[i][j] == 1){
        man.push_back(make_pair(i + 1, j + 1));
      }
    }
  }
  
  vector<int> man2;
  bool o = false;
  for(int i = 0; i < h - 1; i++){
    if(a[i][w - 1] == 1){
      if(!o){
        man2.push_back(i + 1);
        o = true;
      }else{
        o = false;
      }
    }else if(o){
      man2.push_back(i + 1);
    }
  }
  
  cout << man.size() + man2.size() << endl;
  for(int i = 0; i < (int)man.size(); i++){
    int y = man[i].first;
    int x = man[i].second;
    
    cout << y << ' ' << x << ' ' << y << ' ' << x + 1 << endl;
  }
  
  for(int i = 0; i < (int)man2.size(); i++){
    int y = man2[i];
    
    cout << y << ' ' << w << ' ' << y + 1 << ' ' << w << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4212
import math
import sys

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

dp = [False] * (K + 1)
for i in range(K + 1):
    for a in As:
        if i + a <= K:
            dp[i + a] |= (not dp[i])
ans = "First" if dp[K] else "Second"
print(ans)



Measured memory_bytes: 41964
n=int(input())
dic={}
mxd=[]
mxc=0
for i in range(n):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
  if dic[s] > mxc:
    mxc=dic[s]
    mxd=[]
  if dic[s] == mxc:
    mxd.append(s)
mxd.sort()
for d in mxd:
  print(d)

Measured memory_bytes: 33416
#include <stdio.h>
int main(){
    int n, d1, d2, cnt=0;
    scanf("%d",&n);
    for(int i=0; i<n; i++){
        scanf("%d%d", &d1, &d2);
        if( d1==d2 ){ cnt++; }
        else        { cnt=0; }
        if( cnt==3 ){ printf("Yes\n"); return 0; } 
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 1628
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections

#X = str(raw_input()).split()
N = int(raw_input())
ST = str(raw_input()).split()
S = ST[0]
T = ST[1]
ans = ""

for i in xrange(N):
  ans = ans + S[i] + T[i]

print(ans);


Measured memory_bytes: 16268
from sys import stdin
N = int(stdin.readline().rstrip())
a = [int(_) for _ in stdin.readline().rstrip().split()]
avg = sum(a) / len(a)
ans_idx = 0
ans_f = 101
for i, f in enumerate(a):
    diff = abs(f-avg)
    if diff < ans_f:
        ans_f = diff
        ans_idx = i
print(ans_idx)

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

int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    if (n % x == 0)
        cout << n / x * t << endl;
    else
        cout << (n / x + 1) * t << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>

int main(void){
    int K, A, B;

    scanf("%d", &K);
    scanf("%d", &A);
    scanf("%d", &B);

    int result = (B / K) * K;

    if(A <= result){
        printf("OK");
    }else{
        printf("NG");
    }

    return 0;
}

Measured memory_bytes: 1704
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long


int calc(int n){
  if(n%2)return 0;
  n/=10;
  int ans = n;
  while(n){
    n/=5;
    ans += n;
  }
  return ans;
}
signed main(){
  int n;
  cin >> n;
  cout << calc(n) << endl;
  // LOOP(i,100)cout << calc(i) << " ";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 1000000
int p[N];
int main() {
	int i, j,n,cnt;
	for (i = 2; i <= sqrt(N); i++) if (!p[i]) for (j = i*i; j < N; j += i)p[j] = 1;
	while (cin >> n) {
		for (i = n - 1;; i--) if (!p[i]) { cout << i<<" "; break;}
		for (i = n + 1;; i++) if (!p[i]) { cout << i << endl; break; }
	}
	return 0;
}

Measured memory_bytes: 6872
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<string>
using namespace std;

int main(){
	string s,p;
	cin >> s >> p;
	s = s + s;

	int a = s.find(p);

	if (a == -1){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 3224
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){	
			final int N = sc.nextInt();
			
			String[] ss = new String[N];
			int[] ts = new int[N];
			for(int i = 0; i < N; i++) {
				ss[i] = sc.next();
				ts[i] = sc.nextInt();
			}
			
			boolean found = false;
			final String X = sc.next();
			
			int answer = 0;
			for(int i = 0; i < N; i++) {
				if(found) { answer += ts[i]; }
				
				if(ss[i].equals(X)) {
					found = true;
				}
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

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

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    int g = 0;
    int k = 0;
    rep(i,n){
        if(a[i]%2==0){
            g++;
        }else{
            k++;
        }
    }

    if(k%2==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
  int a,b,c,i,n;
  
  while(scanf("%d %d %d",&a,&b,&n)!=EOF){
    a=a%b;
    for(c=0,i=1;i<=n;i++){
      a*=10;
      c+=a/b;
      a=a%b;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 596
import heapq

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

candidates = []
heapq.heappush(candidates, (-(A[0] + B[0] + C[0]), 0, 0, 0))
used = {(0, 0, 0)}
for _ in range(K):
    s, i, j, k = heapq.heappop(candidates)
    print(-s)
    if i < X - 1 and (i+1, j, k) not in used:
        heapq.heappush(candidates, (-(A[i+1] + B[j] + C[k]), i+1, j, k))
        used.add((i+1, j, k))
    if j < Y - 1 and (i, j+1, k) not in used:
        heapq.heappush(candidates, (-(A[i] + B[j+1] + C[k]), i, j+1, k))
        used.add((i, j+1, k))
    if k < Z - 1 and (i, j, k+1) not in used:
        heapq.heappush(candidates, (-(A[i] + B[j] + C[k+1]), i, j, k+1))
        used.add((i, j, k+1))


Measured memory_bytes: 4852
#include"cstdio"
int main(){
	int n,i=0,t=1;
	scanf("%d",&n);
	while(1){
		if(n!=1)
			{
			n=n/2;
			t=t*2;
			}
		else{
			break;
		}
		
	}
	printf("%d\n",t);
	
	return 0;
}

Measured memory_bytes: 128
def f(a,b):
  p,q=a,b
  while q!=0: p,q=q,p%q
  return a/p*b
  
while 1:
  x=map(int,raw_input().split())
  if any(x)==0: break
  A=[]
  for i in range(0,6,2):
    c=1
    while pow(x[i],c,x[i+1])!=1: c+=1
    A.append(c)
  x=reduce(lambda a,b: f(a,b), A)
  print x

Measured memory_bytes: 4320
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int h, w, k;
    string s;
    cin >> h >> w >> k;
    vector<vector<int>> ans(h+2, vector<int>(w+2, 0));
    int cnt = 1;
    for(int i = 0; i < h; i++) {
        cin >> s;
        for(int j = 0; j < w; j++) {
            if (s[j] == '#') {
                ans[i+1][j+1] = cnt++;
            }
        }
    }
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            if (ans[i][j] == 0)
                ans[i][j] = ans[i][j-1];
        }
        for(int j = w; j >= 1; j--) {
            if (ans[i][j] == 0)
                ans[i][j] = ans[i][j+1];
        }
    }
    for(int j = 1; j <= w; j++) {
        for(int i = 1; i <= h; i++) {
            if (ans[i][j] == 0) {
                ans[i][j] = ans[i-1][j];
            }
        }
        for(int i = h; i >= 1; i--) {
            if (ans[i][j] == 0) {
                ans[i][j] = ans[i+1][j];
            }
        }
    }
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}




Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int k;
    cin >> k;
    ll sum = 0;
    for(int i = 1;i <= k;i++){
        for(int j = 1;j <= k;j++){
            for(int l = 1;l <= k;l++){
                
                for(int m = min(i,(min(j,l)));m > 0;m--){
                    if(i % m == 0 && j % m == 0 ){
                        if(l % m == 0){
                        sum += m;
                        
                        break;
                    }
                    }
                }
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using vi = vector<int>;

int solve()
{
    string s,t;
    cin >>s >>t;
    int S = s.size(), T = t.size();

    for(int i=min(S,T); i>0; --i)
    {
        set<vi> x;

        vi ct(26);
        rep(j,i) ++ct[s[j]-'a'];
        x.insert(ct);

        for(int j=i; j<S; ++j)
        {
            --ct[s[j-i]-'a'];
            ++ct[s[j]-'a'];
            x.insert(ct);
        }

        ct = vi(26);
        rep(j,i) ++ct[t[j]-'a'];
        if(x.count(ct)) return i;

        for(int j=i; j<T; ++j)
        {
            --ct[t[j-i]-'a'];
            ++ct[t[j]-'a'];
            if(x.count(ct)) return i;
        }
    }
    return 0;
}

int main()
{
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 3864
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> k >> n;
  if (k*500>=n){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> inline bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> inline bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int s,w;
    cin>>s>>w;
    puts(w>=s?"unsafe":"safe");
}

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

int main(){
	string S;
	cin >> S;
	char a = S[0];
	char b = S[1];
	char c = S[2];
	char d = S[3];

   if(a == b||b == c||  c == d){
   	cout  << "Bad" << endl;
   }
   else{
   	cout << "Good" << endl;
   }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n;
	cin>>n;
	ll x=sqrt(n);
	ll ans=0;
	for(int i=1;i<=x;i++){
		if(n%i==0){
			if(n/i<i-1)ans+=i-1;
			ll p=n/i;
			if(n/p<p-1)ans+=p-1;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n,m;
    cin >> n >> m;
    vector<int>k(m);
    vector<vector<int>>s(m,vector<int>(0));
    rep(i,m){
        cin >> k[i];
        rep(j,k[i]){
            int a;
            cin >> a;
            a -= 1;
            s.at(i).push_back(a);
        }
    }
    vector<int>p(m);
    rep(i,m)cin >> p[i];

int ans = 0;
    rep(i,(1 << n)){
        bool allOn = true;
        rep(j,m){
            int onCount = 0;
            rep(l,s.at(j).size()){
                if((i >> s.at(j).at(l)) & 1)onCount += 1;
            }
            if(onCount % 2 != p[j])allOn = false;
        }
        if(allOn) ans += 1;
    }
    cout << ans << endl;
}

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

using namespace std;

const int MAX = 1e5;

int main() {
	int n, arr[MAX];
	cin >> n;
	
	for (int i=0; i<n; ++i) {
		cin >> arr[i];
	}
	
	sort(arr, arr+n);
	int k = 1;
	
	for (int i=0; i<n-1; ++i) {
		if (arr[i + 1] > arr[i]) k++;
	}
	
	if (k%2) cout << k;
	else cout << k-1;
	return 0;
}




Measured memory_bytes: 640
N=int(input())
table=[]
for i in range(N):
    x,y,d=input().split()
    x,y=int(x),int(y)
    table.append((x,y,d))
anspos=[0]
inf=10**10
a=-inf
b=-inf
c=-inf
for i in range(N):
    x,y,d=table[i]
    if d=='L':
        a=max(x,a)
    elif d=='R':
        b = max(x, b)
    else:
        c = max(x, c)
#anspos+=[(a+b)/2,(b+c)/2,(c+a)/2]
#anspos+=[max( (a-b)/2,0),max((b-a)/2,0),max(c-a,0),max(a-c,0),max(abs(b-c),0),max(c-b,0)]
anspos+=[abs(a-b)/2,abs(a-c),abs(b-c)]
a=inf
b=inf
c=inf
for i in range(N):
    x,y,d=table[i]
    if d=='L':
        a=min(x,a)
    elif d=='R':
        b = min(x, b)
    else:
        c = min(x, c)
anspos+=[abs(a-b)/2,abs(a-c),abs(b-c)]
a=-inf
b=-inf
c=-inf
for i in range(N):
    x,y,d=table[i]
    if d=='U':
        a=max(y,a)
    elif d=='D':
        b = max(y, b)
    else:
        c = max(y, c)
anspos+=[abs(a-b)/2,abs(a-c),abs(b-c)]
a=inf
b=inf
c=inf
for i in range(N):
    x,y,d=table[i]
    if d=='D':
        a=min(y,a)
    elif d=='U':
        b = min(y, b)
    else:
        c = min(y, c)
ans=10**30
anspos+=[abs(a-b)/2,abs(a-c),abs(b-c)]
#print(anspos)
for t in anspos:
    xmax=-inf
    xmin=inf
    ymax=-inf
    ymin=inf
    for i in range(N):
        x, y, d = table[i]
        if d=='U':
            y+=t
        elif d=='D':
            y-=t
        elif d=='L':
            x-=t
        elif d=='R':
            x+=t
        xmax=max(xmax,x)
        xmin = min(xmin, x)
        ymax = max(ymax, y)
        ymin = min(ymin, y)
    kai=(xmax-xmin)*(ymax-ymin)
    #print(kai,t)
    ans=min(ans,kai)
print(ans)


Measured memory_bytes: 99928
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N, M; scanf("%d%d", &N, &M);
    dsu uf(N);    
    for(int i=0; i<M; i++) {
        int u, v; scanf("%d%d", &u, &v);
        u--; v--;
        uf.merge(u, v);
    }

    cout << (int)uf.groups().size() - 1 << endl;
    return 0;
}


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


int main() {

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

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+7;

int p[MAXN];
int r[MAXN];

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

    for (int i = 1; i <= n; i++) {
        cin >> p[i];
        r[p[i]] = i;
    }

    int ans = 1;
    int run = 1;
    for (int i = 2; i <= n; i++) {
        if (r[i-1] < r[i]) run++;
        else run = 1;
        ans = max(ans, run);
    }

    cout << n-ans << "\n";


    return 0;
}


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

using namespace std;

int ans[100001];

int main()
{
	string s;
	getline(cin,s);
	int cur;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='R')
		{
			cur=i;
			while(s[cur]=='R')
				cur++;
			if((cur-i)%2) 
			{
				ans[cur]+=(cur-i)/2;
				ans[cur-1]+=(cur-i)/2;
			}
			else
			{
				ans[cur]+=(cur-i+1)/2;
				ans[cur-1]+=(cur-i-1)/2;
			}
			i=cur;
		}
	}
	for(int i=s.size()-1;i>=0;i--)
	{
		if(s[i]=='L')
		{
			cur=i;
			while(s[cur]=='L')
				cur--;
			if((i-cur)%2)
			{
				ans[cur+1]+=(i-cur)/2+1;
				ans[cur]+=(i-cur)/2+1;
			}
			else
			{
				ans[cur]+=(i-cur+1)/2+1;
				ans[cur+1]+=(i-cur-1)/2+1;
			}
			i=cur;
		}
	}
	for(int i=0;i<s.size();i++)
		cout<<ans[i]<<' ';
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		char[] array = a.toCharArray();
		for(int i = 0; i < array.length - 1; i++) {
			if(array[i] == array[i + 1]) {
				System.out.println("Bad");
				System.exit(0);
			}
		}
		System.out.println("Good");
	}
}

Measured memory_bytes: 21972
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P) {
	int i = 0;
	for (int j = 0; j < k; j++) {
		llong s = 0;
		while (s + T[i] <= P) {
			s += T[i];
			i++;
			if(i == n) return n;
		}
	}	
	return i;
}

int solve() {
	llong left = 0;
	llong right = 100000 * 10000;
	llong mid;
	while (right - left > 1) {
		mid = (left + right) / 2;
		int v = check(mid);
		if (v >= n) right = mid;
		else left = mid;
	}
	
	return right;
}

main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> T[i];
	llong ans = solve();
	cout << ans << endl;
}


Measured memory_bytes: 3872
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;

int eukureides(int x, int y)
{
	int z=INFINITY;
	while (z > 0)
	{
		z = x % y;
		x = y; y = z;
	}
	return x;

}

int main()
{
	cin >> n;
	vector<int> x(n + 1);
	rep(i, n + 1)
		cin >> x[i];
	sort(all(x));
	vector<int> sa(n);
	rep(i, n)
		sa[i] = x[i + 1] - x[i];
	sort(all(sa));

	a = sa[0];
	for (int i = 0; i < n; i++)
	{
		int x = 0;
		x = sa[i] % a;
		if (x == 0)
			continue;
		else
		{
			a = eukureides(a, x);
		}
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();

		int[] x = new int[n];
		int[] y = new int[n];
		int[] h = new int[n];

		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			h[i] = sc.nextInt();
		}

		int ax = 0;
		int ay = 0;
		int ah = 0;
		boolean flag = false;

		for (int i = 0; i <= 100; i++) {
			for (int j = 0; j <= 100; j++) {
				flag = true;

				int valid = -1;

				for (int k = 0; k < n; k++) {
					if (h[k] == 0)
						continue;
					valid = k;
				}
				int H = h[valid] + Math.abs(i - x[valid]) + Math.abs(j - y[valid]);

				for (int k = 0; k < n; k++) {
					if (h[k] != Math.max(0, H - Math.abs(x[k] - i) - Math.abs(y[k] - j))) {
						flag = false;
					}
				}
				if (flag) {
					ax = i;
					ay = j;
					ah = H;
					break;
				}

			}
		}

		System.out.println(ax + " " + ay + " " + ah);

		sc.close();

	}
}

Measured memory_bytes: 24384
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll N;
    cin >> N;
    ll count = 0;
    for (auto &&i: irange(1LL, N + 1)) {
        if (i % 2 == 0) continue;
        ll c = 0;
        for (auto &&j: irange(1LL, i + 1)) {
            if ((i % j) == 0) {
                c++;
            }
        }
        if (c == 8) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;
int a[1001];
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,k;
	cin>>n>>k;
	REP(i,n)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int cnt=0;
	REP(i,k)cnt+=a[i];
	cout<<cnt<<endl;
	return 0;
}


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

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

    for(int i = 0; i < n; i++)
    {
        string in_str;
        string ans;
        bool is_checked[256] = {};
        cin >> in_str;
         
        ans += in_str[0];
        is_checked[in_str[0]] = true;
        //cout << "debug: ascii " << in_str[0] - 'a' << " "
        //     << "in_str[j] = "  << in_str[0] << endl;
        for(int j = 1; j < in_str.size(); j = j + 3)
        {
            //cout << "debug: ascii " << in_str[j + 2] - 'a' << " "
            //     << "in_str[j + 2] = "  << in_str[j + 2] << endl;
            if(is_checked[in_str[j + 2]])
            {
                continue;
            }

            is_checked[in_str[j + 2]] = true;

            if(in_str[j] == '-' && in_str[j + 1] == '>')
            {
                ans = ans + in_str[j + 2];
            }
            else if(in_str[j] == '<' && in_str[j + 1] == '-')
            {
                ans = in_str[j + 2] + ans;
            }
            else
            {
                /* Nop */
            }
        }
        cout << ans << endl;
    }
    return 0;
}



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

const int mod=1000000007;
typedef long long ll;
const int N=22,N2=40001;
int f[N2],g[N],n,m;
#define pc __builtin_popcount

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=m;++i){
		int x,y;cin>>x>>y;--x;--y;
		g[x]|=1<<y;
	}
	f[0]=1;
	for(int i=1;i<(1<<n);++i)
		if((i&1)==(i>>1&1)){
			f[i]=1;
			for(int j=(i-1)&i;j;j=(j-1)&i){
				if((j&1)!=(j>>1&1))continue;
				int res=f[i-j];
				for(int k=0;k<n;++k)
					if(i>>k&1){
						if(j>>k&1)res=((ll)res<<pc(g[k]&(i-j)))%mod;
						else res=(((ll)res<<pc(g[k]&j))-res)%mod;
					}
				f[i]=(f[i]+res)%mod;
			}
		}
	int ans=1;
	for(int i=1;i<=m;++i)ans=ans*2%mod;
	ans=(ans-f[(1<<n)-1]+mod)%mod;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 384
class UnionFind():
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            st = []
            while self.parents[x] >= 0:
                st.append(x)
                x = self.parents[x]
            for y in st:
                self.parents[y] = x
            return x

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.N) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = map(int,input().split())
uf = UnionFind(N)
for i in range(M):
    A,B = map(int,input().split())
    uf.union(A-1,B-1)
print(uf.group_count()-1)

Measured memory_bytes: 72504
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(){
 int n,i;
 int max=0;
 int X[101],Y[101],D[101];
 double Da=0,Db=0,Dc=0,Dd=0;

/*n???????????????*/
 scanf("%d",&n);

/*x???????????????*/
 for(i=1;i<n;i++){
  scanf("%d ",&X[i]);
 }
  scanf("%d",&X[n]);

/*y???????????????*/
 for(i=1;i<n;i++){
  scanf("%d ",&Y[i]);
 }
  scanf("%d",&Y[n]);

/*?????¶??????????¨????*/
 for(i=1;i<=n;i++){
  D[i]=abs(X[i]-Y[i]);
  Da+=D[i];
  if(D[i]>max){
   max=D[i];
  }
 }
/*Db????¨????*/
 for(i=1;i<=n;i++){
  Db+=pow(D[i],2);
 }
  Db=sqrt(Db);

 for(i=1;i<=n;i++){
  Dc+=pow(D[i],3);
 }
  Dc=pow(Dc,1.0/3.0);

  Dd=max;

 printf("%lf\n%lf\n%lf\n%lf\n",Da,Db,Dc,Dd);

return 0;
}

Measured memory_bytes: 700
#include <stdio.h>
int main ()
{
	int N,a[150],i,j,s=0;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<N;i++)
	{
		for(j=i+1;j<N;j++)
		{
			s=s+a[i]*a[j];
		}
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 128
def main():
  ch=input()
  l=len(ch)
  for i in range(l):
    if(i%2==0 and (ch[i]!='R' and ch[i]!='U' and ch[i]!='D')):
      print('No')
      break
    elif(i%2==1 and (ch[i]!='L' and ch[i]!='U' and ch[i]!='D')):
      print('No')
      break
    elif(i==l-1):
      print('Yes')
  
main()

Measured memory_bytes: 3060