akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            int n = int.Parse(Console.ReadLine());
            string[] str = new string[n];
            int[] p = new int[n];
            int[] q = new int[n];

            str = Console.ReadLine().Split(' ');
            for(int i = 0; i < n; i++)
            {
                p[i] = int.Parse(str[i]);
            }

            str = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                q[i] = int.Parse(str[i]);
            }

            int def = Math.Abs(jisho(n, p) - jisho(n, q));
            Console.WriteLine(def);
            


            //ここまで
        }

        static int jisho(int n, int[] x)
        {
            if(n == 1) { return 1; }
            else
            {
                int[] temp = new int[n - 1];
                for(int i = 0; i < n-1; i++)
                {
                    if (x[i + 1] > x[0]) { temp[i] = x[i + 1] - 1; }
                    else { temp[i] = x[i + 1]; }
                }
                return (x[0] - 1) * kaijo(n - 1) + jisho(n - 1, temp);
            }
        }
        static int kaijo(int n)
        {
            if (n == 1) { return 1; }
            else { return n * kaijo(n - 1); }
        }
    }
}


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

int main() {
	int a, b;
	cin >> a >> b;
	if(a == b) {
 		cout << "a == b" << endl;
	}else if(a < b) {
		cout << "a < b" << endl;
	}else if(a > b) {
		cout << "a > b" << endl;
	}
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>

using namespace std;

// dp[i][max_w]: i番目までの品物から重さmax_wを超えないように選んだときの最大の価値
long long dp[101][100001];

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

    int weight[101], value[101];
    for (int i = 1; i <= N; i++) {
        cin >> weight[i] >> value[i];
    }

    int i = 1;
    for (int j = 1; j <= W; j++) {
        if (j < weight[i]) {
            dp[i][j] = 0;
        } else {
            dp[i][j] = value[i];
        }
    }

    // ループごとにdp[i][max_w]を計算
    for (int i = 2; i <= N; i++) {
        for (int j = 1; j <= W; j++) {
            if (j < weight[i]) {
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = max(dp[i - 1][j - weight[i]] + value[i], dp[i - 1][j]);
            }
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}

Measured memory_bytes: 78464
#include<stdio.h>

void trace(int A[],int N){
  int i;
  for (i = 0;i < N;i++){
    if(i > 0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

void insertionSort(int A[],int N){
  int j,i,v;
  for(i = 1;i < N;i++){
    v = A[i];
    j = i-1;
    while (j >=0 && A[j] > v){
      A[j + 1] = A[j];
      j--;
    }
      A[j + 1]=v;
      trace(A,N);
    }
  }

  int main(){
    int N,i,j;
    int A[100];

    scanf("%d",&N);
    for(i = 0;i < N;i++) scanf("%d",&A[i]);

    trace(A,N);
    insertionSort(A,N);

    return 0;
  }



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

using ll = long long;

int main() {
    int N, L, Q;
    cin >> N;
    vector<int> x(N);
    rep(i, N) cin >> x[i];
    x.push_back(2e9);
    cin >> L >> Q;
    vector<int> a(Q), b(Q);
    rep(i, Q) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        if (a[i] > b[i]) swap(a[i], b[i]);
    }
    vector<vector<int>> next(N, vector<int>(17));
    rep(i, N) {
        next[i][0] = upper_bound(x.begin(), x.end(), x[i] + L) - x.begin() - 1;
        //cout << "next[" << i << "][0]=" << next[i][0] << "\n";
    }
    rep(j, 16) {
        rep(i, N) {
            next[i][j + 1] = next[next[i][j]][j];
            //cout << "next[" << i << "][" << j + 1 << "]=" << next[i][j + 1] << "\n";
        }
    }
    rep(i, Q) {
        int ans = 1;
        for (int j = 16; j >= 0; j--) {
            if (next[a[i]][j] >= b[i]) continue;
            ans += 1 << j;
            a[i] = next[a[i]][j];
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 12152
N, M = map(int,input().split())
A = []
B = []
for i in range(M):
  a, b = map(int,input().split())
  A.append(a)
  B.append(b)
  
link_dic = {}
for i in range(M):
  if A[i] not in link_dic.keys():
  	link_dic[A[i]] = [B[i]]
  else:
  	link_dic[A[i]].append(B[i])
  if B[i] not in link_dic.keys():
  	link_dic[B[i]] = [A[i]]
  else:
  	link_dic[B[i]].append(A[i])

sign = [0] * N
j = 1
current_room = [1]

def search_room(l):
  global current_room
  did = 0
  next_cr = []
  for i in l:
    li = link_dic[i]
    for k in range(len(li)):
      if sign[li[k]-1] == 0:
        sign[li[k]-1] = i
        next_cr.append(li[k])
        did += 1
        
  current_room = list(next_cr)
        
  if did == 0:
  	return 1
  else:
  	return 0
  	
while j > 0:
  result = search_room(current_room)
  if result:
    break

sign_ans = sign[1:N]
if min(sign_ans) == 0:
  print('No')
else:
  print('Yes')
  for i in sign_ans:
    print(i)
  

Measured memory_bytes: 44152
#include<stdio.h>
#include<stdlib.h>

int desc(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
}

int main(){

	int N;	
	scanf("%d", &N);

	int L[N];
	for( int l=0; l<N; l++ ){
		scanf("%d", &L[l]);
	}

	int cnt=0;

	qsort(L, N, sizeof(int), desc);

/* 	
	for( int i=0; i<N; i++ ){
		printf("%d", L[i]);
	}
		printf("\n");
*/

	for( int i=0; i<N-2; i++ ){
		for( int j=i+1; j<N-1; j++ ){

			int diff = L[i]-L[j];
			int k = j+1;

			for( int k=j+1; k<N; k++ ){
				if( diff < L[k] ){
					cnt++;
//					printf("%d,%d,%d\n", L[i],L[j],L[k]);
				}else{
					break;
				}
			}
/* 			while( diff < L[k] ){
				printf("%d,%d,%d\n", L[i],L[j],L[k]);
				cnt++;
				k++;
*/

/*				
				if( L[k] == L[k-1] ){
					break;
				}
			}	
			for( int k=j+1; k<N; k++ ){
				if( diff < L[k] ){
					
					int diff2=0;

					if( L[i] > L[k] ){
						diff2 = L[i] - L[k];
					}else{
						diff2 = L[k] - L[i];
					}
					
					if( diff2 < L[j] ){
						cnt++;
					}
				}
			}
*/
		}
	}

	printf("%d", cnt);

	return 0;
}

Measured memory_bytes: 128
n=int(input())

def f(s): #文字列sで始まる753の個数
  if int(s) > n:
    return 0
  ret=1 if all(s.count(c) > 0 for c in "753") else 0 #sが753数だったら+1
  for c in "753":
    ret += f(s+c)
  return ret

print(f("0"))

Measured memory_bytes: 2940
n, w = map(int, input().split())
goods = [list(map(int, input().split())) for _ in range(n)]
dp = [[10 ** 11] * (10 ** 5 + 1) for _ in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    weight, value = goods[i]
    for sum_value in range(10 ** 5 + 1):
        if (sum_value - value) >= 0:
            dp[i + 1][sum_value] = min(dp[i + 1][sum_value], dp[i][sum_value - value] + weight)
        dp[i + 1][sum_value] = min(dp[i + 1][sum_value], dp[i][sum_value])

ans = 0
for sum_value in range(10 ** 5 + 1):
    if dp[n][sum_value] <= w:
        ans = sum_value

print(ans)

Measured memory_bytes: 121456
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(N);
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }
    
    priority_queue<P, vector<P>, greater<P>> que;
    for(int i = 0; i < N; i++){
        que.push(P(A[i], B[i]));
    }
    
    int cnt = 0;
    ll res = 0;
    
    while(cnt < M && !que.empty()){
        P p = que.top();
        que.pop();
        while(cnt < M && p.second > 0){
            p.second--;
            cnt++;
            res += p.first;
        }
    }
    
    cout << res << endl;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	string N;
	cin >> N;
	int s=N[N.size()-1]-'0';
	if(s==0||s==1||s==6||s==8) cout << "pon" << endl;
	else if(s==3) cout << "bon" << endl;
	else cout << "hon" << endl;

	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 200010;
int N;
int p[MC];

int main(){
	cin >> N;
	repp(i,0,2*N) cin >> p[i];
	sort(p,p+2*N);
	double ans = 0;
	repp(i,0,2*N) ans += 1. * p[i] / (2*N-1) * i;
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt() / 1000;
		for (int x=0; x<=2000; x++) {
			for (int y=0; y<=4000; y++) {
				int z = N - x - y;
				if (z >= 0 && 10*x + 5*y + z == Y) {
					System.out.println(String.format("%d %d %d", x, y, z));
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m,p,q,r;

vector<P> a;

void shuffle(int x, int y){
	vector<P> nex;
	vector<P> b[3];
	int in[] = {x,y,n};
	int cnt = 0;
	int c2 = 0;
	int c3 = 0;
	for (int i = 0;i < a.size();i++){
		//cout << i << "cnt" << endl;
		if(cnt+a[i].second - a[i].first+1 < in[c2]){ b[c3].push_back(a[i]); cnt += a[i].second-a[i].first+1;}
		else{
			b[c3].push_back(P(a[i].first,a[i].first+(in[c2]-cnt-1)));
			a[i].first += in[c2] - cnt;
			cnt += in[c2] - cnt;
			c2++;
			c3++;
			if(a[i].first <= a[i].second) i--;
			if(c3 == 3) break;
		}
	}
	for (int i = 2;i >= 0;i--){
		for (int j = 0;j < b[i].size();j++){
			nex.push_back(b[i][j]);
		}
	}
	a = nex;
	return ;
}

int count(int x,int y){
	int cnt = 0;
	int ret = 0;
	int in[] = {x-1,y};
	int c2 = 0;
	for (int i = 0;i < a.size();i++){
		//cout << ret << "ret" << cnt << " " << a[i].first << " " << a[i].second <<endl;
		if(cnt+a[i].second - a[i].first+1 < in[c2]){
			   	cnt += a[i].second-a[i].first+1;
				if(c2 == 1){
					ret += max(0,min(a[i].second,r) - a[i].first+1);
				}
		}
		else{
			int tmp = a[i].first+(in[c2] - cnt - 1);
			if(c2 == 1) ret += max(0,min(tmp,r) - a[i].first+1);
			a[i].first += in[c2]-cnt;
			cnt += in[c2]-cnt;
			i--;
			c2++;
		}
	}
	return ret;
}

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

	while(true){
		cin >> n ;
		if(n == 0) break;
		cin >> m >> p >> q >> r;
		a = vector<P>(1);
		a[0] = P(1,n);

		for (int i = 0;i < m;i++){
			int x,y; cin >> x >> y;
			shuffle(x,y);
			/*for (int j = 0;j < a.size();j++){
					cout << a[j].first << " " << a[j].second << endl;
			}*/
		}
		cout << count(p,q) << endl;
	}



	return 0;

}



Measured memory_bytes: 3344
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int N;  cin >> N;
    vd x(N);
    vs u(N);
    REP(i, N) cin >> x[i] >> u[i];

    double ans = 0;
    REP(i,N) {
        if (u[i] == "JPY") ans += x[i];
        else ans += 380000 * x[i];
    }

    cout << fixed << setprecision(4) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main
{
	public static void main(String[] args)
	{
		Boolean[] bit = new Boolean[1000000];
		Arrays.fill(bit, true);
		bit[0] = false;
		bit[1] = false;

		for(int i=2; i<1000; ++i){
			if(bit[i]){
				for(int j=i*2; j<1000000; j+=i)
					bit[j] = false;
			}
		}

		int[] prime = new int[1000000];
		prime[0] = 0;
		for(int i=1; i<1000000; ++i)
			prime[i] = prime[i-1] + (bit[i] ? 1 : 0);

		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String str;
		try{
			while((str = bf.readLine()) != null){
				int n = Integer.parseInt(str);
				System.out.println(prime[n]);
			}
		}
		catch(IOException ex){
			System.out.println(ex);
		}
	}
}

Measured memory_bytes: 17000
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
int n;
vector<P> c;
vector<vector<ll> > adj;
vector<ll> x;
bool d=true;
void dfs(ll pos, ll par) {
	ll buf=0;
	ll sum=0;
	int cnt=0;
	REP(i,adj[pos].size()) {
		if(adj[pos][i]==par) continue;
		++cnt;
		dfs(adj[pos][i],pos);
	}
	if(cnt==0) {
		c[pos].first=x[pos];
		c[pos].second=0;
		return;
	}
	if(!d) return;
	vector<bool> nap(5001,false);
	nap[0]=true;
	REP(i,adj[pos].size()) {
		if(adj[pos][i]==par) continue;
		buf+=min(c[adj[pos][i]].first,c[adj[pos][i]].second);
		sum+=c[adj[pos][i]].first;
		sum+=c[adj[pos][i]].second;
		queue<ll> q;
		REP(j,5001) {
			if(nap[j]) {
				q.push(j+c[adj[pos][i]].first);
				q.push(j+c[adj[pos][i]].second);
			}
		}
		while(!q.empty()) {
			ll kazu=q.front();
			q.pop();
			if(kazu<=5000) {
				nap[kazu]=true;
			}
		}
	}
	if(buf>x[pos]) {
		d=false;
		return;
	}
	ll ret=INF*INF;
	REP(i,5001) {
		if(nap[i]&&i<=x[pos]) {
			ret=min(ret,sum-i);
		}
	}
	c[pos].first=x[pos];
	c[pos].second=ret;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n;
	vector<ll> p(n-1);
	REP(i,n-1) cin>>p[i];
	c.resize(n);
	adj.resize(n);
	x.resize(n);
	REP(i,n) cin>>x[i];
	REP(i,n-1) {
		adj[p[i]-1].pb(i+1);
		adj[i+1].pb(p[i]-1);
	}
	dfs(0,-1);
	if(d) cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 512
from itertools import combinations, combinations_with_replacement
from math import sqrt


n = int(input())
ans = [0] * (n + 1)
for x, y, z in combinations_with_replacement(range(1, int(sqrt(n))), 3):
    i = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if i <= n:
        if x == y == z:
            ans[i] += 1
        elif all([(s != t) for s, t in combinations([x, y, z], 2)]):
            ans[i] += 6
        else:
            ans[i] += 3

for i in range(1, n + 1):
    print(ans[i])


Measured memory_bytes: 9208
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		int b[]=new int[n];
		boolean flag=false;
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
		}
		int count=0;
		for(int i=0;i<n;i++) {
			if(a[i]==b[i]) {
				count++;
				if(count==3) {
					flag=true;
					break;
				}
			}
			else {
				count=0;
			}
		}
		if(flag)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 35972
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char S[102];
int N;
long long K;
int sz;
int arr[100];
int main(){
  int i;
  int j;
  long long res = 0;
  N = rd(S);
  rd(K);
  for(i=(0);i<(N);i++){
    if(S[i] != S[0]){
      break;
    }
  }
  if(i==N){
    res = K * N / 2;
    wt_L(res);
    wt_L('\n');
    return 0;
  }
  j = 0;
  for(i=(1);i<(N+1);i++){
    if(i == N || S[i] != S[i-1]){
      arr[sz++] = i - j;
      j = i;
    }
  }
  if(S[0] == S[N-1]){
    res += arr[0] / 2;
    res += arr[sz-1] / 2;
    res += ((arr[0] + arr[sz-1]) / 2) * (K-1);
    for(i=(1);i<(sz-1);i++){
      res += (arr[i] / 2) * K;
    }
  }
  else{
    for(i=(0);i<(sz);i++){
      res += (arr[i] / 2) * K;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190929-1

// --- original code ---
// char S[102];
// int N; ll K;
// int sz, arr[100];
// {
//   int i, j;
//   ll res = 0;
//   rd(S@N, K);
// 
//   rep(i,N) if(S[i] != S[0]) break;
//   if(i==N){
//     res = K * N / 2;
//     wt(res);
//     return 0;
//   }
// 
//   j = 0;
//   rep(i,1,N+1){
//     if(i == N || S[i] != S[i-1]){
//       arr[sz++] = i - j;
//       j = i;
//     }
//   }
// 
//   if(S[0] == S[N-1]){
//     res += arr[0] / 2;
//     res += arr[sz-1] / 2;
//     res += ((arr[0] + arr[sz-1]) / 2) * (K-1);
//     rep(i,1,sz-1) res += (arr[i] / 2) * K;
//   } else {
//     rep(i,sz) res += (arr[i] / 2) * K;
//   }
//   wt(res);
// }


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

//Class.
vector<int> list[100000];
int N, M, E;
int match[100000];
bool used[100000];
int x[10000], y[10000];

bool DFS(int V) {
	used[V] = true;
	for (int i = 0; i < list[V].size(); i++) {
		int u = list[V][i]; int w = match[u];
		if (w < 0 || !used[w] && DFS(w)) {
			match[V] = u;
			match[u] = V;
			return true;
		}
	}
	return false;
}

int supermatching() {
	int r = 0;
	memset(match, -1, sizeof(match));
	for (int j = 0; j < N + M; j++) {
		if (match[j] < 0) {
			memset(used, 0, sizeof(used));
			if (DFS(j)) { r++; }
		}
	}
	return r;
}

//main.
int main() {
	while (true) {
		for (int i = 0; i < 100000; i++) { list[i].clear(); }
		cin >> N >> M; if (!N) { break; }
		for (int i = 0; i < N; i++) {
			cin >> x[i];
		}
		for (int i = 0; i < M; i++) {
			cin >> y[i];
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				if (__gcd(x[i], y[j]) != 1) {
					list[i].push_back(j + N);
				}
			}
		}
		cout << supermatching() << endl;
	}
	return 0;
}

Measured memory_bytes: 5084
#include<iostream>
#include<string>

using namespace std;

int main(){
  int i;
  string str;

  cin >> str;

  for(i=0; i<str.size(); ++i){
    str[i] -= 3;

    if(str[i] < 'A')
      str[i] += 26;
  }

  cout << str << endl;

  return 0;
}

Measured memory_bytes: 0
package main
import (
  "fmt"
  "sort"
)
func main() {
  var n int
  var s string
  fmt.Scan(&n)
  m := map[string]int64{}
  for i:=0;i<n;i++ {
    fmt.Scan(&s)
    r := RuneSlice([]rune(s))
    sort.Sort(r)
    t := string(r)
    m[t]++
  }
  ans := int64(0)
  for _,v := range m {
    ans += v*(v-1)/2
  }
  fmt.Println(ans)
}
type RuneSlice []rune
func(p RuneSlice) Len() int { return len(p) }
func(p RuneSlice) Less(i,j int) bool { return p[i] < p[j] }
func(p RuneSlice) Swap(i,j int) { p[i],p[j] = p[j],p[i] }

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

string s[11] = {"light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy"};
double b[11] = {48,51,54,57,60,64,69,75,81,91,1e100};

int main() {
  double w;
  while(cin >> w) cout << s[lower_bound(b,b+11,w)-b] << endl;
  return 0;
}

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

constexpr double eps = 1e-9;
constexpr double inf = 1e6;
constexpr bool eq(double x, double y) {
  return fabs(x - y) < eps;
}

struct P {
  double x, y;
  P(double x = 0, double y = 0): x(x), y(y) { }
  P rot() const { return P(-y, x); }
  P operator + (P p) const { return P(x + p.x, y + p.y); }
  P operator - (P p) const { return P(x - p.x, y - p.y); }
  P operator * (double k) const { return P(x * k, y * k); }
  double nm() const { return sqrt(x * x + y * y); }
};

struct C {
  P o; double r;
  C(P o = P(), double r = 0): o(o), r(r) { }
  vector<P> sc(C c) {
    P p = c.o - o;
    double l = p.nm();
    if (eq(l, 0)) {
      return {};
    }
    if (eq(l + r + c.r, max({ l, r, c.r }) * 2.0)) {
      return { o + p * (r / l) };
    }
    if (l + r + c.r < max({ l, r, c.r }) * 2.0) {
      return {};
    }
    double x = -(c.r * c.r - l * l - r * r) / (2.0 * l);
    double y = sqrt(r * r - x * x);
    P md = o + p * (x / l);
    p = p.rot();
    return { md + p * (y / l), md - p * (y / l) };
  }
  bool con(P p) {
    return (p - o).nm() < r + eps;
  }
};

int main() {
  int N, K;
  scanf("%d %d", &N, &K);
  if (K == 1) {
    puts("0");
    return 0;
  }
  vector<C> cs(N);
  vector<double> coeff(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lf %lf %lf", &cs[i].o.x, &cs[i].o.y, &coeff[i]);
  }
  double ok = inf, ng = 0;
  for (int step = 0; step < 60; ++step) {
    double md = (ok + ng) / 2;
    vector<P> ps;
    for (int i = 0; i < N; ++i) {
      cs[i].r = md / coeff[i];
      ps.push_back(cs[i].o);
      for (int j = 0; j < i; ++j) {
        for (auto p: cs[i].sc(cs[j])) {
          ps.push_back(p);
        }
      }
    }
    ([&] {
      for (auto p: ps) {
        int cnt = 0;
        for (auto c: cs) {
          if (c.con(p)) {
            ++cnt;
          }
        }
        if (cnt >= K) {
          return true;
        }
      }
      return false;
    }() ? ok : ng) = md;
  }
  printf("%.10lf\n", ok);
  return 0;
}


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

using namespace std;

int f(int n){
	if(n&1)return 3*n+1;
	return n/2;
}

const int N=1e6+6;

int a[N];

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	int d;
	while(cin >> d)
	{
		int sum = 0;
		int areas = 600 / d;
		for(int i = d; i < 600; i += d)
		{
			sum += d * i * i;
		}
		cout << sum << endl;
	}
}

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

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
    vector<pair<int, int>>v1;
    vector<pair<int, int>>v2;
    int m, n, n1, m1;
    cin>>n>>m;
    n1 = n;
    m1 = m;
    while(n1--)
    {
        int a, b;
        cin>>a>>b;
        v1.push_back(make_pair(a, b));
    }
    while(m1--)
    {
        int a, b;
        cin>>a>>b;
        v2.push_back(make_pair(a, b));
    }
    for(int i = 0; i<n; i++)
    {   ll mi = INT_MAX, ans = 1;
        for(int j = 0; j<m; j++)
        {
            ll x;
            ll a, b, c, d;
            a = v1[i].first;
            b = v2[j].first;
            c = v1[i].second;
            d = v2[j].second;

            x = abs(a-b) + abs(c - d);
            if(x<mi)
            {
                ans = j + 1;
                mi = x;
            }

        }
        cout<<ans<<endl;
    }

   return 0;

}



Measured memory_bytes: 3564
def main():
    #input data
    import sys
    input = lambda:sys.stdin.readline().strip()
    N = int(input())
    S = input()
    
    #solve
    right=0
    left=0

    for i in range(N):
        if S[i]=='(':
            right+=1
        else:
            if right:
                right-=1
            else:
                left+=1
    print(left*'('+S+right*')')

if __name__=='__main__':
    main()

Measured memory_bytes: 9100
#include<bits/stdc++.h>
#define lson l, mid, i<<1
#define rson mid+1, r, i<<1|1
#define PII pair<int, int>
using namespace std;
typedef long long LL;
const LL MOD = 1e9+7;
const auto INF  = 0x3f3f3f3f;
const int N = 1e5+5;

int a[N];
int visit[N];

LL fac[N];

void init()
{
    int i;
    fac[0] =1;
    for(i =1; i <= N-3; i++)
        fac[i] = fac[i-1]*i % MOD;
}

LL pow(LL a, LL b)
{
    LL tmp = a % MOD, ans =1;
    while(b)
    {
        if(b &1)  ans = ans * tmp % MOD;
        tmp = tmp*tmp % MOD;
        b >>=1;
    }
    return  ans;
}

LL C(LL n, LL m)
{
    if(m > n)  return 0;
    return  fac[n]*pow(fac[m]*fac[n-m], MOD-2) % MOD;
}

LL Lucas(LL n, LL m)
{
    if(m ==0)  return 1;
    else return  (C(n%MOD, m%MOD)*Lucas(n/MOD, m/MOD))%MOD;
}

int main() {
    init();
    int n;
    scanf("%d", &n);
    int pos1 = 0, pos2 = 0;
    for(int i=1; i<=n+1; i++) {
        scanf("%d", &a[i]);
        if(visit[a[i]]) {
            pos1 = visit[a[i]];
            pos2 = i;
        }
        visit[a[i]] = i;
    }
    for(int i=1; i<=n+1; i++) {
        if(i==1) {
            printf("%d\n", n);
        } else {
            LL ans = Lucas(n+1, i);
            int L = pos1-1;
            int R = n+1-pos2;
            ans = (ans - Lucas(L+R, i-1) + MOD)%MOD;
            printf("%lld\n", ans);
        }
    }
}


Measured memory_bytes: 2816
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=1000023};

char a[N];
ll f[N][2];

int main(){
	scanf("%s",a+1);
	int n=strlen(a+1);
	f[n+1][1]=1e9;
	f[n+1][0]=0;
	rev_rep(i,n,1){
		f[i][0]=min(f[i+1][0]+a[i]-'0',f[i+1][1]+a[i]-'0'+1);
		f[i][1]=min(f[i+1][0]+10-(a[i]-'0'),f[i+1][1]+10-(a[i]-'0'+1));
	}
	printf("%lld\n",min(f[1][0],f[1][1]+1));
	return 0;
}


Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n=0;
    scanf("%d", &n);
    int sum=0;
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        sum+=1;
        sum+=b-a;
    }
    printf("%d", sum);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 10000000000

int main() {
	long long n;
	long long num;
	string ans = "";
	cin >> n;

	while (n > 26) {
		num = n % 26;
		if (num == 0) num = 26;
		n -= num;
		n /= 26;
		ans.push_back('a' + num-1);
	}
	ans.push_back('a' + n-1);
	reverse(ans.begin(), ans.end());

	cout << ans;
	return 0;
}

Measured memory_bytes: 3604
N ,M = map(int,input().split())
L = []
for i in range(1,int(M**(1/2)+1)):
    if M % i == 0:
        L.append((i,M//i))
ans = 0
for x in L:
    if x[1] >= N:
        ans = max(ans,x[0])
    if x[0] >= N:
        ans = max(ans,x[1])
print(ans)


Measured memory_bytes: 38640
mod = 998244353
a,b,c,d= map(int, input().split())

# dp[i][j]:i*jの盤面のときの盤面の組み合わせ
dp=[[0]*(d+1) for i in range(c+1)]

dp[a][b]=1
for i in range(a,c+1):
    for j in range(b,d+1):
        dp[i][j]+=dp[i-1][j]*j
        dp[i][j]+=dp[i][j-1]*i
        dp[i][j]-=dp[i-1][j-1]*(i-1)*(j-1)
        dp[i][j]%=mod


print(dp[c][d])

Measured memory_bytes: 136512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n;
	vector<string> s(n);
	for(int i=0;n>i;i++){
		cin>>s.at(i);
	}
	cin>>m;
	vector<string> t(m);
	for(int j=0;m>j;j++){
		cin>>t.at(j);
	}
	vector<int> p(n);
	for(int i=0;n>i;i++){
		for(int j=0;n>j;j++){
			if(s.at(i)==s.at(j)){
				p.at(i)++;
			}
		}
		for(int j=0;m>j;j++){
			if(s.at(i)==t.at(j)){
				p.at(i)--;
			}
		}
	}
	for(int i=0;n>i;i++){
		if(p.at(0)<p.at(i)){
			p.at(0)=p.at(i);
		}
	}
	if(p.at(0)<0){
		p.at(0)=0;
	}
	cout<<p.at(0)<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

    static boolean isPrime(int n){
        if(n == 2){
            return true;
        }else if(n < 2 || n % 2 == 0){
            return false;
        }else{
            int x = 3;
            while(x <= Math.sqrt((double)n)){
                if(n%x == 0)    return false;
                x += 2;
            }
            return true;
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());
        int result = 0;

        for(int i = 0; i < n; i++){
            if(isPrime(Integer.parseInt(sc.next()))) result++;
        }

        System.out.println(result);
    }
}



Measured memory_bytes: 41744
import itertools
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
arr = [0]
arr += list(itertools.accumulate(a))
ans = 0

c = Counter(arr)
for v in c.values():
    if v > 1:
        ans += v * (v - 1) // 2

print(ans)


Measured memory_bytes: 44504
parseline(str) = parse.(Int, split(str))
function SumOfLargeNumbers()
    N, K = parseline(readline())
    nums = zeros(Int, N-K+2)
    idx = 1
    for M in K:N+1
        nums[N-M+2] = (M*(N-M+1) + 1)%(10^9+7)
    end
    return println(sum(nums)%(10^9+7))
end
SumOfLargeNumbers()

Measured memory_bytes: 176424
package main

import "fmt"
import "container/heap"
import "strconv"
import "strings"

type SegmentTree struct {
	dat []int
	n   int
}

var stEven SegmentTree
var stOdd SegmentTree

var intMax int
var maxN int

func stInit(nn int) SegmentTree {
	n := 1
	for n < nn {
		n *= 2
	}
	dat := make([]int, 2*n-1)
	for i := 0; i < 2*n-1; i++ {
		dat[i] = intMax
	}
	return SegmentTree{dat, n}
}

func (st *SegmentTree) update(k, a int) {
	k += (st.n - 1)
	st.dat[k] = a
	for k > 0 {
		k = (k - 1) / 2
		if st.dat[k*2+1] < st.dat[k*2+2] {
			st.dat[k] = st.dat[k*2+1]
		} else {
			st.dat[k] = st.dat[k*2+2]
		}
	}
}

func (st *SegmentTree) query(a, b, k, l, r int) int {
	if (r <= a) || (b <= l) {
		return intMax
	}
	if (a <= l) && (r <= b) {
		return st.dat[k]
	}
	vl := st.query(a, b, k*2+1, l, (l+r)/2)
	vr := st.query(a, b, k*2+2, (l+r)/2, r)
	if vl < vr {
		return vl
	}
	return vr
}

func wrapQuery(t string, a, b, k, l int) int {
	var ret int
	if t == "even" {
		if a%2 == 0 {
			ret = stEven.query(a, b, k, l, stEven.n)
		} else {
			ret = stOdd.query(a, b, k, l, stOdd.n)
		}
	} else {
		if a%2 == 0 {
			ret = stOdd.query(a, b, k, l, stOdd.n)
		} else {
			ret = stEven.query(a, b, k, l, stEven.n)
		}
	}
	return ret
}

type Item struct {
	min   int
	i     int
	left  int
	right int
}

type PriorityQueue []*Item

func (pq PriorityQueue) Len() int {
	return len(pq)
}
func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].min < pq[j].min
}
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *PriorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.(*Item))
}
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	x := old[n-1]
	*pq = old[0 : n-1]
	return x
}
func main() {
	intMax = 200001
	maxN = 1 << 17
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}
	stEven = stInit(n)
	stOdd = stInit(n)
	h := make(map[int]int)
	for i, v := range arr {
		h[v] = i
		if i%2 == 0 {
			stEven.update(i, v)
		} else {
			stOdd.update(i, v)
		}
	}
	q := make([]string, n)
	pq := &PriorityQueue{}
	heap.Init(pq)
	x := wrapQuery("even", 0, n, 0, 0)
	heap.Push(pq, &Item{x, h[x], 0, n})
	ii := 0
	for pq.Len() != 0 {
		item := heap.Pop(pq).(*Item)
		q[ii] = strconv.Itoa(item.min)
		ii++
		q1 := wrapQuery("odd", item.i, item.right, 0, 0)
		j := h[q1]
		q[ii] = strconv.Itoa(q1)
		ii++
		if item.i-item.left > 1 {
			x0 := wrapQuery("even", item.left, item.i, 0, 0)
			heap.Push(pq, &Item{x0, h[x0], item.left, item.i})
		}
		if j-(item.i+1) > 1 {
			x1 := wrapQuery("even", item.i+1, j, 0, 0)
			heap.Push(pq, &Item{x1, h[x1], item.i + 1, j})
		}
		if item.right-(j+1) > 1 {
			x2 := wrapQuery("even", j+1, item.right, 0, 0)
			heap.Push(pq, &Item{x2, h[x2], j + 1, item.right})
		}
	}
	fmt.Println(strings.Join(q, " "))
}


Measured memory_bytes: 32896
#include <iostream>
using namespace std;
int main() {
   int a,b ,c,x,y,z;

   scanf("%d %d", &a, &b);

   x = a+b ;
   y = a-b ;
   z = a*b ;
   if(x>y) {
      if(x>z)
         cout<<x<<endl;
      else
         cout<<z<<endl;
   }else {
      if(y>z)
         cout<<y<<endl;
      else
         cout<<z<<endl;
   }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  ll N, M;
  cin >> N >> M;
  vector<P> students;
  vector<P> checkPoints;

  rep(i , N) {
    ll a, b;
    cin >> a >> b;
    students.pb(make_pair(a, b));
  }

  rep(j , M) {
    ll c, d;
    cin >> c >> d;
    checkPoints.pb(make_pair(c, d));
  }

  rep(i, N) {
    ll minLength = INF;
    ll minIndex = -1;

    rep(j, M) {
      ll length = abs(students[i]._1 - checkPoints[j]._1) + abs(students[i]._2 - checkPoints[j]._2);
      if (length < minLength) {
        minLength = length;
        minIndex = j;
      }
    }

    cout << (minIndex + 1) << endl;
  }

}


Measured memory_bytes: 256
import math
import numpy


def resolve():
    a, b, h, m = map(int, input().split())

    ar = 30 * (h) + 30 * (m / 60)
    br = 6 * (m)

    ay = math.sin(math.radians(-ar + 90)) * a
    ax = math.cos(math.radians(-ar+90)) * a

    by = math.sin(math.radians(-br+90)) * b
    bx = math.cos(math.radians(-br+90)) * b

    av = numpy.array([ax, ay])
    bv = numpy.array([bx, by])

    u = bv-av

    print(numpy.linalg.norm(u))
resolve()

Measured memory_bytes: 27272
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MX=300005;

int N,M,ans[MX];
LL res;

struct seg
{
    int l,r,len;
    void init(int _l,int _r){l=_l,r=_r,len=_r-_l+1;}
    bool operator < (const seg& a)const{return len<a.len;}
}P[MX];

struct FastIn
{
    static const int MXL=20000000;
    char bf[MXL],*p1,*p2;
    FILE *I;
    FastIn(FILE *I):p1(bf),p2(bf),I(I){}
    char getchar(){return p1==p2&&(p2=(p1=bf)+fread(p1,1,MXL,I),p1==p2)?EOF:*p1++;}
    int operator () ()
    {
        int x=0,c=getchar();
        while(!isdigit(c))c=getchar();
        while(isdigit(c))x=x*10+c-'0',c=getchar();
        return x;
    }
}IN(stdin);

namespace Subtask1_3_5
{
    int tr[MX];

    inline void add(int u,int v){for(;u<=N;u+=u&-u)tr[u]+=v;}
    inline int ask(int u){int ans=0;for(;u;u^=u&-u)ans+=tr[u];return ans;}
    void main()
    {
        sort(P+1,P+M+1);
        for(int i=1,j=1;i<=N;i++)
        {
            while(j<=M&&P[j].len<i)add(P[j].l,1),add(P[j].r+1,-1),j++;
            int &tmp=ans[i];
            tmp=M-j+1;
            for(int k=i;k<=N;k+=i)tmp+=ask(k);
        }
    }
}

namespace Subtask2_4
{
    void main()
    {
        for(int i=1;i<=M;i++)
        {
            int l=P[i].l-1,r=P[i].r;
            for(int j=1,k,tmp;j<=r;j=k+1)
            {
                tmp=r/j,k=r/tmp;
                if(max(j,l/tmp+1)<=k)ans[max(j,l/tmp+1)]++,ans[k+1]--;
            }
        }
        for(int i=1;i<=N;i++)ans[i]+=ans[i-1];
    }
}

int main()
{
    M=IN(),N=IN();
    for(int i=1,l,r;i<=M;i++)l=IN(),r=IN(),P[i].init(l,r);
    if(N<=100000)Subtask1_3_5::main();
    else Subtask2_4::main();
    for(int i=1;i<=N;i++)printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  string s,t;
  cin >>s;
  
  t="CODEFESTIVAL2016";
  
  int ans=0;
    
  rep(i,s.size()) {
    if(s[i]!=t[i]) ans++;
  }
  
  cout << ans << endl;
  
  
}


Measured memory_bytes: 256
;;(declaim (optimize (speed 0) (safety 3) (debug 3)))
(declaim (optimize (debug 0) (safety 0) (speed 3)))

(defvar n (read))

(let ((d (mod n 10)))
  (cond ((= d 3) (princ "bon"))
	((or (= d 0) (= d 1) (= d 6) (= d 8)) (princ "pon"))
	(t (princ "hon"))))


Measured memory_bytes: 23568
//Kaori Miyazono, did I reach you ?
//"I can't die because... I have to protect you." -Asuna Yuuki

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

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}	






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i=0; i<n; i++)
    {
        string s;
        cin >> s;
        if(mp.count(s) == 0) mp[s] = 0;
        else mp.at(s)++;
    }

    int nax = 0;
    for(auto itr = begin(mp); itr != end(mp); itr++)
    {
        if(nax < itr->second) nax = itr->second;
    }
    for(auto itr = begin(mp); itr != end(mp); itr++)
    {
        if(itr->second == nax) cout << itr->first << endl;
    }
    return 0;
}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
string isCoffee(string str){
    if(str.size()!=6)
        return "No";
    if ((str[2]==str[3])&&(str[4]==str[5]))
        return "Yes";
    return "No";
}
int main()
{
    string str;
    cin>>str;
    cout<<isCoffee(str)<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll dp[311][311][311];
int mini[311][5], maxi[311][5];
int main()
{
	int num, way;
	scanf("%d%d", &num, &way);
	for (int i = 0; i <= num + 10; i++)for (int j = 0; j < 5; j++)maxi[i][j] = 0, mini[i][j] = num + 10;
	bool fff = true;
	for (int i = 0; i < way; i++)
	{
		int za, zb, zc;
		scanf("%d%d%d", &za, &zb, &zc);
		za++, zb++;
		mini[zb][zc] = min(mini[zb][zc], za), maxi[zb][zc] = max(maxi[zb][zc], za);
		if (zc > 1)fff = false;
		if (zb - za + 1 < zc)
		{
			printf("0\n");
			return 0;
		}
		if (maxi[zb][zc] > mini[zb][zc - 1] || maxi[zb][zc + 1]>mini[zb][zc])
		{
			printf("0\n");
			return 0;
		}
	}
	dp[2][2][1] = 1;
	for (int i = 2; i <= num; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			for (int k = 0; k < j; k++)
			{
				if (mini[i + 1][1] >= j&&maxi[i + 1][2] < j&&mini[i + 1][2] >= k&&maxi[i + 1][3] < k)dp[i + 1][j][k] = (dp[i + 1][j][k] + dp[i][j][k]) % mod;
				if (mini[i + 1][1] >= i + 1 && maxi[i + 1][2] < i + 1 && mini[i + 1][2] >= k&&maxi[i + 1][3] < k)dp[i + 1][i + 1][k] = (dp[i + 1][i + 1][k] + dp[i][j][k]) % mod;
				if (mini[i + 1][1] >= i + 1 && maxi[i + 1][2] < i + 1 && mini[i + 1][2] >= j&&maxi[i + 1][3] < j)dp[i + 1][i + 1][j] = (dp[i + 1][i + 1][j] + dp[i][j][k]) % mod;
			}
		}/*
		for (int j = 0; j <= num + 10; j++)
		{
			for (int k = 0; k <= num + 10; k++)
			{
				if (dp[i + 1][j][k] >= 1)printf("%d %d %d   %lld\n", i + 1, j, k, dp[i + 1][j][k]);
			}
		}*/
	}
	ll sum = 0;
	for (int i = 0; i <= num + 2; i++)for (int j = 0; j <= num + 2; j++)sum += dp[num + 1][i][j];
	printf("%lld\n", sum * 3 % mod);
}

Measured memory_bytes: 227456
#include <stdio.h>
#include <set>
using namespace std;
int main(){
    int n,temp;
    set<int>s;
    scanf("%d",&n);
    while(n--){
        scanf("%d",&temp);
        s.insert(temp);
    }
    scanf("%d",&n);
    while(n--){
        scanf("%d",&temp);
        if(s.count(temp))s.erase(temp);
        else s.insert(temp);
    }
    for(int i:s)printf("%d\n",i);
    
}


Measured memory_bytes: 21500
import sys

def solve():
      input = sys.stdin.readline
      N = int(input())
      A = [int(a) for a in input().split()]
      total = 1000
      stock = 0
      status = -1 #1なら増加,-1なら減少
      for i in range(1, N):
            if A[i] > A[i-1]:
                  if status == -1:
                        stock = total // A[i-1]
                        total -= stock * A[i-1]
                        status = 1
            elif A[i] < A[i-1]:
                  if status == 1:
                        total += stock * A[i-1]
                        stock = 0
                        status = -1
      if stock > 0:
            total += stock * A[N-1]
      print(total)


      return 0

if __name__ == "__main__":
      solve()

Measured memory_bytes: 9216
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;

public class Main {
    static final int BASE = 1_000_000_001;

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        int N = sc.nextInt();
        Set<Long> blacks = new HashSet<>();
        for (int i = 0; i < N; ++i) {
            int a = sc.nextInt();
            int b = sc.nextInt();

            blacks.add(encode(a, b));
        }

        System.out.println(solve(H, W, blacks));

        sc.close();
    }

    static String solve(int H, int W, Set<Long> blacks) {
        Set<Long> centers = new HashSet<>();
        for (long black : blacks) {
            int blackR = (int) (black / BASE);
            int blackC = (int) (black % BASE);

            for (int dr = -1; dr <= 1; ++dr) {
                for (int dc = -1; dc <= 1; ++dc) {
                    int centerR = blackR + dr;
                    int centerC = blackC + dc;

                    if (centerR >= 2 && centerR <= H - 1 && centerC >= 2 && centerC <= W - 1) {
                        centers.add(encode(centerR, centerC));
                    }
                }
            }
        }

        long[] result = new long[10];
        for (long center : centers) {
            int centerR = (int) (center / BASE);
            int centerC = (int) (center % BASE);

            int count = 0;
            for (int dr = -1; dr <= 1; ++dr) {
                for (int dc = -1; dc <= 1; ++dc) {
                    int r = centerR + dr;
                    int c = centerC + dc;
                    if (blacks.contains(encode(r, c))) {
                        ++count;
                    }
                }
            }

            ++result[count];
        }

        result[0] = (H - 2L) * (W - 2) - Arrays.stream(result).sum();

        return Arrays.stream(result).mapToObj(String::valueOf).collect(Collectors.joining("\n"));
    }

    static long encode(int r, int c) {
        return (long) r * BASE + c;
    }
}

Measured memory_bytes: 164668
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int check(string s) {
    int N = s.size();
    if(N%2 == 1) {
        return 0;
    }
    int n = N/2;

    int flag = 0;
    rep(i, n) {
        if(s[i] != s[i+n]) {
            flag = 1;
            break;
        }
    }

    if(flag) {
        return 0;
    }
    else {
        return 1;
    }
}

int main() {
    string S;
    cin >> S;

    while(1) {
        S.pop_back();

        if( check(S) ) {
            cout << S.size() << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

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

string s;

int main() {
  cin >> s;
  long N = s.size();
  if (N==2) {
    if (s.at(0) == s.at(1)) {
      cout << 1 << ' ' << 2 << endl;
    } else {
      cout << -1 << ' ' << -1 << endl;
    }
    return 0;
  }
  rep(i,N-2) {
    if (s.at(i+2) == s.at(i+1)) {
      cout << i+2 << ' ' << i+3 << endl;
      return 0;
    } else if (s.at(i+2) == s.at(i)) {
      cout << i+1 << ' ' << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << ' ' << -1 << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int Ssum[200001][4]={};
int Tsum[200001][4]={};
int main(){
	int H,W;
	int N;
	int sr,sc;
	string S,T;
	map<char,int> c;
	c['L']=0,c['U']=1,c['R']=2,c['D']=3;
	scan(H>>W>>N>>sr>>sc>>S>>T);
	/*rep(i,N){
		rep(j,4){
			Ssum[i+1][j]=Ssum[i][j];
			Tsum[i+1][j]=Tsum[i][j];
		}
		Ssum[i+1][c[S[i]]]++;
		Tsum[i+1][c[T[i]]]++;
	}
	int aomax[4]={sc,sr,W-sc+1,H-sr+1};
	int flag=1;
	rep(i,N){
		rep(j,4){
			printf("i:%d j:%d Ssum:%d Tsum:%d aomax:%d\n",i,j,Ssum[N][j]-Ssum[i][j],Tsum[N-1][(j+2)%4]-Tsum[i][(j+2)%4],aomax[j]);
			if((Ssum[N][j]-Ssum[i][j])-(Tsum[N-1][(j+2)%4]-Tsum[i][(j+2)%4])>=aomax[j]){
				prin("NO");
				return 0;
			}
		}
		if(T[i]=='U'||T[i]=='D') aomax[(c[T[i]]+2)%4]=min(aomax[(c[T[i]]+2)%4]+1,H);
		else aomax[(c[T[i]]+2)%4]=min(aomax[(c[T[i]]+2)%4]+1,W);
	}*/
	int flag=1;
	int yoko=sc;
	rep(i,N){
		if(S[i]=='L') yoko--;
		if(yoko<=0) flag=0;
		if(T[i]=='R') yoko=min(W,yoko+1);
	}
	yoko=sc;
	rep(i,N){
		if(S[i]=='R') yoko++;
		if(yoko>W) flag=0;
		if(T[i]=='L') yoko=max(1,yoko-1);
	}
	int tate=sr;
	rep(i,N){
		if(S[i]=='U') tate--;
		if(tate<=0) flag=0;
		if(T[i]=='D') tate=min(H,tate+1);
	}
	tate=sr;
	rep(i,N){
		if(S[i]=='D') tate++;
		if(tate>H) flag=0;
		if(T[i]=='U') tate=max(1,tate-1);
	}
	if(flag) prin("YES");
	else prin("NO");
	return 0;
}


Measured memory_bytes: 776