akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

vector<int> edges[200000];
vector<int> d(100100, -1);
vector<bool> f(100100, false);
deque<int> de;

void bfs(int i) {
    de.pop_front();
    f.at(i) = true;
    for(int j : edges[i]){
        if(!f[j]){
            d.at(j) = i;
            de.push_back(j);
            f.at(j) = true;
        }
    }
    if(!de.empty()) {
        bfs(de.front());
    }
}

int main(){
    ll n, m;
    cin >> n >> m;
    ll a, b;
    rep(i, m){
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }
    de.push_back(0);
    bfs(0);
    bool flag = true;
    REP(i, n){
        if(!f[i]){
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "Yes" << endl;
        REP(i, n) {
            cout << d.at(i)+1 << endl;
        }
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 12584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
    // clang-format on

#include <utility>
using P = pair<int, int>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    while (cin >> h >> w, h + w) {
        P pos[128];
        REP(i, 0, h) {
            string s;
            cin >> s;
            REP(j, 0, s.size()) {
                pos[s[j]] = make_pair(i, j);
            }
        }
        string s;
        cin >> s;
        P p(0, 0);
        int ans = 0;
        for (auto c : s) {
            ans += abs(p.first - pos[c].first) + abs(p.second - pos[c].second) + 1;
            p = pos[c];
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	--a, --b, --c, --d;
	string s; cin >> s;
	bool ok = true;
	int left = min(a, b), right = max(c, d);
	rep(i, left, right - 1)
	{
		if (s[i] == '#'&&s[i + 1] == '#')ok = false;
	}
	if (!ok)
	{
		cout << "No" << endl;
		return 0;
	}

	if (c < d) cout << "Yes" << endl;
	else
	{
		ok = false;
		rep(i, b, d)
		{
			if (s[i - 1] == '.'&&s[i] == '.'&&s[i + 1] == '.')ok = true;
		}
		if (ok)cout << "Yes" << endl;
		else cout << "No" << endl;
	}	
}

Measured memory_bytes: 640
N,X=map(int,input().split())
PILE=[2**(i+2)-3 for i in range(51)]
def dp(n,x):#レベルnバーガーのx層目まで
   if x==0:
       return 0
   if n==0 and x==1:
       return 1
   if n>=1:
       bp=PILE[n-1]
       if x==1:
           return 0
       elif x<=1+bp:
           return dp(n-1,x-1)
       elif x==2+bp:
           return 1+dp(n-1,bp)
       elif 2+bp<x<=2+2*bp:
           return 1+dp(n-1,bp)+dp(n-1,x-2-bp)
       elif x==3+2*bp:
           return 1+dp(n-1,bp)*2

print(dp(N,X))

Measured memory_bytes: 3064
import array
import itertools
from collections import defaultdict, deque


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return map(int, input().split())


def solve():
    num_nodes, num_edges = tuple(input_ints())

    edges = [tuple(input_ints()) for _ in range(num_edges)]

    navigatility = defaultdict(lambda: [])

    for e in edges:
        navigatility[e[0]].append(e[1])
        navigatility[e[1]].append(e[0])

    queue = deque()
    queue.append([1])
    result = []

    while queue:
        path = queue.popleft()

        if len(path) == num_nodes:
            result.append(path)
        else:
            n = path[-1]

            for m in navigatility[n]:
                if m not in path:
                    queue.append(path + [m])

    return result


def main():
    print(len(solve()))


main()


Measured memory_bytes: 4084
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc[1000][1000],cd[1000][1000];
vector<ll> va,vb,vc;

int main(){
    cin>>n>>m;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>cc[i][j];
        }
    }
    
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            cin>>cd[i][j];
        }
    }
    
    for(int i=0;i<=n-m;i++){
        for(int j=0;j<=n-m;j++){
            r=true;
            for(int bi=0;bi<m;bi++){
                for(int bj=0;bj<m;bj++){
                    r=r and cc[bi+i][bj+j]==cd[bi][bj];
                }
            }
            if(r){
                C "Yes" E;
                return 0;
            }
            
        }
    }
    C "No" E;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define INF 1000000000
#define pb push_back
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define tr(c, i) for (typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())

long long mod = 1e9 + 7;

long long bigmod(long long a, long long p){
    if(p == 0){
        return 1;
    }
    long long ans = bigmod(a, p/2);
    ans = (ans * ans) % mod;
    if(p % 2 == 1){
        ans = (ans * a) % mod;
    }
    return ans;
}

int main(){
    ll n,k,i,j,ara[200005],x=0;
	cin>>n>>k;

    for(i=1;i<=k;i++){
        ara[i] = bigmod((k/i),n);
    }

   

    for(i=k;i>=1;i--){
        for(j=2;j*i<=k;j++){

            ara[i] = ara[i]-ara[j*i] + mod;
            ara[i] %= mod;

            
        }

    }

    for(i=1;i<=k;i++) x = (x+ara[i]*i)%mod;
    cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 4428
#include <stdio.h>

#define MIN(x, y) ((x) < (y) ? (x) : (y))
int main(){
  int n, x, y, b, p, min;
  scanf("%d", &n);
  while(n--){
    scanf("%d%d%d%d", &x, &y, &b, &p);
    min = x * b + y * p;
    if(b >= 5 && p >= 2) min = MIN(min, (x * b + y * p) * 0.8);
    else if(b >= 5) min = MIN(min, (x * b + y * 2) * 0.8);
    else if(p >= 2) min = MIN(min, (x * 5 + y * p) * 0.8);
    else min = MIN(min, (x * 5 + y * 2) * 0.8);
    printf("%d\n", min);
  }
  return 0;
}

Measured memory_bytes: 600
def gcd(a, b)
  a, b = b, a if a > b
  until a == 0
    a, b = b%a, a
  end
  return b
end

# 最小公倍数
def lcm(a, b)
  a*b/gcd(a, b)
end

while gets do
  a, b = $_.chomp.split(' ').map(&:to_i)
  puts "#{gcd(a, b)} #{lcm(a, b)}"
end


Measured memory_bytes: 6832
#include <stdio.h>

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


Measured memory_bytes: 256
n = int(input())

a = list(map(int, input().split()))

uoo = {}

cnt = 1
for i in a:
    uoo[i] = cnt

    cnt += 1


ans = ''

for j in range(1,n+1):
    if j == 1:
        ans += str(uoo[j])
    else:
        ans += ' '
        ans += str(uoo[j])

print(ans)
    



Measured memory_bytes: 20704
using System.Linq;
using System;


public class hello
{
    public static void Main()
    {

        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var ary = Enumerable.Repeat(0, n).ToArray();
            string[] line = Console.ReadLine().Trim().Split(' ');
            var m = int.Parse(line[1]);
            for (int j = 2; j < m+2; j++) ary[int.Parse(line[j]) - 1] = 1;
            for (int j = 0; j < n; j++)
            {
                Console.Write(ary[j]);
                if (j == n - 1) Console.WriteLine();
                else Console.Write(" ");
            }
        }
    }
}

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int d[N];
	int ans;
	for (int i = 0; i < N; i++)
	{
		cin >> d[i];
	}
	sort(d, d+N);
	if(N%2==1){
		ans = 0;
	}else{
		ans = d[N/2]-d[N/2-1];
	}
  	cout << ans << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	vector<vector<pair<int,int>>> saying;
	REP(i,n){
		cin >> a[i];
		vector<pair<int,int>> tmp;
		REP(j,a[i]){
			int x,y;
			cin >> x >> y;
			tmp.push_back({x-1, y}); // 0-based
		}
		saying.push_back(tmp);
	}
	
	int ans=0;
	for(int bit=0; bit<(1<<n); bit++){
		bool flag = true;
		
		REP(i,n){
			if(!(bit & (1<<i))) continue; 
			REP(j,a[i]){
				int x;
				if(bit&(1<<saying[i][j].first)) x=1;
				else x=0;
				
				if(x!=saying[i][j].second) flag = false;
			}
		}
		
		if(flag){
			chmax(ans,__builtin_popcount(bit));
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3652
from math import gcd
INF = float('inf')
N = int(input())
A = list(map(int,input().split()))
flg = True
lis = [0] * (10**6+5)
for i in A:
    lis[i] += 1

for i in range(2,10**6+1):
    cnt = 0
    for j in range(i,10**6+1,i):
        cnt += lis[j]
    if cnt > 1:
        flg = False

if flg == True:
    print('pairwise coprime')
    exit()



val = A[0]
for i in range(1,N):
    val = gcd(val,A[i])
if val == 1:
    print('setwise coprime')
    exit()
print('not coprime')

Measured memory_bytes: 194472
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int num;
    int max, min,a;
    long sum;

    scanf("%d",&num); 
    scanf("%d",&a);
    max = a; min = a;
    sum = a;

    while(num-1 > 0){
        scanf("%d",&a);
        sum = sum + a;

        if(a > max){
            max = a;
        }else if(a < min){
            min = a;
        }

        num--; 

    }

    printf("%d %d %ld\n",min,max,sum);

    return 0;
}

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

using namespace std;

string s[3];

int main(void)
{
	cin >> s[0] >> s[1] >> s[2];
	
	for(int i = 0; i < 3; i++){
		cout << (char)(s[i][0] - 'a' + 'A');
	}
	cout << endl;
	
	return 0;
}

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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " = " << x << endl
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define infll 1e18
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };



//===========================DEBUG======================//
#define XOX 1
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

//================================================================//



//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=2e5+5;
ll ans[lmt];

ll sq(ll n){
	return n*n;
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
    fast

    ll n; cin>>n;
    ll rtn = sqrt(n)+2;
    loop1(i,rtn)loop1(j,rtn)loop1(k,rtn){
    	ll val = sq(i+j)+sq(j+k)+sq(i+k);
    	val /= 2;
    	if(val>n)break;
    	ans[val]++;
    }

    loop1(i,n) pt(ans[i]);
}


/*


*/





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

int H[110000];
bool good[110000];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N, M; cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> H[i];

	fill(good, good + N, 1);
	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b;
		a--, b--;
		if (H[a] <= H[b]) good[a] = 0;
		if (H[a] >= H[b]) good[b] = 0;
	}

	int cnt = 0;
	for (int i = 0; i < N; i++) if (good[i]) cnt++;
	cout << cnt << '\n';
	return 0;
}


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

int main()
{
  ios::sync_with_stdio(0);
  int n, a[100100], sum = 0, sumAbs = 0;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    sum += a[i];
    sumAbs += abs(a[i]);
  }

  sort(a, a + n);

  if (n == 2) cout << a[1] - a[0] << endl << a[1] << ' ' << a[0] << endl;
  else if (a[0] >= 0)
  {
    cout << sum - a[0] * 2 << endl;
    int value = a[0];
    for (int i = 1; i < n - 1; i++)
    {
      cout << value << ' ' << a[i] << "\n";
      value -= a[i];
    }
    cout << a[n - 1] << ' ' << value << endl;
  }
  else if (a[n - 1] <= 0)
  {
    cout << 2 * a[n - 1] - sum << endl;
    int value = a[n - 1];
    for (int i = n - 2; i >= 0; i--)
    {
      cout << value << ' ' << a[i] << "\n";
      value -= a[i];
    }
  }
  else
  {
    cout << sumAbs << endl;

    int posId = 0;
    while (a[posId] < 0)
      posId++;

    int value = a[posId], negId = posId - 1;
    if (posId < n - 1)
    {
      value = a[negId--];
      for (int i = posId; i < n - 1; i++)
      {
        cout << value << ' ' << a[i] << "\n";
        value -= a[i];
      }
      cout << a[n - 1] << ' ' << value << "\n";
      value = a[n - 1] - value;
    }

    for (int i = negId; i >= 0; i--)
    {
      cout << value << ' ' << a[i] << "\n";
      value -= a[i];
    }
  }
}

Measured memory_bytes: 2304
#include <stdio.h>

int main() {
	char n[2000001];
	int sum =0;

	scanf("%s", n);

	for(int i=0; n[i]!=NULL; i++) {
		sum += n[i] - '0';
	}
	
	if(sum%9 == 0) {
		puts("Yes");
	} else {
		puts("No");
	}
	
	return 0;
}


Measured memory_bytes: 1820
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1130&lang=jp
*/

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int di[4] = {+1, 0, -1, 0};
const int dj[4] = {0, -1, 0, +1};

int w, h;
string tiles[20];

int solve(int si, int sj){
    int res = 0;
    queue<pair<int, int> > Q;
    bool visited[h][w];
    memset(visited, false, sizeof visited);
    visited[si][sj] = true;
    res++;
    Q.push(make_pair(si, sj));
    while(!Q.empty()){
        pair<int, int> p = Q.front();
        Q.pop();
        int pi = p.first, pj = p.second;
        for(int k=0;k<4;k++){
            int ni = pi + di[k];
            int nj = pj + dj[k];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if(!visited[ni][nj] && tiles[ni][nj] == '.'){
                visited[ni][nj] = true;
                Q.push(make_pair(ni, nj));
                res++;
            }
        }
    }
    return res;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    while(1){
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        int si, sj;
        for(int i=0;i<h;i++){
            cin >> tiles[i];
            for(int j=0;j<w;j++){
                if(tiles[i][j] == '@'){
                   si = i;  
                   sj = j;
                }
            }
        }
        int ans = solve(si, sj);
        cout << ans << endl;
    }
}



Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int A,B,C;
    cin>>A>>B>>C;
    for(int i=0;i<B;i++){
        if((A*i)%B==C){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 256
N = gets
str = gets.chomp
len = str.length
 
if len % 2 != 0
  puts("No")
  exit 0
end
 
half = len/2
first = str[0..half-1]
second = str[half..-1]
 

if first == second 
  puts("Yes")
else
  puts("No")
end


Measured memory_bytes: 1788
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <iomanip>
using namespace std;

int main(int argc, char const *argv[]) {
  int H,W;
  cin >> H >> W;
  vector<string> s;
  for(int i = 0; i < H; i++){
    string si;
    cin >> si;
    s.push_back(si);
  }
  for(int i = 0; i < H; i++){
    cout << s[i] << endl;
    cout << s[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 888
using System;

public class Program
{
    static long[] a;

    static string output;

    public static void Main(string[] args)
    {
        Input();
        Proc();
        Output();
    }

    static void Input()
    {
        string[] input = null;

        // スペース区切りの整数の入力(横、配列)
        input = Console.ReadLine().Split(' ');

        a = new long[3];
        for (long idx = 0; idx < 3; idx++)
        {
            a[idx] = long.Parse(input[idx]);
        }
    }

    static void Proc()
    {
        int z5 = 0;
        int z7 = 0;

        for (long idx = 0; idx < 3; idx++)
        {
            if (a[idx] == 5)
            {
                z5++;
            }
            else if (a[idx] == 7)
            {
                z7++;
            }
        }

        if (z5 == 2 && z7 == 1)
        {
            output = "YES";
        }
        else
        {
            output = "NO";
        }
    }

    static void Output()
    {
        // 出力
        Console.WriteLine(output);
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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 = 1e11;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int s,a,c = 2;
    cin >> s;
    if (s%2 == 0) a = s/2;
    else a = 3*s+1;
    bool exist[1000005] = {0};
    exist[s] = true;
    while(!exist[a]){
        exist[a] = true;
        if (a%2) a = 3*a+1;
        else a /= 2;
        c++;
    }
    PRINT(c);
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long
#define ld long double
#define MAX 1000000000
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	//cin>>t;
	for(int cc=1;cc<=t;cc++){
        //cout<<"Case #"<<cc<<": ";
        ll n,m,ans=0;
        cin>>n>>m;
        ll a[m];
        for(int i=0;i<m;i++)
        	cin>>a[i],ans+=a[i];
        cout<<max(-1LL,n-ans)<<endl;
	}
}


Measured memory_bytes: 3716
#!/usr/bin/rdmd
import std.stdio;
import std.conv: to;
import std.array: split;
import std.ascii: newline;

immutable greater = "a > b";
immutable less    = "a < b";
immutable equa    = "a == b";
void main()
{
   int[2] a;
   foreach (string line; lines(stdin))
   {
      if(line == newline) break;
      else
      {
         a = to!(int[])(split(line));
         if(a[0] > a[1])         writeln(greater);
         else if(a[0] < a[1])    writeln(less);
         else                    writeln(equa);
      }
   }
}

Measured memory_bytes: 992
#include<iostream>
#include<queue>
using namespace std;
string s[12];
bool used[12][12];
int d[]={0,1,0,-1,0};
void f(int x,int y)
{
    used[x][y]=1;
    for(int r=0;r<4;r++)
    {
        int tx=x+d[r],ty=y+d[r+1];
        if(tx<0||ty<0||tx>=12||ty>=12||used[tx][ty]||s[tx][ty]=='0')continue;
        f(tx,ty);
    }
}
main()
{
    while(cin>>s[0])
    {
        for(int i=1;i<12;i++)cin>>s[i];
        for(int i=0;i<12;i++)for(int j=0;j<12;j++)used[i][j]=0;
        int ans=0;
        for(int i=0;i<12;i++)
        {
            for(int j=0;j<12;j++)
            {
                if(!used[i][j]&&s[i][j]!='0')
                {
                    ans++;
                    f(i,j);
                }
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3224
'''
むー
たとえば、5 8とかなら…
1+2+3
1+2+4
1+2+…

1+3+4
1+3+5
1+3+…
みたいな形で総当たりすればいいのか。
ああー、でかい方から調べた方が効率良い？
いや見落とされるか。

それよりも、方法ない？
たとえば最小は6。1,2,3の組み合わせしかありえない。
7は1,2,4だけ。
8は1,2,5と1,3,4の2つ。
9は1,2,6、1,3,5、2,3,4の3つ
10は1,2,7、1,3,6、1,4,5、2,3,5の4つ
11は1,2,8、1,3,7、1,4,6、2,3,6、2,4,5の5つ
12は1,2,9、1,3,8、1,4,7、1,5,6、2,3,7、2,4,6、3,4,5で7つ
こんなかんじで1を含むものは
1//2x-2
2を含むものは
1//3x-2ちがう
1/2x-2
1/2x-3.5
1/2x-5
…

x-n>=3が最大
差が1増えるごとに1ずつ、5を超えると2ずつ、7を超えると3ずつ減る
1を含むものはx-n-3
2を含むものはx-n-3-2違うね。
x-n-3-2-()
3を含むものはx-n-3-2-2
…

リストで処理しなきゃダメじゃん…
'''

#テスト値
#n = 5
#x = 9



def countingWays(n,x):
    r = [
        i+j+k 
        for i in range(1,n)
        for j in range(i+1,n)
        for k in range(j+1,n)
        if i+j+k==x
        ]
        
    c = len(r)
    print(c)

#countingWays(n+1,x)
#print(c)

#s = []

while True:
    t = input()
    if t == "0 0":
        break
    else:
        n,x = map(int, t.split())
        countingWays(n+1, x)
#t = [s.pop(i*2) for i in range(len(s)/2)]




Measured memory_bytes: 5624
import math
 
n = int(input())
wn = list(map(int, input().split()))
 
mini = 10000000000
for i in range(n-1):
    new_mini = abs(sum(wn[:i+1]) -sum(wn[i+1:]))
    if new_mini < mini:
        mini = new_mini
print(mini)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 10005
 
#define PI   3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007



int main()
{
	FAST;
	string s;
	cin >> s;
	ll  x = 0;
	for(ll i = 0; i < s.size(); i ++){
		if(s[i] == '1'){
			x ++;
		}
	}
	cout << x;
	return 0;
}

Measured memory_bytes: 3648
X, Y = map(int, input().split())
b2 = Y - 2*X
a2 = 4*X - Y
if a2 >= 0 and b2 >= 0 and b2 % 2 == 0 and a2 % 2 == 0:
    b = b2 / 2
    a = a2/ 2
    if a + b == X and 2*a + 4*b == Y:
        print('Yes')
else:
    print('No')

Measured memory_bytes: 9188
from sys import stdin
import math
def input():
	return stdin.readline()[:-1]

def intput():
	return int(input().rstrip())

def sinput():
	return input().rstrip().split()

def intsput():
	return map(int, sinput())

def main():
	n, k = intsput()
	for i in range(1,100):
		if k**i>n:
			print(i)
			return

if __name__ == '__main__':
	main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};
class rcompare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<0>(a) < get<0>(b));
	}
};
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi a(n), b(n), c(n), d(n);
	vector<tii> red, blue;
	rep(i, n) {
		cin >> a[i] >> b[i];
		red.push_back(tii(a[i], b[i]));
	}
	rep(i, n) {
		cin >> c[i] >> d[i];
		blue.push_back(tii(c[i], d[i]));
	}
	sort(all(red), rcompare()); sort(all(blue), compare());
	int ans = 0; 
	rep(i, n) {
		int  x = get<0>(blue[i]);
		int  y = get<1>(blue[i]);
		for (int j = n-1; j>=0; j--) {
			if (get<0>(red[j]) < x && get<1>(red[j]) < y) {
				ans++;
				//cout << get<0>(blue[j]);
				get<0>(red[j]) = INF;
				j = -1;
			}
		}
		//cout << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
table = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
total = int(input())

for i in range(total):
    B, F, R, V = list(map(int, input().split()))
    table[B - 1][F - 1][R - 1] += V

for i, bldg in enumerate(table):
    if i > 0:
        print("####################")
    for j, flr in enumerate(bldg):
        for k, room in enumerate(flr):
            print(f" {room}", end="")
        print()
            
        


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

int main() {
  int N, X;
  scanf("%d%d", &N, &X);

  int D = 0;
  int ans = 1;
  for (int i = 0; i < N; ++i) {
    int L = 0;
    scanf("%d", &L);
    D += L;
    if (D <= X) ans++;
  }

  printf("%d", ans);
  return 0;
}

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

#define PROB "Doughnut"
#define vi vector<int>

void init(){
    freopen(PROB".inp","r",stdin);
    freopen(PROB".out","w",stdout);
}

int main(){
    int N,X;
    int a,Min=100001;
    int res;
    cin>>N>>X;
//    cout<<N<<" "<<X;
    res=N;
    while(N--){
        cin>>a;
        Min=min(a,Min);
        X-=a;
    }
    res+=(X/Min);
    cout<<res;
}


Measured memory_bytes: 256
#include<cstdio>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;

int a[200005];

int main() {
    int n,i,flag=1;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
   sort(a,a+n);
   for(i=1;i<n;i++){
        if(a[i]==a[i-1]){
            flag=0;
            break;
        }
   }
    if(flag)
        printf("YES\n");
    else
        printf("NO\n");
}

Measured memory_bytes: 896
#include<cstdio>
int main(void){int n,x,c,i,j,k;scanf("%d%d",&n,&x);while((n!=0)||(x!=0)){for(c=0,i=1;i<=n;++i){for(j=i+1;j<=n;++j){for(k=j+1;k<=n;++k){c+=(i+j+k==x)?1:0;}}}printf("%d\n",c);scanf("%d%d",&n,&x);}return(0);}


Measured memory_bytes: 2664
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}


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

 int n,k;
 cin>>n>>k;
 vector<int> v(n);
 for(int i=1;i<=n;i++)
 {
    cin>>v[i-1];
 }
 int ans=0;
 sort(v.begin(),v.end());
 for(int i=0;i<k;i++)
    ans+=v[i];
cout<<ans;
}

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

//#define debug
typedef long long ll;
vector<int> t;

int main(){
#ifdef debug
    freopen("test.in", "r", stdin);
#endif
    int N, T;
    cin>>N>>T;
    t.resize(N);
    for(int i=0; i<N; ++i){
        cin>>t[i];
    }
    ll ans=0, start=0, end=T;
    for(int i=1; i<N; ++i){
        if(t[i]>=end){
            ans+=end-start;
            start=t[i];
            end=t[i]+T;
        }else{
            end=t[i]+T;
        }
    }
    ans+=end-start;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
Var S:String;
    Ok,Ok1,OK2:Boolean;
    i,r:Longint;
Begin
    Readln(S); OK:=True; OK1:=true; Ok2:=true;
    For i:=1 to length(S) div 2 do
        If S[i]<>S[length(S)-i+1] then OK:=False;
    For i:=1 to length(S) div 4 do
        If S[i]<>S[length(S) div 2 - i + 1] then OK1:=False;
    If odd(length(S)) then r:=length(S) div 2 + 2 else r:=length(S) div 2 + 1;
    For i:=r to r+(length(S) - r) div 2 do
        If S[i]<>S[length(S) div 2 - i + r] then OK2:=False;
    If (OK) and (OK1) and (OK2) then writeln('Yes') else writeln('No');
End.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
	ll i,s=0;
	string n;
cin>>n;
for(i=0;i<n.length();i++)
{
	s+=(n[i]-'0');
}
	if(s%9==0)
	{
		cout<<"Yes"<<endl;
		return;
	}
	else
	{
		cout<<"No"<<endl;
		return;
	}
	
}





		int main()
		{
#ifndef ONLINE_JUDGE
			// for getting input from input.txt
			freopen("input.txt", "r", stdin);
			// for writing output to output.txt
			freopen("output.txt", "w", stdout);
#endif

			int t=1;
			//cin >> t;

			while (t--)
			{
				solve();
			}
			return 0;
		}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <deque>

void solve() {
  std::string str;
  bool reverse = false;
  int q;
  std::cin >> str >> q;
  std::deque<char> d;
  for (int i = 0; i < str.size(); i++) d.push_back(str[i]);
  
  for (int i = 0; i < q; i++) {
    int t;
    std::cin >> t;
    if (t == 1) reverse = (!reverse);
    else {
      int f;
      char c;
      std::cin >> f >> c;
      if (reverse && f == 2 || !reverse && f == 1) d.push_front(c);
      else d.push_back(c);
    }
  }
  if (reverse)
    for (std::deque<char>::reverse_iterator i = d.rbegin(); i != d.rend(); ++i)
      std::cout << *i;
  else
    for (std::deque<char>::iterator i = d.begin(); i != d.end(); ++i)
      std::cout << *i;
  
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 896
import sys
import bisect  # 二分法


MAX_N = 200005
INF = 10**9 + 5

sys.setrecursionlimit(MAX_N)

N = int(sys.stdin.readline())
A = [int(x) for x in sys.stdin.readline().split()]
E = [[] for _ in range(N)]  # 辺の情報

for _ in range(N-1):
    u, v = map(int, sys.stdin.readline().split())
    E[u-1].append(v-1)
    E[v-1].append(u-1)

lis = [INF] * N
ans = [0] * N 

def dfs(u,r=-1):

    # u を訪れたときの処理
    i = bisect.bisect_left(lis, A[u])  # 
    old = lis[i]  # 書き換え前の値を一時保存
    lis[i] = A[u]

    for v in E[u]:
        if v == r: continue  # 親は無視

        dfs(v,u)
    
    ans[u] = bisect.bisect_left(lis,INF-1)
    lis[i] = old  # 書き換え前の状態に戻す

dfs(0)
for i in range(N):
    print(ans[i])

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

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


Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

void solve()
{

}

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
int ans=0;
rep(i,1,n)
{
	int x;
	cin>>x;
	if(i%2==1&&x%2==1)ans++;
}
ol(ans);
return 0;
}



Measured memory_bytes: 3604
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "Good";
		for(int i = 1; i < s.length(); i++){
		    if(s.charAt(i) == s.charAt(i-1)) result = "Bad";
		}

		// 出力
		System.out.println(result);
		
	}
}


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

int main() {
  int n,k; string s;
  cin >> n >> k >> s;
  cout << s.substr(0,k-1);
  string t = s.substr(k-1,1);
  if (t == "A") cout << "a";
  else if (t == "B") cout << "b";
  else cout << "c";
  cout << s.substr(k,n-k) << endl;
  return 0;
}


Measured memory_bytes: 3540
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

// snukeさんのmodint
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// mint N;
//cout << N.x << endl;

ll N;
vector<vector<int>> G(200005);
vector<ll> cnt(200005,0),par(200005,-1);
vector<bool> used(200005,false);

int dfs(int v){
  int res = 0;
  for(auto nv:G[v]){
    if(used[nv]) continue;
    par[nv] = v;
    used[nv] = true;
    res += dfs(nv);
  }
  return cnt[v] = res + 1;
}

int main(){
  cin >> N;
  for(int i=0; i<N-1; i++){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  used[0] = true;
  dfs(0);
  mint ans=0,two=2;
  for(int i=0; i<N; i++){
    mint now = 0;
    ll sum = 0;
    for(auto nv: G[i]){
      if(nv == par[i]) continue;
      sum += cnt[nv];
      now += two.pow(cnt[nv]) - 1;
    }
    if(par[i] != -1) now += two.pow(N-sum-1) - 1;
    ans += two.pow(N-1) - 1 - now;
  }
  ans /= two.pow(N);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 20992
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
#define kd int
#define fors(i,a,b) for(int i=(a);i<=(b);++i)
int main(){
    ios::sync_with_stdio(0);
    register int a,wh[9],b,c,d,e,f,g,h,i;
    cin>>a>>b>>e;
    fors(c,-100,500){
        wh[1]=a+b+c;
        if(wh[1]<a+e) continue;
        fors(i,-100,500){
            wh[7]=a+e+i;
            if(wh[7]!=wh[1]) continue;
            fors(f,-100,500)
            {
                wh[6]=c+f+i;
                if(wh[6]!=wh[7]) continue;
                fors(d,-100,500){
                    wh[2]=d+e+f;
                    if(wh[2]!=wh[6]) continue;
                    fors(g,-100,500)
                    {
                        wh[4]=g+d+a;
                        wh[8]=c+e+g;
                        if((wh[8]!=wh[4])) continue;
                        fors(h,-100,500){
                            wh[3]=g+h+i;
                            wh[5]=b+e+h;
                            if((wh[3]!=wh[5]) || (wh[3]!=wh[4]) || (wh[3]!=wh[8])) continue;
                                printf("%d %d %d \n", a,b,c);
                                printf("%d %d %d \n", d,e,f);
                                printf("%d %d %d \n", g,h,i);
                                return 0;
                        }
                    }       
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10;
int fa[maxn],co[maxn];
bool bz[maxn],pd[maxn];
int i,j,k,l,r,t,n,m,cnt;
ll ans;
int getfa(int x){
    if (!fa[x]) return x;
    int t=getfa(fa[x]);
    co[x]^=co[fa[x]];
    return fa[x]=t;
}
int main(){
    //freopen("data.in","r",stdin);
    scanf("%d%d",&n,&m);
    fo(i,1,m){
        scanf("%d%d",&j,&k);
        bz[j]=1;bz[k]=1;
        l=getfa(j);r=getfa(k);
        if (l<r){
            swap(l,r);
            swap(j,k);
        }
        if (l==r&&co[j]==co[k]) pd[l]=1;
        if (l==r) continue;
        pd[r]|=pd[l];
        fa[l]=r;
        co[l]=co[j]^co[k]^1;
    }
    fo(i,1,n)
        if (!bz[i]) cnt++;
    ans=(ll)cnt*(n-cnt)*2+(ll)cnt*cnt;
    cnt=0;
    fo(i,1,n)
        if (bz[i]&&!fa[i]) cnt++;
    ans+=(ll)cnt*cnt;
    cnt=0;
    /*fo(i,1,n)
        if (bz[i]&&fa[i]){
            k=getfa(i);
            if (!pd[k]&&co[i]!=co[k]) cnt++;
        }*/
    fo(i,1,n)
        if (bz[i]&&!fa[i]&&!pd[i]) cnt++;
    fo(i,1,n)
        if (bz[i]&&!fa[i]&&!pd[i]) ans+=(ll)cnt;
    printf("%lld\n",ans);
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
int main(){
  int n,l;
  char s[110][110],temp[110];
  scanf("%d %d",&n,&l);
  for(int i=0;i<n;i++)
    scanf("%s",s[i]);
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++){
      if(strcmp(s[i],s[j])>=1){
        strcpy(temp,s[i]);
        strcpy(s[i],s[j]);
        strcpy(s[j],temp);
      }
    }
  for(int i=0;i<n;i++)
    printf("%s",s[i]);
  printf("\n");
}

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

const int MAX = 100010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();

    long long n, k;
    cin >> n >> k;
    
    vector<long long> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

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

    long long ans = 0;
    for(int i = k - 1; i < n; i++){
        ans = (ans + (A[i] * COM(i, k - 1)) % MOD) % MOD;
    }

    for(int i = 0; i < n - k + 1; i++){
        ans = (ans - (A[i] * COM(n - i - 1, k - 1)) % MOD) % MOD;
        if(ans < 0) ans += MOD;
    }

    cout << ans << endl;

    return 0;
}

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b,a%b);
}

//3項以上の場合
ll gcd(vector<ll>a) {
    ll ans = a[0];
    for (int i=1; i<a.size(); i++) {
        ans = gcd(ans, a[i]);
    }
    return ans;
}

int main() {
    int N;
    ll X;
    cin >> N >> X;
    vector<ll> x(N), y(N);
    for (int i=0; i<N; i++) {
        cin >> x[i];
        y[i] = abs(x[i] - X);
    }
    
    cout << gcd(y) << endl;
    
    
}

Measured memory_bytes: 2560
from collections import defaultdict


n, m = map(int, input().split())
d = defaultdict(int)
for i in range(n):
    tmp = list(map(int, input().split()))
    for a in tmp[1:]:
        d[a] += 1
cnt = 0
for value in d.values():
    if value == n:
        cnt += 1
print(cnt)


Measured memory_bytes: 3316
//*******************************By Harry Singh From Phillaur.
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000006
const ll mo=1000000007;
#define string_to_any_base(s,base) stoll(s, 0, base);
#define vc vector
// #define mp map<ll,ll> mp;
#define bt(M,value) bitset<M> b(value)
#define S set<ll> s;
#define pb push_back
#define ST set<string> s;
#define INF 1e15
using namespace std;
set<ll> primes;
vector<pair<ll,ll>> adj[MAX];
vector<ll> ad[MAX];
///******************************ALL important functions;
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b);} 
ll lcm(ll a, ll b)  {  return (a*b)/gcd(a, b);  } 
void Sieve(){ bool prime[MAX+1]; memset(prime, true, sizeof(prime)); for (int p=2; p*p<=MAX; p++) { if (prime[p] == true) {for (int i=p*p; i<=MAX; i += p) prime[i] = false; } } for(int i=2;i<=MAX;i++)if(prime[i]==true)primes.insert(i);} 
ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;}
ll modpow(ll a, ll n=mo-2) {ll r=1;while(n)r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;return r;}



int visited[100006]={0};
void dfs(int u)
{
	visited[u]=true;
	for(auto s:ad[u])
	if(!visited[s])dfs(s);
}

int main()
{
int n,m,a,b,z;
cin>>n>>m;
for(int i=1;i<=m;i++)
{cin>>a>>b>>z;
	ad[a].pb(b);ad[b].pb(a);
}
int c=0;
for(int i=1;i<=n;i++)
{
	if(!visited[i])
	dfs(i),c++;
}
cout<<c<<endl;
}



Measured memory_bytes: 55680
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    cout << 180 * (N - 2) << endl;
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("internationalization");
            //i18n
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("smiles");
            //s4s
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("xyz");
            //x1z
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string S = InputList[0];

        int StrLen = S.Length;
        Console.WriteLine("{0}{1}{2}", S[0], StrLen - 2, S[StrLen - 1]);
    }
}


Measured memory_bytes: 11220