akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define INF 1<<30
#define LINF 1ll<<60ll
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)


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

Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 998244353

a, b, c, d = MAP()
dp0 = list2d(c+1, d+1, 0)
dp1 = list2d(c+1, d+1, 0)

dp1[a][b] = 1
for i in range(a, c+1):
    for j in range(b, d+1):
        dp0[i][j] += dp0[i-1][j] * j
        dp0[i][j] += dp1[i-1][j] * j
        dp1[i][j] += dp1[i][j-1] * i
        dp1[i][j] += dp0[i][j-1]
        dp0[i][j] %= MOD
        dp1[i][j] %= MOD
ans = (dp0[c][d] + dp1[c][d]) % MOD
print(ans)


Measured memory_bytes: 209200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <array>

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

using namespace std;

#define ll long long
#define all(v) v.begin(),v.end()
#define bootstrap ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);


void solve() {
    // A and B = All - ~A - ~B + ~(A or B)
    ll num;
    cin >> num;
    ll a = 1;
    ll b = 2;
    ll c = 1;
    ll mod = 1000000007;
    for (ll i = 0; i < num; i++) {
        a = (a * 10) % mod;
        b = (b * 9) % mod;
        c = (c * 8) % mod;
    }
    ll res = (a - b + c) % mod;
    if(res >= 0){
        cout << res;
    } else {
        cout << res + mod;
    }
}

int main() {
    bootstrap
    solve();
}


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

int main(int argc, const char * argv[]) {
    char c;
    cin >> c;
    char vowels[6] = "aiueo";
    for (int i(0); i < 6; i++){
        if (c == vowels[i]){
            cout << "vowel";
            return 0;
        }
    }
    cout << "consonant";
    return 0;
} 

Measured memory_bytes: 256
#import decimal
#decimal.getcontext().prec==500 Floatの桁数を500まで増やす
#Decimal(c).sqrt() それで平方根を求める
#Decimal(1) / Decimal(7) 1/7
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math
from fractions import gcd
import sys
#input = sys.stdin.readline


#N=int(input())

N,Ma,Mb=map(int,input().split())
ABC=[list(map(int,input().split())) for i in range(N)]
idle_max=10**9
dp=[[idle_max for m in range(403*400)] for i in range(N)]
used=set()
a,b,c=ABC[0]
dp[0][a*401+b]=c
for n in range(1,N):
    a,b,c=ABC[n]
    for i in range(len(dp[0])):
        if i-(a*401+b)>=0 and dp[n-1][i-(a*401+b)]!=idle_max:
            dp[n][i]=min(dp[n-1][i-(a*401+b)]+c,dp[n-1][i])
        else:
            dp[n][i]=dp[n-1][i]
    dp[n][a*401+b]=min(dp[n-1][a*401+b],c)

value=idle_max
for i in range(len(dp[0])):
    if dp[-1][i]:
        A=i//401;B=i%401
        if A and B:
            Z=gcd(A,B)
            A//=Z;B//=Z
            if Ma==A and Mb==B:
                value=min(value,dp[-1][i])
if value!=idle_max:
    print(value)
else:
    print(-1)


Measured memory_bytes: 145484
def get_operator(n):
    if n == -1:
        return "-"
    return "+"


def main():
    ticket_num = input()
    numbers = [int(ticket_num[i]) for i in range(len(ticket_num))]
    operator = [1, -1]
    flag = True
    for op1 in operator:
        for op2 in operator:
            for op3 in operator:
                if numbers[0] + op1 * numbers[1] + op2 * numbers[2] + op3 * numbers[3] == 7 and flag:
                    print(ticket_num[0] + get_operator(op1) + ticket_num[1] + get_operator(op2) + ticket_num[2] +
                          get_operator(op3) + ticket_num[3] + "=7")
                    flag = False


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES //円周率を使用
#include <math.h>
#include <iomanip> //小数点以下を表示
#include <iostream>
using namespace std;

int main(void)
{
	int n; //整数の個数
	long int a[10000]; //整数
	int i; //カウンタ変数
	long int min = 0, max = 0, total = 0;

	cin >> n;

	if (n <= 0 || n > 10000)
		return 0;

	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	for (i = 0; i < n; i++)
	{

		if (a[i] < -1000000 || a[i] > 1000000)
			return 0;

	}

	min = a[0];
	for (i = 1; i < n; i++)
	{
		if (min > a[i])
			min = a[i];
	}

	max = a[0];
	for (i = 1; i < n; i++)
	{
		if (max < a[i])
			max = a[i];
	}

	for (i = 0; i < n; i++)
	{
		total += a[i];
	}

	cout << min << ' ' << max << ' ' << total << endl;

	return 0;
}


Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> a(m),b(m);
  for(Int i=0;i<m;i++) cin>>a[i]>>b[i];

  const Int BS = 400;
  vector<Int> x(n,0);
  vector<vector<Int> > p(BS,vector<Int>(BS,0));
  vector<Int> d(n,0);
  Int f=0;
  
  for(Int i=0;i<m;i++){
    if(b[i]<BS){
      for(Int j=0;j<b[i];j++)
	p[b[i]][j]+=(a[i]+j+1)%b[i];
    }else{
      f++;
      d[0]+=a[i];
      for(Int j=b[i]-(a[i]+1);j<n;j+=b[i])
	d[j]+=-b[i];
    }
  }
  
  for(Int i=1;i<BS;i++)
    for(Int j=0;j<n;j++)
      x[j]+=p[i][j%i];

  for(Int j=0;j<n;j++){
    if(j) d[j]+=d[j-1];
    d[j]+=f;
    x[j]+=d[j];
  }
  
  for(Int i=0;i<n;i++) cout<<x[i]<<endl;
  return 0;
}



Measured memory_bytes: 7076
#include<bits/stdc++.h>
using namespace std;
mt19937 rd(time(0));
#define int long long
const int M=1004535809;
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
const int N=250005;
pii f1[N],f2[N];
char s[N];
int n;
map<pair<int,int>,int> Map;
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=x*x%M)
		if (y&1)(ans*=x)%=M;
	return ans;
}
pii fuhe(pii x,pii y){
	return mp((x.fi*y.fi)%M,(x.fi*y.se+x.se)%M);
}
signed main(){
	scanf("%lld",&n);
	scanf("%s",s+1);
	int x1=rd()%(M-1)+1,x2=rd()%(M-1)+1;
	int Inv1=ksm(x1,M-2),Inv2=ksm(x2,M-2);
	f1[0]=mp(1,0);f2[0]=mp(1,0);
	for (int i=1;i<=n;i++){
		if (s[i]=='+')f1[i]=fuhe(f1[i-1],mp(1,1)),f2[i]=fuhe(f2[i-1],mp(1,1));
		if (s[i]=='-')f1[i]=fuhe(f1[i-1],mp(1,M-1)),f2[i]=fuhe(f2[i-1],mp(1,M-1));
		if (s[i]=='<')f1[i]=fuhe(f1[i-1],mp(x1,0)),f2[i]=fuhe(f2[i-1],mp(x2,0));
		if (s[i]=='>')f1[i]=fuhe(f1[i-1],mp(Inv1,0)),f2[i]=fuhe(f2[i-1],mp(Inv2,0));
	}
	int ans=0;
	for (int i=1;i<=n;i++){
		Map[mp((fuhe(f1[i-1],f1[n])).se,(fuhe(f2[i-1],f2[n])).se)]++;
		ans+=Map[mp(f1[i].se,f2[i].se)];
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 39552
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
listToTuple (x : y : _) = (x, y)

main = do
    [n, m] <- getIntList
    scs <- sort . map listToTuple <$> replicateM m getIntList
    let ns = f n
    let ans = [n | n <- ns, and $ map (\(s, c) -> (show n) !! (s - 1) == head (show c)) scs]
    if null ans then print (-1) else print $ head ans

f n | n == 1 = [0..9]
    | n == 2 = [10..99]
    | n == 3 = [100..999]

Measured memory_bytes: 764
#include "bits/stdc++.h"

using namespace std;

#define cerr if(false)cerr
#define what(x) cerr<<#x<<" = "<<x<<endl
 
typedef long long ll;
typedef pair<ll, ll> ii;

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 322;

int main(){

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

	int n, m;
	cin >> n >> m;

	vector<vector<int>> graph(n);

	int a, b;
	for(int i = 0; i < m; i++){
		cin >> a >> b;
		--a;--b;
		graph[a].push_back(b);
		graph[b].push_back(a);

	}

	vector<bool> vis(n, false);
	vector<int> parent(n, 0);
	
	queue<int> pq;
	pq.push(0);
	while(!pq.empty()){
		int node = pq.front();
		pq.pop();
		vis[node] = true;
		for(auto& it : graph[node]){
			if(vis[it]) continue;
			vis[it] = true;
			parent[it] = node;
			pq.push(it);
		}
	}

	for(int i = 0; i < n; i++){
		if(!vis[i]){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	for(int i = 1; i < n; i++){
		cout << parent[i] + 1 << endl;
	}


	return 0;
}

Measured memory_bytes: 10120
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
#define fo(i,x,y) for(register int i=x;i<=y;++i)
#define go(i,x,y) for(register int i=x;i>=y;--i)
using namespace std;

inline int read(){
	int x=0,fh=1;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*fh;
}

const int maxn=1e4+5;
int a[maxn],b[maxn],ans;

int main(){
	int x=read(),n=read(),cha=0;
	fo(i,1,n) a[i]=read(),b[a[i]]=1;
	while(1){
		int p=x-cha,q=x+cha;
		if(!b[p]){
			ans=p;
			break;
		}
		if(!b[q]){
			ans=q;
			break;
		}
		if(p==0) break;
		++cha;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define L long long
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define aa first
#define bb second
#define xx aa.aa
#define yy aa.bb
#define zz bb
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
int n,m,t,f[810][810],dx[4]={1,-1,0,0},dy[4]={0,0,1,-1},x[1000000],y[1000000],r,p=1e9;
char s[810][810];
inline void chk(int i,int j)
{
	int k=min(min(i-1,j-1),min(n-i,m-j));
	k=(k?((k-1)/t+1):0);
	p=min(p,k+1);
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j;
	scanf("%d%d%d",&n,&m,&t);
	for(i=1;i<=n;i++)
	  scanf("%s",&s[i][0]+1);
	for(i=1;i<=n;i++)
	  for(j=1;j<=m;j++)
	    if(s[i][j]=='S')
	      {
		   r=1;
		   x[1]=i;
		   y[1]=j;
		   f[i][j]=1;
		  }
	for(i=1;i<=r && f[x[i]][y[i]]<=t;i++)
	  for(j=0;j<4;j++)
	    if(x[i]+dx[j]>0 && x[i]+dx[j]<=n && y[i]+dy[j]>0 && y[i]+dy[j]<=m && !f[x[i]+dx[j]][y[i]+dy[j]] && s[x[i]+dx[j]][y[i]+dy[j]]=='.')
	      {
		   f[x[i]+dx[j]][y[i]+dy[j]]=f[x[i]][y[i]]+1;
		   x[++r]=x[i]+dx[j];
		   y[r]=y[i]+dy[j];
		  }
	for(i=1;i<=r;i++)
	  chk(x[i],y[i]);
	printf("%d\n",p);
	return 0;
}


Measured memory_bytes: 11264
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
       if(a<b && b<c) {
    	   System.out.println("Yes");
       }else {
    	   System.out.println("No");
       }

    }

}


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

using namespace std;
 

 
int main()
{
    long long int N,M;
    cin>>N>>M;
 
    if(N==1 && M==1) 
        cout<<1;   
    else if(N==1 && M>1) 
        cout<<M-2;
    else if(N>1 && M==1) 
        cout<<N-2;
    else
    {
        cout<<M*N - 2*(M+N) + 4;
    } 
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<bits/stdc++.h>
using namespace std;
string s[105];
int n,l;
int main(){
	cin>>n>>l;
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	sort(s,s+n);
	string ans="";
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
			ans=ans+s[i][j];
		}
	}
	cout<<ans;
	return 0;
}

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

int main()
{
	cin>>n;
	int ans, x;
	cin >> ans;
	for(int i=1;i<n;i++){
		cin>>x;
		ans = __gcd(ans, x);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() 
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int x = A + B - (C + D);

  if (x == 0) puts("Balanced");
  else if (x > 0) puts("Left");
  else puts("Right");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int n, m, in[5000];
int twoans = 0;
vector<int> edge[5000];
vector<int> ans;
int main() {
	fill(in, in + 5000, 0);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		edge[a].push_back(b);
		in[b]++;
	}

	while (ans.size()!=n) {
		int memo = -1;
		for (int i = 0; i < n; i++) {
			if (in[i] == 0) {
				if (memo == -1) {
					memo = i;
				}
				else {
					memo = i;
					twoans = 1;
					break;
				}
			}
		}
		ans.push_back(memo + 1);
		for (int j = 0; j < edge[memo].size(); j++) {
			in[edge[memo][j]]--;
		}
		in[memo]--;
	}
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}
	cout << twoans << endl;
	return 0;
}




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

int main(){
	int n,m;
	cin >> n >> m;
	vector<bool> broken(n,false);
	int a;
	REP(i,m){
		cin >> a;
		broken[a] = true;
	}
	ll modnum = 1000000007;
	vector<ll> step(n+1);
	
	step[0] = 1;
	for(int i=1; i<=n; ++i){
		if(broken[i]) continue;
		ll count = 0;
		if(i-1 >= 0 && !broken[i-1]){
			count += step[i-1];
		}
		if(i-2 >= 0 && !broken[i-2]){
			count += step[i-2];
		}
		count = count%modnum;
		step[i] = count;
	}
	
	cout << step[n] << endl;
	
	return 0;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int n;
int x[100005][3];
int f[100005][3];

int main(){
	scanf("%d",&n);
	fore(i,0,n)fore(j,0,3)scanf("%d",&x[i][j]);
	fore(i,0,n)fore(j,0,3)fore(k,0,3)if(j!=k)
		f[i+1][k]=max(f[i+1][k],f[i][j]+x[i][k]);
	int r=0;
	fore(j,0,3)r=max(r,f[n][j]);
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <iostream>

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName
#define INPUT_LLINT(valName) long long int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string& str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }

template <typename T> void insert(vector<T>& dest, const vector<T>& src) { copy(src.begin(), src.end(), back_inserter(dest)); }

template <long long int MOD> long long int mod_inv(long long int a) {
	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}

template <long long int MOD> long long int mod_add(long long int a, long long int b) {
	return (a + b) % MOD;
}

template <long long int MOD> long long int mod_sum(long long int a, long long int b) {
	return (a - b) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b) {
	return (a % MOD) * (b % MOD) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b, long long int c) {
	return mod_mul<MOD>(a, mod_mul<MOD>(b, c));
}

template <long long int MOD> long long int mod_div(long long int a, long long int b) {
	return (a % MOD) * mod_inv<MOD>(b) % MOD;
}

int sign(long long int a) {
	return a >= 0 ? 1 : -1;
}


//------------------------------------------------------------------------------------------------------------------------------

void f(string& str, int offset, int k, int m, int N) {

	str[offset] = 'a' + (k-1);

	//printf("%d,%d,   %s\n",offset, k, str.c_str());

	if (offset + 1 < N) {
		for (int n = 1; n <= m + 1; ++n) {
			f(str, offset + 1, n, max(m, n), N);
		}
	} else {
		OUTPUT(str);
	}
}


int main() {

	// TODO: streamやめる

	cin.tie(0); ios::sync_with_stdio(false);

	INPUT_LLINT(N);

	std::string str;
	for (int i = 0; i < N; ++i) {
		str.append("a");
	}

	f(str, 0, 1, 1, N);

	return 0;
}


Measured memory_bytes: 1536
import math
a,b,x=map(float, input().split())

n=x/a/a
if n>b/2:
    n=(b-n)*2
    atan = math.degrees(math.atan(n/a))
    print('{:.10f}'.format(atan))
else:
    n=n/b*2*a
    atan = math.degrees(math.atan(b/n))
    print('{:.10f}'.format(atan))

Measured memory_bytes: 3060
import std.stdio;
import std.math;

double[3] xp, yp;

void main(){
	int n;
	double xk, yk, xs, ys;
	readf("%d\n", &n);
	for (int i = 0; i < n; i++) {
		readf("%s %s %s %s %s %s %s %s\n", &xp[0], &yp[0], &xp[1], &yp[1], &xp[2], &yp[2], &xk, &yk, &xs, &ys);
		if (inTriangle(xk, yk) + inTriangle(xs, ys) == 0) writeln("OK");
		else writeln("NG");
	}
}

// true -> 1, false -> -1
int inTriangle(double x, double y){
	int a, b, c;
	a = outerProduct(xp[0], yp[0], xp[1], yp[1], x, y);
	b = outerProduct(xp[1], yp[1], xp[2], yp[2], x, y);
	c = outerProduct(xp[2], yp[2], xp[0], yp[0], x, y);
	if (abs(a+b+c) == 3) return 1;
	else return -1;
}

// return sign of AB x AP
int outerProduct(double ax, double ay, double bx, double by, double px, double py){
	double abx, aby, apx, apy;
	abx = bx - ax;
	aby = by - ay;
	apx = px - ax;
	apy = py - ay;
	if (abx*apy - apx*aby > 0) return 1;
	else return -1;
}

Measured memory_bytes: 1040
l= list(map(int, input().split()))
long=len(l)
for i in range(long-1):
	for j in range(long-1,i,-1):
		if (l[j]<l[j-1]):
			temp=l[j]
			l[j]=l[j-1]
			l[j-1]=temp

print(l[0],l[1],l[2])


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	cin>>n;
	vector<int> a(n);
	for(auto &_ : a) cin>>_;
	
	sort(ALL(a));
	
	int ans = 0;
	for(int i=0;i<n;++i)
	for(int j=0;j<i;++j)
	for(int k=0;k<j;++k) if(a[i]!=a[j]&&a[j]!=a[k] && a[i]<a[j]+a[k]) ++ans;
	
	cout<<ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 3660
def sieve(n)
  prime = (2..n).to_a
  2.upto(Math.sqrt(n)) { |i|
    prime.reject! { |v|
      v % i == 0 && v != i
    }
  }
  return prime
end

prime = sieve(100000)

loop do
  m, a, b = gets.chomp.split.map(&:to_i)

  if (m || a || b) == 0
    break
  end

  ans_p = 1;
  ans_q = 1;

  for i in prime
    for j in prime
      if i * j > m
        break
      end
      if i > j
        next
      end
      if a * j > b * i
        next
      end
      if ans_p * ans_q >=  i * j
        next
      end
      ans_p = i
      ans_q = j
    end
  end

  puts "#{ans_p} #{ans_q}"
  
end

Measured memory_bytes: 7048
#include<iostream>

using namespace std;

int main(){

  int m,n,mypozi;

  while(cin >> n >> m){
    if(n == 0 && m == 0) break;
    mypozi = 1;
    int masu[n+7];
    int status = 1;

    for(int i = 0; i < n+7; i++) masu[i] = 0;

    for(int i = 1; i < n+1; i++){
      cin >> masu[i];
    }

    for(int i = 0; i < m; i++){
      int in;
      cin >> in;
      if(status){
	mypozi += in;
	mypozi += masu[mypozi];
	if(mypozi >= n){
	  cout << i+1 << endl;
	  status = 0;
	}
      }
    } 
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

#define REP(i,f,n) for(int i=(f); i < (n); ++i)
#define PER(i,f,n) for(int i=(n-1); i >= f; --i)

constexpr int evx[4] = { 1, 0, -1, 0 };
constexpr int evy[4] = { 0, 1, 0, -1 };

//----------------------------------
//----------------------------------

signed main()
{
    ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string right = "CODEFESTIVAL2016";
	int count =0;
	REP(i, 0, 16)
	{
		if(s[i] != right[i])
			count++;
	}
	cout << count << '\n';
		
}



Measured memory_bytes: 256
S = list(map(str,input()))

ans = int(0)

for i in range(len(S)):
    if i%2 == 0 and S[i] == 'R' or S[i] == "U" or S[i] == 'D':
        ans += 1
        continue
    if i%2 == 1 and S[i] == 'L' or S[i] == "U" or S[i] == 'D':
        ans += 1
        continue
    else:
        break


if ans == len(S):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N - 1; i++) {
            int A = sc.nextInt();
            a[A - 1]++;
        }
        for (int i : a) {
            System.out.println(i);
        }
    }
}


Measured memory_bytes: 61684
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x; }

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

  ll n, x; cin >> n >> x;
  vector<ll> vec(n);
  rep(i, n) {
    int a; cin >> a;
    vec[i] = abs(a-x);
  }

  ll ans = vec[0];
  for(int i = 1; i < n; ++i) {
    ans = gcd(ans, gcd(vec[i], vec[i-1]));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	int n, m;
	int cnt,ans,c;
	cnt = ans = c = 0;
	cin >> n >> m;
	int a[105];
	for (int i = 0;i < n;i++)cin >> a[i],cnt+=a[i];
	double l,t;
	l = 1 / double(4 * m);
	t = cnt * l;
	for (int i = 0;i < n;i++) {
		if (a[i] >= t) {
			c++;
			if (c == m) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


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

using namespace std;

#define DB( x ) cout << #x << " = " << x << endl;
#define LEFT(n) (2 * (n))
#define RIGHT(n) (2 * (n) + 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> node;
//typedef vector <vector <ll>> matrix;

const ll INF = 1e9;
const double EPS = 1e-9;
const ll MOD = (ll)(23 + 99);
const ll MAXV = (ll)(2e5 + 10);
const ll MAXE = (ll)(1e6 + 10);

ll n, m;

vector<pair<ll, ll>> A;

int main(){
	cin.sync_with_stdio( 0 );cin.tie( 0 );

	cin >> n >> m;

	set<ll> S;

	for(int i = 0;i < m;i ++)
		S.insert(i);

	ll a, b;

	for(int i = 0;i < n;i ++){
		cin >> a >> b;
		A.push_back(make_pair(-b, a));
	}

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

	ll ans = 0;

	for(int i = 0;i < n;i ++){
		a = A[i].second;
		b = - A[i].first;

		auto p = S.upper_bound(m - a);
		if(p == S.begin())
			continue;
		p --;
		S.erase(p);
		ans += b;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 7160
//https://vjudge.net/contest/341126#problem/B
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 100005;
int h[N], n, a, b;

bool check(int x){
    ll sum = 0;
    rep(i, 0, n - 1){
        if(h[i] < 1LL * b * x) continue;
        sum += ceil(1.0*(h[i] - b * x)/(a - b));
    }
    return (sum > 1LL*x? false:true);
}

int binarySearch(){
    int left = 1, right = inf;
    int ans = inf;
    while(left <= right){
        int mid = left + (right - left)/2;
        if(check(mid)){
            ans = min(ans, mid);
            right = mid - 1;
        }else{
            left = mid + 1;

        }
    }
    return ans;
}

int main(){
    io;
    //freopen("input.txt", "r", stdin);
    cin >> n >> a >> b;
    rep(i, 0, n - 1){
        cin >> h[i];
    }
    cout << binarySearch();
    return 0;
}


Measured memory_bytes: 640
N = gets.to_i
H = gets.split.map(&:to_i)

max = H[0]
ans = true
1.upto(N - 1) do |i|
  if H[i] > max
    H[i] -= 1
    max = H[i]
  elsif H[i] < max
    ans = false
    break
  end
end

if ans
  puts 'Yes'
else
  puts 'No'
end


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);

	double ans=a[0]/pow(2.0, n-1);
	for(int i=1; i<n; i++){
		ans+=a[i]/pow(2.0, n-i);
	}
	printf("%.9f\n", ans);
	return 0;
}

Measured memory_bytes: 256
import sys
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
a=[0 for i in[0]*n];d=0;c=0;k=n*(n-1)//2
while c!=k and d<=10**4:
  L=[0 for i in[0]*n];y=0
  for i in range(n):
    if L[i]<1 and a[i]<n-1:
      x=l[i][a[i]]
      if l[x-1][a[x-1]]-1==i and L[x-1]<1:
        a[i]+=1;a[x-1]+=1;L[i]=1;L[x-1]=1;c+=1;y+=1
  d+=1
  if y==0:
    print(-1)
    sys.exit()
print([k,d][d<10**4])

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

int main()
{
    int N;
    cin >> N;
    
    vector<long int> H(N);
    
    for(int i=0; i<N; i++){
        long int h;
        cin >> h;
        H[i] = h;
    }
    
    for (int i=0; i<N; i++){
        if(i == 0){
            H[i] = H[i] - 1;
        }
        else{
            if(H[i-1] - H[i] >= 1){
                cout << "No" << endl;
                break;
            }
            else if(H[i-1] - H[i] == 0){
                H[i] = H[i];
            }
            else{
                H[i] = H[i] - 1;
            }
        }
        if (i == N-1){
            cout << "Yes" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

void dfs(int a, const vvll &e, vb &ald){
    if(a == 0){return;}
    if(ald[a] == true){return;}
    ald[a] = true;
    for(auto x: e[a]){
        dfs(x, e, ald);
    }
}

int main(){

    ll N, M; cin >> N >> M;
    vvll edge(N+1, vll(0));
    vll am(M), bm(M);

    for(int i=0; i<M; i++){
        int a, b; cin >> a >> b;
        am[i] = a; bm[i] = b;
        edge[a].emplace_back(b);
        edge[b].emplace_back(a);
    }
    ll c = 0;
    for(int i=0; i<M; i++){
        vvll edge2 = edge;
        for(auto &x: edge2[am[i]]){
            if(x == bm[i]){
                x = 0;
            }
        }
        for(auto &x: edge2[bm[i]]){
            if(x == am[i]){
                x = 0;
            }
        }
        vb ald(N+1, false);
        dfs(1, edge2, ald);
        for(int j=1; j<N+1; j++){
            if(ald[j] == false){
                c++;
                break;
            }
        }
    }
    cout << c;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

def prime_factor(x) :
  ret = dict()
  if x % 2 == 0 :
    ret[2] = 0
    while x % 2 == 0 :
      x //= 2
      ret[2] += 1
          
  i = 3
  while i * i <= x :
    if x % i == 0 :
      ret[i] = 0
      
      while x % i == 0 :
        x //= i
        ret[i] += 1
    i += 2
      
  if x != 1 :
    ret[x] = 1
  
  return ret

def pairwise() :
  done = set()
  for a in A :
    for k in prime_factor(a).keys() :
      if not k in done :
        done.add(k)
      else :
        return False
  return True
    
def setwise() :
  done = set(prime_factor(A[0]).keys())
  for a in A[1:] :
    done &= set(prime_factor(a).keys())
    if len(done) == 0 :
      return True
  return False
  
if pairwise() :
  print('pairwise coprime')
elif setwise() :
  print('setwise coprime')
else :
  print('not coprime')

Measured memory_bytes: 189292
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <math.h>
#include <stack>
#include <cctype>
using namespace std;
#define int long long
#define pi 2*acos(0.0)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)

signed main()
{
	int r;
	cin >> r;
	int pow = 1;
	FOR(i,1,r+1){
		pow *= i;
		pow = pow % 1000000007;
	}
	cout << pow << endl;
}

Measured memory_bytes: 256
# 初項a，交差dの数列n個の和
def arithmetic_series(a, d, n):
    return n * (2 * a + (n - 1) * d) // 2


def main():
    n = int(input())
    print(arithmetic_series(1, 1, n))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int n,val,max =0,sum=0;
    scanf("%d",&n);
    int i;
    for(i=0;i<n;i++){
        scanf("%d",&val);
        if(val > max) max = val;
        sum += val;
    }
    sum -= max/2;
    printf("%d",sum);
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    ll minx, miny, maxx, maxy;
    minx = miny = 3e9;
    maxx = maxy = -minx;
    // printf("%lld %lld %lld %lld\n", minx, miny, maxx, maxy);
    rep(i, n)
    {
        ll x, y;
        cin >> x >> y;
        minx = min(minx, x + y);
        miny = min(miny, x - y);
        maxx = max(maxx, x + y);
        maxy = max(maxy, x - y);
    }
    ll ans = max(maxx - minx, maxy - miny);
    cout << ans << endl;
    return 0;
}

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

ll N, M;
const int MAX = 5.0e5 + 100;
const int MOD = 1.0e9 + 7;
ll fac[MAX], finv[MAX], inv[MAX];

vector<ll> primeFactorization(ll n) {
    vector<ll> ret;
    ll a = 2;
    while (n >= a * a) {
        if (n % a == 0) {
            ret.push_back(a);
            n /= a;
        } 
        else a++;
    }
    ret.push_back(n);
    return ret;
}

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();

    cin >> N >> M;

    if (M == 1) {
        cout << 1 << endl;
    }
    else {
        vector<ll> pf = primeFactorization(M);
        map<ll, ll> mp;
        for (int i = 0; i < pf.size(); i++) {
            mp[pf[i]]++;
        }

        ll ans = 1;
        for (auto itr = mp.begin(); itr != mp.end(); itr++) {
            ll val = itr->second;
            ans = (ans * COM(N+val-1, val)) % MOD;
        }

        cout << ans << endl;
    }
    
    return 0;
}

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

using namespace std;
typedef long long ll;

ll N,M;
ll ac[100001], wa[100001];

int main(){
    cin >> N >> M;
    for(int i=0;i<=N;i++) ac[i] = wa[i] = 0;
    ll c_a, c_w;
    c_a = c_w = 0;
    for(int i=0;i<M;i++){
        ll p;
        string s;
        cin >> p;
        cin >> s;
        if(s == "AC"){
            if(ac[p] == 0) c_a++; 
            ac[p]++;
        }else{
            if(ac[p] == 0) wa[p]++;
        }
    }
    for(int i=0;i<=N;i++){
        if(ac[i] == 0) continue;
        c_w += wa[i];
    }
    cout << c_a << " " << c_w << endl;
    return 0;
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn dfs(cn: usize, map: &Vec<Vec<usize>>, done: &mut Vec<bool>, tn: usize, d: usize) -> bool {
    if cn == tn {
        return true;
    }
    if done[cn] {
        return false;
    }
    if d >= 2 {
        return false;
    }
    done[cn] = true;
    for i in 0..map[cn].len() {
        let mi = map[cn][i];
        if !done[mi] {
            if dfs(mi, map, done, tn, d + 1) {
                return true;
            }
        }
    }
    return false;
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut map: Vec<Vec<usize>> = vec![vec![]; n + 1];

    for _ in 0..m {
        let a: usize = read();
        let b: usize = read();
        map[a].push(b);
        map[b].push(a);
    }
    let mut done: Vec<bool> = vec![false; n + 1];
    let result = dfs(1, &map, &mut done, n, 0);
    if result {
        println!("POSSIBLE");
    } else {
        println!("IMPOSSIBLE")
    }
}


Measured memory_bytes: 18684
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
int main() {
  long long a, b, ans[4] = {};
  cin >> a >> b;
  rep(i, 4) {
    if (i == 0) {
      a = -a;
      ans[i]++;
    }
    if (i == 1) {
      b = -b;
      ans[i] += 2;
    }
    if (i == 2) {
      a = -a;
      b = -b;
    }
    if (i == 3) {
      b = -b;
      ans[i]++;
    }
    if (b >= a)
      ans[i] += b - a;
    else
      ans[i] = 1000000010LL;
  }
  sort(ans, ans + 4);
  cout << ans[0] << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

public class Example {
    public static void Main() {
        while(true) {
            string str = Console.ReadLine();
            if (str == null) break;
            int d = int.Parse(str);
            int s = 0;
            for (int i = d; i < 600; i += d) {
                s += i*i * d;
            }
            Console.WriteLine(s);
        }
    }
}

Measured memory_bytes: 8984
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> reach(n);
  vector<vector<int>> route(n, vector<int>());
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (b == n - 1) reach[a] = true;
    if (a == 0) route[a].push_back(b);
  }
  bool flag = false;
  for (auto v : route[0]) {
    if (reach[v]) {
      flag = true;
      break;
    }
  }
  if (flag)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 8512
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int w, h, c[52][52];

void dfs(int i, int j) {
    c[i][j] = 0;
    for (int k = i - 1; k < i + 2; k++) {
        for (int l = j - 1; l < j + 2; l++) {
            if (c[k][l] == 1) dfs(k, l);
        }
    }
}

int main() {
    cin >> w >> h;
    while (w) {
        rep(i, 52) rep(j, 52) c[i][j] = 0;
        rep(i, h) rep(j, w) cin >> c[i + 1][j + 1];
        int ans = 0;
        rep(i, h + 2) rep(j, w + 2) {
            if (c[i][j] == 1) {
                dfs(i, j);
                ans++;
            }
        }
        cout << ans << "\n";
        cin >> w >> h;
    }
}


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

int main(void) {
    int a=0,b=0;
    string s;
    cin >> s;
    int si = s.size();
    int ans=si;
    for (int i=1 ; i<si; i++) {
        int tmp;
        if (s[i-1] != s[i]) {
            tmp = max(i, si - i);
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


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


int main()
{
  vector<vector<int> > v = vector<vector<int> >(4, vector<int>());
  int n, w;
  cin >> n >> w;
  int w1, v1;
  cin >> w1 >> v1;
  v[0].push_back(v1);
  for(int i = 1; i < n; ++i){
    int ww, vv;
    cin >> ww >> vv;
    v[ww-w1].push_back(vv);
  }
  for(int i = 0; i < 4; ++i){
    sort(v[i].begin(), v[i].end(), greater<int>());
  }
  int maxv = 0, ip=0, jp=0, kp=0, lp=0, ivalue = 0;
  for(int i = -1; i < (int)v[0].size(); ++i){
    if (i >= 0)
      ivalue += v[0][i];
    int jvalue = 0;
    for(int j = -1; j < (int)v[1].size(); ++j){
      if (j >= 0)
        jvalue += v[1][j];
      int kvalue = 0;
      for(int k = -1; k < (int)v[2].size(); ++k){
        if (k >= 0)
          kvalue += v[2][k];
        int lvalue = 0;
        for(int l = -1; l < (int)v[3].size(); ++l){
          if (l >= 0)
            lvalue += v[3][l];
          int tmpv = ivalue + jvalue + kvalue + lvalue;
          if ((long long)(i+1)*w1 + (long long)(j+1)*(w1+1) + (long long)(k+1)*(w1+2) + (long long)(l+1)*(w1+3) <= (long long)w){
            if (tmpv > maxv){
              maxv = tmpv;
            }
          }
        }
      }
    }
  }
  cout << maxv << endl;
  return 0;
}


Measured memory_bytes: 256
#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, k;
  cin >> n >> k;

  double ans;
  rep(i, n) {
    int j = 1, l = n - i;
    while (l * j < k) j <<= 1;
    ans += 1.0 / j;
  }
  ans /= n;

  cout << setprecision(12);
  cout << ans << endl;
}

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


using namespace std;


int main ()
{
	int n;
	int m;
	cin >> n;
	int a[n-1],f[n];
	for (int i=0;i<n;i++)
		f[i]=0;
	for (int i=0;i<n-1;i++)
	{
		cin >> a[i];
		f[a[i]-1]++;
	}
	for (int i=0;i<n;i++)
	{
		cout << f[i] << endl;
	}

	/*if (sum <= n)
	cout << (n-sum);
	else
	cout << "-1";*/
		return 0;
}

Measured memory_bytes: 5196
mod=10**9+7
L=input()

dp=[]
for _ in L:
  dp.append([-1,-1])
dp[0][0]=1
dp[0][1]=2
#print(dp)
for i in range(1,len(L)):
  if L[i] == "0":
    dp[i][0] = 3*dp[i-1][0] %mod
    dp[i][1] = dp[i-1][1]
  elif L[i] == "1":
    dp[i][0] = (3*dp[i-1][0]+dp[i-1][1]) %mod
    dp[i][1] = 2*dp[i-1][1] %mod
    
#print(dp)
print((dp[-1][0]+dp[-1][1])%mod)

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

const int SIZE = 255;

int main()
{
	bool table[ SIZE ][ SIZE * 3 ];

	int n;
	while( cin >> n && n ){
		memset( table, 0, sizeof(table) );
		for( int i = 0; i < n; ++i ){
			for( int j = 0; j < n; ++j ){
				char c;
				cin >> c;
				table[ i ][ j + SIZE ] = c == '1' ? true : false;
			}
		}
		int maxLength = 0;
		for( int i = 0; i < n; ++i ){
			int col = 0, row = 0;
			for( int j = 0; j < n; ++j ){
				if( table[ i ][ j + SIZE ] ){
					++col;
					if( maxLength < col ) maxLength = col;
				}else{
					col = 0;
				}
				if( table[ j ][ i + SIZE ] ){
					++row;
					if( maxLength < row ) maxLength = row;
				}else{
					row = 0;
				}
			}
		}
		for( int i = 0; i < n * 2; ++i ){
			int diaL = 0, diaR = 0;
			for( int j = 0; j < n; ++j ){
				if( table[ j ][ i + SIZE - j ] ){
					++diaL;
					if( maxLength < diaL ) maxLength = diaL;
				}else{
					diaL = 0;
				}
				if( table[ j ][ n - 1 - i + j + SIZE ] ){
					++diaR;
					if( maxLength < diaR ) maxLength = diaR;
				}else{
					diaR = 0;
				}
			}
		}
		cout << maxLength << endl;
	}

	return 0;
}

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

class Program
{
	static void Main(string[] args)
	{
		var numbers = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));
		var min = numbers[0];
		var max = numbers[1];
		var range = numbers[2];

		var results = Enumerable.Range(min, range).Where(number => number <= max).ToList();
		results.AddRange(Enumerable.Range(max - range + 1, range).Where(number => number >= min));
		results = results.Distinct().ToList();
		results.Sort();

		results.ForEach(number => Console.WriteLine(number));
	}
}

Measured memory_bytes: 13396
N = gets.to_i
S = gets.chomp
T = gets.chomp

l = [S.size, T.size].min
ans = S + T

(0...l).each do |idx|
  s = S[-(idx + 1)..-1]
  t = T[0..idx]

  if s == t
    ans = S[0...-(idx + 1)] + s + T[(idx + 1)..-1]
  end
end

puts ans.size


Measured memory_bytes: 1788
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i, j, n, w, h, x1, y1, x2, y2, x3, y3, result;
		result = 0;
		w = scan.nextInt();
		h = scan.nextInt();
		n = scan.nextInt();
		x1 = scan.nextInt();
		y1 = scan.nextInt();
		for(i = 1; i < n; i++){
			x2 = scan.nextInt();
			y2 = scan.nextInt();
			x3 = x2 - x1;
			y3 = y2 - y1;
			if (x3 * y3 > 0){
				if(x3 < 0){
					x3 *= -1;
				}
				if(y3 < 0){
					y3 *= -1;
				}
				if(x3 > y3){
					result += x3;
				} else {
					result += y3;
				}
			} else {
				if(x3 < 0){
					x3 *= -1;
				}
				if(y3 < 0){
					y3 *= -1;
				}
				result += x3 + y3;
			}
			x1 = x2;
			y1 = y2;
		}
		scan.close();
		System.out.println(result);
	}
}

Measured memory_bytes: 25484
#include<bits/stdc++.h>
#define F(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RF(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {F(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {F(i, 0, a.size()) cout<<a[i]<<" ";}
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin>>s;

    stack<char> st;
    int ans = 0;
    F(i, 0, s.size()) {
    	if(!st.empty() && st.top() != s[i]) {
    		st.pop();
    		ans+=2;
    	} else {
    		st.push(s[i]);
    	}
    }
    cout<<ans;

    return 0;
}/*

*/

Measured memory_bytes: 512
n = int(input())
city = []
point = []
for i in range(n):
    c,p = map(str,input().split())
    p = -1*int(p)
    city.append([c,p,i+1])
    point.append([p,c,i+1])
city.sort()
point.sort()
for i in range(n):
    print(city[i][2])


Measured memory_bytes: 3060
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const N  = Number(arg[0].split(" ")[0]);
    const Q  = arg[0].split(" ")[1];
    const S  = arg[1];
    //const lr = arg.split("\n").slice(2, N + 1);
    let dp = [0, 0];
    let cnt = 0;
    
    for(let i=2; i<=N; i++) {
        if(S.charAt(i-2) === "A" && S.charAt(i-1) === "C") {
            dp.push(dp[i-1] + 1);
        } else {
            dp.push(dp[i-1]);
        }
    }

    for(let i=0; i<Q; i++) {
        let lr = arg[i+2].split(" ");
        let l = lr[0];
        let r = lr[1];
        
        console.log(dp[r]-dp[l]);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
inline int read(){
	register int x=0;
	register bool f=0;
	register char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') f=1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+c-48;
		c=getchar();
	}
	return f?-x:x;
}
const int maxn=305;
int d[15][15],f[maxn][maxn];
int n,m;
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++) d[i][j]=read();
	}
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			for(int x=1;x<=n;x++){
				for(int y=1;y<=m;y++)
				f[i][j]=max(f[i][j],d[x][y]-i*x-j*y);
			}
		}
	}
	for(int x=1;x<=n;x++){
		for(int y=1;y<=m;y++){
			int sum=1000000007;
			for(int i=0;i<=100;i++){
				for(int j=0;j<=100;j++){
					sum=min(sum,f[i][j]+i*x+j*y);
				}
			}
			if(sum!=d[x][y]){
				puts("Impossible");
				return 0;
			}
		}
	}
	cout<<"Possible"<<endl;
	cout<<300<<" "<<10401<<endl;
	int tot=0;
	for(int i=1;i<=100;i++){
		printf("%d %d X\n",i,i+1);
		tot++;
	}
	for(int j=300;j>=201;j--){
		printf("%d %d Y\n",j-1,j);
		tot++;
	}
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			printf("%d %d %d\n",i+1,300-j,f[i][j]);
			tot++;
		}
	}
	puts("1 300");
    return 0;
}

Measured memory_bytes: 512