akhauriyash/Code-Regression huggingface dataset:
// C++ program to demostrate working of Guassian Elimination
// method
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#pragma GCC optimize ("Ofast")
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define pb push_back
#define fs first
#define sc second
#define MOD 1000000007
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

ll n, k;
vector<int> edgtmp[100100];
vector<int> edg[100100];
bool vis[100100];
void dfs(int at){
    if(vis[at]) return;
    vis[at] = true;
    rep(i,0,edgtmp[at].size()){
        int nxt = edgtmp[at][i];
        if(!vis[nxt]){
            edg[at].pb(nxt);
            dfs(nxt);
        }
    }
}

ll ans = 1;
void solve(int at){
    rep(i,0,edg[at].size()){
        if(at == 0) ans = (ans * (k-1-i)) % MOD;
        else ans = (ans * (k-2-i)) % MOD;
        solve(edg[at][i]);
    }
}

int main()
{
    cin.sync_with_stdio(false);
    memset(vis,0,sizeof(vis));
    cin >> n >> k;
    rep(i,0,n-1){
        int a, b;
        cin >> a >> b;
        a--;b--;
        edgtmp[a].pb(b);
        edgtmp[b].pb(a);
    }
    dfs(0);
    solve(0);
    cout << (ans*k)%MOD << endl;
}


Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a.rbegin(),a.rend());
  int ans=0;
  for(int i=0;i<k;i++) ans+=a[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())

def gcd(a, b):
  return b if a == 0 else gcd(b % a, a)

def get25(p):
  n2 = 0
  n5 = 0
  while p % 2 == 0:
    n2 += 1
    p //= 2
  while p % 5 == 0:
    n5 += 1
    p //= 5
  return (n2, n5)

d = defaultdict(int)

for i in range(N):
  s = input()
  for i, c in enumerate(s):
    if c == '.':
      q = int(s[:i] + s[i+1:])
      p = 10 ** (len(s) - i - 1)
      break
  else:
    q = int(s)
    p = 1
  g = gcd(p, q)
  p, q = p // g, q // g
  p2, p5 = get25(p)
  q2, q5 = get25(q)
  

  d[(q2 - p2, q5 - p5)] += 1
  # print(q, p, q2, p2, q5, p5)

# print(d)

d = list(d.items())

ans = 0

# print(d)

for j in range(len(d)):
  if d[j][0][0] >= 0 and d[j][0][1] >= 0:
    ans += d[j][1] * (d[j][1] - 1) // 2
  for i in range(j):
    if d[i][0][0] + d[j][0][0] >= 0 and d[i][0][1] + d[j][0][1] >= 0:
      # print(d[i], d[j])
      ans += d[i][1] * d[j][1]

print(ans)


Measured memory_bytes: 9432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = -0; i < H; i++) {
        cin >> S[i];
    }
    vector<bool> tate(W, false);
    vector<bool> yoko(H, false);

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if(S[i][j] == '#'){
                yoko[i] = true;
                tate[j] = true;
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if(yoko[i] == true && tate[j] == true){
                printf("%c", S[i][j]);
            }
        }
        if(yoko[i] == true){
            printf("\n");
        }
    }

}

Measured memory_bytes: 3628
// #include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#define pb emplace_back
#define LOCAL
  
using namespace std;
  
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+5;
typedef long long ll;
typedef pair<int,int> Pii;
 
template <typename T>inline void read(T& t){
    char c=getchar();t=0;
    int f=1;
    while(!isdigit(c)){
       if(c=='-')f=-1;
        c=getchar();
    }
    while(isdigit(c))t=t*10+c-48,c=getchar();
    t=f*t;
}
  
template <typename T,typename... Args> inline void read(T& t,Args&... args){
    read(t);read(args...);
}

char maze[1005][1005];
int vis[1005][1005];
int c1,c2,d1,d2;
queue<Pii> q[2];//q[0]代表第一种方式,q[2]代表第二种方式
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
 
int main(){
    int t=1;
    // read(t);
    while(t--){
        int n;
        read(n);
        puts(n>=30?"Yes":"No");
    }
    return 0;
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var n = int.Parse(ss[0]);
            var m = int.Parse(ss[1]);

            Console.WriteLine((n - 1) * (m - 1));
        }
    }
}

Measured memory_bytes: 13140
#include"bits/stdc++.h"
using namespace std;

const long long MOD = 1e9 + 7;
const int MAX = 510000;

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

// テーブルを作る前処理
void modcombinit(long long mod = MOD) {
    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;
    }
}

// nCk (mod )
long long modcomb(long long n, long long k, long long mod = MOD){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

void Main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;

  modcombinit();

  long long ans = 0;
  int x = B, y = H - A - 1;
  for (int i = 0; x + i < W && y - i >= 0; i++) {
    int tmpx = x + i, tmpy = y - i;
    long long first = modcomb(tmpx + tmpy, tmpx);
    long long second = modcomb(H - 1 - tmpy + W - 1 - tmpx, W - 1 - tmpx);
    long long tmp = (first * second) % MOD;
    ans = (ans + tmp) % MOD;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 15536
ab = [list(map(int, input().split())) for i in range(3)]
one, two, three, four = 0, 0, 0, 0
for i in ab:
    one += i.count(1)
    two += i.count(2)
    three += i.count(3)
    four += i.count(4)
if one == 3 or two == 3 or three == 3 or four == 3:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
using ll = long long;
using namespace std;

ll GCD(ll a, ll b) {
	return b ? GCD(b, a%b) : a;
}

//sort(a, a + N, greater<int>())   // descend
//sort(a, a+N)                    //  ascend

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

	ll a[220000];
	ll b[220000];
	ll c[220000];
	pair<ll, ll> p[n];
	for (ll i = 0; i < n; i++) {
		cin >> p[i].second >> p[i].first;
	}
	sort(p, p + n);
	c[0] = p[0].second;
	//rep(i, 0, n) c[i + 1] = c[i] + p[i].second;


	bool y = true;
	ll cnt = 0;
	rep(i, 0, n) {
		cnt += p[i].second;
		if (cnt> p[i].first) {
			y = false;
			break;
		}
	}
	if (y) cout << "Yes";
	else cout << "No";

}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#pragma GCC optimize("O999")
//示例：#define ll long long
//unsigned long long ;
const int INF=0x3f3f3f3f;
const int maxn=50000005;
using namespace std;

int main(){
	//freopen(".in", "r",stdin );
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	int x, ans=0;
	cin >> x;
	ans+=x/500*1000;
	x%=500;
	ans+=x/5*5;
	cout<< ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    lli X;
    cin >> X;
    lli tmp = 100;
    lli cnt = 0;
    while (tmp < X)
    {
        tmp += (lli)(tmp / 100);
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
  int n, m, A[100][100], b[100], c[100];  
    
  cin >> n >> m;
  for ( int i = 0; i < n; i++ )
    for ( int j = 0; j < m; j++ ) cin >> A[i][j];
  for ( int i = 0; i < m; i++ ) cin >> b[i];
  
  for ( int i = 0; i < n; i++){
    c[i] = 0;
    for ( int j = 0; j < m; j++ ){
      c[i] += A[i][j]*b[j];
    }
  }
   
  for ( int i = 0; i < n; i++ ) cout << c[i] << endl;
  
  return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string S;
  cin >> S;
  int way1 = 0;
  int way2 = 0;
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0) {
      if (S[i] == '0') {
        way1++;
      }
      if (S[i] == '1') {
        way2++;
      }
    } else if (i % 2 == 1) {
      if (S[i] == '0') {
        way2++;
      }
      if (S[i] == '1') {
        way1++;
      } 
    }
  }
  int ans = min(way1,way2);
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    short i, j;
    short l;
    char c;
};

P p[3001][3001];

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

    string s, t;
    cin >> s >> t;

    int n = s.size();
    int m = t.size();

    int l = 0, i0, j0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i - 1] == t[j - 1]) {
                p[i][j] = p[i - 1][j - 1];
                p[i][j].l++;
                //if (p[i][j].c != 0) {
                    p[i][j].i = i - 1;
                    p[i][j].j = j - 1;
                //}
                p[i][j].c = s[i - 1];

                if (p[i][j].l > l) {
                    l = p[i][j].l;
                    i0 = i;
                    j0 = j;
                }
            } else {
                p[i][j] = p[i][j - 1].l >= p[i - 1][j].l ? p[i][j - 1] : p[i - 1][j];
                if (p[i][j - 1].l >= p[i - 1][j].l) {
                    p[i][j].i = i;
                    p[i][j].j = j - 1;
                } else {
                    p[i][j].i = i - 1;
                    p[i][j].j = j;
                }
                p[i][j].c = 0;
            }
        }
    }

    if (l == 0) {
        cout << endl;
        exit(0);
    }

    string r;
    for (;;) {
        P& t = p[i0][j0];
        if (i0 == 0 || j0 == 0) break;
        if (t.c != 0) r.push_back(t.c);
        i0 = t.i;
        j0 = t.j;
        //cout << t.l << endl;
    }
    reverse(r.begin(), r.end());
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 70656
from itertools import product
from collections import Counter

H, W, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
D = tuple(product((-1, 0, 1), repeat=2))

cnt = Counter()
for a, b in AB:
    for h, w in D:
        if 2 <= a + h <= H - 1 and 2 <= b + w <= W - 1:
            cnt[(a + h, b + w)] += 1

ans = [0] * 10
for c in cnt.values():
    ans[c] += 1

ans[0] = (H - 2) * (W - 2) - sum(ans)
print(*ans, sep='\n')


Measured memory_bytes: 180328
#include <stdio.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int partition(int A[], int p, int r)
{
    int x = A[r];
    int i = p -1;
    for(int j = p; j < r; j++)
    {
        if(A[j]<=x)
            swap(A[++i], A[j]);
    }
    swap(A[r], A[i+1]);
    return i+1;
}

int main ()
{
    int n;
    cin >> n;
    int A[n];
    for(int i= 0;i < n; i++)
        cin >> A[i];
    int x = partition(A,0,n-1);
    for(int i = 0; i< n; i++)
    {
        if(i)cout << " ";
        if(i == x)
            cout << "[" << A[i] << "]";
        else 
            cout << A[i];
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 3476
c = []
for i in range(3):
    c.append(list(map(int, input().split())))
tmp = [[] for i in range(4)]
for i in range(3):
    tmp[0].append(c[1][i] - c[0][i])
    tmp[1].append(c[2][i] - c[0][i])
    tmp[2].append(c[i][1] - c[i][0])
    tmp[3].append(c[i][2] - c[i][0])
if set([len(set(i)) for i in tmp]) == {1}:
    print('Yes')
else:
    print('No')


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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int main()
{
  int N;
  cin >> N;
  int out = 0;
  if(N%2 == 0) out = N/2;
  else out = N/2 + 1;
  cout << out;
  
  return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e6;
const int Nmax=2e5+1;
const int Nd=61;


int main(){
  char c;
  cin>>c;

  printf("%c",c+1);


}


Measured memory_bytes: 3572
from sys import stdin

n = stdin.readline().rstrip()
cnt = 0
for i in range(len(n)):
    if i%2 == 0:
        if n[i] == "R" or n[i] == "U" or n[i] == "D":
            cnt+= 1
        else:
            print("No")
            exit()

    else:
        if n[i] == "L" or n[i] == "U" or n[i] == "D":
            cnt+=1
        else:
            print("No")
            exit()

print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define ty 2443
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);
}
int co[510][510];

int main(){
	int H,W,h,w;read(H);read(W);read(h);read(w);
	if(H%h==0&&W%w==0){puts("No");return 0;}
	
	puts("Yes");
	if(H%h!=0){
		rep(i,1,H){
			rep(j,1,W){
				if((i-1)%h!=0){co[i][j]=-ty;}
				else{co[i][j]=ty*(h-1)-1;}
			}
		}
	}else{
		rep(i,1,H){
			rep(j,1,W){
				if((j-1)%w!=0){co[i][j]=-ty;}
				else{co[i][j]=ty*(w-1)-1;}
			}
		}
	}
	
	rep(i,1,H){
		rep(j,1,W){write(co[i][j]);putchar((j==W)?'\n':' ');}
	}
	return 0;
}


Measured memory_bytes: 2688
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
 
		int N = int.Parse(input[0]);
		int X = int.Parse(input[1]);
		int T = int.Parse(input[2]);
 
        //出力
		Console.WriteLine(Math.Ceiling(((double)N/(double)X))*T);
	}
}

Measured memory_bytes: 27452
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x, y = find(x), find(y)
    if x == y:
        return False
    
    if par[x] > par[y]:
        x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True

def size(x):
    return -par[find(x)]

n, m = map(int, input().split())
ab = []
for _ in range(m):
    a, b = map(int, input().split())
    ab.append([a-1, b-1])
par = [-1]*n

icnt=0
for i in range(m):
    unite(ab[i][0],ab[i][1])
    
szmax=0    
for i in range(n):
    sz=size(i)
#    print(sz)
    szmax=max(szmax,sz)
    
print(szmax)  

Measured memory_bytes: 104428
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left
import heapq
import numpy as np

def input(): return sys.stdin.readline().strip()
def INt(): return int(input())
def MAP(): return map(int, input().split())
def LISt(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	s = input()
	t = input()
	if len(set(s)&set(t)) != len(set(t)):
		print(-1)
		exit()

	dic = defaultdict(list)
	for i, char in enumerate(s):  # 文字列が出現する位置のリスト
		dic[char].append(i)
	
	loop = 0
	index = -1
	for i in range(len(t)):
		idx = bisect_left(dic[t[i]], index)  # リストの何個目とヒットするか
		if idx != len(dic[t[i]]):
			index = dic[t[i]][idx] + 1
		else:  # idx = |dic[t[i]]| -> もうヒットする箇所がないので次のループ
			loop += 1
			index = -1
			idx = bisect_left(dic[t[i]], index)
			index = dic[t[i]][idx] + 1

	print(len(s)*loop+index)

if __name__ == '__main__':
	main()


Measured memory_bytes: 18032
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	R := sc.NextFloat()

	fmt.Println(2 * R * math.Pi)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1756
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(ReadLine());
        }

        public static long[] Reads()
        {
            return ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x,long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();         
            var a = Reads();
            var ans = new long[(long)Math.Pow(10, 6)];
            var l = 5*(long)Math.Pow(10, 5);
            var r = 5*(long)Math.Pow(10, 5)-1;
            for (int i = 0; i < n; i++)
            {
                if (i%2 == 0)
                {
                    ans[l] = a[i];
                    l++;
                }
                else
                {
                    ans[r] = a[i];
                    r--;
                }
            }
            if (n % 2 != 0)
            {
                for (long i = l - 1; i > r; i--)
                {
                    Write(ans[i]);
                    Write(" ");
                }
                WriteLine();
            }
            else
            {
                for (long i = r+1; i < l; i++)
                {
                    Write(ans[i]);
                    Write(" ");
                }
                WriteLine();
            }

            

            Console.Out.Flush();
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll h,w,n;
    cin>>h>>w>>n;
    Vec a(n);
    rep(i,n)cin>>a[i];
    VV g(h,Vec(w));

    ll now = 0;
    ll cnt = 0;

    rep(i,h){
        rep(j,w){
            cnt++;
            if(i%2==0){
                g[i][j] = now;
            }else{
                g[i][w-1-j] = now;
            }
            if(cnt>=a[now]){
                now++;
                cnt = 0;
            }
        }
    }

    rep(i,h){
        rep(j,w){
            cout<<g[i][j]+1<<" ";
        }
        cout<<endl;
    }
    return  0;
}


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

using namespace std ;

const long long mod = 1e9 + 7ll ;
const int MAX = 2e5 + 10 ;

long long arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	long long sum = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>arr[i] ;
		sum += arr[i] ;
	}
	sum %= mod ;
	long long ans = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		sum = (sum - arr[i] + mod) % mod ;
		long long x = (arr[i] * sum) % mod ;
		ans = (ans + x) % mod ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 5208
function Main(input) {
    var lines = input.split("\n").map(function(value) { return value - 0; });
    var N = lines.shift() - 0;
    var max = Math.max(...lines);
    var total = 0;
    lines.forEach(function(value) {
        if (max == value) {
            total += value / 2;
            max = 0;
        } else {
            total += value;
        }
    });
    
    console.log(total);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  ll n = SZ(s);
  ll ans = 0, c = 0;
  REP(i, n) {
    if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
      c++;
    } else {
      c = 0;
    }
    ans = max(ans, c);
  }
  cout << ans << endl;
}

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

#define N 100000

typedef struct que{
  char name[10];
  int num;
}que;

int main(void){
  int i,n,q,sum=0,head,tail;
  que Q[N];

  scanf("%d %d",&n,&q);
  if(n>N||n<=0) exit(1);

    

  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].num);
  }

  head=1;
  tail=n+1;

  while(head!=tail){
    if(Q[head].num<=q && Q[head].num!=0){
      sum+=Q[head].num;
      printf("%s ",Q[head].name);
      printf("%d\n",sum);
      if(head==N-1) head=0;
      head++;
      
    }
    else {
      Q[head].num-=q;
      sum+=q;
      Q[tail]=Q[head];
      if(head==N-1) head=0;
      if(tail==N-1) tail=0;
      tail++;
      head++;
	}
  }

  
  return 0;
}

Measured memory_bytes: 2160
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>

#define N 300005
#define M 8000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

int i,j,m,n,p,k,A[N];

int main()
{
		scanf("%d",&n);
		for (i=1;i<=n;++i) scanf("%d",&A[i]);
		long long l=2,r=2;
		for (i=n;i>=1;--i)
		{
				long long L=(l+A[i]-1)/A[i]*A[i],R=r/A[i]*A[i];
				if (L>R) 
				{
						puts("-1");	
						return 0;
				}
				R+=A[i]-1;
				l=L;r=R;
		}
		cout<<l<<' '<<r<<endl;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

using Bs = bitset<26000>;
Bs dp[81][81];
constexpr int sht = 12801;

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

    int H, W;
    cin >> H >> W;
    vector<Vi> A(H, Vi(W)), B(H, Vi(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> B[i][j];
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            A[i][j] = abs(A[i][j] - B[i][j]);
        }
    }

    dp[0][0].set(A[0][0] + sht);
    dp[0][0].set(-A[0][0] + sht);
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            if (h - 1 >= 0) {
                dp[h][w] |= dp[h - 1][w] << A[h][w];
                dp[h][w] |= dp[h - 1][w] >> A[h][w];
            }
            if (w - 1 >= 0) {
                dp[h][w] |= dp[h][w - 1] << A[h][w];
                dp[h][w] |= dp[h][w - 1] >> A[h][w];
            }
        }
    }

    int ans = I_INF;
    for (int i = 0; i < 26000; i++) {
        if (dp[H - 1][W - 1][i]) {
            ans = min(ans, abs(i - sht));
        }
    }

    cout << ans << endl;

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int X,Y,Z,K;
    cin>>X>>Y>>Z>>K;
    vector<ll> A(X),B(Y),C(Z);
    REP(i,X) cin>>A[i];
    REP(i,Y) cin>>B[i];
    REP(i,Z) cin>>C[i];
    sort(ALL(A),greater<ll>());
    sort(ALL(B),greater<ll>());
    sort(ALL(C),greater<ll>());

    vector<ll> temp;
    REP(i,X) {
        REP(j,Y) {
            temp.pb(A[i] + B[j]);
        }
    }
    sort(ALL(temp),greater<ll>());

    vector<ll> ans;
    REP(i,min(K,X*Y)) {
        REP(j,Z) {
            ans.pb(temp[i] + C[j]);
        }
    }
    sort(ALL(ans),greater<ll>());

    REP(i,K) {
        cout<<ans[i]<<endl;
    }
    return 0;
}

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

using namespace std;

struct Edge {
	int to, cost;
};

int main() {
	int N, M; cin >> N >> M;
	vector<int> cnt(N, 0);
	vector<int> dist(N, 0);
	vector< vector<Edge> > G(N);
	for (int i = 0; i < M; ++i) {
		int a, b, c; cin >> a >> b >> c;
		G[a].push_back( (Edge){b, c} );
		cnt[b]++;
	}
	queue<int> Q; Q.push(0);
	while ( !Q.empty() ) {
		int v = Q.front(); Q.pop();
		assert(cnt[v] == 0);
		for (int i = 0; i < G[v].size(); ++i) {
			Edge& e = G[v][i];
			dist[e.to] = max(dist[e.to], dist[v]+e.cost);
			cnt[e.to]--;
			if (cnt[e.to] == 0) {
				Q.push(e.to);
			}
		}
	}
	cout << dist[N-1] << endl;
}

Measured memory_bytes: 1240
#include <tuple>
#include <vector>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
using ll	= long long;
using ull	= unsigned long long;
using ld	= long double;
using pii	= pair<int,int>;
using pll	= pair<ll,ll>;
using vi	= vector<int>;
using vb	= vector<bool>;
using vc	= vector<char>;
using vvi	= vector<vi>;
using vvb	= vector<vb>;
using vpii	= vector<pii>;
using vpll	= vector<pll>;
using vll	= vector<ll>;
using vull	= vector<ull>;
#define ever (;;)
#define f first
#define s second
#define pb emplace_back
#define sz size()
#define graph vector<vertex>
#define deg(X) (int)G[X].e.size()
#define INF 1234567890
#define INFll 2000000000000000000
#define maxe(X, Y) if((Y) > (X)) (X) = (Y)
#define mine(X, Y) if((Y) < (X)) (X) = (Y)
#define rep(i, begin, end) for(__typeof(end) i = (begin); i < (end); ++i)
#define repr(i, begin, end) for(__typeof(end) i = (begin)-1; i >= (end); --i)
#define bend(X) X.begin(), X.end()
pii operator+(const pii& A, const pii& B) { return {A.f+B.f, A.s+B.s}; }
pii operator-(const pii& A, const pii& B) { return {A.f-B.f, A.s-B.s}; }
pii operator-(const pii& A) { return {-A.f, -A.s}; }

//
// END OF DEFINES
//

int n, k;
vi T, DP;

bool in() {
	scanf("%d %d", &n, &k);
	T.resize(n);
	DP.resize(n, INF);
	DP[0] = 0;
	rep(i, 0, n)
		scanf("%d", &T[i]);
	
	return true;
}

ll solve() {
	rep(i, 1, n)
		rep(j, 1, k+1)
			if(i-j >= 0)
				mine(DP[i], DP[i-j]+abs(T[i]-T[i-j]));
	return DP[n-1];
	
	return -INF;
}

int main() {
	int noOfTests = 1;
	//scanf("%d", &noOfTests);
	
	while(noOfTests --> 0) {
		if(!in()) {
			printf("popsute wejscie\n");
			continue;
		}
		ll result = solve();
		if(result == ll(-'t'))
			printf("TAK\n");
		else if(result == ll(-'n'))
			printf("NIE\n");
		else if(result != -INF)
			printf("%lld\n", result);
	}
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<string> v;
	for (int i = 0; i < N; i++) {
		string w;
		cin >> w;
		if (!i) {
			v.push_back(w);
			continue;
		}

		if (count(v.begin(), v.end(), w)) {
			cout << "No" << endl;
			return 0;
		}

		string l = v.back();
		if (l.back()!=w.front()) {
			cout << "No" << endl;
			return 0;
		}

		v.push_back(w);
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

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

	cout << r * r*  3 << endl;
	
	return 0;
}

Measured memory_bytes: 3632
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = head . words
printer = unlines . (:[])

solver ws =
  if last ws == 's'
  then ws ++ "es"
  else ws ++ "s"

Measured memory_bytes: 3988
n = gets.to_i
c = Array.new(n, 0)
s = Array.new(n, 0)
f = Array.new(n, 0)

(n - 1).times do |i|
  ct, st, ft = gets.chomp.split.map(&:to_i)
  c[i] = ct
  s[i] = st
  f[i] = ft
end

n.times do |i|
  res = 0
  i.step(n - 2) do |j|
    if j == i
      res += s[j]
    elsif res < s[j]
      res = s[j]
    else
      res += (f[j] - res) % f[j]
    end
    res += c[j]
  end
  puts res
end

Measured memory_bytes: 14264
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        boolean debug = false;
        if (debug == false) {
            return;
        }
        System.out.println(str);
    }

    public static class Edge {
        int u;
        int v;
        int w;

        public Edge(int u, int v, int w) {
            this.u = u;
            this.v = v;
            this.w = w;

        }
    }
    public static class Node {
        List<Edge> edge = new LinkedList<>();
    }

    public static void main(String[] args) {

        int N;
        Node[] node;
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            node = new Node[N];
            for (int i = 0; i < N; i++) {
                node[i] = new Node();
            }
            for (int i = 0; i < N - 1; i++) {
                int u = sc.nextInt();
                int v = sc.nextInt();
                int w = sc.nextInt();
                Edge e = new Edge(u, v, w);
                node[u-1].edge.add(e);
                node[v-1].edge.add(e);
            }
        }
        int[] distans = new int[N];
        HashSet<Edge> visited = new HashSet<>();
        Deque<Integer> queue = new LinkedList<>();
        queue.push(1);
        distans[0] = 0;
        Integer target;
        while((target = queue.pollFirst()) != null){
            List<Edge> list = node[target -1].edge;
            for(Edge e : list){
                if(visited.contains(e)){
                    continue;
                }else{
                    int d = (distans[target-1] + e.w) %2;
                    int i;
                    if(e.u != target ){
                        i = e.u;
                    }else{
                        i = e.v;
                    }
                    queue.addLast(i);
                    distans[i  -1] = d;
                    visited.add(e);
                }
            }
        }
        for(int i : distans){
            System.out.println(i%2);
        }
    }


}


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

void Main()
{
  int X,N; cin >> X >> N;
  vector<int> p(N);
  set<int> se;
  rep(i,N) {cin >> p[i]; se.insert(p[i]);}
  int kurabe = X; int sabun = 0;
  while (true) {
    if (se.find(X-sabun) == se.end()) {cout << X-sabun << endl; return;}
    else if (se.find(X+sabun) == se.end()) {cout << X+sabun << endl; return;}
    sabun++;
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 3660
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    N,P=MI()
    S=input()
    
    if P==2 or P==5:
        ans=0
        for i in range(N):
            if int(S[i])%P==0:
                ans+=i+1
                
        print(ans)
        exit()
    
    
    
    from collections import defaultdict
    dd = defaultdict(int)
    
    now=0
    dd[0]=1
    for i in range(N):
        now=now+(pow(10,i,P)*int(S[-1-i]))
        now%=P
        dd[now]+=1
        
    ans=0
    for k,v in dd.items():
        ans+=(v*(v-1))//2
        
    print(ans)
    

main()


Measured memory_bytes: 75080
// Aizu Vol-10 1019: Vampirish Night
// 2017.8.17 bal4u@uu

#include <stdio.h>

int s[102], t[102];

int main()
{
	int n, k;
	int i, j, b;

	while (scanf("%d%d", &n, &k) == 2 && n && k) {
		for (i = 0; i < k; i++) scanf("%d", s + i), t[i] = 0;
		for (j = 0; j < n; j++)
			for (i = 0; i < k; i++) { scanf("%d", &b); t[i] += b; }
		for (i = 0; i < k; i++) if (t[i] > s[i]) break;
		puts(i == k ? "Yes" : "No");
	}
	return 0;
}

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

int main()
{
	int n,k;
	cin >> n >> k;
	if(k < n)
	{
		vector<int> mons;
		long long suma=0;
		for(int i =0; i < n; ++i)
		{
			long long h; cin >> h;
			mons.push_back(h);
			
		}
		sort(mons.begin(), mons.end());
		for(int i =0; i < n-k; ++i)
		{
			suma+=mons[i];
		}
		cout << suma;
		
	}else{cout << 0;}
	
	

  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
#include <numeric>
#include <set>
using namespace std;

#define ll long long
#define ld long double
#define pi 3.14159265359;

// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// vector 要素の総和算出
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// vector 最大値( return ite )
#define _max_element(v) max_element(v.begin(),v.end())
// vector 最大値が格納されている要素値
#define _max_element_number(v) distance(v.begin(),max_element(v.begin(),v.end()))
// 特定コンテナの中から特定の値をカウントする
#define _count(v,value) count(v.begin(),v.end(),value)

//set<uint32_t> member;	// 重複するデータを保持する事はできない member.insert(2) member.insert(2) ⇒ member.count(2)は1
//                                                              member.emplace(2)とかも同じ
//multiset<uint32_t> v;	// 重複するデータも保持する事はできる   member.insert(2) member.insert(2) ⇒ member.count(2)は2

// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値 ex) 3.30303 ⇒ 4
#define _ceil(x) ceil(x)
// 指定された要素以上の値が現れる最初の位置のイテレータを取得する
#define _lower_bound(v,min) lower_bound(v.begin(), v.end(), min)
// 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
#define _upper_bound(v,min) upper_bound(v.begin(), v.end(), min)

// 順列 n個の数が与えられる
// 0,1,2,...,n-1
// 全ての並べ方を1行ごとに出力する
// ex 0 1 2 / 0 2 1 / 1 0 2 / 1 2 0 / 2 0 1 / 2 1 0
#define _next_permutation(v) do {   \
	for (auto num : v) {            \
		printf("%d ", num);         \
	}                               \
	printf("\n");                   \
} while (next_permutation(v.begin(), v.end()))

// 絶対値
static int32_t _abs(const int32_t x) { return  (x > 0 ? x : -x); }
// 最大公約数
static int gcd(int a, int b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}
// 最小公倍数
static int lcm(int a, int b) { return a * b / gcd(a, b); }
// 多次元 std::vector 生成
template<class T>
vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
// ex) auto dp = make_vec<uint64_t>(SIZE + 1, 2, 2);

// UINT32_MAX
// 4294967295 ≒ 4 * 1e9 


/*

*/
// ABC 162 C
// https://atcoder.jp/contests/abc162/tasks/abc162_c
int main()
{
	uint32_t n;
	cin >> n;

	uint64_t result = 0;
	for (uint32_t i = 1; i <= n; i++) {
		for (uint32_t j = 1; j <= n; j++) {
			for (uint32_t k = 1; k <= n; k++) {

				result += gcd(gcd(i, j), k);

			}

		}

	}
	printf("%llu\n", result);
	return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,wt;
    cin>>n>>wt;
    long long w[n],val[n];
    long long sum=0;
    for(int i=0;i<n;i++){
        cin>>w[i]>>val[i];
        sum+=val[i];
    }
    long long dp[2][sum+1];
    for(int i=0;i<2;i++)
    {
        for(int j=0;j<sum+1;j++){
            dp[i][j]=INT_MAX;
        }
    }
    dp[0][0]=0;
    for(long long i=1;i<n+1;i++){
        for(long long j=0;j<sum+1;j++){
            if(val[i-1]<=j){
                dp[1][j]=min(dp[0][j],w[i-1]+dp[0][j-val[i-1]]);
            }
            else
                dp[1][j]=dp[0][j];
        }
        for(int k=0;k<sum+1;k++){
            //cout<<setw(10)<<dp[1][k]<<" ";
            dp[0][k]=dp[1][k];
            dp[1][k]=INT_MAX;
        }
    }
    long long ans=INT_MIN;
    for(long long i=0;i<=sum;i++){
        if(dp[0][i]<=wt)
            ans=max(ans,i);

    }
    cout<<ans<<endl;
}


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

void fun(){
    int n , k;
    cin>>n>>k;
    vector<int>  arr(n+1 , 0);
    while(k--){
        int d;
        cin>>d;
        while(d--){
            int c;
            cin>>c;
            arr[c] += 1;
        }
    }
    int count = 0;
    for(int i=1;i<=n;i++){
        if(arr[i]==0){
            count+=1;
        }
    }
    cout<<count<<endl;
    return;
}


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

Measured memory_bytes: 3604
#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;}

int main(){
    int n;
    cin >> n;
    vi a(3*n);
    rep(i, 3*n){
        cin >> a[i];
    }
    Sort(a);
    ll ans = 0;
    REP(i, n+1){
        ans += a.at(3*n-2*i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
    ll n;
    string s;
    cin >> n;
    cin >> s;

    string ans;

    char bef = -1;
    for (ll i = 0; i < n; i++){
        if (bef != s[i]){
            bef = s[i];
            ans+=bef;
        }
    }
    

    cout << ans.size();


}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n, k;
    string s, s1;
    cin >> n >> s >> k;

    for (int i=0; i<n; i++){
        if (s[i]==s[k-1]){
            s1 = s1+s[i];
        }
        else{
            s1 = s1+'*';
        }
    }
    cout << s1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc 	   = new Scanner(System.in);
		String 	string = sc.next();
		int i=0;	boolean isNOTfound=false;
		
		int[]  count = new int[26];
		char[] alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n',
						  'o','p','q','r','s','t','u','v','w','x','y','z'};
		char[] chars    = string.toCharArray();
		for(i=0;i<chars.length;i++) 
			count[chars[i]-97] ++; 
		for(i=0;i<count.length;i++)
			if(count[i]==0) { isNOTfound = true; break; }
		if(isNOTfound)	System.out.println(alphabet[i]); 
		else 			System.out.println("None");
	}

}


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

int main(){

    int n;
    cin >> n;
    int d;
    cin >> d;
    d*=2;
    d++;
    int ans=n/d;
    if(n%d!=0)ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
   
   string s;
   cin >> s;
   
   if(s=="Sunny"){
      cout << "Cloudy\n";
   }else if(s == "Cloudy"){
      cout << "Rainy\n";
   }else{
      cout << "Sunny\n";
   }
   
   
   
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fr(i,k,n) for(int i=k;i<n;i++)
#define read(x) cin>>x
#define ll long long int
#define mod 1000000007 
#define print(x) cout<<x<<endl
#define pb(x) push_back(x)
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
int main() { 
    fastIO;
     int t=1,h,w ;
     //cin>>t;
     while(t--){
         cin>>h>>w ;
       
      vector<vector<ll>>dp(h,vector<ll>(w,0));
         vector<vector<char>>path(h,vector<char>(w ));
      //cin>>path[0][0]
       
       dp[0][0]=1;
        
       fr(i,0,h)
         fr(j,0,w)
       {cin>>path[i][j];
        if(i==0 && j==0)
          continue;
        if((i*j) ==0)
        { if(path[i][j]=='#')
          dp[i][j]=0;
        else  if(j==0)
         dp[i][j]= dp[i-1][j];
         else
           dp[i][j]=dp[i][j-1];
        }
       }
      fr(i,1,h){
         
         for(int j= 1;j<w;j++){
          
          if(path[i][j]=='#')
            dp[i][j]=0;
          else
            dp[i][j]+=dp[i][j-1]+dp[i-1][j];
           dp[i][j]%=mod;
          
        }}
      cout<<dp[h-1][w-1]% mod<<endl;}
	return 0;
}


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

int main() {
    ll n, a, b, cur_max = 0, ans = 0;
    cin >> n;
    for(int i = 0; i< n; i++) {
        cin >> a >> b;
        if (a > cur_max) {
            cur_max = a;
            ans = a + b;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
s = list(input())
if (s[0] == s[1] and s[2] == s[3] and s[0] != s[2]) or (s[0] == s[2] and s[1] == s[3] and s[0] != s[1]) or (s[0] == s[3] and s[1] == s[2] and s[0] != s[1]):
    print("Yes") 
else:
    print("No") 

Measured memory_bytes: 38384