akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int K;
    cin >> K;
    vector<int> A(K);
    cin >> A;
    if (A[K - 1] != 2) {
        cout << -1 << endl;
        return 0;
    }
    int minValue = 2, maxValue = 3;
    for (int i = K - 2; i >= 0; i--) {
        int now = (minValue / A[i] + (minValue % A[i] != 0)) * A[i];
        if (minValue <= now && now <= maxValue) {
            minValue = now;
            maxValue = (maxValue / A[i]) * A[i] + A[i] - 1;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << minValue << " " << maxValue << endl;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val s = readLine()!!

    // 解説参考
    // mod 計算は桁ごとに分解できる
    // そして桁ごとの計算結果を dp に格納することによって計算量を削減できる

    val modVal = (1e9 + 7).toInt()
    val dp = Array(s.length) { IntArray(13) { 0 } }

    val sRev = s.reversed()

    // dp の一桁目を初期化
    if (sRev[0] != '?') {
        dp[0][sRev[0].toString().toInt() % 13] = 1
    } else {
        for (i in 0..9) {
            dp[0][i] = 1
        }
    }

    // dp の二桁目以降を求める
    for (i in 1 until s.length) {
        val c = sRev[i]

        if (c != '?') {
            // 10の i 乗 は値が大きくなるとオーバーフローするので注意
            val res = (c.toString().toInt() * powMod(10, i.toLong(), 13)) % 13

            // 既存の結果から i 桁目の対しての dp 計算
            for (j in 0..12) {
                val index = (res + j) % 13
                dp[i][index.toInt()] = (dp[i][index.toInt()] + dp[i - 1][j]) % modVal
            }
        } else {
            for (j in 0..9) {
                val res = (j * powMod(10, i.toLong(), 13)) % 13

                // 既存の結果から i 桁目に対しての dp計算
                for (k in 0..12) {
                    val index = (res + k) % 13
                    dp[i][index.toInt()] = (dp[i][index.toInt()] + dp[i - 1][k]) % modVal
                }
            }
        }
    }

    println(dp[s.length - 1][5])
}


/**
 * a^n mod modVal を計算する
 * 二分累乗法で累乗計算を O(logN) で行いつつ，OverFlow を避けるため適宜 mod 計算を行う
 */
fun powMod(a: Long, n: Long, modVal: Long, ans: Long = 1): Long {

    if (n == 0L) {
        return ans
    }

    // ビット演算の結果 2^0 の桁が 0 の場合は ans に掛けずに次の桁へ
    if (n.and(1L) == 0L) {
        return powMod(a * a % modVal, n.shr(1), modVal, ans)
    }

    // ビット演算の結果 2^9 の桁が 1 の場合は ans を更新
    return powMod(a * a % modVal, n.shr(1), modVal, ans * a % modVal)
}

Measured memory_bytes: 48140
class WeightedUnionFind:
    def __init__(self, n):
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
        self.weight = [0]*(n+1)
    def Find_Root(self, x):
        if self.root[x] < 0:
            return x
        else:
            y = self.Find_Root(self.root[x])
            self.weight[x] += self.weight[self.root[x]]
            self.root[x] = y
            return y
    def Weigh(self, x):
        self.Find_Root(x)
        return self.weight[x]
    def Diff(self, x, y):
        return self.Weigh(y) - self.Weigh(x)
    #y - x = w
    def Unite(self, x, y, w):
        w += self.Weigh(x) - self.Weigh(y)
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        if x == y:
            if w==0:
                return
            else:
                print('No')
                exit()
        else:
            if self.rnk[x] < self.rnk[y]:
                x, y = y, x
                w = -w
            self.root[x] += self.root[y]
            self.root[y] = x
            self.weight[y] = w
            if self.rnk[x] == self.rnk[y]:
                self.rnk[x] += 1
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    def Size(self, x):
        return -self.root[self.Find_Root(x)]

import sys
input = sys.stdin.readline
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
uf=WeightedUnionFind(n)
for x in l:
    uf.Unite(x[0],x[1],x[2])
print('Yes')

Measured memory_bytes: 57952
from collections import Counter,defaultdict
import sys,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = inp()
v = inpl()
c = inpl()
res = 0
for i in range(n):
    if v[i] - c[i] > 0:
        res += v[i] - c[i]
print(res)

Measured memory_bytes: 3948
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/multiprecision/cpp_int.hpp>
// ↓これいる？
#include <boost/graph/strong_components.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;
using namespace boost::numeric;
using namespace boost::multiprecision;
using ll = long long;
namespace bst = boost;
template<class T> void fill(T& v) { for (auto&& i : v) cin >> i; }

//#include "atcoder.hpp"

int main() {
    int A;
    
    cin >> A;
    
    cout << A * A << endl;
    
    return 0;
}






Measured memory_bytes: 256
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    static int mod=1000000007;
    public static void main(String[]$) {
        Scanner sc = new Scanner(in);
        String ans;
        int n=sc.nextInt();
        int[] a=new int[n];
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextInt();
        }
        int temp=0;
        for (int i = 0; i < n; i++) {
            temp+=a[i]%2;
        }
        ans=temp==0?"second":"first";
        out.println(ans);
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
    //最大公約数
    static int gcd (int a,int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
    //※最小公倍数はa*b/gcd(a,b)である
    static class UF{
        static int size=51;
        static int[] par=new int[size];
        //初期化
        static void init(){
            for (int i = 1; i <size ; i++) {
                par[i]=i;
            }
        }
        //根をたどる
        static int root(int x){
            if(par[x]==x){
                return x;
            }else{
                return par[x]=root(par[x]);
            }
        }
        //同じ根をもつか(同じ集合に属するか)判定
        static boolean same(int x,int y){
            return root(x)==root(y);
        }
        //合体
        static void unite(int x,int y){
            x=root(x);
            y=root(y);
            if(x==y)return;
            par[x]=y;
        }
    }
}

Measured memory_bytes: 52548
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  s <-getLine
  print $minimum $map (abs .(753-) .(read::String->Int)) $subString 3 s

subString _ [] = []
subString n s@(x:xs)
  |n<=length s = take n s : subString n xs
  |otherwise   = []

Measured memory_bytes: 3824
n, k = tuple(map(int, input().split(' ')))
r, s, p = tuple(map(int, input().split(' ')))
t = (input())
point = {'r':p, 's':r, 'p':s, 'any':0}
st = {i:t[i] for i in range(k)}
ans1 = sum(map(lambda x: point[x], t[:k]))
ans2 = 0
for i in range(k, n):
    h = t[i]
    m = i%k
    if st[m] != h:
        ans2 += point[h]
        st[m] = h
    else:
        st[m] = 'any' 
print(ans1 + ans2)

Measured memory_bytes: 15208
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c;
	if(a+b<c){cout<<"dangerous";}
	else if(a>c){cout<<"delicious";}
	else{cout<<"safe";}




	cout<<endl;
} 


Measured memory_bytes: 256
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

H, W = nl()
grid = []
for i in range(H):
    grid.append(s())

ups = [[0]*W for j in range(H)]
downs = [[0]*W for j in range(H)]
lefts = [[0]*W for j in range(H)]
rights = [[0]*W for j in range(H)]

for col in range(W):
    p = 0
    for row in range(H):
        if grid[row][col] == '#':
            p = 0
        else:
            p += 1
        ups[row][col] = p

    p = 0
    for row in range(H-1, -1, -1):
        if grid[row][col] == '#':
            p = 0
        else:
            p += 1
        downs[row][col] = p

for row in range(H):
    p = 0
    for col in range(W):
        if grid[row][col] == '#':
            p = 0
        else:
            p += 1
        lefts[row][col] = p

    p = 0
    for col in range(W-1, -1, -1):
        if grid[row][col] == '#':
            p = 0
        else:
            p += 1
        rights[row][col] = p

res = 0
for row in range(H):
    for col in range(W):
        res = max(res, ups[row][col] + downs[row][col] + lefts[row][col] + rights[row][col] -3)
print(res)



Measured memory_bytes: 179972
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

"""
最後の2つを決める：[0,x) [x,N)
小問題2つに分割できる。
全ての連続区間を計算すればよい
"""

N = int(input())
A = np.array(input().split(), np.int64)

# Acum[L,R] = A[L:R].sum()
Acum = np.zeros((N,N+1), dtype=np.int64)
for L in range(N):
    Acum[L,L+1:] = A[L:].cumsum()

dp = np.zeros((N,N+1), dtype=np.int64)
for size in range(2,N+1):
    for L in range(N-size+1):
        R = L + size
        dp[L,R] = (dp[L,L+1:R] + dp[L+1:R,R]).min() + Acum[L,R]

answer = dp[0,N]
print(answer)

Measured memory_bytes: 16928
#include<iostream>

using namespace std;
int main()
{
	string n;
	bool flag=false;
	cin>>n;
	for(int x=0;x<n.size();x++)
	{
		if(n[x]=='9')
		
			flag=true;
	}
	if(flag)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

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

using namespace std;
bool judge(string s)
{
    string a,b;
    a = s;
    reverse(s.begin(),s.end());
    b = s;
    if(a == b)return true;
    else return false;
}
int main()
{
    string a,b,c;
    cin >> a;
    int n = a.size();
    b = a.substr(0,(n-1)/2);
    c = a.substr((n + 3) / 2-1);
    if(judge(a) && judge(b) && judge(c))cout <<"Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[100010];
int b[100010];
int main()
{
    int n;
    while(scanf("%d",&n)!=-1)
    {
        for(int i=1;i<=n;i++)
            scanf("%d",&a[i]);
        int x=1,ans=0,f=-1;
        while(!b[x])
        {
            b[x]=1;
            if(x==2)
            {
                f=ans;break;
            }
            x=a[x];
            ans++;
        }
        printf("%d\n",f);
    }
    return 0;
}


Measured memory_bytes: 1024
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve()
}

func resolve() {
	n := scanInt(sc)
	a, b := scanInt(sc), scanInt(sc)
	d := (b - a) / 2
	if (b-a)%2 == 0 {
		fmt.Println(d)
	} else {
		var ad int
		if a < n-b+1 {
			ad = a
		} else {
			ad = n - b + 1
		}
		fmt.Println(ad + d)
	}
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

int main(){
  int n;
  long long d;
  long long k;
  int count=0;
  cin >> n >> d;
  vector<long long> x(n,0);
  vector<long long> y(n,0);
  for(int i=0;i<n;i++){
    cin >> x.at(i) >> y.at(i);
  }
  d=d*d;
  for(int i=0;i<n;i++){
    k=x.at(i)*x.at(i)+y.at(i)*y.at(i);
    if(k<=d){
      count++;
    }
  }
  cout << count << endl;

  return(0);
}


Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<(a*n<b?a*n:b)<<endl;
}


Measured memory_bytes: 256
// 2011/02/06 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int i;
		cin >> i;
		if(i==0)
			break;

		int jir[25];
		for(int j=0; j<i; j++)
			cin >> jir[j];

		int n = 32;
		bool flg = true;
		int jir_i = 0;
		while(n>0){
			if(flg){
				int taro = (n-1)%5;
				if(taro>n)
					taro = n;
				n -= taro;
				cout << n << endl;
				flg = false;
			}
			else{
				int jiro = jir[jir_i];
				jir_i = (jir_i+1)%i;
				if(jiro>n)
					jiro = n;
				n -= jiro;
				cout << n << endl;
				flg = true;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
ll ans[123456],revans[123456],revv[123456],v[123456],revx[123456];
ll x[123456],maxi,wow,baba[123456],revbaba[123456];
int main(){
    std::ios::sync_with_stdio(false);
    ll n,c;
    ll i;
    cin>>n>>c;
    f(i,1,n+1){
    	cin>>x[i]>>v[i];
    	revx[n-i+1]=x[i];
    	revv[n-i+1]=v[i];

    }
    f(i,1,n+1){
    	ans[i]=ans[i-1]+v[i];
    	
    	maxi=max(maxi,ans[i]-x[i]);
    	revans[i]=revans[i-1]+revv[i];
    	maxi=max(maxi,revans[i]-c+revx[i]);

    }
    f(i,1,n+1){
    	baba[i]=max(baba[i-1],ans[i]-x[i]);
    	revbaba[i]=max(revbaba[i-1],revans[i]-c+revx[i]);
    	//cout<<revans[i]<<endl;
    }
    f(i,1,n){

    	wow=ans[i]-2*x[i]+revbaba[n-i];
    	//cout<<revbaba[n-i-1]<<endl;
    	maxi=max(maxi,wow);
    	wow=revans[i]-2*c+2*revx[i]+baba[n-i];
    	maxi=max(maxi,wow);
    }
    cout<<maxi<<endl;


    return 0;  
    
}



Measured memory_bytes: 7296
#include <iostream>
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a[3];
	int n = 3;
	int c_5 = 0;
	int c_7 = 0;
	for (int i = 0; i < n; i++)
	{
		scanf(" %d", &a[i]);
		if (a[i] == 5)
			c_5++;
		if (a[i] == 7)
			c_7++;
	}
	if (c_5 == 2 && c_7 == 1)
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}
	return 0;
}

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

int main()
{

    ios_base::sync_with_stdio(false);

    char a, b, c;

    cin >> a >> b >> c;

    if(a == 'R' && b == 'R' && c == 'R')
        cout << 3;
    else if(a == 'R' && b == 'R' || b == 'R' && c == 'R')
        cout << 2;
    else if(a == 'R' || b == 'R' || c == 'R')
        cout << 1;
    else
        cout << 0;


    return 0;

}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll A, B, C;
    cin>>A>>B>>C;
    ll count=0;
    if(A%2!=B%2 && A%2!=C%2){
        count++; B++; C++;
    }
    else if(B%2!=A%2 && B%2!=C%2){
        count++; A++; C++;
    }
    else if(C%2!=A%2 && C%2!=B%2){
        count++; A++; B++;
    }
    ll Maxima=max({A, B, C});
    count+=(Maxima-A)/2+(Maxima-B)/2+(Maxima-C)/2;
    cout<<count<<endl;
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	string s;
	cin >> s;
	if (s.size()<4) {
		ce("No")
	}
	else {
		if (s.substr(0,4)=="YAKI") {
			ce("Yes")
		}
		else {
			ce("No")
		}
	}
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char const *argv[]) {
 int a, b, c, temp;
 scanf("%d %d %d", &a, &b, &c);
 if (b > c) {
  temp = b;
  b = c;
  c = temp;
 }
 if (a > b) {
  temp = b;
  b = a;
  a = temp;
 }
 if (b > c) {
  temp = b;
  b = c;
  c = temp;
 }
 printf("%d %d %d\n", a, b, c);
 return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		int[] H = new int[N];

		int near_i = 0;
		double temp = 0;
		double near_t = Integer.MAX_VALUE;
		for(int i=0;i<N;i++) {
			H[i] = sc.nextInt();
			temp = T - (H[i] * 0.006);

			if(Math.abs(temp - A) < Math.abs(near_t - A)) {
				near_t = temp;
				near_i = i;
			}
		}
		System.out.println(near_i+1);
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

void solve()
{
	double d;
	cin >> d;
	double ans = d * sqrt(2.0);
	for (int x = 1; x <= 10; ++x)
	{
		if (d * d - x * x >= 0)
		{
			double y = sqrt(d * d - x * x);
			if (y < 1.0)
			{
				y = 1.0;
			}
			ans = max(ans, x + y);
		}
	}
	printf("%.12lf\n", ans);
}

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

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

A = [list(input()) for i in range(N)]
B = [list(input()) for j in range(M)]

check = True
Flag = False

for s in range(N-M+1):
    for t in range(N-M+1):
        check = True
        for p in range(M):
            for q in range(M):
                if A[s+p][t+q] != B[p][q]:
                    check = False
        if check:
            Flag = True

if(Flag):
    print("Yes")
else:
    print("No")


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

namespace ABC120D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = ReadInt();
            long N = NM[0];
            int M = NM[1];

            long[] anss = new long[M];
            int[] A = new int[M];
            int[] B = new int[M];
            for (int i = 0; i < M; i++)
            {
                var input = ReadInt();
                A[i] = input[0] - 1;
                B[i] = input[1] - 1;
            }

            var uf = new UnionFind((int)N);

            anss[M - 1] = N * (N - 1) / 2; //初期化
            for (int i = M - 2; i >= 0; i--)
            {
                if (uf.Same(A[i + 1], B[i + 1]))
                {
                    //変化なし
                    anss[i] = anss[i + 1];
                }
                else
                {
                    anss[i] = anss[i + 1] - uf.count[uf.Find(A[i + 1])] * uf.count[uf.Find(B[i + 1])];
                }
                uf.Unite(A[i + 1], B[i + 1]);
            }

            foreach (var a in anss)
            {
                Console.WriteLine(a);
            }
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
    class UnionFind
    {
        int[] par;
        int[] rank;

        public long[] count;

        public UnionFind(int n)
        {
            init(n);
        }

        void init(int n)
        {
            par = new int[n];
            rank = new int[n];

            count = new long[n];

            for (int i = 0; i < n; i++)
            {
                par[i] = i;
                rank[i] = 0;

                count[i] = 1;
            }
        }

        public int Find(int x)
        {
            if (par[x] == x)
            {
                return x;
            }
            else
            {
                return par[x] = Find(par[x]);
            }
        }

        public void Unite(int x, int y)
        {
            x = Find(x);
            y = Find(y);
            if (x == y) return;

            if (rank[x] < rank[y])
            {
                par[x] = y;

                count[y] += count[x];
            }
            else
            {
                par[y] = x;
                if (rank[x] == rank[y]) rank[x]++;

                count[x] += count[y];
            }

        }
        public bool Same(int x, int y)
        {
            return Find(x) == Find(y);
        }
    }
}


Measured memory_bytes: 21432
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,mini=INT_MAX,c;
    string s,t;
    cin>>s>>t;
    n=s.length();
    m=t.length();
    for(int i=0;i<=n-m;i++)
    {
        c=0;
        for(int j=0;j<t.length();j++)
        {
            if(s[i+j]==t[j])
            {
                continue;
            }
            else
            {
                c++;
            }
        }
        if(mini>c)
        {
            mini=c;
        }
    }
    cout<<mini<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;

int main(void){

    int x;
    cin>>x;
    set<int> s;
    s.insert(0);
    vi a{100,101,102,103,104,105};
    for (int i = 0; i < 1001;i++){
        set<int> tmp;
        for (auto it = s.begin(); it != s.end();it++){
            for (int j = 0; j < 6;j++){
                if (a[j] + (*it)<=x)
                    tmp.insert(a[j] + (*it));
            }
        }
        // for (auto it = tmp.begin(); it != tmp.end(); it++)
        // {
        //     s.insert(*it);
        // }
        if (s.find(x) != s.end()){
            fin(1);
            return 0;
        }
            s.clear();
        s=tmp;
    }
    fin(s.find(x)!=s.end());
}

Measured memory_bytes: 640
import sys


def fill_balls(a):
    b = [0]
    c = [0]
    for ball in a:
        if b[-1] == 0:
            b.append(ball)
        elif b[-1] < ball and c[-1] < ball:
            if b[-1] < c[-1]:
                c.append(ball)
            else:
                b.append(ball)
        elif b[-1] < ball:
            b.append(ball)
        elif c[-1] < ball:
            c.append(ball)
        else:
            return 'NO'
    return 'YES'



for i in range(input()):
    a = map(int, raw_input().split(' '))
    print fill_balls(a)

Measured memory_bytes: 4244
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;

vector<int> DP(100005);

int main() {
    int N;
    cin>>N;
    for(int i=0;i<100005;++i){
        DP[i] = inf;
    }
    vector<int> arr(N);
    for(int i=0;i<N;++i){
        cin>>arr[i];
    }
    reverse(arr.begin(), arr.end());
    int index;
    for(int i=0;i<N;++i){
        index = upper_bound(DP.begin(), DP.end(), arr[i]) - DP.begin();
        DP[index] = arr[i];
    }
    cout<<lower_bound(DP.begin(), DP.end(), inf) - DP.begin()<<endl;
}



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

using namespace std;


int main()
{
	int n; cin >> n;
	int x = n%10;
	if(x == 0 || x == 1 || x == 6 || x == 8) cout << "pon";
	else if(x == 3) cout << "bon";
	else cout << "hon";
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll fin = 9 * 16;
ll ans, N;

ll makeNum(int x){
	string ret;
	while(x){
		if(x >= 9)	ret += '9';
		else{
			ret += (x + '0');
			break;
		}
		x -= 9;
	}
	if(ret.empty())	ret = "0";
	reverse(ret.begin(), ret.end());
	return stoll(ret);
}

int main(){
	cin >> N;
	for(ll i = 0; i <= fin; i++){
		ll x = makeNum(i);
		if(x <= N){
			ans = max(i, ans);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(void){
  char S[100] = {};
  char T[100] = {};
  int len;
  int i, j, k;
  int flag;//一致させられれば1，そうでなければ0
  scanf("%s %s", S, T);
  len = strlen(S);
  for(i = 0; i < len; i++){
    flag = 1;
    for(j = 0; j < len; j++){
      if(S[(i+j)%len] != T[j]){
        flag = 0;
        break;
      }
    }
    if(flag == 1){
      printf("Yes\n");
      return 0;
    }
  }
  if(flag == 0){
    printf("No\n");
    return 0;
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

int gcd(int c,int d){
    return d ? gcd(d, c % d) : c;
}



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

    int n; cin >> n;
    vector<int> d(n);
    for(int i = 0;i < n;i ++) cin >> d.at(i);
    int m; cin >> m;
    vector<int> t(m);
    for(int i = 0;i < m;i ++) cin >> t.at(i);

    if(n < m){
        cout << "NO" << endl;
        return 0;
    }

    sort(d.begin(),d.end());
    sort(t.begin(),t.end());

    int j = 0;
    for(int i = 0;i < m;i ++){
        for(;j < n;j ++){
            if(t.at(i) == d.at(j)){
                j ++;
                break;
            }
            if(j == n-1){
                cout << "NO" << endl;
                return 0;
            }
        }
    }

    cout << "YES" << endl;
}



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

int main() {
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    int ap = 0, bp = 0, cp = 0;
    char now_player = 'a';
    while (true) {
        if (now_player == 'a' && ap == sa.length()) {
            cout << 'A' << endl;
            return 0;
        }
        if (now_player == 'b' && bp == sb.length()) {
            cout << 'B' << endl;
            return 0;
        }
        if (now_player == 'c' && cp == sc.length()) {
            cout << 'C' << endl;
            return 0;
        }
        if (now_player == 'a') {
            now_player = sa[ap];
            ap++;
        }
        else if (now_player == 'b') {
            now_player = sb[bp];
            bp++;
        }
        else {
            now_player = sc[cp];
            cp++;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N;

int main(){
  cin >> N;
  if(N == 3) {
    cout << 2 << " " << 5 << " " << 63 << endl;
    return 0;
  }
  if(N <= 15002) {
    if((N - 2) % 3 == 1) {
      for(int i = 1; i <= N - 4; i++) {
        cout << i * 2 << " ";
      }
      cout << (N - 2) * 2 << " " << (N - 1) * 2 << " " << 3 << " " << 9 << endl;
    } else {
      for(int i = 1; i <= N - 2; i++) {
        cout << i * 2 << " ";
      }
      cout << 3 << " " << 9 << endl;
    }
  } else if(N % 2 == 0) {
    REP(i, 15000){
      cout << (i + 1) * 2 << " ";
    }
    REP(i, N - 15000) {
      cout << i * 6 + 3;
      if(i == N - 15000 - 1) cout << endl;
      else cout << " ";
    }
  } else {
    REP(i, 15000 - 1){
      cout << (i + 1) * 2 << " ";
    }
    REP(i, N - 15000 + 1) {
      cout << i * 6 + 3;
      if(i == N - 15000) cout << endl;
      else cout << " ";
    }
  }

  return 0;

}



Measured memory_bytes: 384
N = int(input())
p = [int(x) for x in input().split()]

ans = 0
for i in range(N):
  if i < N - 1 and p[i] == i + 1:
    p[i] = p[i+1]
    p[i+1] = i+1
    ans += 1
  elif i == N -1 and p[i] == i+1:
    p[i] = p[i-1]
    p[i-1] = i + 1
    ans += 1
print(ans)

Measured memory_bytes: 13880
#include<stdio.h>

#define MAX 10000
#define NOT_FOUND 0 

int n,q;
int A[MAX],T[MAX];

int i,j;
int C=0;
int linerSearch(){
  for(i=0;i<n;i++){
    if(A[i]==T[j])return 1;
  }
  return NOT_FOUND;
}





int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);

  scanf("%d",&q);

  for(j=0;j<q;j++){
    
    scanf("%d",&T[j]);
	
    C+=linerSearch();
  }


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

  return 0;
}






	   



Measured memory_bytes: 2104
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#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 loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 1e6 + 5 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 998244353 ;
const double eps = 1e-7 ;
template <class T> void read(T &a)
{
	int f = 1 ; a = 0;
	char ch = getchar() ;
	while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
	while (isdigit(ch)) { a =  (a << 3) + (a << 1) + ch - '0' ; ch = getchar() ; }
	a *= f ;
}

ll n, rs, gs, bs, a[5], rl, gl, bl, b[5], ans = 1;

char s[maxn];

signed main()
{
	scanf("%lld", &n);
	rep(i, 1, n) (ans *= i) %= mod;
	// printf("%lld\n", fac);
	scanf("%s", s + 1);
	rep(i, 1, 3 * n)
	{
		if(s[i] == 'R') rs ++;
		if(s[i] == 'G') gs ++;
		if(s[i] == 'B') bs ++;
		a[1] = rs, a[2] = gs, a[3] = bs;
		sort(a + 1, a + 4);
		// rep(i, 1, 3) printf("%lld%c", a[i], " \n"[i == 3]);
		// if(a[3] != b[3]) (ans *= fac) %= mod;
		if(a[2] != b[2]) (ans *= b[3] - b[2]) %= mod;
		if(a[1] != b[1]) (ans *= b[2] - b[1]) %= mod;
		rl = rs, gl = gs, bl = bs;
		b[1] = rl, b[2] = gl, b[3] = bl;
		sort(b + 1, b + 4);
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

unsigned long long int gcd(unsigned long long int a, unsigned long long int b) {
    return b == 0 ? a : gcd(b, a % b);
}
int main(){
	unsigned long long int A, B, C, D;
	cin >> A >> B >> C >> D;
	unsigned long long int result = B - A + 1;

	result -= B / C - (A - 1) / C;
	result -= B / D - (A - 1) / D;
	unsigned long long int lcm = C * D / gcd(C, D);
	result += B / lcm - (A - 1) / lcm;
	cout << result << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    int N; cin>>N;
    vector<pair<ll,ll>> RL;

    rep(i,N){
        ll L,R;
        cin>>L>>R;
        RL.emplace_back(R,L);
    }

    SORT(RL);

    ll maxLup[N];
    ll maxLdown[N];

    ll ma=0;

    rep(i,N){
        maxi(ma,RL[i].second);
        maxLup[i]=ma;
    }

    ma=0;
    repr(i,N-1,0){
        maxi(ma,RL[i].second);
        maxLdown[i]=ma;
    }

    ll ans=0;

    reps(i,1,N){
        ll buff=0;

        ll ueR=RL[0].first;
        ll sitaR=RL[i].first;
        ll ueL=maxLup[i-1];
        ll sitaL=RL[i].second;
        ll nokoriL;
        if(i!=N-1) nokoriL=maxLdown[i+1];
        else nokoriL=1;
    
        ll buff1=ueR-ueL+1+max(0LL,sitaR-max(sitaL,nokoriL)+1);
        ll buff2=sitaR-sitaL+1+max(0LL,ueR-max(ueL,nokoriL)+1);
        buff=max(buff1,buff2);
        maxi(ans,buff);
    }

    cout<< ans<<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 3568
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){

    ll x;
    cin >> x;

    while(true){
        bool isPrime = true;
        for(int i = 2; i * i <= x; i++){
            if(x % i == 0){
                isPrime = false;
                break;
            }
        }
        if(isPrime){
            cout << x << endl;
            return 0;
        }
        x++;
    }
}

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


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

    int sum = 0;
    rep(i,M){
        int A; cin >> A;
        sum += A;
    }

    cout << max(-1, N-sum) << endl;
}

Measured memory_bytes: 3624
fun main(args: Array<String>) {

    val t1 = readLine()!!.split(" ").map { it.toInt() }
    val t2 = readLine()!!.split(" ").map { it.toInt() }
    val t3 = readLine()!!.split(" ").map { it.toInt() }

    val t4 = listOf(t1[0], t2[0], t3[0])
    val t5 = listOf(t1[1], t2[1], t3[1])
    val t6 = listOf(t1[2], t2[2], t3[2])

    val t7 = listOf(t1[0], t2[1], t3[2])
    val t8 = listOf(t1[2], t2[1], t3[0])

    val N = readLine()!!.toInt()
    val b = (1..N).map { readLine()!!.toInt() }

    val t = listOf(t1, t2, t3, t4, t5, t6, t7, t8)

    (if (t.any { b.containsAll(it) }) "Yes" else "No").let{println(it) }
}


Measured memory_bytes: 35952
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll h,w;
ll direction2[4][2]={{1,0},{0,1},{0,-1},{-1,0}};
bool valid(int a,int b)
{
    if(a>=1&&a<=h&&b>=1&&b<=w)return true;
    else return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll d,n;
    cin>>d>>n;
    if(d==0){
        if(n==100)cout<<"101";
        else cout<<n;
    }
    else if(d==1){
        if(n==100)cout<<"101";
        else cout<<n;
        cout<<"00";
    }
    else{
        if(n==100)cout<<"101";
        else cout<<n;
        cout<<"0000";
    }
}


Measured memory_bytes: 3640
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <list>
using namespace std;

int main() {
 int i,n,k,box;
 double s,a,b,da[15];
 list<double> lis;
 list<double>::iterator it;
 while(cin >> box) {
 n=0;
 while(cin >> da[n++]) if (cin.peek()=='\n') break;
 sort(da,da+n);
 lis.push_front(da[0]);
 for (i=1;i<(n/2)*2;i++) {
	 k=(i % 2)==0 ? i/2 : (n-1)-i/2;
  if ((i % 2==1 && (lis.front()<lis.back())) || (i % 2==0 && (lis.front()>lis.back()))) lis.push_front(da[k]);
  else lis.push_back(da[k]); }
 if (n>1 && n % 2==1)
	 if (2*sqrt(da[n/2]*lis.front())-lis.front()<2*sqrt(da[n/2]*lis.back())-lis.back()) lis.push_front(da[n/2]); 
	 else lis.push_back(da[n/2]);   
 s=lis.front();
 for (it=lis.begin(),i=0;i<n-1;i++,it++) { a=*it++; b=*it--; s+=2*sqrt(a*b); }
 s+=lis.back();
 if (s<=box) cout << "OK" << endl; else cout << "NA" << endl; 
 lis.clear();
 }
 return 0;	
}

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


const int size = 1 << 13;
int dp[1010][size];
const int INF = 100100100;

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < size; ++i) {
    for (int j = 0; j < 1010; ++j) {
      dp[j][i] = INF;
    }
  }
  dp[0][0] = 0;
  vector<int> la(m);
  int max =  (1<<n);
  for (int i = 0; i < m; ++i) {
    int b;
    cin >> la[i] >> b;
    vector<int> lc(b);
    int hash = 0;
    for (int j = 0; j < b; ++j) { 
      cin >> lc[j];
      hash += (1 << (lc[j]-1));
    }
    // cout << hash << " " << endl;
    // for (int j = 0; j < size; ++j) { 
    for (int j = 0; j < max; ++j) { 
      // cout << i << " " << j << " " << dp[i][j] << endl;
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]); // 使わない場合
      dp[i+1][j|hash] = min(dp[i+1][j|hash], dp[i][j]+la[i]); // 使う場合
      // cout << i+1 << " " << j << " " << (j|hash) << " " << dp[i][j] << " " << la[i] << " " << dp[i+1][j|hash] << endl;
    }
  }
  int hash = (1<<n)-1;
  int ans = dp[m][hash]; 
  if (ans == INF) { cout << -1 << endl;}
  else { cout << ans << endl; }
}



Measured memory_bytes: 32512
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Applicative
import Control.Monad.Fix
import Control.Monad.ST
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> VU.Vector Int -> (Int, [(Int, Int)])
solve !n !an = second (map (\(!x, !y) -> (x + 1, y + 1))) $ if ordered
  then (0, [])
  else
    let positiveOrder = abs maxOfPos > abs maxOfNeg
    in  toPair (bottomup positiveOrder ++ fold positiveOrder)
 where
  ordered = snd $ VU.foldr'
    (\(!ai) (!acc, !isit) -> if isit then (ai, acc >= ai) else (acc, isit))
    (maxBound, True)
    an

  (imaxOfPos, maxOfPos) =
    VU.maximumBy (\x y -> compare (snd x) (snd y)) $ VU.indexed an
  (imaxOfNeg, maxOfNeg) =
    VU.minimumBy (\x y -> compare (snd x) (snd y)) $ VU.indexed an

  toPair xs = (length xs, xs)

  bottomup isPositive = VU.ifoldl'
    (\(!acc) (!i) (!ai) -> case () of
      () | isPositive && ai < 0     -> (imaxOfPos, i) : acc
      () | not isPositive && ai > 0 -> (imaxOfNeg, i) : acc
      ()                            -> acc
    )
    []
    an

  fold leftToRight = if leftToRight
    then [ (i, i + 1) | i <- [0 .. n - 2] ]
    else [ (i, i - 1) | i <- reverse [1 .. n - 1] ]

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  an <- VU.unfoldrN n readInt <$> B.getLine
  let (m, xs) = solve n an
  print m
  mapM_ (\(x, y) -> putStrLn $ show x ++ " " ++ show y) xs


Measured memory_bytes: 636
import java.util.*;

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

        int x = sc.nextInt();
        if(x==3 || x==2){
            System.out.println(x);
            return;
        }
        if(x==1){
            System.out.println(2);
            return;
        }

        for(int i=0; i<=100003; i++){
            for(int j=2; j*j<=x+i; j++){
                if((x+i)%j==0){
                    break;
                }
                if((j+1)*(j+1)>x+i){
                    System.out.println(x + i);
                    return;
                }
            }
        }
    }
}

Measured memory_bytes: 21716
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).
*/

main :-
    get_string(S),
    S @=< "2019/04/30" -> writeln("Heisei") ; writeln("TBD").


Measured memory_bytes: 8012
q=int(input())
l=[list(map(int,input().split())) for i in range(q)]

def primes(n):
  is_prime=[True]*(n+1)
  is_prime[0]=False
  is_prime[1]=False
  for i in range(2,int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2,n+1,i):
      is_prime[j]=False
  return [i for i in range(n+1) if is_prime[i]]

L1=primes(100000)
L2=set(L1)
like2017=[]
for i in range(len(L1)):
  if (L1[i]+1)//2 in L2:like2017.append(L1[i])
like2017=set(like2017)
ansL=[]
ct=0
for i in range(100000):
  if i in like2017:ct+=1
  ansL.append(ct)

for i in range(q):
  print(ansL[l[i][1]]-ansL[l[i][0]-1])

Measured memory_bytes: 30040