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

const int INF=1e9;

long long g[110][110]={};
int N,M;
long long d[110][110]; //最短経路を記録
int used[110][110]={};

void init(){
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i==j) d[i][j]=0;
            else d[i][j]=INF;
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(g[i][j]!=0) d[i][j]=g[i][j];
        }
    }
}

void warshall_floyd(){ //全点間最短経路, O(N^3)
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        g[a][b]=c;
        g[b][a]=c;
    }
    init();
    warshall_floyd();
    /*
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cout << d[i][j];
        }
        cout << endl;
    }
    */
    int ans=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(i==j) continue;
            if(g[i][j]==0) continue;
            if(g[i][j]>d[i][j]) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    Map<Integer, List<Integer>> rooms = new HashMap<>();
    for (int i = 1; i <= n; i++) {
      rooms.put(i, new ArrayList<>());
    }
    for (int i = 0; i < m; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      rooms.get(a).add(b);
      rooms.get(b).add(a);
    }
    Map<Integer, Integer> mins = new HashMap<>();
    Map<Integer, Integer> parent = new HashMap<>();
    for (int i = 1; i <= n; i++) {
      mins.put(i, Integer.MAX_VALUE);
    }
    mins.put(1, 0);
    Deque<Integer> queue = new ArrayDeque<>();
    queue.add(1);
    while (!queue.isEmpty()) {
      int room = queue.poll();
      for (int next : rooms.get(room)) {
        if (mins.get(next) > mins.get(room) + 1) {
          mins.put(next, mins.get(room) + 1);
          parent.put(next, room);
          queue.add(next);
        }
      }
    }
    int[] result = new int[n + 1];
    for (int i = 2; i <= n; i++) {
      int to = i;
      if (!parent.containsKey(to)) {
        System.out.println("No");
        return;
      }
      int from = parent.get(to);
      result[to] = from;
    }
    StringBuilder sb = new StringBuilder();
    sb.append("Yes");
    for (int i = 2; i <= n; i++) {
      sb.append("\n");
      sb.append(result[i]);
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 97328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll a,b;cin >> a >>b;
    cout << 100 <<" " <<100 <<endl;
    vector<vector<char>> g(100,vector<char>(100,'.'));
    rep(i,50){
        rep(j,100){
            g[i][j]='#';
        }
    }
    a--;b--;
    ll i=0,j=0;
    while(a!=0){
        if(j%2==0){g[i][j]='.';a--;}
        j++;if(j==100){j=0;i+=2;}
    }
    i=99;j=99;
    while(b!=0){
        if(j%2==0){g[i][j]='#';b--;}
        j--;if(j==-1){j=99;i-=2;}
    }
    rep(i,100){
        rep(j,100){
            cout << g[i][j];
        }
        cout <<endl;
    }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))

half = [i//2 for i in A]

def f(v):
    r = 0
    while v % 2 == 0:
        v /= 2
        r += 1
    return r

from fractions import gcd
def f2(x, y):
    return (x * y) // gcd(x, y)

d = f(A[0])
for ai in A:
    if d != f(ai):
        print(0)
        break
else:
    lcm = 1
    for ai in half:
        lcm = f2(lcm, ai)

    r = M // lcm
    ans = (r + 1) // 2
    print(ans)


Measured memory_bytes: 14244
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)
int main() {
  struct query {
    int t;
    int f;
    char c;
  };

  string s;
  cin >> s;
  int Q;
  cin >> Q;
  vector<query> queries(Q);
  for (int i = 0; i < Q; ++i) {
    int t;
    cin >> t;
    if (t == 1) {
      queries[i].t = t;
    } else if (t == 2) {
      int f;
      char c;
      cin >> f >> c;

      queries[i].t = t;
      queries[i].f = f;
      queries[i].c = c;
    }
  }
  string prepend = "";
  string append = "";

  bool rev = false;
  for (const auto& q : queries) {
    if (q.t == 1) {
      rev = !rev;
      swap(prepend, append);
    } else if (q.t == 2) {
      if (q.f == 1) {
        prepend.push_back(q.c);
      } else if (q.f == 2) {
        append.push_back(q.c);
      }
    }
  }

  string ret;
  reverse(prepend.begin(), prepend.end());
  if (rev) {
    reverse(s.begin(), s.end());
  }
  ret = prepend + s + append;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 6624
#include <iostream>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;
int mod = 1e9+7;

map<int, int64> mii;

int main() {
	int64 X;
	cin >> X;
	for (int i = 0; i <= 120; ++i) {
		int64 tmp = i * i;
		tmp *= tmp;
		tmp *= i;
		mii[i] = tmp;
	}
	for (int i = 0; i <= 120; ++i) {
		for (int j = i; j <= 120; ++j) {
			if (mii[i] - mii[j] == X) {
				cout << i << " " << j << "\n";
				return 0;
			} else if (mii[i] + mii[j] == X) {
				cout << i << " " << -j << "\n";
				return 0;
			} else if (-mii[i] + mii[j] == X) {
				cout << -i << " " << -j << "\n";
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3648
a = []
for i in range(10):
    n = int(input())
    a.append(n)
    a.sort(reverse=True)

b = []
for i in range(10):
    m = int(input())
    b.append(m)
    b.sort(reverse=True)
    
print('{} {}'.format(a[0]+a[1]+a[2],b[0]+b[1]+b[2]))



Measured memory_bytes: 5596
#include <iostream>
#define ll long long

using namespace std;

int main() {
    int n;
    cin >> n;
    ll v[200005];
    for(int i=0;i<n;i++) cin >> v[i];
    
    ll soma = 0;
    for(int i=1;i<n;i++){
        if(v[i]<v[i-1]){
            ll temp = v[i-1]-v[i];
            soma+=temp;
            v[i]+=temp;
        }
    }
    
    cout << soma << endl;
    
    return 0;
}

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

using namespace std;

const int maxn=4e5+10;
int n,m,ans,g[maxn],head[maxn],cnt,vis[maxn],vi[maxn];

struct ed{
	int next,to;
}e[maxn];

void add(int u,int v){
	e[++cnt]=(ed){head[u],v};head[u]=cnt;
	e[++cnt]=(ed){head[v],u};head[v]=cnt;
}

void dfs(int now,int col){
	vis[now]=col;
	for(int i=head[now];i;i=e[i].next){
		int tt=e[i].to;
		if(!vis[tt]) dfs(tt,col);
	}
}	

void dfs2(int now,int col){
	vi[now]=1;
	if(g[now]>0&&vis[g[now]]==col)ans++;
	for(int i=head[now];i;i=e[i].next){
		int tt=e[i].to;
		if(!vi[tt]&&vis[tt]==col) dfs2(tt,col);
	}
}

int main(){
	scanf("%d%d",&n,&m);int u,v;
	for(int i=1;i<=n;i++) scanf("%d",&g[i]);
	for(int i=1;i<=m;i++) scanf("%d%d",&u,&v),add(u,v);
	for(int i=1;i<=n;i++) if(!vis[i]) dfs(i,i),dfs2(i,i);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

int main()
{
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) {
    cin >> h[i];
  }
  int ans = 0;
  int tmp = 0;
  int current = h[n-1];

  for (int i = n-2; i > -1; i--) {
    if (h[i] >= current) {
      tmp += 1;
      current = h[i];
      chmax(ans, tmp);
    } else {
      chmax(ans, tmp);
      tmp = 0;
      current = h[i];
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using Graph = vector<vector<ll>>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll n; cin >> n;
	Graph G(n);
	for (ll i = 0; i < n; ++i)
	{
		ll a, k; cin >> a >> k;
		--a;
		for (ll j = 0; j < k; ++j)
		{
			ll b;
			cin >> b;
			G[a].push_back(--b);
		}
	}

	vector<ll> d(n, -1);
	d[0] = 0;
	queue<ll> que;
	que.push(0);

	while (!que.empty())
	{
		ll now = que.front(); que.pop();

		for (auto &nv : G[now])
		{
			if (d[nv] != -1) continue;
			d[nv] = d[now] + 1;
			que.push(nv);
		}
	}

	for (ll i = 0; i < n; ++i)
		std::cout << i + 1 << " " << d[i] << std::endl;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	ll X;

	cin >> X;

	rep(a,2000) rep(b,2000){
		ll A = a - 1000;
		ll B = b - 1000;
		if(A*A*A*A*A - B*B*B*B*B == X){
			cout << A << " " << B << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3580
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 2019;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

ll mypow(ll x, ll n) {
    if (n == 0) return 1;
    if (n%2 == 0) return mypow(((x%mod)*(x%mod))%mod, n/2);
    else return ((x%mod) * mypow(((x%mod)*(x%mod))%mod, (n-1)/2))%mod;
}

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    for (int i=0; i<1000; i++) {
        if (K*i >= A && K*i <= B) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   map<string,string> ans;
   ans["Sunny"] = "Cloudy";
   ans["Cloudy"] = "Rainy";
   ans["Rainy"] = "Sunny";

   string s;
   cin >> s;
   cout << ans[s] << '\n';
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long lcm(long long u, long long v){
    if(u == 0 || v == 0){
        return 0;
    }else{
        long long s=u*v;
        long long r;
        while (0 != v) {
        r = u % v; u = v; v = r;
        }
        s /= u;
        return s;
    }
}
int gcd(long long u, long long v) {
  long long r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

int main(){
    long long n,m;
    string s,t;
    cin >> n >> m;
    cin >> s >> t;
    long long l = lcm(n,m);
    long long o = gcd(n,m);
        long long x = n/o;
        long long y = m/o;
        for(long long i=0;i<o;i++){
            if(s[x*i] != t[y*i]){
                goto dame;
            }
        }
        goto oke;
    
    dame:
    cout << "-1" << endl;
    goto owari;
    oke:
    cout << l << endl;
    owari:
    return 0;
    
}


Measured memory_bytes: 512
N, A, B, C, D = (int(i) for i in input().split())  
S = input()

bef = ''
row_dot_max = 0
count = 0
for i, s in enumerate(S):
  if bef == '#' and s == '#' and i > A and i <= max(C,D)-2:
    print('No')
    exit()
  
  if s == '.' and i >= B-2 and i <= D:
    count += 1
  else:
    row_dot_max = max(row_dot_max, count)
    count = 0
  bef = s

row_dot_max = max(row_dot_max, count)
if C > D:
  if row_dot_max >= 3:
    print('Yes')
  else:
    print('No')
else:
  print('Yes')

Measured memory_bytes: 3572
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if B > A:
    A = A + V*T
    B = B + W*T
    if A >= B:
        print('YES')
    else:
        print('NO')
else:
    A = A - V*T
    B = B - W*T
    if A <= B:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9152
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC097D();

#if 1
int main()
{
	ABC097D();
	fflush(stdout);
	return 0;
}
#endif

class UnionFindTree
{
protected:
	int* _par = 0;
	int* _rank = 0;
	int* _count = 0;

	void init(int size) {
		_par = new int[size];		//	親ノード
		_rank = new int[size];		//	高さ
		_count = new int[size];		//	結合グループの要素数

		for (int i = 0; i < size; i++) {
			_par[i] = i;
			_rank[i] = 0;
			_count[i] = 1;
		}
	}

public:
	UnionFindTree(int size = 10) {
		init(size);
	}

	~UnionFindTree() {
		delete[] _par;
		delete[] _rank;
		delete[] _count;
	}

	//	木の根を求める
	int find(int x) {
		if (_par[x] == x) {
			return x;
		}
		else {
			return(_par[x] = find(_par[x]));
		}
	}

	//	x と y の属する集合を併合
	void Unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) {
			//	すでに同じ集合だった
			return;
		}

		if (_rank[x] < _rank[y]) {
			//	数をまず加算しておく
			_count[y] = _count[y] + _count[x];
			_par[x] = y;
		}
		else {
			//	数をまず加算しておく
			_count[x] = _count[y] + _count[x];

			_par[y] = x;
			if (_rank[x] == _rank[y]) {
				_rank[x]++;
			}
		}
	}

	bool IsUnion(int x, int y) {
		return (find(x) == find(y));
	}

	int count(int x) {
		return _count[find(x)];
	}
};

static void ABC097D()
{
	int N, M;
	getint(N, M);

	std::vector<int> pn(N);
	for (int i = 0; i < N; i++) {
		getint(pn[i]);
		pn[i]--;
	}

	UnionFindTree uf(N);
	for (int i = 0; i < M; i++) {
		int x, y;
		getint(x, y); x--; y--;
		uf.Unite(x, y);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (uf.IsUnion(i, pn[i])) {
			ans++;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1792
eval"N,K,*A="+`dd`.split*?,
c=1;j=0
A.sort!
p (K..N).sum{|i|c.*A[i-1]-A[-i]+0*c=c*i*($*[j+=1]=j<2?1:M/j*-$*[M%j])%M=10**9+7}%M

Measured memory_bytes: 33756
#include <stdio.h>

#define N 100001

int main(void)
{
	char s[N];
	scanf("%s", s);

	int i, r, l;
  	i = 0;
	while (s[i] != '\0')
	{
		r = i;
		while (s[i + 1] == 'R')
		{
			i++;
			printf("0 ");
		}
		l = ++i;
		while (s[i + 1] == 'L')
			i++;
        i++;
		printf("%d ", (l - r + 1) / 2 + (i - l) / 2);
		printf("%d ", (l - r) / 2 + (i - l + 1) / 2);
		for (l = l + 1; l < i; l++)
			printf("0 ");
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 512
r, c = map(int, input().split())

rows = [0]*(r+1)
rows[r] = []
total = 0

for i in range(r):
    rows[i] = list(map(int, input().split()))
    total += sum(rows[i])
    rows[i].append(sum(rows[i]))
    
for j in range(c):
    col_sum = 0
    for i in range(r):
        col_sum += rows[i][j]
    rows[r].append(col_sum)

rows[r].append(total)

for i in range(r+1):
    for j in range(c+1):
        rows[i][j] = str(rows[i][j])
    line = " ".join(rows[i])
    print(line)



Measured memory_bytes: 6260
n, m= map(int, input().split())
c = []
for i in range(n):#h:高さ
    c.append([int(m) for m in input().split()])
c.sort()
ans = 0
buy = 0
for i in range(n):
    if buy + c[i][1] < m:
        buy += c[i][1]
        ans += c[i][0] * c[i][1]
    else:
        ans += (m - buy) * c[i][0]
        break
print(ans)

Measured memory_bytes: 21616
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include <functional>
#include <queue>

using namespace std;

#define MOD 1000000007
#define INF 1050000000

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

	long long dp[110][4][4][4];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < 4; i++)for (int j = 0; j < 4; j++)for (int k = 0; k < 4; k++)dp[3][i][j][k] = 1;
	dp[3][0][2][1] = 0;
	dp[3][2][0][1] = 0;
	dp[3][0][1][2] = 0;
	//ここでは0='A',1='C',2='G',3='T'として実装をする
	//上記が初期条件

	for (int x = 3; x < n; x++)for (int i = 0; i < 4; i++)for (int j = 0; j < 4; j++)for (int k = 0; k < 4; k++) for(int l=0;l<4;l++){
		if (j == 0 && k == 2 && l == 1)continue;
		if (j == 2 && k == 0 && l == 1)continue;
		if (j == 0 && k == 1 && l == 2)continue;
		if (i == 0 && k == 2 && l == 1)continue;
		if (i == 0 && j == 2 && l == 1)continue;

		dp[x + 1][j][k][l] =( (dp[x][i][j][k] + dp[x+1][j][k][l]) % MOD);
	}

	long long ans = 0;

	for (int i = 0; i < 4; i++)for (int j = 0; j < 4; j++)for (int k = 0; k < 4; k++) {
		ans =((ans + dp[n][i][j][k]) % MOD);
	}

	cout << ans << endl;






}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	char a,b,c;
	scanf("%c%c%c",&a,&b,&c);
	printf("%d\n",700+(a=='o'?100:0)+(b=='o'?100:0)+(c=='o'?100:0));
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a[200000];
  int n,ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      ans=1;
      break;
    }
  }
  if(ans==0){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1024
a, b = map(int, input().split())

asum = 0
bsum = 0

for kk in range(b):
    asum = asum * 10 + a

for ll in range(a):
    bsum = bsum * 10 + b

if asum > bsum:
    print(asum)
else:
    print(bsum)

Measured memory_bytes: 2940
#include <iostream>
#include<string>
#include<algorithm>
#include<stdio.h>

using namespace std;

int main(){
    int a,b,c,x;
    cin>>a>>b>>c;
    if(a==b && b==c)cout<<1<<endl;
    else if(a==b || b==c || c==a)cout<<2<<endl;
    else cout<<3<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;
bool sr(int a, int b)
{
	return a > b;
}
bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(ll n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
template <class T>
void print(const T &value)
{
	std::cout << value << std::endl;
}
bool ssign(int a,int b){
	if(a>0&&b>0){
		return true;
	}else if(a<0&&b<0){
		return true;
	}else{
		return false;
	}
}
bool larger(int a,int b){
	if(a<b){
		return true;
	}else{
		return false;
	}
}
int main()
{
	int x,y;
	cin>>x>>y;
	long ans=1e10;
	int ay=abs(y);
	int ax=abs(x);
	int dif=abs(ay-ax);
	rep(i,4){
		int cnt=dif;
		int tx=x;
	//	cout<<tx<<" ";
		if(i&1<<0){
			tx*=-1;
			cnt++;
		}
		tx+=dif;
		if(i&1<<1){
			tx*=-1;
			cnt++;
		}
		if(tx==y){
			ans=min(ans,(long)cnt);
		}
	}
	
cout<<ans<<endl;

}

Measured memory_bytes: 256
import math
N,M=map(int,input().split())
X=math.factorial(N)%(10**9+7)
Y=math.factorial(M)%(10**9+7)
if abs(N-M)>=2:
  print(0)
elif N==M:
  print(X*Y*2%(10**9+7))
else:
  print(X*Y%(10**9+7))


Measured memory_bytes: 79216
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

// A = B * C <-> A % N = (B % N) * (C % N) % N 
// A = B + C <-> A % N = (B % N) + (C % N) % N

int main(void) {
    u64 N;
    cin >> N;

    boost::dynamic_bitset<> X;
    //string X;
    cin >> X;
    
    // pre cal
    u64 bcnt = X.count();
    u64 bcnt_p = bcnt + 1;
    u64 bcnt_m = (bcnt > 1) ? bcnt - 1 : 1;
    vector<u64> mod_p(N, 1);
    vector<u64> mod_m(N, 1);

    mod_p[0] = 1 % bcnt_p;
    mod_m[0] = 1 % bcnt_m;
    for(u64 i=1; i<N; i++) {
        mod_p[i] = mod_p[i-1] * 2 % bcnt_p;
        mod_m[i] = mod_m[i-1] * 2 % bcnt_m;
    }

    u64 pre_ans_p = 0;
    u64 pre_ans_m = 0;
    for(u64 i=0; i<N; i++) {
        if(X[i]) {
            pre_ans_p = (pre_ans_p + mod_p[i]) % bcnt_p;
            pre_ans_m = (pre_ans_m + mod_m[i]) % bcnt_m;
        }
    }

    for(s64 i=N-1; i>=0; i--) {
        boost::dynamic_bitset<> Xi = X;
        Xi.flip(i);

        // all 0
        if(Xi.none()) {
            cout << 0 << endl;
            continue;
        }

        // firstly
        u64 val;
        if(Xi[i]) {
            val = (pre_ans_p + mod_p[i]) % bcnt_p;
        } else {
            val = (pre_ans_m >= mod_m[i]) ? (pre_ans_m - mod_m[i]) % bcnt_m : (pre_ans_m + bcnt_m - mod_m[i]);;
        }

        // secondly
        u64 ans = 1;
        while(val > 0) {
            ans++;
            u64 nxt = val;
            u64 mod = 0;
            while(val > 0) {
                mod += val & 1;
                val /= 2;
            }
            val = nxt % mod;
        }

        cout << ans << endl;
    }

    return 0;
}

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

#define ll long long
#define db double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif

	long db x;
	cin >> x;
	x /= 3;
	x = x * x * x;
	cout << setprecision(20) << x;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    string T;cin>>T;
    int N,S,E,W;
    N=S=E=W=0;
    REP(i,T.size()){
        if(T[i]=='N')N++;
        if(T[i]=='S')S++;
        if(T[i]=='E')E++;
        if(T[i]=='W')W++;
    }
    if((N>0&&S==0)||(S>0&&N==0)||(E>0&&W==0)||(W>0&&E==0))cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n; cin >>n;
  print((1000-n%1000)%1000);
}

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

int main(){
  int N,n,sum=0;
  cin >> N;
  n=N;
  while(n!=0){
    sum += n%10;
    n /= 10;
  }
  if(N%sum==0)cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int monsterHealth, attackPower, attacksAmount, isKilled;
	scanf("%d %d", &monsterHealth, &attackPower);

	// Counts how many attacks will take whole HP of the monster
	attacksAmount = monsterHealth / attackPower;

	// Checks if attacks where enough to kill monster, if not then adds one more attack
	isKilled = attacksAmount * attackPower >= monsterHealth;
	if (!isKilled)
	{
		attacksAmount++;
	}

	printf("%d \n", attacksAmount);

	return 0;
}

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

 using namespace std;

 int main() {
   long long N, A, B;
   cin >> N >> A >> B;

   if (A > B) cout << 0 << endl;
   else if (A == B) cout << 1 << endl;
   else if (N == 1) cout << 0 << endl;
   else cout << (N - 2) * (B - A) + 1 << endl;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#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 WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';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(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

set<string> s;
int dp[1 << 16];
int place;
char sstr[20];

int dfs2(){
	if(sstr[place] == '-'){
		place++;
		return 1 - dfs2();
	}
	else if(sstr[place] == '('){
		place++;
		int a = dfs2();
		char c = sstr[place];
		place++;
		int b = dfs2();
		place++;
		if(c == '^')return a ^ b;
		else return a & b;
	}
	else{
		return sstr[place++] - '0';
	}
}

int f(){
	place = 0;
	return dfs2();
}

int investigate(string str){
	int ret = 0;
	REP(i,(1<<4)){
		REP(j,str.size()){
			if(str[j] >= 'a' && str[j] <= 'd'){
				sstr[j] = (char)('0' + ((i & (1 << (str[j] - 'a')))>0));
			}
			else{
				sstr[j] = str[j];
			}
		}
		ret |= (f() << i);
	}
	return dp[ret] = min(dp[ret],(int)str.size());
}


void check(string str){
	int cou = 0;
	REP(i,str.size()){
		if(str[i] == 'X')cou++;
	}
	int num = 1;
	REP(i,cou)num *= 6;
	REP(i,num){
		string now = "";
		int tmp = i;
		REP(j,str.size()){
			if(str[j] == 'X'){
				int seica = tmp % 6;
				if(seica < 4){
					now += (char)('a' + seica);
				}
				else{
					now += (char)('0' + (seica - 4));
				}
				tmp /= 6;
			}
			else{
				now += str[j];
			}
		}
		investigate(now);
	}
}

void dfs(string str){
	if(str.size() > 14 || s.count(str))return;
	s.insert(str);
	check(str);
	REP(i,str.size()){
		if(str[i] == 'X'){
			dfs(str.substr(0,max(0LL,i)) + "(X*X)" + str.substr(i+1));
			dfs(str.substr(0,max(0LL,i)) + "(X^X)" + str.substr(i+1));
			if(!(i > 0 && str[i-1] == '-'))dfs(str.substr(0,max(0LL,i)) + "-X" + str.substr(i+1));
		}
	}
}	
	

int main(){
	REP(i,1<<16)dp[i] = INF;
	dfs("X");
	string str;
	while(cin >> str,str[0] != '.'){
		cout << investigate(str) << endl;
	}
	return 0;
}



Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    int ans=1;
    rep(k,0,K){
        int n=S.at(k)-'0';
        if(n!=1){
            ans=n;
            break;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    int N;
    cin >> N;
    string S;
    cin >> S;
    REP(i,S.size()){
        S[i]+=N;
        if(S[i]>=91){
            S[i]-=26;
        }
    }
    cout <<S<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

bool ok(string t){
    int n = t.size();
    if (n % 2 != 0) return false;
    else {
        bool flag = true;
        rep(i, n / 2){
            if (t[i] != t[i + n / 2]) flag = false;
        }
        return flag;
    }
}


int main(){
    string s;
    cin >> s;
    int m = s.size();
    rrep(i, m){
        if(ok(s.substr(0, i))){
            cout << s.substr(0, i).size() << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        String op = new String();
        int a, b;
        while (input.hasNextInt()) {
            a = input.nextInt();
            op = input.next();
            b = input.nextInt();
            if (a == 0 && op.equals("?") && b == 0) break;
            if (op.equals("+")) System.out.println(a + b);
            else if (op.equals("-")) System.out.println(a - b);
            else if (op.equals("*")) System.out.println(a * b);
            else if (op.equals("/")) System.out.println(a / b);
        }
    }         
}

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

using ll = long long; using vi = vector<int>; using vll = vector<ll>;
using vvi = vector<vi>; using vvll = vector<vll>;
const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll INF_MAX = numeric_limits<ll>::max();
#include <boost/range/irange.hpp>
using boost::irange;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vi arr;
  for (int i : irange(1, min(a, b) + 1)) {
    if (a % i == 0 and b % i == 0) arr.push_back(i);
  }
  sort(arr.rbegin(), arr.rend());
  cout << arr[k - 1] << endl;
}


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

int main() {
  long n,ans=0,aaa=999999999999,minus=0;
  cin >> n;
  for(long i=0;i<n;i++) {
    long a;
    cin >> a;
    if(a>0) {
      ans+=a;
      aaa=min(aaa,a);
    } else if(a<0) {
      ans+=0-a;
      aaa=min(aaa,0-a);
      if(minus<1000000000) minus++;
    } else {
      minus=1000000000;
    }
  }
  if(minus%2==1) ans-=aaa*2;
  cout << ans << endl;
}

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

vector<pair<string, int> > v;

int main(){
while(1){//start
	string s, t;
	int n;
	cin >> n;
	if(n == 0) break;

	for(int i = 0; i < n; i++){
		cin >> s >> t;
		v.push_back(make_pair(s, 1));
		v.push_back(make_pair(t, 0));
	}

	sort(v.begin(), v.end());

	int stock = 1;
	int ans = 1;

	for(int i = 0; i < (int)v.size(); i++){
		if(v[i].second){
			if(stock - 1 < 0) ans += 1;
			else stock -= 1;
		}
		else{
			stock += 1;
		}
	}

	cout << ans << endl;

	v.clear();
}//end	

	return 0;
}



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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    int ans = 1e9 + 7;
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    for(int i = 1; i < 100; i++){
        int sum = 0;
        for(int j = 0; j < n; j++){
            sum += ((x[j] - i) * (x[j] - i));
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
const int N=307;
int P,C[N][N],f[N][N],s[N][N];
void inc(int&a,int b){a+=b-P,a+=a>>31&P;}
void dec(int&a,int b){a-=b,a+=a>>31&P;}
int main()
{
    int n,k;scanf("%d%d%d",&n,&k,&P);
    for(int i=0;i<=n;++i) for(int j=C[i][0]=1;j<=i;++j) inc(C[i][j]=C[i-1][j],C[i-1][j-1]);
    for(int i=0;i<=k;++i) f[1][i]=1,s[1][i]=k-i+1;
    for(int i=2;i<=n+1;++i)
    {
	for(int j=0;j<=k;++j) for(int l=1;l<i;++l) inc(f[i][j],1ll*f[i-l][j]*s[l][j+1]%P*C[i-2][l-1]%P);
	for(int j=k;j;--j) inc(s[i][j]=s[i][j+1],f[i][j]);
    }
    printf("%d",f[n+1][0]);
}


Measured memory_bytes: 1280
#include<stdio.h>
int main(){
int n,m,i,j,k,l,x,y,z,a,b;
x=0;y=0;z=0;
scanf("%d%d%d",&a,&b,&k);
for(i=0;i<k&&i+a<=b;i++){
printf("%d\n",a+i);}
x=a+k;
if(x<b-k+1){x=b-k+1;}
for(i=x;i<=b;i++){
printf("%d\n",i);}
return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
typedef long long ll;

int n, m;
int xs[100000+10];

int main(void) {
  scanf("%d%d", &n, &m);
  REP(i, m) {
    scanf("%d", &xs[i]);
  }
  sort(xs, xs + m);
  int res = 0;
  vector<int> ds;
  REP(i, m-1) {
    ds.push_back(xs[i+1] - xs[i]);
  }
  sort(ds.begin(), ds.end());
  REP(i, m-n) {
    res += ds[i];
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 1276
# ????????????????????°????±???????????????°??????
import sys
import itertools

def main():
    while True:
        data = sys.stdin.readline().strip().split(' ')
        n = int(data[0])
        x = int(data[1])
        
        if n == 0 and x == 0:
            break

        cnt = 0
        for i in itertools.combinations(range(1, n+1), 3):
            if sum(i) == x:
                cnt += 1

        print(cnt)

if __name__ == '__main__':
    main()

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

#define MOD ((int)(1e9) + 7)
#define NMAX 1005
using namespace std;

int dp[NMAX][NMAX], mat[NMAX][NMAX];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;

    cin.get();
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
        {
            char ch;
            cin >> ch;

            if(ch == '#')
                mat[i][j] = -1;
        }
    dp[1][0] = 1;
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
            if(mat[i][j] != -1)
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;

    cout << dp[n][m] << '\n';
    return 0;
}


Measured memory_bytes: 8192
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

struct G {
    N: usize,
    A: Vec<Vec<usize>>,
    P: Vec<usize>,
}

impl G {
    fn decomp(&mut self) {
        for v in 0..self.N {
            self.dfs(v, v);
        }
    }

    fn dfs(&mut self, v: usize, p: usize) {
        debug!((v, p, self.P[v]));
        if self.P[v] != self.N {
            return;
        }

        self.P[v] = p;

        for i in 0..self.A[v].len() {
            let w = self.A[v][i];
            self.dfs(w, p);
        }
    }
}

fn main() {
    let (N, K, L) = read!(usize, usize, usize);

    // subway instead of rails
    let mut R = vec![vec![]; N];
    let mut S = vec![vec![]; N];

    for _ in 0..K {
        let (u, v) = read!(usize, usize);
        R[u - 1].push(v - 1);
        R[v - 1].push(u - 1);
    }

    for _ in 0..L {
        let (u, v) = read!(usize, usize);
        S[u - 1].push(v - 1);
        S[v - 1].push(u - 1);
    }

    let mut rg = G {
        N: N,
        A: R,
        P: vec![N; N],
    };
    rg.decomp();

    let mut sg = G {
        N: N,
        A: S,
        P: vec![N; N],
    };
    sg.decomp();

    let mut m = BTreeMap::new();
    for v in 0..N {
        *m.entry((rg.P[v], sg.P[v])).or_insert(0) += 1;
    }

    let mut ns = vec![];
    for v in 0..N {
        ns.push(m[&(rg.P[v], sg.P[v])]);
    }

    debug!(sg.A, rg.A, m);

    println!("{}", ns.into_iter().map(|n| n.to_string()).vec().join(" "))
}


Measured memory_bytes: 43772
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <complex>

using namespace std;
using pii = pair<int, int>;
using ll = long long;

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

	int n, m;
	cin >> n >> m;
	vector<vector<int>> adj(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		adj[a - 1].push_back(b - 1);
	}
	vector<int> answer;
	for (int i = 0; i < n; i++) {
		queue<int> q;
		vector<int> parent(n, -1);
		for (int nxt : adj[i]) {
			parent[nxt] = i;
			q.push(nxt);
		}
		while (!q.empty()) {
			int now = q.front();
			q.pop();
			if (now == i) {
				vector<int> nowanswer = { now };
				now = parent[now];
				while (now != i) {
					nowanswer.push_back(now);
					now = parent[now];
				}
				if (answer.empty() || answer.size() > nowanswer.size()) answer = nowanswer;
			}
			for (int nxt : adj[now]) {
				if (parent[nxt] == -1) {
					parent[nxt] = now;
					q.push(nxt);
				}
			}
		}
	}
	if (answer.empty()) cout << -1;
	else {
		cout << answer.size() << "\n";
		for (int ans : answer) cout << ans + 1 << "\n";
	}

	return 0;
}


Measured memory_bytes: 384
N = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))

x = [0]*N
for i in range(N):
	x[i] = v[i]-c[i]

ans = 0
for i in range(N):
	if x[i] > 0:
		ans += x[i]
print(ans)


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int X; cin >> X;
    for (int i = 1; ; i++) {
        if (X * i % 360 == 0) {
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
import fileinput

chr_master = [
    ' ', '\',.!?', 'abcABC', 'defDEF', 'ghiGHI',
    'jklJKL', 'mnoMNO', 'pqrsPQRS', 'tuvTUV', 'wxyzWXYZ'
]

for s in (line.strip() for line in fileinput.input()):
    s += '!'
    prev_c = None
    cnt = 0
    ans = ''
    for c in s:
        if c == prev_c:
            cnt += 1
            continue
        if prev_c == '0':
            if cnt > 1:
                ans += ' ' * (cnt - 1)
        else:
            if prev_c is not None:
                ans += chr_master[int(prev_c)][cnt - 1]

        prev_c = c
        cnt = 1
    print(ans)

Measured memory_bytes: 7488
#include <stdio.h>

int main (void){
  int N;
  scanf("%d",&N);
  int X[N];
  int ans=10000000;
  int A=0;
  for(int i=0;i<N;i++){
    scanf("%d",&X[i]);
  }
  for(int P=1;P<101;P++){
    for(int i=0;i<N;i++){
      A+=(X[i]-P)*(X[i]-P);
    }
    if(ans>A){
      ans=A;
    }
    A=0;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
S = input()

def is_even_string(S):
    if len(S) % 2 == 1:
        return False
    return S[:len(S) // 2] == S[len(S) // 2:]

for i in range(len(S) - 1, -1, -1):
    if is_even_string(S[:i]):
        print(i)
        quit()

Measured memory_bytes: 3060
N, M = map(int, input().split())
Lumps = [[]] * M
for i in range(M):
  Lumps[i] = list(map(int, input().split()))[1:]
p = list(map(int, input().split()))
ans = 0
s = 0

for j in range(2 ** N):
  ss = format(s, "010b")[10 - N:]
  m = 0
  for k in range(M):
    if sum([int(ss[i-1]) for i in Lumps[k]]) % 2 == p[k]:
      m += 1
    else:
      break
  if m == M:
    ans += 1
  s += 1
print(ans)

Measured memory_bytes: 42992
from itertools import combinations

N = int(input())

candidates = {c:0 for c in "MARCH"}
combination = combinations("MARCH", 3)

for c in tuple(input()[0] for _ in range(N)):
    if c in "MARCH":
        candidates[c] += 1

print(0 if sum(candidates.values()) < 3 else sum(candidates[a] * candidates[b] * candidates[c] for a, b, c in combination))


Measured memory_bytes: 4004
import math


def deviation(data: list):
    ave = sum(data) / len(data)
    return math.sqrt(sum([(d - ave) ** 2 for d in data]) / n)


while True:
    n = int(input())
    if n == 0:
        break
    data =  [int(i) for i in input().strip().split()]
    print(deviation(data))


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


public class Contest
{
	public static void Main()
	{

/*
		int n = a[0];
		int[][] e = new int[n][];
		for(int i=0; i<n; i++) MyIO.ReadArray(out e[i]);

		int[] a;
		MyIO.ReadArray(out a);

        long a,b,c,d,e,f;
        MyIO.ReadMulti(out a, out b, out c, out d, out e, out f);

		MyIO.WriteArray(ans);
*/

        int k,s;
		MyIO.ReadMulti(out k, out s);


		int ans = 0;
		for(int i=0; i<=k;i++){
			for(int j=0; j<=k;j++){
				int z = s-i-j;
				if(z<0) break; 
				if(z<=k)ans++;
			}
		}

		Console.WriteLine(ans);
	}


}

public static class MyIO
{
	private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
	private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
	private static T cv<T>(string s) => eq<T, int>()    ? ct<T, int>(int.Parse(s))
	                                  : eq<T, long>()   ? ct<T, long>(long.Parse(s))
	                                  : eq<T, double>() ? ct<T, double>(double.Parse(s))
	                                  : eq<T, char>()   ? ct<T, char>(s[0])
	                                                    : ct<T, string>(s);
	public static string[] ReadArray<T>(out T[] a) {		
		var ar = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); 												
		a = System.Array.ConvertAll(ar, new Converter<string,T>(cv<T>));
		return ar;
	}										
	public static string[] ReadMulti<T>(out T a) {
		var ar = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); 
		a = cv<T>(ar[0]);
		return ar;
	}
	public static string[] ReadMulti<T, U>(out T a, out U b) {
		var ar = ReadMulti<T>(out a); 
        b = cv<U>(ar[1]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
		var ar = ReadMulti<T, U>(out a, out b); 
        c = cv<V>(ar[2]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c, out W d) {
		var ar = ReadMulti<T, U, V>(out a, out b, out c); 
        d = cv<W>(ar[3]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
		var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d); 
        e = cv<X>(ar[4]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) {
		var ar = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e); 
        f = cv<Y>(ar[5]);
		return ar;
	}

	public static void WriteArray<T>(T[] a) {
		Console.WriteLine(string.Join(" ", Array.ConvertAll(a, x => x.ToString())));
	}


}




Measured memory_bytes: 13140