akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int solve(){
  int a,b;
  cin >> a >> b;
  string aa = "",bb = "";
  rep(i,b)aa += to_string(a);
  rep(i,a)bb += to_string(b);
  if(aa > bb)cout << bb << endl;
  else cout << aa << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Measured memory_bytes: 256
#!/usr/bin/env python3
import collections as cl
import sys

import math


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, x, t = MI()

    print(math.ceil(n / x) * t)


main()


Measured memory_bytes: 65060
n = int(input())
a = [[0]+list(map(int,input().split())) for _ in range(2)]
for i in range(n):
    a[0][i+1] += a[0][i]
for i in range(n,0,-1):
    a[1][i-1] += a[1][i]
ans = 0
for i in range(1,n+1):
    ans = max(ans, a[0][i]+a[1][i])
print(ans)

Measured memory_bytes: 9096
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1LL<<60)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



int n;
pair<int, int> p[5000];

long long dp[5001][5001];

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

	cin>>n;
	rep(i, n)cin >> p[i].first >> p[i].second;

	sort(p, p + n, [](const pair<int,int> &a,const pair<int,int> &b){
	return a.first+a.second < b.first+b.second; });

	rep(i,n+1)rep(j,n+1){
		dp[i][j] = INF;
	}
	dp[0][0] = 0;
	rep(i,n)rep(j,n+1)if(dp[i][j]!=INF){
		dp[i + 1][j] = min(dp[i+1][j], dp[i][j]);
		if (dp[i][j] <= p[i].first)
			dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + p[i].second);
	}
	int ans=0;
	rep(j, n + 1)if (dp[n][j]!=INF)ans=j;

	cout << ans <<endl;


	return 0;
}

Measured memory_bytes: 195712
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int a;
    cin >> a;
    int h = 0;
    int m = 0;
    while(a >= 60) {
        a -= 60;
        m++;
    }
    while(m >= 60) {
        m -= 60;
        h++;
    }
    cout << h << ":" << m << ":" << a << endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    ll N, K;
    cin >> N >> K;
    vector<pair<ll, ll>> ab(N);
    cin >> ab;

    SORT(ab);
    ll k = 0;
    REP(i, N) {
        k += ab[i].second;
        if (k >= K) {
            cout << ab[i].first << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

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

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();
    
    int n, a, b;
    cin >> n >> a >> b;
    
    cout << min(n * a, b);
    
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static BufferedReader reader;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		String[] strings = readLine();
		int N = Integer.parseInt(strings[0]);
		int A = Integer.parseInt(strings[1]);
		int B = Integer.parseInt(strings[2]);
		if(N*A>B) {print(B);}
		else {print(A*N);}
		//String[] s = readLine();
		//print(num);
	}
	
	//functions here
	//note that all methods should be STATIC

	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n;
  int ocupant[4*3*10] = {};
  cin >> n;
  
  int b,f,r,v;
  for(int i=0;i<n;i++){
      cin >> b >> f >> r >> v;
      b -= 1;
      f -= 1;
      r -= 1;
      ocupant[b*30 + f*10 + r] += v;
  }
  
  for(int i=0;i<4;i++){
      for(int j=0;j<3;j++){
          for(int k=0;k<10;k++){
              cout << " " << ocupant[i*30 + j*10 + k];
          }
          cout << endl;
      }
      if(i!=3) cout << "####################" << endl;
  }

  
  return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;

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

        int n = scanner.nextInt();
        int ans = 0;

        for (int i = 0; i < n; i++) {
            int minNum = scanner.nextInt();
            int maxNum = scanner.nextInt();

            ans += maxNum - minNum + 1;

        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 28396
/**
 *    author:  tourist
 *    created: 22.12.2019 03:30:55       
**/
#include <bits/stdc++.h>

using namespace std;

template <typename T>
class fenwick {
 public:
  vector<T> fenw;
  int n;

  fenwick(int _n) : n(_n) {
    fenw.resize(n);
  }

  void modify(int x, T v) {
    while (x < n) {
      fenw[x] += v;
      x |= (x + 1);
    }
  }

  T get(int x) {
    T v{};
    while (x >= 0) {
      v += fenw[x];
      x = (x & (x + 1)) - 1;
    }
    return v;
  }
};

struct node {
  long long x = 0;

  inline void operator += (node &other) {
    x = max(x, other.x);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    --h[i];
  }
  long long ans = 0;
  fenwick<node> fenw(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    long long dp = fenw.get(h[i] - 1).x + a;
    ans = max(ans, dp);
    fenw.modify(h[i], {dp});
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, m;
  cin >> n >> m;
  cout << abs((m-2)*(n-2)) << newl;
  return 0;
}


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

#define F first
#define S second
#define pb push_back
#define ll long long
#define int long long

using namespace std ;

const int MAXN = 1001 * 1001 ; 

vector<int> adj[MAXN] , val ; 

bool mark[MAXN] ; 

int col[MAXN] ; 

int f = 0 , cnt = 0 ;

void dfs(int u)
{
	cnt ++ ; 
	for(auto v : adj[u])
	{
		int C = 1 - col[u] ; 
		if(mark[v])
		{
			if(col[v]!=C)
				f = 1 ;
			continue ; 
		}
		mark[v] = 1 ; 
		col[v] = C ;
		dfs(v) ; 
	}
}

int32_t main()
{
	ios::sync_with_stdio(0) ; cin.tie(0) ; 
	int n , m ; 
	cin >> n >> m ;
    int n1 = 0 , n2 = 0 , n3 = 0 ; 
	for(int i = 0 ; i < m ; i ++ ) 
	{
		int x , y ;
		cin >> x >> y ;
		adj[x].pb(y) ; 
		adj[y].pb(x) ; 
	}	
	for(int i = 1 ; i <= n ; i ++ )
	{
		if(!mark[i])
		{
			f = 0 ;
			cnt = 0 ;
			dfs(i) ; 
			if(cnt == 1 ) n1 ++ ;
			else if(!f) n2 ++ ; 
			else n3 ++ ; 
		}
	}
	int ans = n1 * n + (n-n1) * n1 ; 
	ans += n3 * n3 ; 
	ans += n3 * n2 ;
	ans += n3 * n2 ; 
	ans += n2 * 2 * n2 ; 
    cout << ans << '\n' ; 	
}

Measured memory_bytes: 36224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n;
ll a[maxx];
ll dd[maxx];
ll ans;

int main() {
	scanf("%d", &n);
	int tot = 0;
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		dd[i] = abs(a[i]);
		ans += dd[i];
		if(a[i] < 0) tot++;
	}
	sort(dd + 1, dd + n + 1);
	if(tot & 1) ans -= dd[1] * 2;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
	}
	int k=0,res=0;
	vi used(n);
	while(1){
		if(k==1) break;
		if(used[k]){
			res=-1;
			break;
		}
		used[k]=1;
		k=a[k];
		res++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Arrays;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    if(a % 2 == 0){
      System.out.println(a);
    }else{
      System.out.println(a*2);
    }
    
  }
}

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

using namespace std;

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

    int h[N], dp[N];

    for(int i=0;i<N;i++)
    {
        cin >> h[i];
    }
    dp[N-1]=0;
    dp[N-2]=abs(h[N-1]-h[N-2]);

    for(int i=N-3;i>=0;i--)
    {
        dp[i]=min(dp[i+1]+abs(h[i+1]-h[i]), dp[i+2]+abs(h[i+2]-h[i]));
    }
    cout << dp[0];
}


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

struct Node {
    int key;
    struct Node *prev;
    struct Node *next;
};

typedef struct Node Node;

Node *nil;

void init(void) {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node* listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst(void) {
    deleteNode(nil->next);
}

void deleteLast(void) {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void printList(void) {
    Node *cur = nil->next;
    while (cur != nil) {
        printf("%d", cur->key);
        if (cur->next != nil) {
            printf(" ");
        }
        cur = cur->next;
    }
    printf("\n");
}

int main(void) {
    int n, i, x;
    char s[20];
    init();
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf(" %s", s);
        if (s[0] == 'i') {
            scanf("%d", &x);
            insert(x);
        } else if (s[0] == 'd') {
            if (strlen(s) > 6) {
                if (s[6] == 'F') {
                    deleteFirst();
                } else if (s[6] == 'L') {
                    deleteLast();
                }
            } else {
                scanf("%d", &x);
                deleteKey(x);
            }
        }
    }
    printList();
    return 0;
}



Measured memory_bytes: 32968
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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; }

int n, m;
vi to[45];
int ans = 0;
bool vis[10];

void dfs(int v, int cnt=0, int p=-1) {
  if (cnt == n-1) {
    ans++;
    return;
  }

  vis[v] = true;
  for (int u : to[v]) {
    if (vis[u]) continue;
    dfs(u,cnt+1,v);
  }
  vis[v] = false;
  return;
}

int main () {
  cin >> n >> m;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    to[a].pb(b);
    to[b].pb(a);
  }
  dfs(0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll n;
    cin>>n;
    ll a[4]={0};
    rep(0,i,n){
        string s;
        cin>>s;
        if(s=="AC"){
            ++a[0];
        }else if(s=="WA"){
            ++a[1];
        }else if(s=="TLE"){
            ++a[2];
        }else{
            ++a[3];
        }
    }
    cout<<"AC x "<<a[0]<<endl;
    cout<<"WA x "<<a[1]<<endl;
    cout<<"TLE x "<<a[2]<<endl;
    cout<<"RE x "<<a[3]<<endl;
}

Measured memory_bytes: 3632
import scala.io.StdIn._
object Main extends App {

  val Array(n, m) = readLine().split(" ").map(_.toInt)
  val switchesOfLight: Seq[Array[Int]] = Seq.fill(m)(readLine().split(" ").drop(1).map(_.toInt - 1))
  val conds: Array[Int] = readLine().split(" ").map(_.toInt)
  
  val condAndSwitchesSeq: Array[(Int, Array[Int])] = conds zip switchesOfLight

  def solve() = {
    (0 until (1 << n)).count { i =>
      val onLightCount = condAndSwitchesSeq.count { case (cond, switches) =>
        val onSwitchCount = switches.count(isOn(i, _))
        onSwitchCount % 2 == cond
      }
      onLightCount == m
    }
  }

  def isOn(combi: Long, switch: Int) =
    (combi & (1 << switch)) != 0

  println(solve)

}

Measured memory_bytes: 27804
#include<iostream>
#include<set>
using namespace std;
int cnt[100001] = {0};
set<int> s;
set<int>::iterator it;
int main()
{
    int n, temp, sum = 0;
    scanf("%d", &n);
    while(n--)
    {
        scanf("%d", &temp);
        cnt[temp]++;
        s.insert(temp);
    }
    for(it = s.begin(); it != s.end(); it++)
    {
        sum += cnt[*it] * (*it - 1);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int main(){
	int ta[10000]={0},n;
	cin>>n;
		int ans=0,ansi=10000;
	for(int i=0;i<n;i++){
	int a,b;
	cin>>a>>b;
	if(ans<b)ans=b,ansi=a;
	if(ans==b)ansi=min(ansi,a);
	}


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

Measured memory_bytes: 1168
class union_find:
    def __init__(self, N):
        # par < 0 の時はsizeを格納
        self.par = [-1 for i in range(N)]
        self.excluded = [0 for i in range(N)]
    
    def root(self, a):
        if self.par[a] < 0:
            return a
        else:
            # 経路圧縮
            self.par[a] = self.root(self.par[a])
            return self.par[a]
    
    def unite(self, a, b):
        ar = self.root(a)
        br = self.root(b)
        if ar == br:
            return
        if self.par[ar] > self.par[br]:
            ar, br = br, ar
        self.par[ar] += self.par[br]
        self.par[br] = ar
    
    def friend(self, a, b):
        self.unite(a, b)
        self.excluded[a] += 1
        self.excluded[b] += 1
    
    def block(self, a, b):
        ar = self.root(a)
        br = self.root(b)
        if ar != br:
            return
        self.excluded[a] += 1
        self.excluded[b] += 1
    
    def get_friend_sugestion_size(self, a):
        return -self.par[self.root(a)] - 1 - self.excluded[a]

N, M, K = map(int, input().split())
UF = union_find(N)
for i in range(M):
    A, B = map(int, input().split())
    UF.friend(A-1, B-1)
for i in range(K):
    A, B = map(int, input().split())
    UF.block(A-1, B-1)
print(*[UF.get_friend_sugestion_size(x) for x in range(N)])

Measured memory_bytes: 13420
#include<bits/stdc++.h>
using namespace std;
int main(){
    int c,n;
    cin>>c>>n;
    int m[1000][1000];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            char c;
            cin>>c;m[i][j]=(c=='0'?0:1);
        }
    }
    set<int> s;
    for(int i=0;i<(n+1)/2;i++){
        for(int j=0;j<(n+1)/2;j++){
            if(m[i][j]!=m[n-1-i][j]||m[i][j]!=m[n-1-i][n-1-j]||m[i][j]!=m[i][n-1-j]){
                s.insert(i*n+j);
            }
        }
    }
    int ans=0;
    if(s.empty()){
        ans++;
    }
    c--;
    while(c--){
        int d;
        cin>>d;
        set<int> e;
        for(int i=0;i<d;i++){
            int r,c;
            cin>>r>>c;
            r--;c--;
            m[r][c]^=1;
            e.insert(min(r,n-1-r)*n+min(c,n-1-c));
        }
        for(set<int>::iterator i=e.begin();i!=e.end();i++){
            int h=*i;
            int x=h/n,y=h%n;
            if(m[x][y]==m[x][n-1-y]&&m[x][y]==m[n-1-x][y]&&m[x][y]==m[n-1-x][n-1-y]){
                s.erase(h);
            }else{
                s.insert(h);
            }
        }
        if(s.empty()){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
  ll s;cin >>s;
  string n[10];
  n[0]=n[1]=n[6]=n[8]="pon";
  n[3]="bon";
  n[2]=n[4]=n[5]=n[7]=n[9]="hon";
  cout <<n[s%10]<<endl;
  return 0;
}



Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;


int c[3][3];


int main(){
    Rep(i,3) Rep(j,3) cin>>c[i][j];
    rep(i,2) Rep(j,3){
        c[i][j]-=c[0][j];
    }
    if(c[1][0]==c[1][1]&&c[1][0]==c[1][2]&&c[2][0]==c[2][1]&&c[2][0]==c[2][2]){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline

    x,y = map(int,input().split())
    a_old = 2 * y - x
    b_old = 2 * x - y

    def cmb(n, r):
        if n - r < r: r = n - r
        if r == 0: return 1
        if r == 1: return n

        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]

        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot

        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])

        return result

    if (a_old % 3 == 0) and (b_old % 3 == 0) and (a_old >= 0) and (b_old >= 0):
        a_new = int(a_old // 3)
        b_new = int(b_old // 3)
        n = a_new + b_new
        r = cmb(n,a_new)
        print(int(r % (10**9 + 7)))
    else:
        print(0)

if __name__ == "__main__":
    main()

Measured memory_bytes: 102028
/*
    なせば大抵なんとかなる！
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a>=c ; a--)
#define UPC(oo) (a>='A' && a<='Z')
#define LWC(oo) (a>='a' && a<='z')

inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void sctlld(LL &a,LL &b,LL &c){scanf("%I64d %I64d %I64d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}

inline void prd(int a){printf("%d",a);};
inline void prdd(int a,int b){printf("%d %d",a,b);};
inline void prtd(int a, int b, int c){printf("%d %d %d",a,b,c);};
inline void prtlld(LL a, LL b, LL c){printf("%I64d %I64d %I64d",a,b,c);};
inline void prdlld(LL a, LL b){printf("%I64d %I64d",a,b);};
inline void prtlld(LL a){printf("%I64d",a);};

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	char a[200000],b[200000];
	scanf("%s %s",a,b);
	int len=strlen(a);
	int lenb=strlen(b);
	if(len<lenb)
	{
		printf("LESS\n");
		return 0;
	}
	else if(len>lenb)
	{
		printf("GREATER\n");
		return 0;
	}
	
	for(int i=0 ; i<len ; i++)
	{
		if(a[i]>b[i])
		{
			printf("GREATER");
			return 0;
		}
		else if(a[i]<b[i])
		{
			printf("LESS");
			return 0;
		}
	}
	printf("EQUAL\n");
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    String a = sc.next();
    String b = sc.next();
    String c = sc.next();

    if(a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)){
        System.out.println("YES");
    }else{
        System.out.println("NO");
    }



    


    








    

    
    

    


    
    


    


    
    


    
	}
}

Measured memory_bytes: 35652
X,N = map(int,input().split())
p = list(map(int,input().split()))
xp = X
xm = X
for i in range(101):
  if (xp not in p) and (xm not in p):
    print(min(xp,xm))
    break
  if xp not in p:
    print(xp)
    break
  if xm not in p:
    print(xm)
    break
  xp += 1
  xm -= 1

Measured memory_bytes: 9196
#include<iostream>
#include<vector>
using namespace std;
int func( int n){
  int ans = 1;
  for (int i = 1; i <= n;i++){
    ans *= i;
  }
  return ans;
}
int main(){
  int n;
  cin >> n;
  vector<int> p(n), q(n), r1(n+1), r2(n+1);
  int ans = 0, a = 0, b = 0;
  for (int i = 0; i < n;i++){
    r1[i] = i + 1;
    r2[i] = i + 1;
  }

  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
    int tmp = 0;

    for (int j = 0; j < n; j++){
        if(r1[j] == p[i]){
          r1[j] = 0;
          break;
        }
      if(r1[j] != p[i] && r1[j] != 0){
        tmp++;
      }
    }
    //cout << tmp << endl;
    a += tmp * func(n - i - 1);
    //cout << a << endl;
  }
  for (int i = 0; i < n; i++){
    cin >> q[i];
    int tmp = 0;

    for (int j = 0; j <= n; j++)
    {
      if(r2[j] == q[i]){
        r2[j] = 0;
        break;
      }
      if (r2[j] != q[i] && r2[j] != 0)
      {
        tmp++;
      }
    }
    b += tmp * func(n - i - 1);
  }
  if(a>b){
    ans = a - b;
  }else{
    ans = b - a;
  }
  // cout << a << endl
      //  << b << endl;
  cout << ans << endl;
}

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	cout << "Christmas";
	for (int i = n; i < 25; i++)
		cout << " Eve";
	cout << '\n';	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  ll n; cin >> n;
  vi a(100000, 0);
  ll s = 0;
  for(int i = 0; i < n; i++){
    int t; cin >> t;
    a[t-1]++;
    s += t;
  }
  int q; cin >> q;
  for(int i = 0; i < q; i++){
    int b, c; cin >> b >> c;
    s += (c - b) * a[b-1];
    a[c-1] += a[b-1];
    a[b-1] = 0;
    cout << s << endl;
  }

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	LL X;
	cin >> X;
	LL ans=0;
	ans+=X/500*1000;
	X%=500;
	ans+=X/5*5;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//                     بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
//                   لآ اِلَهَ اِلّا اللّهُ مُحَمَّدٌ رَسُوُل اللّهِ

#include <bits/stdc++.h>

using namespace std;
#define endl "\n"

const int MOD = 1000000007;
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	
	int n,a = 0, b = 0, c= 0, d = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		string x;
		cin >> x;
		if(x == "AC") a++;
		else if(x == "WA") b++;
		else if(x == "TLE") c++;
		else if(x == "RE") d++;
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << b << endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;
	
	return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

//-----CODE------//

//-----CODE------//
class DisjointSet{
  public:
  vector<int> rank,p;
  DisjointSet(){}
  DisjointSet(int size)
  {
    rank.resize(size,0);
    p.resize(size,0);
    for (int i = 0; i < size; i++)
    {
      makeSet(i);
    }
  }
void makeSet(int x)
{
  p[x] = x;
  rank[x] = 0;
}

bool same(int x, int y)
{
  return findSet(x) == findSet(y);
}

void unite(int x, int y)
{
  link(findSet(x),findSet(y));
}
void link(int x, int y)
{
  if(rank[x] > rank[y])
  {
    p[y] = p[x];
  }
  else
  {
    p[x] = p[y];
  }
  if(rank[x] == rank[y])
  {
    rank[y]++;
  }
}
  int findSet(int x)
  {
    if(x != p[x])
    {
      p[x] = findSet(p[x]);
    }
    return p[x];
  }
};


void solve(void)
{ 

  int N,M;
  cin>>N>>M;
  map<int,int> mp;
  for (int i = 0; i < N; i++)
  {
    int X;cin>>X;
    X--;
     mp[X] = i;
  }
  DisjointSet ds(2*N);
  for (int i = 0; i < M; i++)
  {
    int X,Y;
    cin>>X>>Y;
    X--;Y--;
    ds.unite(X,Y);
  }
  int cnt = 0;
  for (int i = 0; i < N; i++)
  {
    if(ds.same(i,mp[i]))cnt++;
  }
  cout<<cnt<<endl;;
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 9600
#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
using namespace std;

void koch(pair<double,double> left,
          pair<double,double> right, int n){
  if(n==0){
    std::cout << left.first << ' ' << left.second << '\n';
    return;
  }

  double x1, y1, x2, y2, x3, y3;
  x1 = left.first*2/3 + right.first*1/3;
  y1 = left.second*2/3 + right.second*1/3;
  pair<double,double> s = make_pair(x1, y1);

  x2 = left.first*1/3 + right.first*2/3;
  y2 = left.second*1/3 + right.second*2/3;
  pair<double,double> t = make_pair(x2, y2);

  double theta = atan2((y2-y1),(x2-x1));
  theta += M_PI/3;
  double r = sqrt((y2-y1)*(y2-y1) + (x2-x1)*(x2-x1));
  x3 = r*cos(theta) + x1;
  y3 = r*sin(theta) + y1;
  pair<double,double> u = make_pair(x3, y3);

  koch(left, s, n-1);
  koch(s, u, n-1);
  koch(u, t, n-1);
  koch(t, right, n-1);
}


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

  pair<double,double> left = make_pair(0,0);
  pair<double,double> right = make_pair(100,0);

  koch(left, right, n);
  std::cout << right.first << ' ' << right.second << '\n';

  return 0;
}



Measured memory_bytes: 3748
#include <iostream>

using namespace std;

int n;
int predt, predx, predy;
int tempt, tempx, tempy;

int main()
{
	cin >> n;
	int aux;
	for (int i = 1;i <= n;++i)
	{
		cin >> tempt >> tempx >> tempy;
		aux = abs(tempx - predx) + abs(tempy - predy);
		if (aux % 2 != (tempt - predt) % 2 || aux > (tempt - predt))
		{
			cout << "No\n";
			return 0;
		}
		predt = tempt;
		predx = tempx;
		predy = tempy;
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main(){
    //cout.precision(10);
    cin.tie(0);//cin高速化
    string s;
    cin >> s;
    int q = s.size()-1;
    if (s[q] == 's') s += "es";
    else s += "s";
    cout << s << endl;
}

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

int main() {
    int n, q, tmp, count = 0;
    set<int> S;
    cin >> n;
    while (n--) {
        cin >> tmp;
        S.insert(tmp);
    }
    cin >> q;
    while (q--) {
        cin >> tmp;
        count += S.count(tmp);
    }
    cout << count << endl;
    return 0;
}

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

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

int minPrimeFactor[1000001];
bool isPrime[1000001];
bool isExist[1000001];
int a[1000000];

int main() {
  rep(i, 1000001) { isPrime[i] = true; isExist[i] = false; }
  int n;
  cin >> n;
  rep(i, n) {
    cin >> a[i];
  }

  int ans = 0;

  /* preprocess */
  for (int i = 2; i <= 1000000; i++) {
    if (isPrime[i]) {
      for (int j = i; j <= 1000000; j += i) {
        if (isPrime[j]) {
          minPrimeFactor[j] = i;
          isPrime[j] = false;
        }
      }
    }
  }
  minPrimeFactor[1] = 1;

  rep(i, n) {
    vector<int> factors;
    factors.push_back(minPrimeFactor[a[i]]);
    int next = a[i] / minPrimeFactor[a[i]];
    while (next != 1) {
      //cout << "next " << next << endl;
      int factor = minPrimeFactor[next];
      if (factor != factors[factors.size() - 1]) {
        factors.push_back(factor);
      }
      next = next / factor;
    }
    rep(j, factors.size()) {
      if (isExist[factors[j]] && factors[j] != 1) ans = 1;
      else isExist[factors[j]] = true;
    }
  }

  if (ans == 0) {
    cout << "pairwise coprime" << endl;
    return 0;
  }

  int g = a[0];
  rep(i, n - 1) {
    g = gcd(a[i + 1], g);
  }
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }

  cout << "not coprime" << endl;

  return 0;
}
/*
*/


Measured memory_bytes: 13372
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int k,x; cin >> k >> x;
    if (500*k>=x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
// 木の巡回
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 30
const int NIL = -1;

typedef struct node
{
    // 節点の親
    int parent;
    // 節点の左の子
    int left;
    // 節点の右の子
    int right;
}Node;

// グローバル変数の定義
Node Tree[MAX_N];
int treeWalk[MAX_N];
int n, elementNum;

void print(int num);
void preorderTreeWalk(int ele_num);
void inorderTreeWalk(int ele_num);
void postorderTreeWalk(int ele_num);

int main(void)
{

    int i, node, left, right, root;

    cin >> n;

    for( i = 0; i < n; i++)
    {
        // 全要素の初期化
        Tree[i].parent = NIL;
        Tree[i].left = NIL;
        Tree[i].right = NIL;
    }

    for( i = 0; i < n; i++ )
    {
        cin >> node >> left >> right;

        // 左の子を設定する
        Tree[node].left = left;
        // 右の子を設定する
        Tree[node].right = right;

        // 親の情報を設定
        if( left != NIL )
        {
            Tree[left].parent = node;
        }

        if( right != NIL )
        {
            Tree[right].parent = node;
        }
    }

    for( i = 0; i < n; i++ )
    {
        if( Tree[i].parent == NIL )
        {
            // ルートの要素を検索する
            // [ 親 = NIL ] のものが, rootとなる
            root = i;
        }
    }

    elementNum = 0;
    preorderTreeWalk(root);
    print(1);

    elementNum = 0;
    inorderTreeWalk(root);
    print(2);

    elementNum = 0;
    postorderTreeWalk(root);
    print(3);

    return 0;
}

// 結果の表示用
void print(int num)
{
    switch(num)
    {
        case 1:
            printf("Preorder\n");
        break;

        case 2:
            printf("Inorder\n");
        break;

        case 3:
            printf("Postorder\n");
        break;
    }

    for(int i = 0; i < n; i++)
    {
    	printf(" ");

        printf("%d", treeWalk[i]);
    }

    printf("\n");
}

// 根節点、左部分木、右部分木の順で節点を巡回
void preorderTreeWalk(int ele_num)
{
    if( ele_num == NIL)
    {
    	return;
    }

    treeWalk[elementNum++] = ele_num;
    preorderTreeWalk(Tree[ele_num].left);
    preorderTreeWalk(Tree[ele_num].right);

    return;
}

int pre_right = 0;

// 左部分木、根節点、右部分木の順で節点を巡回
void inorderTreeWalk(int ele_num)
{

    if( ele_num == NIL)
    {
    	return;
    }

    inorderTreeWalk(Tree[ele_num].left);
    treeWalk[elementNum++] = ele_num;
    inorderTreeWalk(Tree[ele_num].right);

    return;
}

// 左部分木、右部分木、根節点の順で節点を巡回
void postorderTreeWalk(int ele_num)
{

    if( ele_num == NIL)
    {
    	return;
    }

    postorderTreeWalk(Tree[ele_num].left);
    postorderTreeWalk(Tree[ele_num].right);
    treeWalk[elementNum++] = ele_num;

    return;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
 
int H,W;
 
int used[111][111];
 
int dx[]={0,0,-1,-1};
int dy[]={0,-1,0,-1};
 
typedef long long ll;
 
bool check(int x,int y){
  if( x < 1 || y < 1 ) return true;
  vector<int> p;
  for(int i=0;i<4;i++)
    p.push_back( used[x+dx[i]][y+dy[i]] );
  sort(p.begin(),p.end());
  p.erase(unique(p.begin(),p.end()),p.end());
 
  if( p.size() == 4 ) return false;
  return true;
}
 
void view(){
  cout << "view" << endl;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout << used[j][i] << " ";
    }
    cout << endl;
  }
}
 
ll dfs(int x,int y,int cnt){
 
  if( x >= W ) return dfs(0,y+1,cnt);
  //  view();
  if( y >= H ){
    return 1LL;
  }
  ll res = 0;
 
  if( used[x][y] == -1 ){
    if( x + 1 < W && used[x+1][y] == -1 ){
      used[x][y] = cnt;
      used[x+1][y] = cnt;
      if( check( x, y ) ){
    res += dfs(x+1,y,cnt+1);
      }
      used[x][y] = -1;
      used[x+1][y] = -1;
    }
    if( y + 1 < H && used[x][y+1] == -1 ){
      used[x][y] = cnt;
      used[x][y+1] = cnt;
      if( check( x, y ) ){
    res += dfs(x+1,y,cnt+1);
      }
      used[x][y] = -1;
      used[x][y+1] = -1;
    }
  } else if( check(x,y) )
      return dfs(x+1,y,cnt);
   
  return res;
}
 
int main(){
  while( cin >> H >> W &&(W||H) ){
    memset(used,-1,sizeof(used));
    cout << dfs(0,0,0) << endl;
  }
}

Measured memory_bytes: 1276
# -*- coding:utf-8 -*-
import itertools

def solve():
    N, M = list(map(int, input().split()))
    Ks, Ss = [], []
    for i in range(M):
        _in = list(map(int, input().split()))
        Ks.append(_in[0])
        Ss.append(_in[1:])
    Ps = list(map(int, input().split()))

    # 全探索でいける
    switches = itertools.product([0,1], repeat=N)
    ans = 0
    for switch in switches:
        is_ok = True
        for i in range(M):
            on_num = 0
            for s in Ss[i]:
                if switch[s-1] == 1:
                    on_num += 1
            if on_num%2 != Ps[i]:
                is_ok = False
                break
        
        if is_ok:
            ans += 1

    print(ans)
    



if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
N = int(input())
counter = 0
list = ['3','5','7']
ok = []
for a in list:
    for b in list:
        for c in list:
            ok.append(a+b+c)
            for d in list:
                ok.append(a+b+c+d)
                for e in list:
                    ok.append(a+b+c+d+e)
                    for f in list:
                        ok.append(a+b+c+d+e+f)
                        for g in list:
                            ok.append(a+b+c+d+e+f+g)
                            for h in list:
                                ok.append(a+b+c+d+e+f+g+h)
                                for i in list:
                                    ok.append(a+b+c+d+e+f+g+h+i)
                                    for j in list:
                                        ok.append(a+b+c+d+e+f+g+h+i+j)

okk = []
for _ in ok:
    x3 = _.count('3')
    x5 = _.count('5')
    x7 = _.count('7')
    if x3>0 and x5>0 and x7>0:
        okk.append(_)
fin = [int(_) for _ in okk]
fin.sort()
for _ in fin:
    if _ > N:
        print(fin.index(_))
        break


Measured memory_bytes: 13360
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[][] fs = new int[N][10];
        int[][] ps = new int[N][11];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 10; j++) {
                fs[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 11; j++) {
                ps[i][j] = sc.nextInt();
            }
        }

        int ans = Integer.MIN_VALUE;
        for (int mask = 1; mask < 1 << 10; mask++) {
            int[] count = new int[N];
            for (int i = 0; i < 10; i++) {
                if (((mask >> i) & 1) == 1) {
                    for (int j = 0; j < N; j++) {
                        if (fs[j][i] == 1) {
                            count[j] = count[j] + 1;
                        }
                    }
                }
            }
            int total = 0;
            for (int i = 0; i < N; i++) {
                total += ps[i][count[i]];
            }
            ans = Math.max(total, ans);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 28160