akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
public class Main{

    static long MOD = 1000000007L;
    static long [] fac;
    static int[][] dir = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    static long lMax = 0x3f3f3f3f3f3f3f3fL;
    static int iMax = 0x3f3f3f3f;
    static HashMap <Long, Long> memo = new HashMap();
    static int n, m;
    static int[][] mat;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t-- > 0){
            int a = sc.nextInt();
            int b = sc.nextInt();
            out.println(a * b);

        }
        out.close();
    }
    public static long C(int n, int m)
    {
        if(m == 0 || m == n) return 1l;
        if(m > n || m < 0) return 0l;
        long res = fac[n] * quickPOW((fac[m] * fac[n - m]) % MOD, MOD - 2) % MOD;

        return res;
    }
    public static long quickPOW(long n, long m)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % MOD;
            n = (n * n) % MOD;
            m >>= 1;
        }
        return ans;
    }
    public static int gcd(int a, int b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long gcd(long a, long b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long solve(long cur){
        return 0L;
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

Measured memory_bytes: 33032
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<climits>
#include<bitset>
#include<climits>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){
    int f=1,ans=0;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
    return f*ans;
}
const int MAXN=701+11;
vector<int> vec[MAXN];bool ff;
int MM[MAXN][MAXN],N,M,col[MAXN],INF=INT_MAX;
int c0,c1,f[MAXN],g[MAXN];
void dfs(int u,int co){
    //cerr<<"ff:"<<ff<<" "<<u<<" "<<co<<endl;
    if(!ff) return;col[u]=co;if(!co) c0++;else c1++;
    for(auto v:vec[u]){
        if(col[v]==-1) dfs(v,co^1);
        else if(col[v]==co){ff=0;break;}
    }return;
}
int fff(int u){return (u*(u-1))/2;}
int cacl(int u){return fff(u)+fff(N-u);}
int main(){
    N=read(),M=read();for(int i=1;i<=M;i++){int u=read(),v=read();MM[u][v]=MM[v][u]=1;}
    for(int i=1;i<=N;i++) for(int j=i+1;j<=N;j++) if(!MM[i][j]) vec[i].pb(j),vec[j].pb(i);
    memset(col,-1,sizeof(col));f[0]=1;
    for(int i=1;i<=N;i++){
        if(col[i]!=-1) continue;
        c0=c1=0,ff=1;dfs(i,0);if(!ff){printf("-1\n");return 0;}
        for(int j=0;j<=N;j++) g[j]=f[j];memset(f,0,sizeof(f));
        for(int j=c0;j<=N;j++) f[j]|=g[j-c0];for(int j=c1;j<=N;j++) f[j]|=g[j-c1];
    }int Minn=INF;
    for(int i=0;i<=N;i++) if(f[i]) Minn=min(Minn,cacl(i));
    printf("%d\n",Minn);return 0;
}



Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(int argc, char* argv[])
{
	char str[]="abcdefghijklmnopqrstuvwxyz";
	map<char,int> sMap;
	int i;
	for (i=0;i<26;i++){
		sMap[str[i]]=0;
	}
	string s;
	cin>>s;
	map<char,int>::iterator mit;
	for (i=0;i<s.size();i++){
		mit=sMap.find(s[i]);
		(*mit).second++;
	}

	for (mit=sMap.begin();mit!=sMap.end();mit++){
		if ((*mit).second == 0){
			cout<<(*mit).first<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;

	return 0;
}

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

int main(){
  int n,l;
  cin>>n>>l;
  vector<string> s(n);
  for(int i=0; i<n; i++)cin>>s.at(i);

  sort(s.begin(), s.end());
  for(int i=0; i<n; i++)cout<<s.at(i);
  cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N; cin>>N;
    vector<int> b(N+1,1e6);
    for (int i = 1; i < N; ++i) {
        cin>>b[i];
    }
    ll ans=0ll;
    for (int i = 0; i < N; ++i) {
        ans+=(ll)min(b[i],b[i+1]);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
"use strict"; // inputに入力データ全体が入る

function Main(input) {
  var lines = input.split('\n');
  var k = parseInt(lines[0].split(' ')[0]);
  var a = lines[1].split(' ').map(function (aa) {
    return parseInt(aa);
  });
  var mx = k - a[a.length - 1] + a[0];
  var sum = mx;

  for (var i = 0; i < a.length - 1; i++) {
    var b = a[i + 1] - a[i];
    sum += b;

    if (mx < b) {
      mx = b;
    }
  }

  console.log(sum - mx);
} //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int grid[10][1000];
int H, W, K;

int solve(vector<int> v){
    int ret = 0;
    vector<int> boarder;
    boarder.push_back(0);
    rep(i, H-1){
        if(v[i]){
            ret++;
            boarder.push_back(i+1);
        }
    }
    boarder.push_back(H);
    int work[boarder.size()-1][W];
    rep(i, boarder.size()-1){
        int from = boarder[i], to = boarder[i+1];
        for(int k = 0; k < W; k++){
            int acc = 0;
            for(int j = from; j < to; j++){
                if(grid[j][k]) acc++;
            }
            work[i][k] = acc;
        }
    }
    rep(i, boarder.size()-1){
        for(int j = 1; j < W; j++){
            work[i][j] += work[i][j-1];
        }
    }
    int cut_idx = -1;
    rep(j, W){
        bool ok = true;
        rep(i, boarder.size()-1){
            if(cut_idx != -1){
                int num_white = work[i][j] - work[i][cut_idx];
                if(num_white > K){
                    ok = false;
                    if(j == cut_idx+1) return mod;
                }
            }
            else{
                if(work[i][j] > K){
                    ok = false;
                    if(j == 0) return mod;
                }
            }
        }
        if(!ok){
            ret++;
            cut_idx = j-1;
        }
    }
    return ret;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int ans = mod;
    cin >> H >> W >> K;
    string S[H];
    rep(i, H){
        cin >> S[i];
        rep(j, W){
            grid[i][j] = S[i][j]-'0';
        }
    }
    int loop = (1 << (H-1));
    rep(i, loop){
        int val = i;
        vector<int> work;
        rep(j, H-1){
            work.push_back(val%2);
            val/=2;
        }
        ans = min(ans, solve(work));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int suu = Integer.parseInt(str);
        String[] num = str.split("");
        int sum =0;
        for(int i=0;i<num.length;i++){
            sum=sum+Integer.parseInt(num[i]);
        }
        if(suu%sum==0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#define min(a, b) ((a < b) ? a : b)

int main() {
    int x, y, z, e, ans;

    while (1) {
        scanf("%d", &e);
        if (!e) { break; }
        ans = e;

        for (z = 0; z*z*z <= e; z++) {
            for (y = 0; y*y + z*z*z <= e; y++) {
                x = e - y*y - z*z*z;
                ans = min(ans, x+y+z);
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
const  ll modo=1e9+7;

int vis[100005]={0};
int col[100005];
vector<pair<int,int>> vv[100005];

void addedge(int u, int v ,int wt)
{
    vv[u].pb(mp(v,wt));
    vv[v].pb(mp(u,wt));
}

void dfs(int node,int cc)
{
    col[node]=cc;
    vis[node]=1;
    for(auto i:vv[node])
    {
        if(!vis[i.first])
        {
            //cout<<i.first<<" "<<i.second<<" "<<!cc<<" "<<cc<<endl;
            if((i.second)%2)dfs(i.first,!cc);
            else dfs(i.first,cc);
        }
    }
}

int main()
{
    faf;

    int n;
    cin>>n;
    int i;
    int u,v,wt;
    for(i=1;i<n;i++)
    {
        cin>>u>>v>>wt;
        addedge(u,v,wt);
    }

    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        dfs(i,0);
    }
    for(i=1;i<=n;i++)cout<<col[i]<<"\n";

}

Measured memory_bytes: 7936
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl
using namespace std;
using ll = long long;
const int INFINT = 1 << 30;
const ll INFLL = 1LL << 60;
const int MOD = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a%b) : a;}

int main() {

	int h, w;

	cin >> h >> w;

	vector<string> map(h);
	REP(i, h) map[i].resize(w);
	vector<int> dx(w);
	vector<int> dy(h);

	REP(i, h)
		cin >> map[i];

	REP(i, h)
		REP(j, w)
		cin >> map[i][j];

	REP(y, h) {
		bool del = true;
		REP(x, w) {
			if (map[y][x] == '#') {
				del = false;
			}
		}
		if (del) dy[y] = 1;
	}
	REP(x, w) {
		bool del = true;
		REP(y, h) {
			if (map[y][x] == '#') {
				del = false;
			}
		}
		if (del) dx[x] = 1;
	}

	REP(y, h) {
		bool out = false;
		REP(x, w) {
			if (dx[x] == 0 && dy[y] == 0) {
				cout << map[y][x];
				out = true;
			}
		}
		if (out) cout NL;
	}



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int, int>pi;
typedef     pair<long long, long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define       FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
int main()
{
  int t;
  t=1;
  //cin >> t;
  while (t--)
  {
    ll n,i,j,x,y,m,s=0;
    cin>>n>>m;
    int a[n+3];
    pair<int,int>p[m+1];
    for(i=1;i<=n;i++) cin>>a[i];
      sort(a+1,a+n+1);
    for(i=0;i<m;i++)
    {
      cin>>x>>y;
      p[i].first=y;
      p[i].second=x;
    }
    sort(p,p+m);
    x=1;
    for(i=m-1;i>=0;i--)
    {
     int  l=x;
      if(p[i].first>a[x]){
      for(j=l;j<=l+p[i].second-1&&j<=n;j++)
      {
        if(a[j]<p[i].first)
        {
          a[j]=p[i].first;
        }else
        {
          break;
        }
        x++;

      }
    
     }
    }
    // int l=1;
    // for(i=m-1;i>=0;i--)
    //  {
    //    x=p[i].second;
    //    if(p[i].fisrt>a[l])
    //    {
    //     for(j=l+1;j<=l+x-1&&j<=l+n-1;j++)
    //     {
    //         if()
    //     }
    //    }
    //  }
   for(i=1;i<=n;i++)
   {
    s+=a[i];
  // cout<<a[i]<<" ";
   }
   cout<<s<<endl;

  }
  return 0;
}

Measured memory_bytes: 4812
n, m, x = map(int, input().split())

C = []
A = []
for _ in range(n):
    tmp = list(map(int, input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])
    
f_inf = float("inf")    
ans = f_inf
for s in range(1<<n):
    cst = 0
    D = [0] * m
    for i in range(n):
        if s>>i & 1:
            cst += C[i]
            for j in range(m):
                D[j] += A[i][j]
    
    flg = True
    for d in D:
        if d < x: flg = False
    if flg: ans = min(ans, cst)

if ans == f_inf: 
  print(-1)
else: 
  print(ans)

Measured memory_bytes: 9220
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  char s[n+1];
  scanf("%s", s);
  int ans = 1; char c = s[0];
  for (int i=1; i<n; i++) {
    if (c == s[i]) continue;
    ans++;
    c=s[i];
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var btn = new string[] { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var result = "";
            var s = Console.ReadLine().Trim();
            var number = -1;
            var count = 0;
            for (int j = 0; j < s.Length; j++)
                if (s[j] != '0') { number = int.Parse(s[j].ToString()); count++; }
                else if (number != -1)
                {
                    result += getChar(number, count, btn);
                    number = -1;
                    count = 0;
                }
            Console.WriteLine(result);
        }
    }
    public static string getChar(int n, int i, string[] btn)
    {
        var bL = btn[n - 1].Length;
        return btn[n - 1][(i + bL - 1) % bL].ToString();
    }
}

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

int main(){
	int N;
	cin>>N;
	vector<int>a(N);
	bool flag=true;
	int ans=0;
	rep(i,N){
		cin>>a.at(i);
	}
	while(flag){
		rep(i,N){
			if(a.at(i)%2==1){
				flag=false;
				break;
			}else{
				a[i]/=2;
			}
		}
		if(flag){
			ans++;
		}
	}
	cout<<ans;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String text = scan.next();
        char[] data = text.toCharArray();
        data[5] = ' ';
        data[13] = ' ';
        System.out.println(data);
    }
}

Measured memory_bytes: 25300
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)
using namespace std;
int main(){
        long long x,y,i;
        cin >> x >> y;
        i=0;
        while(true) {
                if(x>y) break;
                i++;
                x<<=1;
        }
        cout << i << endl;
        return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;


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

    i64 A, B, P, Q, R;
    cin >> A >> B >> P >> Q >> R;

    i64 x = P*B - (B - A) * Q;
    i64 y = (Q + R);

    double k = double(x) / double(y);
    cout << fixed << setprecision(9);
    cout << k + B << endl;

    return 0;
}



Measured memory_bytes: 3308
import java.util.Scanner;

public class Main {


	/**
	 * たてHｃｍよこWｃｍのチェック柄の長方形を描くプログラム
	 * @param args　H,W
	 */

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


		for(;scan.hasNext();){
			
			int height = scan.nextInt();
			int width = scan.nextInt();
			
			if(height == 0 && width== 0){
				break;
			}
//			int height=Integer.parseInt(args[k]);
//			int width=Integer.parseInt(args[k+1]);

			boolean flag=true;



			for(int i=0;i< height;i++){
				for(int j = 0;j< width;j++){
					if(flag){
						System.out.print("#");
						flag = false;
					}else{
						System.out.print(".");
						flag = true;
					}
				}
				System.out.println("");
				flag =!flag;
				if(width%2 != 0){//偶数だったら
					flag = !flag;	//フラグ反転処理
				}

			}
			System.out.println("");		//一つのくくりが終わったので改行する
			flag = true;				//最初は#
		}
	}
}


Measured memory_bytes: 37864
from functools import lru_cache
@lru_cache(maxsize=None)
def is_prime(x):
    if x==1:
        return False
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            return False
    return True

# @lru_cache(maxsize=None)
def like2017(x):
    return is_prime(i) and is_prime((i+1)//2)
    
table=[0,0]
for i in range(2,10**5):
    table+=table[i-1]+like2017(i),
        
n=int(input())
for _ in range(n):
    a,b=map(int,input().split())
    print(table[b]-table[a-1])
# print(table)


Measured memory_bytes: 18208
#include<stdio.h>
int main()
{
	char s[5];
	scanf("%s", s);
	int ans;
	if (s[0] == 'S' && s[1] == 'U')ans = 7;
	else if (s[0] == 'M')ans = 6;
	else if (s[0] == 'T' && s[1] == 'U')ans = 5;
	else if (s[0] == 'W')ans = 4;
	else if (s[0] == 'T' && s[1] == 'H')ans = 3;
	else if (s[0] == 'F')ans = 2;
	else ans = 1;
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli data[100100];
signed main(){

	lli n;
	cin>>n;

	REP(i,0,n){
		lli a;
		cin>>a;
		a--;
		data[i]=a;
	}

	lli cnt=0;
	REP(i,0,n){
		if(i == data[data[i]])cnt++;
	}
	cout<<cnt/2<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int L; cin >> L;
    int c[1100];
    for(int i=0;i<L;i++){
        cin >> c[i];
    }
    int a[110];
    for(int i=0;i<100;i++){
        a[i] = -1;
    }
    int sp = 0;

    for(int i=0;i<L;i++){
        if(c[i]>0){
            if(a[c[i]-1]==-1){
                a[c[i]-1] = sp;
                sp++;
            }else{
                cout << i+1 <<endl;
                return 0;
            }
        }else{
            if(sp>0 && a[-c[i]-1]==sp-1){
                a[-c[i]-1] = -1;
                sp--;
            }else{
                cout << i+1 << endl;
                return 0;
            }
        }
    }
    cout << "OK" << endl;
    return 0;
}


Measured memory_bytes: 3132
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int n;
    cin >> n;
    vector<ll> a(n), acc(n + 1);
    REP(i, 0, n)
    {
        cin >> a[i];
        acc[i + 1] = acc[i] + a[i];
    }

    ll inf = 1LL << 60;
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, inf));
    REP(i, 0, n)
    {
        dp[i][i + 1] = 0;
    }

    REP(len, 2, n + 1)
    REP(l, 0, n - len + 1)
    {
        int r = l + len;
        REP(m, l + 1, r)
        {
            dp[l][r] = min(dp[l][r], dp[l][m] + dp[m][r]);
        }
        dp[l][r] += acc[r] - acc[l];
    }

    cout << dp[0][n] << endl;
}

Measured memory_bytes: 4516
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define MOD 1000000007
#define MAX 100100
#define ll long long
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,ans=1;
int a[MAX],dg[MAX];
bool cir[MAX];
int col[MAX],foot[MAX],cnt[MAX];
int f[MAX];
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=read(),++dg[a[i]];
	for(int i=1;i<=n;++i)
	{
		if(col[i])continue;
		int x=i;
		for(;!col[x];x=a[x])col[x]=i;
		if(col[x]!=i)continue;//circle with foot
		for(;!cir[x];x=a[x])cir[x]=true;//circle
	}
	for(int i=1;i<=n;++i)//illegal part 
		if((cir[i]&&dg[i]>2)||(!cir[i]&&dg[i]>1)){puts("0");return 0;}
	for(int i=1;i<=n;++i)
	{
		if(dg[i])continue;//start of a foot do not have egde in
		int x=i,len=0;
		while(!cir[x])x=a[x],++len;
		foot[x]=len;//record length
	}
	for(int i=1;i<=n;++i)//calculate answer of circle with feet
	{
		if(!cir[i])continue;//calculate circles
		int x=i,pts=0,st=0,l1=0,fr=0;
		//st:last root of foot,fr:first root of foot,l1:length of the first foot
		//pts:number of the node in the circle
		while(cir[x])
		{
			++pts;cir[x]=false;
			if(foot[x])//a foot in the circle
			{
				if(!fr)st=fr=pts,l1=foot[x];
				else
				{
					int ways=(foot[x]<(pts-st))+(foot[x]<=(pts-st));
					ans=ans*ways%MOD;st=pts;
				}
			}
			x=a[x];
		}
		if(fr)//circle of feet
		{
			int ways=(l1<(pts+fr-st))+(l1<=(pts+fr-st));
			ans=ans*ways%MOD;
		}
		else//just a circle
			cnt[pts]+=1;
	}
	for(int i=1;i<=n;++i)//dp,in order to calc each length of circles
	{
		if(!cnt[i])continue;
		f[0]=1;
		for(int j=1;j<=cnt[i];++j)
		{
			if(i>1&&(i&1))//odd circle
				f[j]=(f[j-1]<<1)%MOD;//two ways
			else//even circle
				f[j]=f[j-1];//only one way
			if(j>1)f[j]=(f[j]+1ll*f[j-2]*(j-1)%MOD*i%MOD)%MOD;
			//merge two circle in the same length
		}
		ans=1ll*ans*f[cnt[i]]%MOD;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define ll long long int  

using namespace std;

void solve(){

	string n;
  	cin>>n;
	
  for(ll i=0;i<3;i++){
   	if(n[i] == '7'){
      cout<<"Yes"<<endl;
    	return;
    }
  }
  cout<<"No"<<endl;
  
}

int main(){

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

	ll t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}

}


Measured memory_bytes: 3652
#include <stdio.h>
int main(void){
    int x[9<<14];
    int i=0;
    int j=0;
    int min=9<<25;
    
    for(;~scanf("%d",x+i);i++);
    for(j=1;j<x[0]-x[1]+2;j++)min=fmin(x[j+x[1]]-x[j+1]+fmin(abs(x[j+1]),abs(x[j+x[1]])),min);
    printf("%d",min);
}

Measured memory_bytes: 2476
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main(){
    string S;
    cin >> S;
    ll w;
    cin >> w;
    REP(i,S.size()){
        if((i)%w==0){
            cout << S[i];
        }
    }
    cout << endl;
    return 0;

}

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

using namespace std;

#define REP(i,n)	for(int i=0, 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(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100010


const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];


int main(){
	int N; cin >> N;
	vector<ll> A(MAX,0);
	ll cnt = 0;

	REP(i,N){
		int t; cin >> t;
		A[t]++;
		cnt += t;
	}

	int Q; cin >>Q;
	REP(i,Q){
		ll B,C;
		cin >> B >> C;
		cnt -= B*A[B];
		cnt += C*A[B];
		A[C] += A[B];
		A[B] = 0;
		cout << cnt << endl;
	}


	return 0;
}
 



Measured memory_bytes: 4060
#include <iostream>

using namespace std;

#define rep(i,n) for(int i=0; i<(int)(n); i++)

typedef long long ll;

int main() {
  int n;
  ll k;
  cin >> n >> k;
  int a[n], b[n];
  rep(i,n) cin >> a[i];
  rep(i,n) b[i] = -1;
  
  int t = 1, l = 0, s;
  while(b[t-1] == -1) {
    b[t-1] = l;
    t = a[t-1];
    l++;
  }
  s = b[t-1];
  l = l - s;
  
  if(k > s) {
    k = (k - s) % l;
  } else {
    t = 1;
  }
  
  for(; k > 0; k--) t = a[t-1];
  cout << t << endl;
  return 0; 
}

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

long long mod = 1000000007;

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int main()
{
	long long x, y;
	cin >> x >> y;

	// 1,2 が　a 個、2,1 が b 個必要と仮定
	// この a, b の組み合わせは一通りだけ
	// まずはこれがあるかどうか見つける

	long long a, b;

	// この連立方程式を解く
	//a + 2 * b == x;
	//b + 2 * a == y;

	//a + 2 * (y - 2 * a) == x
	//a + 2 * y - 4 * a == x
	//-3 * a == x - 2 * y
	//a == (x - 2 * y) / (-3);
	//b == y - 2 * a
	//b == (-3 * y - 2 * x + 4 * y) / (-3)
	//b == (2 * x - y) / 3

	if(0 <= (2 * y - x)
		&& (2 * y - x) % 3 == 0
		&& 0 <= (2 * x - y)
		&& (2 * x - y) % 3 == 0
		) {
		a = (2 * y - x) / 3;
		b = y - 2 * a;

		//あとは a, b の組み合わせの数が解になるはず
		long long m = min(a, b);
		long long ret = 1;
		long long t = a + b;
		for (long long i = 0; i < m; ++i) {
			ret *= t;
			ret %= mod;
			--t;
		}
		for (long long i = 2; i <= m; ++i) {
			ret *= modinv(i, mod);
			ret %= mod;
		}
		cout << ret << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!


n, m = map(int, input().split())
A = [[0 for j in range(m)] for i in range(n)]
B = [0 for i in range(m)]

for i in range(n):
   A[i] = list(map(int, input().split()))
   
for i in range(m):
   B[i] = int(input())

sum = 0
for i in range(n):
   for j in range(m):
      sum += A[i][j] * B[j]
   print(sum)
   sum = 0


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

l_max = 1
r_min = N
for m in range(M):
    left, right = map(int, input().split())
    l_max = max(l_max, left)
    r_min = min(r_min, right)

if r_min < l_max:
    print(0)
else:
    print(r_min-l_max + 1)



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

int main() {
  int N;
  cin >> N;
  N %= 10;
  if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) cout << "hon" << "\n";
  else if (N == 3) cout << "bon" << "\n";
  else cout << "pon" << "\n";
}

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

const int INF = 1001001001;

int main() {
int a,b,c;
cin >> a >> b >> c;
if (a+b == c || a+c == b || b+c == a) {
  cout << "Yes" << endl;
} else cout << "No" << endl;




return 0;
}

Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> II;
typedef pair<LL, II> III;
typedef priority_queue<III, vector<III>, greater<>> Queue;
static const LL INF = 1LL << 60;

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

#if 0
	auto possible = [&](LL t) {

		return false;
	};
	LL left = 1, right = 1000000000;
	while (right - left > 1) {
		LL mid = (left + right) / 2;
		if (possible(mid)) {
			left = mid;
		} else {
			right = mid;
		}
	}
#endif

void solve(long long a, long long b, long long c, long long d) {
	LL ans = b * d;
	ans = max(ans, a * c);
	ans = max(ans, b * c);
	ans = max(ans, a * d);
	if (ans < 0) {
		if ((a <= 0 && b > 0) || (c <= 0 && d > 0)) {
			ans = 0;
		}
	}
	cout << ans << endl;
}

int main() {
    long long a;
	std::cin >> a;
	long long b;
	std::cin >> b;
	long long c;
	std::cin >> c;
	long long d;
	std::cin >> d;
	solve(a, b, c, d);
	return 0;
}


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

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


const int mod = 1e9 + 7;

pair<string, bool> bits(int x, int n, int k)
{
    int c = 0;
    bool r = false;
    string ret = "1";
    rep(i, n - 1)
    {
        if (x % 2)
        {
            ret += '1';
            c++;
        }
        else
        {
            ret += '0';
        }
        x /= 2;
    }
    if (c == k - 1)
        r = true;

    return make_pair(ret, r);
}

ll cost(int a[], int n, string s)
{
    ll res = 0;
    int height = 0;
    rep(i, n)
    {
        if (s[i] == '1')
        {
            if (height < a[i])
                height = a[i];
            else
            {
                res += height + 1 - a[i];
                height++;
            }
        }
        else
        {
            if (height < a[i])
            {
                height = a[i];
                res += a[i] - height;
            }
        }
    }
    return res;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n) cin >> a[i];
    ll ans = 10e12;
    pair<string, bool> res;

    rep(i, pow(2, n - 1))
    {
        res = bits(i, n, k);
        if (res.second)
            ans = min(cost(a, n, res.first), ans);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(){
	while(true){
		int x,y; cin >> x >> y;
		if(x == 0)break;
		int h = x*x + y*y;
		int dx = x, dy = y;
		int s = (int)1e9;
		bool flag = false;
		for(int i = 1; i < 151; i++){
			for(int j = i+1; j < 151; j++){
				int t = i*i + j*j;
				if(h == t && i > dx && !flag){
					flag = true;
					s = t;
					x = i; y = j;
				}
				else if( t > h && t < s){
					s = t;
					x = i; y = j;
				}
			}
		}
		cout << x << " " << y << endl;
	}


	return 0;
}




Measured memory_bytes: 3068
#include<stdio.h>
#include<string.h>
int main()
{
    char a[1000000];
    long long sum=0,l;
    scanf("%s",a);
    l = strlen(a);
    for(int i = 0;i<l;i++)
    {
        sum+=a[i]-'0';
    }
    if(sum%9==0)
    printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 1812
s = input()
t = input()

for i in range(len(s) - len(t) + 1)[::-1]:
    for j, (ns, nt) in enumerate(zip(s[i:i+len(t)], t)):
        if ns != nt and ns != '?':
            break
        if j == len(t) -1:
            ans = s[:i] + t + s[i+len(t):]
            print(ans.replace('?', 'a'))
            exit()
print('UNRESTORABLE')


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  int A=0, B=0;
  for(int i=0; i<N; i++){
    if(i%2==0){
      A += a[i];
    }else{
      B += a[i];
    }
  }
  cout << A-B << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int linearSearch(int*,int*,int,int);

int main(){
  int n,q,i;
  int S[10000],T[500];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  printf("%d\n",linearSearch(S,T,n,q));
  return 0;
}

int linearSearch(int *S,int *T,int n,int q){
  int cnt=0,i,j;
  
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i] == S[j]){
	cnt++;
	break;
      }
    }
  }
  return cnt;
}



Measured memory_bytes: 2108
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

n_p = list(itertools.permutations([i + 1 for i in range(n)], n))
a = -1
b = -1
for i in n_p:
    if a != -1 and b != -1:
        break
    if i == p:
        a = n_p.index(i)
    if i == q:
        b = n_p.index(i)

print(abs(a - b))

Measured memory_bytes: 8052
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;
import java.awt.*;

public class Main{

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

        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        for (int i = 0; i < 10; i++) {
            x = r*x-d;
            System.out.println(x);
        }



        sc.close();
    }

    
static class Mathalgo{
    static int n;
    static long MOD = 1000000007;
    static int MAX = 510000;
    static long[] finv = new long[MAX];
    static long[] inv = new long[MAX];
    static long[] fac = new long[MAX];

    public static String make_bi_nari(int nbit, int num_to_binary) {
        String res = Integer.toBinaryString(num_to_binary);
        while(res.length() != nbit){
            res = "0" + res;
        }
        return res;
    }


    public static long fib(int x) {
        long[] fib = new long[x+1];
        fib[0] = 0; fib[1] = 1;
        for (int i = 2; i <= x; i++) {
            fib[i] = fib[i-1] + fib[i-2];
        }
        return fib[x];
    }

    public static int ManhattanDist(int x, int y, int xx, int yy) {
        return(Math.abs(xx-x) + Math.abs(yy-y));
    }

    static long modpow(long a, long n, long mod) {
        long res = 1;
        while (n > 0) {
            if (n % 2 == 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }
    
    
    static long modinv(long a, long mod) {
        return modpow(a, mod - 2, mod);
    }

    static void nCkmake() {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i < MAX; i++){
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[(int)MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    
    static long nCk(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }

    public static long gcd_long(long a, long b) {
        if (a < b) {
            long x = a;
            a = b;
            b = x;
        }
        if (b == 0) {
            return a;
        }else{
            return gcd_long(b, a%b);
        }
    }

    public static long lcm_long(long a, long b) {
        long gcd = gcd_long(a,b);
        return a/gcd*b;
    }

    public static long GyakuGenMOD(long a) {
        return RepSquareMethod(a, MOD-2);
    }
    
    public static long factmod(int a) {
        long[] fact = new long[a+1];
        fact[0] = fact[1] = 1;
        for (int i = 2; i <= a; i++) {
            fact[i] = (fact[i-1]*i)%MOD;
        }
        return fact[a];
    }

    public static long RepSquareMethod(long a, long n) { // a^n
        long ans = 1;
        while (n > 0) {
            if ( n % 2 == 1) {
                ans = (ans * a) % MOD;
            }
            a = (a*a)%MOD;
            n/=2;
        }
        return ans;
    }
}
}




Measured memory_bytes: 22228
(let ((o (concatenate 'list (read-line)))
      (e (concatenate 'list (read-line)))
      (lst '()))

  (loop for i from 0 to (1- (length o))
        for j from 0 to (1- (length e))
        do (if (= (length o) (length e))
             (progn (push (nth i o) lst)
                    (push (nth j e) lst))
             (progn (push (nth i o) lst)
                    (push (nth j e) lst)
                    (if (not (nth (1+ j) e)) (push (nth (1+ i) o) lst)))))

  (setq lst2 (concatenate 'string (reverse lst)))

  (format t "~A~%"
          lst2))


Measured memory_bytes: 13544
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
    s = input()
    if(s == "AC"):
        AC += 1
    elif(s == "WA"):
        WA += 1
    elif(s == "TLE"):
        TLE += 1
    else:
        RE += 1
        
print("AC x "+ str(AC))
print("WA x "+ str(WA))
print("TLE x "+ str(TLE))
print("RE x "+ str(RE))


Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
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; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int dist[1000][1000];
string grid[1000];
int h, w, sy, sx, gy, gx;
const int INF = (1 << 30);

int main() {
  cin >> h >> w;
  cin >> sy >> sx;
  sy--, sx--;
  cin >> gy >> gx;
  gy--; gx--;
  rep(i, h){
    rep(j, w){
      dist[i][j] = INF;
    }
  }
  rep(i, h) cin >> grid[i];
  dist[sy][sx] = 0;
  deque<P> que;
  que.push_front(P(sy, sx));
  while (!que.empty()){
    P p = que.front();
    que.pop_front();
    int cy = p.first, cx = p.second;
    for (int i = 0; i < 4; i++){
      int ny = cy + dy[i], nx = cx + dx[i];
      if (ny < 0 || h <= ny || nx < 0 || w <= nx)continue;
      if(grid[ny][nx] == '#')continue;
      if(dist[ny][nx] <= dist[cy][cx])continue;
      dist[ny][nx] = dist[cy][cx];
      que.push_front(P(ny, nx));
    }
    for (int i = cy -2; i <= cy + 2; i++){
      for (int j = cx - 2; j <= cx + 2; j++){
        if (i < 0 || h <= i || j < 0 || w <= j)continue;
        if(grid[i][j] == '#')continue;
        if(dist[i][j] <= dist[cy][cx] + 1)continue;
        dist[i][j] = dist[cy][cx] + 1;
        que.push_back(P(i, j));
      }
    }
  }
  if(dist[gy][gx] ==INF){
    cout << -1 << endl;
  }else{
    cout << dist[gy][gx] << endl;
  }
}


Measured memory_bytes: 9468
#include <stdio.h>

int main(){

    int x, y, z;
    int a;

    scanf("%d %d %d", &x, &y, &z);

    a = z;
    z = y;
    y = x;
    x = a;

    printf("%d %d %d", x, y, z);

    return 0;

}



Measured memory_bytes: 1696
import java.io.*;
import java.util.*;
import java.util.Map.Entry;

public class Main {
		
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int[] P = new int[N];
		int[] num = new int[3];
		for(int i = 0; i < N; i++){
			P[i] = sc.nextInt();
			if(P[i] <= A) num[0]++;
			if(P[i] > A && P[i] <= B) num[1]++;
			if(P[i] > B) num[2]++;
		}
		
		int ans = Math.min(num[0], Math.min(num[1], num[2]));
		System.out.println(ans);
		
		
	}//end main
	
}//end Main

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


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

int main() {
    int N;
    cin >>N;
    vector<int>data(N);
     for(int i=0;i<N;i++)cin >>data[i];
    vector<int>data2=data;
    sort(data.begin(),data.end());
    reverse(data.begin(),data.end());
    int mx1=data[0];
    int mx2=data[1];
   
    for(int i=0;i<N;i++){
        if(data2[i]!=mx1)cout<<mx1<<endl;
        else cout <<mx2<<endl;
    }
}

Measured memory_bytes: 3200
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			double r = sc.nextDouble();
			double ret = 0.00;
			
			ret = 2*3.141592*r;
			
			System.out.println(ret);
			
		}
	}


Measured memory_bytes: 37280
#include <stdio.h>
#define MAX 100000
int A[MAX];
int main(){
  int i, j, k, n, x, p, r, tmp;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  p = 0;
  r = n - 1;
  x = A[r];
  i = p - 1;
  for(j = p; j <= r - 1; j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = tmp;
  for(k = 0; k < (i + 1); k++){
    printf("%d ", A[k]);
  }
  printf("[%d] ", A[i + 1]);
   for(k = (i + 2); k < (n - 1); k++){
    printf("%d ", A[k]);
  } 
  printf("%d\n", A[k]);
  return 0;
}

Measured memory_bytes: 984
N = int(input())

A = [int(input()) for _ in range(N)]

res = 0
last = N
for i,a in zip(reversed(range(N)), reversed(A)):
    j = i-a
    if j > last or j < 0:
        res = -1
        break
    elif j < last:
        last = j
        res += a

print(res)


Measured memory_bytes: 88156
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> a = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
      a.add(sc.nextInt());
    }
    Collections.sort(a);
    int cost1 = a.get(1) - a.get(0);
    int cost2 = a.get(2) - a.get(1);
    System.out.println(cost1 + cost2);
  }
}

Measured memory_bytes: 22996
/**
* Think twice, code once.
* 1.integer overflow(maybe even long long overflow : (a+b >= c) -> (a >= c-b)
* 2.runtime error
* 3.boundary condition
* ---------------------------------------------------------------------------------------
* Author : zzy
* Date : 2020-03-28-19.53.54 Saturday
*/
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

string s;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> s;
    bool ok = false;
    if (s[2] == s[3] && s[4] == s[5]) ok = true;
    cout << (ok?"Yes":"No") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

#define MAX 100000
#define INF 1e+9


int lcs(vector<int>& a){
	  vector<int> L(MAX,INF);
	  for(int i=0; i<a.size(); i++){
			*lower_bound(L.begin(),L.end(),a[i]) = a[i];
	  }
	  return lower_bound(L.begin(),L.end(),INF) - L.begin();
}


int main(){

	  int n; cin >> n;
	  vector<int> a(n);
	  for(int i=0; i<n; i++)
			cin >> a[i];
	  cout << lcs(a) << endl;
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll n,m;cin>>n>>m;
  vector<int>G[n];
  vector<ll>h(n);
  rep(i,n)cin>>h[i];
  rep(i,m){
    ll a,b;cin>>a>>b;a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  ll ans=0;
  rep(i,n){
    bool isOK=true;
    for(auto j :G[i]){
      if(h[i]<=h[j])isOK=false;
    }
    if(isOK)ans++;
  }
  cout<<ans<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 9268