akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String str[] = br.readLine().split("\\s+");
			int array[] = new int[str.length];

			for(int i = 0; i < str.length; i++){
				array[i] = Integer.parseInt(str[i]);
			}

			Dice dice = new Dice();
			dice.setNumber(array[0], array[1], array[2], array[3], array[4], array[5]);


			str = br.readLine().split("\\s+");
			for(int i = 0; i < str.length; i++){
				array[i] = Integer.parseInt(str[i]);
			}
			Dice dice2 = new Dice();
			dice2.setNumber(array[0], array[1], array[2], array[3], array[4], array[5]);

			if(dice.equals(dice2)){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

class Dice{

	private int number[];
	private int work[];
	private final String order = "NNNNWNNNWNNNENNNENNNWNNN";

	Dice(){
		number = new int[6];
		work = new int[6];
	}


	public void roll(char dst){
		for(int i = 0; i < 6; i++) work[i] = number[i];
		switch(dst){
		case 'E':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'N':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'S':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'W':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		}
	};

	public int getTop(){
		return number[0];
	}

	public void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

	public boolean equals(Object object){

		if(object == this)return true;
		if(object == null)return false;
		if(!(object instanceof Dice))return false;

		Dice another = (Dice)object;

		boolean FLG;

		for(int i = 0; i < order.length(); i++){
			roll(order.charAt(i));
			FLG = true;
			for(int k = 0; k < 6; k++){
				if(this.number[k] != another.number[k]){
					FLG = false;
					break;
				}
			}
			if(FLG)return true;
		}

		return false;
	}
};



Measured memory_bytes: 24556
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

signed main() {
  int N; cin >> N;
  vector<int> A(N); cin >> A;
  sort(A.begin(),A.end());
  if (A[0] == 0) {
    cout << 0 << endl;
    return 0;
  }

  int v = 1;
  int limit = 1e18;
  for (int a : A) {
    if (limit/v < a) {
      cout << -1 << endl;
      return 0;
    }
    v *= a;
  }
  cout << v << endl;
  return 0;
}


Measured memory_bytes: 4020
ok=True
okay=True
a,b=map(int,input().split())
val=[]
for i in range(b):
    c,d=map(int,input().split())
    val.append([c,d])
    if c==1 and d==0:
        okay=False
val=sorted(val)
for i in range(b-1):
    if val[i][0]==val[i+1][0] and val[i][1]!=val[i+1][1]:
        ok=False
        print(-1)
        break
if ok:
    e=[0 for i in range(a)]
    strr=""
    for i in val:
        e[i[0]-1]=i[1]
    if e[0]==0:
        if e==[0]:
            print(0)
        else:
            if okay:
                for i in range(1,a):
                    strr+=str(e[i])
                strr="1"+strr
                print(strr)
            else:
                print(-1)
    else:
        for i in range(a):
            strr+=str(e[i])
        print(int(strr))

Measured memory_bytes: 3064
A, B, K = tuple(map(int, input().split()))
for i in range(K):
    if i % 2 == 0:
        if A % 2 != 0:
            A -= 1
        B += A // 2
        A = A // 2
    else:
        if B % 2 != 0:
            B -= 1
        A += B // 2
        B = B // 2
print(A, B)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int MAX=1e6+10;
const int modn=1e9+7;
typedef long long ll ;
#define endl '\n'
#define cwk     freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout)
using namespace std;
ll fastpow(ll a,ll n){
    ll res=1;
    while(n){
        if(n&1){
            res=(res*a)%modn;
        }
        a=(a*a)%modn;
        n>>=1;
    }
    return res;
}
ll x,k,d;
void slove(){
    cin>>x>>k>>d;
    ll now;
    ll ans=abs(x)/d;
    if(k<ans){
        if(x>0)
            cout<<x-d*k;
        else cout<<-d*k-x;
        return;
    }
    now=abs(x)-abs(x)/d*d;
    k-=ans;
    k%=2;
    if(k==0) cout<<now;
    else cout<<d-now;

}
int main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //cwk;
    int _=1;
    //cin>>_;
    while(_--){
        slove();
    }
    return 0;
}

Measured memory_bytes: 3644
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	trees := make([]Tree, n)
	depth := make([]int, n)
	height := make([]int, n)
	siblings := make([]int, n)

	for i := 0; i < n; i++ {
		trees[i].p = -1
		trees[i].l = -1
		trees[i].r = -1
		siblings[i] = -1
	}
	for i := 0; i < n; i++ {
		id := getNextInt(scanner)
		trees[id].l = getNextInt(scanner)
		trees[id].r = getNextInt(scanner)
		if trees[id].l != -1 {
			trees[trees[id].l].p = id
		}
		if trees[id].r != -1 {
			trees[trees[id].r].p = id
		}
	}

	for i := 0; i < n; i++ {
		if trees[i].p == -1 {
			setDepth(depth, trees, i, 0)
			setSiblings(siblings, trees, i)
			setHeight(height, trees, i)
			break
		}
	}

	format := "node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s"

	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, fmt.Sprintf(format, i, trees[i].p, siblings[i], getDegrees(trees[i]), depth[i], height[i], getType(trees[i])))
	}

	writer.Flush()
}

type Tree struct {
	p int
	l int
	r int
}

func setDepth(depth []int, trees []Tree, r, d int) {
	depth[r] = d
	if trees[r].l != -1 {
		setDepth(depth, trees, trees[r].l, d+1)
	}
	if trees[r].r != -1 {
		setDepth(depth, trees, trees[r].r, d+1)
	}
}

func setHeight(height []int, trees []Tree, r int) int {
	if r == -1 {
		return -1
	}
	max := 0
	h := setHeight(height, trees, trees[r].l)
	if max < h+1 {
		max = h + 1
	}
	h = setHeight(height, trees, trees[r].r)
	if max < h+1 {
		max = h + 1
	}
	height[r] = max
	return max
}

func setSiblings(siblings []int, trees []Tree, r int) {
	if trees[r].l != -1 {
		siblings[trees[r].l] = trees[r].r
		setSiblings(siblings, trees, trees[r].l)
	}
	if trees[r].r != -1 {
		siblings[trees[r].r] = trees[r].l
		setSiblings(siblings, trees, trees[r].r)
	}
}

func getDegrees(tree Tree) int {
	degree := 0
	if tree.l != -1 {
		degree++
	}
	if tree.r != -1 {
		degree++
	}
	return degree
}

func getType(tree Tree) string {
	if tree.p == -1 {
		return "root"
	}
	if tree.l == -1 && tree.r == -1 {
		return "leaf"
	}
	return "internal node"
}



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

vector<int> A;

int main(void){
  int N ,M;
  cin >> N >> M;
  A = vector<int>(M+10);
  for(int i=0;i<=M;i++){
    A[i] = 0;
  }

  int k;
  for(int i=0;i<N;i++){
    cin >> k;
    for(int j=0;j<k;j++){
      int f;
      cin >> f;
      A[f] += 1;
    }
  }
  int ans = 0;
  for(int i=0;i<=M;i++){
    if(A[i] == N){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




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

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    from bisect import bisect

    n, x = map(int, input().split())
    ls = list(map(int, input().split()))
    dist = [0]

    for i in range(1, n + 1):
        dist.append(dist[i - 1] + ls[i - 1])

    print(bisect(dist, x))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    a = (a + 11) % 13;
    b = (b + 11) % 13;
    if(a == b) cout << "Draw" << endl;
    else if(a > b) cout << "Alice" << endl;
    else cout << "Bob" << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) for(auto (a): v )   cerr << a << endl
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl


void func() {
  LL N;
  cin >> N;
  vector<LL> T(N);
  vector<LL> A(N);

  REP(i, N) {
    cin >> T[i];
    cin >> A[i];
  }

  LL t = T[0];
  LL a = A[0];
  for(LL i=1; i<N; i++){
    LL aplhaT = (LL)ceil(t / (LD)T[i]);
    LL aplhaA = (LL)ceil(a / (LD)A[i]);
    LL alpha = max(aplhaT, aplhaA);
    //fprintf(stderr, "t=%lld, a=%lld, alpha=%lld\n", t, a, alpha);
    t = T[i]*alpha;
    a = A[i] * alpha;
  }
  cout << t + a;

}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        sc.close();
        if(s[2] == s[3] && s[4] == s[5]){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        
    }
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(si, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

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


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];

int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
  int arr[3];
rep(i, 0, 3) cin>>arr[i];
sort(arr, arr+3);
cout<<(arr[0] + arr[1])<<endl;
  return 0;
}


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


int main() {
  int n;
  cin >> n;
  std::vector<int> x(n),y(n),h(n);
  rep(i,n) cin >> x[i] >> y[i] >> h[i];

  rep(posX,101) rep(posY,101) {
    int needH = -1;
    rep(i,n) {
      if (h[i] > 0) {
        int tmp = h[i] + abs(posX-x[i]) + abs(posY-y[i]);
        if (needH == -1) needH = tmp;
        else {
          if (needH != tmp) {
            needH = -2;
            break;
          }
        }
      }
    }
    if (needH == -2) continue;
    rep(i,n) {
      if (h[i] == 0) {
        int dist = abs(posX-x[i]) + abs(posY-y[i]);
        if (needH > dist) {
          needH = -2;
          break;
        }
      }
    }
    if (needH == -2) continue;
    cout << posX << " " << posY << " " << needH << endl;
    return 0;
  }
}


Measured memory_bytes: 3600
#include <stdio.h>

int main(void){
	int n;
	long long int ans=0;
	scanf("%d",&n);
	char s[n+10];
	scanf("%s",s);
	int countr=0;
	int countg=0;
	int countb=0;
	for(int i=0; i<n; i++){
		if(s[i]=='R'){
			countr++;
		}
		if(s[i]=='G'){
			countg++;
		}
		if(s[i]=='B'){
			countb++;
		}
	}
	ans=countr*countg*countb;
	int i=0;
	int j=1;
	int k=2;
	while(i<=n-3){
		if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k]){
			ans--;
		}
		j++;
		k+=2;
		if(k>n-1){
			i++;
			j=i+1;
			k=i+2;
		}
	}

	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int N;
  cin >> N;
  vector<int> D1(N), D2(N);
  for (int i=0; i<N; i++) cin >> D1[i] >> D2[i];
  for (int i=0; i<N-2; i++) {
    if (D1[i]==D2[i]&&D1[i+1]==D2[i+1]&&D1[i+2]==D2[i+2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3600
import sys
k = int(input())
keta = 0
for x in range(1,11):
    memo_ls = [[0 if (i != 0 or j == 0) else 1 for j in range(10)] for i in range(x)]
    for i in range(1, x):
        for j in range(10):
            memo_ls[i][j] = memo_ls[i-1][j]
            if j > 0:
                memo_ls[i][j] += memo_ls[i-1][j-1]
            if j < 9:
                memo_ls[i][j] += memo_ls[i-1][j+1]
    _sum = sum(memo_ls[-1])
    if _sum >= k:
        keta = x
        break
    else:
        k -= _sum
res = ""
cur_k = k
for start in range(keta, 0, -1):
    last_k = cur_k
    if res == "":
        ls = list(range(1, 10))
    else:
        if 9 > int(res[-1]) > 0:
            ls = [int(res[-1]) - 1, int(res[-1]), int(res[-1]) + 1]
        elif int(res[-1]) > 0:
            ls = [int(res[-1]) - 1, int(res[-1])]
        else:
            ls = [int(res[-1]), int(res[-1]) + 1]
    for i in ls:
        memo_ls = [[0 for i in range(10)] for j in range(start)]
        memo_ls[0][i] = 1
        for ind_keta in range(1, start):
            for j in range(10):
                memo_ls[ind_keta][j] = memo_ls[ind_keta - 1][j]
                if j > 0:
                    memo_ls[ind_keta][j] += memo_ls[ind_keta - 1][j - 1]
                if j < 9:
                    memo_ls[ind_keta][j] += memo_ls[ind_keta - 1][j + 1]
        if sum(memo_ls[-1]) >= cur_k:
            res += str(i)
            break
        else:
            if i == 9:
                res += "0"
                cur_k = last_k
            cur_k -= sum(memo_ls[-1])
print(res)

Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;


struct mise{
    string name;
    int cost;
    int idx;
    mise(string str,int cost,int idx){
        this->name=str;
        this->cost=cost;
        this->idx=idx;
    }

    bool operator < (const mise &s)const{
        return (name != s.name ? name <s.name : cost>s.cost);
    }


};

vector<mise> arr;
signed main(){
    int n;
    cin>>n;
    rep(i,n){
        string str;
        int a,b;
        cin>>str;
        cin>>a;
        arr.push_back(mise(str,a,i+1));

    }
    sort(all(arr));
    rep(i,n){
        cout<<arr[i].idx<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] - c[i] > 0) {
      ans += v[i] - c[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>

#define p(a, b) pair<a, b>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<vector<int>> v(2,vector<int>());
    for (int i = 0;i < 2;i++) {
        for (int j = 0;j < n;j++) {
            int x;
            cin >> x;
            v[i].push_back(x);
        }
    }
    vector<vector<int>> res(2,vector<int>(n,0));
    res[0][0] = v[0][0];
    res[1][0] = v[0][0] + v[1][0];
    for (int i = 1;i < n;i++) {
        res[0][i] = res[0][i-1] + v[0][i];
    }
    for (int i = 1;i < n;i++) {
        res[1][i] = max(res[0][i],res[1][i-1]) + v[1][i];
    }
    cout << res[1][n-1];
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

const int MAX_N = 105;
const int MAX_K = 100005;

int n,k,a[MAX_N];
bool dp[MAX_K][2];

int main()
{
	scanf("%d %d",&n,&k);
	for (int i=1; i<=n; i++)
		scanf("%d",a+i);
	for (int s=1; s<=k; s++)
		for (int p=0; p<2; p++)
		{
			dp[s][p]=false;
			for (int i=1; i<=n; i++)
				if (s-a[i]>=0)
					dp[s][p]|=!dp[s-a[i]][p^1];
		}
	printf("%s\n",dp[k][0]?"First":"Second");
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  vector<int> v(5);
  for (int i = 0; i < 5; i++) {
    cin >> v[i];
  }
  sort(begin(v), end(v), [](auto a, auto b){return a % 10 < b % 10;});
  int ans = 0;
  int r = 10;
  for (int i = 0; i < 5; i++) {
    if (v[i] % 10 != 0) {
      r = min(r, v[i] % 10);
    }
    ans += (v[i] + 9) / 10 * 10;
  }
  if (r != 10) {
    ans = ans - 10 + r;
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;

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

const ll mod = 1e9+7;

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

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

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

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

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

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

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

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



int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool t =true;
    string one="",two="";

    rep(i,q){
        int a;
        cin >> a;
        if(a==1){
            if(t){
                t=false;
            }else{
                t=true;
            }
        }else{
            int b;
            char c;
            cin >> b >> c;
            if((t&&b==1)||(!t&&b==2)){
                one+=c;
            }else{
                two+=c;
            }
        }
    }
    if(t){
        reverse(one);
        s=one+s+two;
    }else{
        reverse(s);
        reverse(two);
        s=two+s+one;
    }
    cout << s << endl;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    ll n, t, a;
    cin >> n >> t >> a;
    
    vector <double> h(n);
    vector <double> temp(n);
    vector <double> sub(n);
    double best = 10000.0;
    double dummy = 10000.0;
    ll ans = -1;
    for(int i=0; i<n; i++) {
        cin >> h[i];
        temp[i] = (double)t - h[i] * 0.006;
        sub[i] = abs((double)a - temp[i]);
        dummy = best;
        best = min(best, sub[i]);
        if (dummy != best) ans=i+1;
    }

    

    cout << ans;
    return 0;

}
    

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

int main() {
  int N,K,S=1;
  cin >> N>> K;
for(int i = 0;i<N;i++){
  if(2*S>S+K){
    S=S+K;
  }
  else{
    S=2*S;
  }
}
  cout<<S<<endl;
}



Measured memory_bytes: 256
# A
S = input()

flag = 0
if len(S)%2!=0:
    flag=1
else:
    for i in range(len(S)//2):
        if S[i*2:i*2+2] != "hi":
            flag = 1
            break

if flag==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
var
 a,b,n,k,i:longint;
function min(a,b:longint):longint;
begin
 if a<b then exit(a) else exit(b);
end;
begin
 readln(n,k); a:=1;
 for i:=1 to n do
  a:=a+min(a,k);
 write(a);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long b;
    while (cin >> b)
    {
        if (b == 0)
            return 0;
        vector<pair<long long, long long>> v;
        for (long long a = 1; a <= 100000; a++)
        {
            if (b <= a * (a - 1) / 2)
                continue;

            long long n = b - a * (a - 1) / 2;
            if (n % a == 0)
            {
                n /= a;
                v.push_back(make_pair(a,n));
            }
        }
        sort(v.rbegin(), v.rend());
        cout << v[0].second << " " << v[0].first << endl;
    }
}


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

int main(){
  int X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> p(A);
  for(int i=0;i<A;i++)  cin >> p.at(i);
  vector<int> q(B);
  for(int i=0;i<B;i++)  cin >> q.at(i);
  vector<int> r(C);
  for(int i=0;i<C;i++)  cin >> r.at(i);

  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  sort(q.begin(),q.end());
  reverse(q.begin(),q.end());
  sort(r.begin(),r.end());
  reverse(r.begin(),r.end());

  long long ans=0;
  priority_queue<int,vector<int>,greater<int>> pq;
  for(int i=0;i<X;i++){
    ans+=p.at(i);
    pq.push(p.at(i));
  }
  for(int i=0;i<Y;i++){
    ans+=q.at(i);
    pq.push(q.at(i));
  }
  int now=0;
  while(!pq.empty()){
    int xx=pq.top();
    pq.pop();
    if(xx>=r.at(now)) break;
    ans-=xx;
    ans+=r.at(now);
    now++;
    if(now>=C)  break;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2552
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    boolean[] isPrime = new boolean[X * 100];
    Arrays.fill(isPrime, true);
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i < isPrime.length; i++) {
      if (isPrime[i]) {
        if (i >= X) {
          System.out.println(i);
          return;
        }
        for (int j = 2 * i; j < isPrime.length; j += i) {
          isPrime[j] = false;
        }
      }
    }
  }
}


Measured memory_bytes: 32212
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

const MOD: usize = 1_000_000_007;
const MAX: usize = 510_000;
fn com_init(fac: &mut [usize], finv: &mut [usize], inv: &mut [usize]) {
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for i in 2..MAX {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

fn bin_coef(n: usize, k: usize, fac: &mut [usize], finv: &mut [usize], inv: &mut [usize]) -> usize {
    if k > n/2 {
        bin_coef(n-k, k, fac, finv, inv)
    } else {
        fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
    }
}


use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;
fn main() {
    input!{
        N: usize,
        h: [isize; N],
    }
    let mut dp = vec![0isize; N];
    dp[0] = 0;
    dp[1] = (h[1] - h[0]).abs();
    for ind in 2..N {
        dp[ind] = cmp::min(dp[ind-1] + (h[ind]-h[ind-1]).abs(), dp[ind-2] + (h[ind]-h[ind-2]).abs()); 
    }
    println!("{}", dp[N-1]);
}


Measured memory_bytes: 6396
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 

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


int r, c, k, dist[805][805];
char arr[805][805];


int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int x, y;
    cin>>r>>c>>k;
    for(int i=1;i<=r;i++){
    	cin>>(arr[i]+1);
    	for(int j=1;j<=c;j++){
    		if(arr[i][j] == 'S'){
    			x = i;	y = j;
    		}
    		dist[i][j] = MOD;
    	}
    }

    priority_queue<iii> pq;
    dist[x][y] = 0;
    pq.push(iii(0, ii(x, y)));
    while(!pq.empty()){

    	int x = pq.top().ss.ff, y = pq.top().ss.ss;
    	int d = -pq.top().ff;
    	pq.pop();

    	if(d > dist[x][y])	continue;

    	for(int i=x-1;i<=x+1;i++)
    		for(int j=y-1;j<=y+1;j++)
    			if(abs(i-x)+abs(j-y)==1 && i>=1&&i<=r&&j>=1&&j<=c && arr[i][j] != '#'){
    				int dd = d + 1;
    				if(dd < dist[i][j] && dd <= k){
    					dist[i][j] = dd;
    					pq.push(iii(-dd, ii(i, j)));
    				}
    			}
    }

// for(int i=1;i<=r;i++){
// 	for(int j=1;j<=c;j++)	cout<<dist[i][j]<<" ";cout<<endl;
// }cout<<endl;


	int ans = MOD;
	for(int i=1;i<=r;i++)
		ans = min(ans, min(dist[i][1], dist[i][c]));
	for(int j=1;j<=c;j++)
		ans = min(ans, min(dist[1][j], dist[r][j]));

	if(ans != MOD){
		ans = (ans + k-1)/k;
		cout<<ans;
		return 0;	
	}

	for(int i=1;i<=r;i++)
		for(int j=1;j<=c;j++)
			if(dist[i][j] != MOD){
				dist[i][j] = 0;
				pq.push(iii(-dist[i][j], ii(i, j)));
			}
	while(!pq.empty()){

    	int x = pq.top().ss.ff, y = pq.top().ss.ss;
    	int d = -pq.top().ff;
    	pq.pop();

    	if(d > dist[x][y])	continue;

    	for(int i=x-1;i<=x+1;i++)
    		for(int j=y-1;j<=y+1;j++)
    			if(abs(i-x)+abs(j-y)==1 && i>=1&&i<=r&&j>=1&&j<=c){
    				int dd = d + 1;
    				if(dd < dist[i][j]){
    					dist[i][j] = dd;
    					pq.push(iii(-dd, ii(i, j)));
    				}
    			}
    }


// for(int i=1;i<=r;i++){
// 	for(int j=1;j<=c;j++)	cout<<dist[i][j]<<" ";cout<<endl;
// }cout<<endl;

    for(int i=1;i<=r;i++)
		ans = min(ans, min(dist[i][1], dist[i][c]));
	for(int j=1;j<=c;j++)
		ans = min(ans, min(dist[1][j], dist[r][j]));
	cout<<(ans+k-1)/k+1;
    return 0;
}










Measured memory_bytes: 4348
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::vector;
using std::queue;
using std::priority_queue;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

ulli K;
ulli N=50;
ulli A[50], d;
int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);

	cin >> K;
	if(K == 0){
		N = 2;
		A[0] = 1;
		A[1] = 1;
	}else if(K <= 50){
		for(ulli i = 0; i < N; i++){
			if(i < K) A[i] = 50;
			else A[i] = 0;
		}
	}else{
		for(ulli i = 0; i < N; i++) A[i] = i;

		d = K%50;
		K /= 50;

		for(ulli i = 0; i < N; i++){
			A[i]+=K;
		}
		for(ulli i = 0; i < d; i++){
			for(ulli j = 0; j < N; j++){
				if(j == i) A[j]+=50;
				else A[j]--;
			}
		}
	}
	cout << N << "\n";
	for(ulli i = 0; i < N; i++){
		cout << A[i];
		if(i < N-1) cout << " ";
		else cout << "\n";
	}

  return 0;
}


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

public class Main {
	public static void solveTravelingAtCoDeer() throws IOException {
		String line;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		line = br.readLine();
		int n = Integer.parseInt(line);
		line = br.readLine();
		int a = 0;
		int b = 0;
		int d = 0;
		char si;
		for (int i = 0; i < n; i++) {
			si = line.charAt(i);
			if (si == '(') {
				d++;
			} else if (si == ')') {
				d--;
			}
			a = d;
			if (d < b)
				b = d;
		}
		br.close();
		String answer = "";
		for (int i = 0; i < -b; i++) {
			answer = answer + "(";
		}
		answer = answer + line + "";
		for (int i = 0; i < a - b; i++) {
			answer = answer + ")";
		}
		System.out.println(answer);
	}

	public static void main(String[] args) {
		try {
			solveTravelingAtCoDeer();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9)
        cout << a * b;
    else
        cout << -1;
  
    cout << endl;
    return 0;
};


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;


int main()
{
    int n;
    cin >> n;
    int f[n][10];
    ll p[n][11];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> f[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 11; j++){
            cin >> p[i][j];
        }
    }
    ll ans = -INF;
    for(int bit = 1; bit < (1<<10); bit++){
        ll tmp = 0;
        for(int i = 0; i < n; i++){
            int cnt = 0;
            for(int j = 0; j < 10; j++){
                if(f[i][j] == 1){
                    if(bit & (1 << j)) cnt++;
                }
            }
            tmp += p[i][cnt];
        }
        if(ans < tmp) ans = tmp;
    }
    cout << ans << endl;
}

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

int main(){
  
  string S;
  cin >> S;
  string ans ="No";
  if ( S[0] == S[1] ){
    if ( S[2] == S[3] && S[1] != S[2]) {
      ans = "Yes";
    }
  }
  else{
    if (S[0] == S[2] && S[1] == S[3]){
      ans = "Yes";
    }
    
    if (S[0] == S[3] && S[1] == S[2]){
      ans = "Yes";
    }
  }
  
  cout << ans << endl;
  return 0;
}
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define repi(i,a,n) for(int i = (int)a; i < (int)(n); i++)
#define ll long long

int main(void){
    int n,m;
    std::cin >> n>>m;
    int sum=0;
    rep(i,m){
        int t;
        std::cin >> t;
        sum+=t;
    }
    if(sum>n){
        std::cout << "-1" << std::endl;
    }else{
        std::cout << n-sum << std::endl;
    }
}

Measured memory_bytes: 3628
N = int(input())
L = [int(i) for i in input().split()]
sort_L = sorted(L,reverse=True)
p = []
for i,l in enumerate(sort_L):
    for j,m in enumerate(sort_L[i+1:]):
        for k,n in enumerate(sort_L[i+j+1:]):
            if l < m+n and l != m and m != n and l!=n:
                p.append([l,m,n])
print(len(p))

Measured memory_bytes: 25368
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>

const int maxn = 20;
const int maxs = (1 << 15) + 1;
const int inf = 0x3f3f3f3f;

int n, m;
int G[maxn][maxn];

int fs;
int f[maxs][maxn];
int g[maxs][maxn];

void checkmin(int &x,int y)
{
	if(y < x) x = y;
}
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1, a, b, c; i <= m; i++)
	{
		scanf("%d%d%d", &a, &b, &c);
		--a, --b;
		G[a][b] = G[b][a] = c;
	}

	fs = (1 << n) - 1;
	
	for(int S = 1; S <= fs; S++)
		for(int i = 0; i < n; i++)
		{
			if((S >> i) & 1) continue;
			
			for(int j = 0; j < n; j++)
				if((S >> j) & 1) g[S][i] += G[i][j];
		}
	
	memset(f, inf, sizeof(f));
	
	f[1][0] = 0;
	for(int S = 1; S <= fs; S++)
		for(int i = 0; i < n; i++)
			if((S >> i) & 1)
			{
				for(int s = (S - 1) & S; s; s = (s - 1) & S)
					if((s >> i) & 1)
					{
						int val = 0;
					
						for(int j = 0; j < n; j++)
							if(i != j && ((s >> j) & 1))
								val += g[S ^ s][j];
						
						checkmin(f[S][i], f[s][i] + val);
					}
				
				for(int j = 0; j < n; j++)
					if((S >> j) & 1)
					{
						if(!G[j][i]) continue;
						
						int s = S ^ (1 << i);
						
						checkmin(f[S][i], f[s][j] + g[s ^ (1 << j)][i]);
					}
			}
	
	printf("%d\n", f[fs][n - 1]);
	return 0;
}

Measured memory_bytes: 5376
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    vector<int> P(N), Q(N), R(N);
    REP(i, N)
    cin >> P[i];

    REP(i, N)
    cin >> Q[i];

    int a, b, count = 1;
    iota(ALL(R), 1);
    do
    {
        if (P == R)
            a = count;
        if (Q == R)
            b = count;
        count++;
    } while (next_permutation(ALL(R)));

    cout << abs(a - b) << endl;

    return 0;
}


Measured memory_bytes: 3132
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char s = sc.next().charAt(0);
        
        char result = '0';
        if (s == 'A') {
            result = 'T';
        } else if (s == 'T') {
            result = 'A';
        } else if (s == 'C') {
            result = 'G';
        } else if (s == 'G') {
            result = 'C';
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,a[100001],res[100001],mn,j,k;
	cin>>n>>k;
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	res[1]=0;
	res[2]=abs(a[1]-a[2]);
	for(i=3;i<=n;i++){
		mn=res[i-1]+abs(a[i]-a[i-1]);
		for(j=2;j<=k&&i-j>0;j++)
		mn=min(mn,res[i-j]+abs(a[i]-a[i-j]));
		res[i]=mn;
	}
	cout<<res[n];
}

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

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  __int128 t = A[0];
  for(int i = 1; i < N; i++){
    if((__int128)1e18 < t*A[i]){
      cout << -1 << endl;
      return 0;
    }
    t *= A[i];
  }
  long long ans = t;
  cout << ans << endl;
}

Measured memory_bytes: 3948
/*
二部グラフになるように色を付ける。
不可能ならば空のvectorを返す

0 or 1で色を付ける
-1は頂点0とつながってない部分

vector<int>();

GはGraphを想定
WeightGraphの場合は//+++++の部分を変える必要がある

verify:
https://atcoder.jp/contests/hitachi2020/tasks/hitachi2020_c

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

using pii=pair<int,int>;

using Graph=vector<vector<int>>;

template<typename G>
vector<int> bipartite(const G &g){
    vector<int> color(g.size(),-1);
    stack<pii> st;
    st.push({0,0});
    while(!st.empty()){
        int idx,nc;
        tie(idx,nc)=st.top();
        st.pop();
        for(auto next:g[idx]){
            if(color[next]==-1){
				color[next]=nc^1;
                st.push({next,nc^1});  //++++++++++++++++++++
            }else{
                if(color[next]!=nc^1) return vector<int>();  //+++++++++++
            }
        }
    }
    return color;
}



signed main(){
	int n;
	cin>>n;
	Graph g(n);

	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	auto color=bipartite(g);

	//vout(color);
	int cnt0=0,cnt1=0;
	int num0=0,num1=1;
	for(int i=0;i<n;i++){
		if(color[i]==0) cnt0++;
		else cnt1++;
	}
	vector<int> ret(n);
	if(cnt0>cnt1) swap(cnt1,cnt0),swap(num1,num0);
	vector<int> v0,v1;
	if(cnt0<=n/3){
		for(int i=0;i<n/3;i++){
			if(i<cnt0) v0.push_back(3*(i+1));
			else v1.push_back(3*(i+1));
		}
		for(int i=1;i<=n;i++){
			if(i%3==0) continue;
			v1.push_back(i);
		}
	}else{
		int now=1;
		for(int i=1;i<=n;i++){
			if(i%3==1) v0.push_back(i);
			else if(i%3==2) v1.push_back(i);
		}
		for(int i=0;i<cnt0-(n+2)/3;i++){
			v0.push_back(now*3);
			now++;
		}
		for(int i=0;i<cnt1-(n+1)/3;i++){
			v1.push_back(now*3);
			now++;
		}
	}
	int now0=0,now1=0;
	for(int i=0;i<n;i++){
		if(num0==color[i]){
			cout<<v0[now0]<<endl;
			now0++;
		}else{
			cout<<v1[now1]<<endl;
			now1++;
		}
	}
}

Measured memory_bytes: 16756
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>
#include<cstdio>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 




/*****************************************************************************/
signed main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	int i, n,l;
	cin >> n>>l;
	vector<string> s(n);
	f(i, 0, n) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	f(i, 0, n) {
		cout << s[i];
	}
	return 0;
}

Measured memory_bytes: 256
//
// Created by Leo Chen on 2019-08-26.
//
#include <iostream>
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    int sum = 0;
    int len = s.length();
    for(int i = 0; i < len; i++) {
        if(i == a) {
            if(s[i] != '-') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if(!(s[i] >= '0' && s[i] <= '9')) {
                sum++;
            }
        }
    }
    if(sum >= 1) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
using namespace std;

int main(){
  int n,x;
  map<int,int>m;
  for(;cin>>x;m[x]++);
  vector<pair<int,int> >v;
  for(map<int,int>::iterator it=m.begin();it!=m.end();it++)v.push_back(make_pair((*it).second,(*it).first));
  sort(v.begin(),v.end(),greater<pair<int,int> >());
  vector<int>w;
  for(n=v[0].first,x=0;v[x].first==n;x++)w.push_back(v[x].second);
  sort(w.begin(),w.end());
  for(n=0;n<w.size();n++)cout<<w[n]<<endl;
}

Measured memory_bytes: 1224