akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
int a[1000],b[1000],c[1000];

void solve(){
    cin >> n;
    rep(i,n){
       cin >> a[i]; 
       a[i]--;
    }
    rep(i,n){
        cin >> b[i];
    }
    rep(i,n-1){
        cin >> c[i];
    }
    int ans=0;
    rep(i,n){
        ans+=b[a[i]];
        if (i>=1) {
            if (a[i-1]+1==a[i]){
                ans+=c[a[i-1]];
            }
        } 
    }

    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int a,b,c;cin>>a>>b>>c;
  if(a+b+c>=22)puts("bust");
  else puts("win");
  
  return 0;
}


Measured memory_bytes: 3632
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int w = s.nextInt();
        int []weight = new int[n];
        long []values = new long[n];
        for(int i = 0;i<n;i++){
            weight[i] = s.nextInt();
            values[i] = s.nextLong();
        }
        long dp[][] = new long[n+1][w+1];
        for(int i = 1;i<=n;i++){
            for(int j =1;j<=w;j++){
                if(weight[i-1] > j){
                    dp[i][j] = dp[i-1][j];
                }
                else{
                    dp[i][j] = Math.max(values[i-1]+dp[i-1][j-weight[i-1]],dp[i-1][j]);
                }
            }
        }
        System.out.println(dp[n][w]);
    }
}


Measured memory_bytes: 127444
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations, combinations_with_replacement
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a * b // g


# 8000000をgcd愚直は間に合うか？ #3つの順番は入れ替わってもよい
# 埋め込むか

def f(K):
    nums = list(range(1, K + 1))
    ans = 0
    for a, b, c in product(nums, nums, nums):
        ans += gcd(gcd(a, b), c)
    return ans


print(f(int(input())))


Measured memory_bytes: 84096
#include <iostream>
using namespace std;
int main (){

  int a,b,c,d,e,r,A;

  cin >>a>>b;

  if( b > a ){
    A=a;
    a=b; 
    b=A;
  }

  while( b  > 0 ){
    r=a%b;
    a=b;
    b=r;
  }
    
  if( b == 0 ){
    cout <<a<<endl;
  }else if( b >= 1 && a >= b ){
    c=a%b;
    for( int i=b ; i >= 1 ; i-- ){
      d=c%i;
      e=b%i;
      if( d == 0 && e == 0 ){
	cout <<i<<endl;
	break;
      }
    }
  }
 
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main(){
  string s;
  cin >> s;
  for(int i = 0;i < s.length();i++) {
    if(i % 2 == 0) {
      cout << s[i];
    }
  }
  cout << endl;
}

Measured memory_bytes: 512
import array
import sys
from collections import deque

def input():
    return sys.stdin.readline().rstrip('\n')

N = int(input())
S = deque(list(input()))
last = S.pop()
count = 1
while(not len(S)==0):
    s = S.pop()
    if not s == last:
        count +=1
        last = s
    else:
        continue
    
print(count)


Measured memory_bytes: 53488
use proconio::{input, fastout};
use proconio::marker::Usize1;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        xy: [(Usize1, Usize1); m],
    }

    let mut prob = vec![false; n];
    prob[0] = true;

    let mut count = vec![1; n];

    for (x, y) in xy {
        if prob[x] {
            prob[y] = true;
        }

        count[x] -= 1;
        if count[x] == 0 {
            prob[x] = false;
        }

        count[y] += 1;
    }

    let ans = prob.into_iter().filter(|&x| x).count();

    println!("{}", ans);
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll n,a,b;
	cin >> n >> a >> b;
	if((b-a)%2==0){
		cout << (b-a)/2 << endl;
	}
	else{
		ll tmp=(a-1)+((b-(a-1))-1)/2+1;
		ll tmp2=(n-b)+(n-(a+(n-b)))/2+1;
		cout << min(tmp,tmp2) << endl;
	}
	return 0;
}


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

int dp[100][100] = {}, a[100], b[100], n;
bool visit[100][100] = {};

int dfs(int s, int t){
    if(visit[s][t]) return dp[s][t];
    visit[s][t] = true;
    if(s == t)  return dp[s][t] = 0;
    if(s+1 == t){
        return dp[s][t] = a[s]*a[t]*b[s]*b[t];
    }
    int score = INT_MAX;
    for(int j = s; j < t; j++){
        score = min(score, a[s]*b[j]*a[j+1]*b[t]+dfs(s,j)+dfs(j+1,t));
    }
    return dp[s][t] = score;
}

int main(){
    int n;
    cin >> n;

    for(int i = 0; i < n; i++)  cin >> a[i] >> b[i];

    cout << dfs(0, n-1) << endl;

    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int INF = 1e9;
const int MOD = INF+7;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb push_back
using P = pair<int,int>;

signed main(){
	int A,B,C;
	cin >> A >> B >> C;
	if(A <= C && C <= B) cout << "Yes" << endl;
	else if(B <= C && C <= A) cout << "Yes" << endl;
	else cout << "No" << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

string s;

signed main() {
	cin >> s;
	for (int i = 0; i < (int)s.size(); i++) {
		if ((!(i % 2) && s[i] == 'L') || (i % 2 && s[i] == 'R')) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
n = int(input())
x = (10 ** 9) + 7
a = 1
b = 1
c = 1
for i in range(n):
    a *= 10
    a %= x
    b *= 9
    b %= x
    c *= 8
    c %= x
ans = a - (2 * b - c)
print(ans % x)

Measured memory_bytes: 63344
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];
	int cnt = 0;
	for(int i = 0;i < n;i++){
	    A[i] = sc.nextInt();		
	}
	for(int i = 0;i < n;i++){
	     cnt+=Prime(A[i]);	    
	}
	System.out.println(cnt);
    }
    public static int Prime(int A){
	if(A == 1) return 0;
	else if(A == 2) return 1;
	else if(A % 2 == 0) return 0;/*ifかも*/
	for(int j = 3;j <= A / j;j+=2){
	    if(A % j == 0) return 0;
	}
	return 1;	    
    }
}
















Measured memory_bytes: 42748
import java.util.Scanner;

public class Main {

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

    private static void solve(Scanner in) {
        char[] S = in.next().toCharArray();
        int ans = 0;
        for (int i = 0; i < S.length - 1; i++) {
            if (S[i] != S[i + 1]) {
                ans++;
            }
        }
        System.out.println(ans);
    }

    static final char B = 'B', W = 'W';
}

Measured memory_bytes: 12876
fun main(args: Array<String>) {
    val (N, K) = listOfInt()
    val H = listOfLong().sorted()
    val sum = H.sum()
    if (N <= K) {
        println(0)
        return
    }
    val ans = H.dropLast(K).sum()
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 83380
//10-A

//関数で考えるとわかりやすいかも
//三角関数　平方根の求め方　sqrt( x長さの2乗　＋　y長さの2乗 )
import java.util.Scanner;

class Main {
    public static void main(String [] args){
         
        Scanner sc = new Scanner(System.in);
        
        double x1 = sc.nextDouble();//始点x
        double y1 = sc.nextDouble();//始点y
        double x2 = sc.nextDouble();//終点x
        double y2 = sc.nextDouble();//終点y
        
        //x方向の辺の長さは
        double xlength = x2 - x1;
        //y方向の辺の長さは
        double ylength = y2 - y1;
        
        //平方根 Math.sqrt(double a)
        double ans = Math.sqrt( xlength * xlength + ylength * ylength );
        System.out.println(ans);
        
        
        
    }
}

Measured memory_bytes: 28056
n = gets.to_i
max_count = 0
max_count_num = 1
for s in 1..n do
  count = 0
  num = s
  while (num % 2 == 0) do
    num /= 2
    count += 1
  end

  if (count > max_count)
    max_count = count
    max_count_num = s
  end
end

puts max_count_num


Measured memory_bytes: 1788
n = gets.to_i
strs = gets.chomp.split(' ').map(&:to_i)

min = 10*100
strs.each_with_index do |str, idx|
  break if idx == n-1
  diff = (strs[0..idx].inject(:+) - strs[(idx+1)..-1].inject(:+)).abs
  min = diff if diff < min
end
puts min

Measured memory_bytes: 1916
#[warn(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      n:usize,
      k:usize,
      a:[Usize1;n],
   }
   let mut town = Vec::new();
   let mut visit = vec![false; n];
   let mut now = 0;
   while !visit[now] {
      town.push(now);
      visit[now] = true;
      now = a[now];
   }
   let l = town.len();
   let mut r = 0;
   while town[r] != now {
      r += 1;
   }
   if k < l {
      println!("{}", town[k] + 1);
   } else {
      println!("{}", town[r + (k - r) % (l - r)] + 1);
   }
}


Measured memory_bytes: 6564
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------

bool dp[110][110][15];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    rep(i,110)rep(j,110)rep(k,15) dp[i][j][k] = false;
    int N;
    cin >> N;
    vector<int> x(N);
    for(int i=0; i<N; i++){
        cin >> x[i];
    }
    int M;
    cin >> M;
    vector<int> a(M),b(M),c(M);
    for(int i=0; i<M; i++){
        cin >> a[i] >> b[i] >> c[i];
        b[i]--;c[i]--;
    }
    for(int i=0; i<N; i++){
        for(int k=0; k<M; k++){
            if(a[k] == x[i]){
                dp[i][i+1][k] = true;
            }
        }
    }
    for(int i=2; i<=N; i++){
        for(int l=0; l<=N-i; l++){
            for(int m=l+1; m<l+i; m++){
                for(int k=0; k<M; k++){
                    dp[l][l+i][k] |= dp[l][m][b[k]] & dp[m][l+i][c[k]];
                    // if(dp[l][l+i][k]){
                    //     cout << l << " " << l+i << " " << k << "\n";
                    // }
                }
            }
        }
    }
    // for(int i=0; i<=N; i++){
    //     for(int j=i+1; j<=N; j++){
    //         for(int k=0; k<M; k++){
    //             cout << i << " " << j << " " << k << "\n";
    //             cout << dp[i][j][k] << "\n";
    //         }
    //     }
    // }
    if(dp[0][N][0]){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3392
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
      
  		int[] h=new int[n];
		for(int c=0;c<n;c++){
    		h[c]=sc.nextInt();
       
          }
    	
  
  		int ans=0;
  		int max=h[0];
  		
  
    for(int d=1;d<n;d++){
        if(h[d]<max-1){
            	ans++;
                break;
            }else{
        	max=Math.max(max,h[d]);
        }
        }
  
  
 	if(ans==0){
    		System.out.println("Yes");
    	}else{
     		System.out.println("No");
   	 }

    	
    }
}

Measured memory_bytes: 49356
import sys


def solve(result):
    ans = 0
    for d1, d2 in result:
        if d1 == d2:
            ans += 1
            if ans == 3:
                return True
        else:
            ans = 0
    return False


def main():
    input = sys.stdin.buffer.readline
    n = int(input())

    result = []
    for _ in range(n):
        d1, d2 = map(int, input().split())
        result.append((d1, d2))

    print("Yes" if solve(result) else "No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9240
#include <iostream>
using namespace std;
typedef unsigned long long int lli;

lli GCD(lli a,lli b);
lli LCM(lli a,lli b);

int main(){
    lli a,b;
    while(cin>>a>>b){
        cout << GCD(a,b) << " " << LCM(a,b) << endl;
    }
    return 0;
}

lli GCD(lli a,lli b){
    if(a<b)
        swap(a,b);
    lli r = 1;
    while(r!=0){
        r = a%b;
        a = b;
        b = r;
    }
    return a;
}

lli LCM(lli a,lli b){
    return a*b/GCD(a,b);
}

Measured memory_bytes: 3044
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int K, S;
    cin >> K >> S;
    int res = 0;
    REP(X, K + 1) {
        REP(Y, K + 1) {
            int Z = S - X - Y;
            if (Z >= 0 && Z <= K) {
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
# x, y, h のベース座標を決める
# ベース座標が満たす条件はh>0
# ベース座標から中心位置X, Y, Hを計算することができそう
# Hを決め打ちする
# Cx, Cyはたかだか100個しかないので、全探索する
N =  int(sys.stdin.readline())
L =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]

for l in L:
    if l[2] > 0:
        base = l
        break

for x in range(0, 101):
    for y in range(0, 101):
        H = abs(base[0] - x) + abs(base[1] - y) + base[2]
        correct = True
        for l in L:
            if l[2] != max((H - abs(l[0] - x) - abs(l[1] - y)), 0):
                correct = False
                break
        if correct:
            print(x, y, H)
            exit()

Measured memory_bytes: 66924
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

    long H[N];
    for ( int i = 0; i < N; i ++  ) {
        cin >> H[i];
    }

    long lasth = H[0];
    int count = 0;
    int maxcount = 0;
    for ( int i = 1; i < N; i ++ ) {
        if ( H[i] <= lasth ) {
            count ++;            
        } else {
            if ( count > maxcount ) maxcount = count;

            count = 0;
        }

        if ( count > maxcount ) maxcount = count;

        lasth = H[i];
    }

    cout << maxcount << endl;

    return 0;
}


Measured memory_bytes: 1024
from collections import Counter
N=int(input())
D=Counter()
A=[]
for i in range(N):
  A.append(input())
D=Counter(A)
if "AC" not in D:
  D["AC"]=0
if "WA" not in D:
  D["WA"]=0
if "TLE" not in D:
  D["TLE"]=0
if "RE" not in D:
  D["RE"]=0

print("AC","x",D["AC"])
print("WA","x",D["WA"])
print("TLE","x",D["TLE"])
print("RE","x",D["RE"])
  

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

using namespace std;
int max(int a , int b)
{
    if(a>=b)
    {
    	//cout<<b<<"\t" ;
        return(a);
    }
    return(b);
}
int main()
{
    long long a,b,c,i,j,n,w ;
	cin>>n>>w ;
	long long arr[n+1][w+1] ;
	for(i=0 ; i<n+1 ; i=i+1)
	{
		arr[i][0] = 0 ;
	}
	for(j=0 ; j<w+1 ; j=j+1)
	{
		arr[0][j] = 0 ;
	}
	vector<pair<long long,long long> >v ;
	for(i=0 ; i<n ; i=i+1)
	{
		cin>>a>>b ;
		pair<long long,long long>p ;
		p.first = a ;
		p.second = b ;
		v.push_back(p) ;
	}
	sort(v.begin(),v.end()) ;
	for(i=1 ; i<n+1 ; i=i+1)
	{
		pair<long long,long long>p ;
		p = v[i-1] ;
		a = p.first ;
		b = p.second ;
		for(j=1 ; j<w+1 ; j=j+1)
		{
			if(a>j)
			{
				arr[i][j] = arr[i-1][j] ;
			}
			else
			{
				c = j - a ;
				arr[i][j] = max(b+arr[i-1][c],arr[i-1][j]) ;
			}
		} 
	}
	cout<<arr[n][w] ;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<double, int>;

int main() {
    int n;
    cin >> n;
    int debt = 100000;
    while(n--) {
        debt = debt * 105 / 100;
        debt = (debt+999) / 1000 * 1000;
    }
    cout << debt << endl;
}


Measured memory_bytes: 2980
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;


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

  if(x>y)cout << '>';
  if(x<y)cout << '<';
  if(x==y)cout << '=';
}

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

int n,a[200001],ans;

signed main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    int sum=a[1],sumx=a[1],l=1,r=1;
    for(int i=1;i<=n;i++)
    {
        while(sum==sumx&&r<=n)
            sum+=a[r+1],sumx^=a[r+1],r++;
        ans+=(r-1)-l+1;
        sum-=a[l],sumx^=a[l];
        l++;
        if(r<l)r=l;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});    
    var H = parseInt(input[0][0], 10);
	var W = parseInt(input[0][1], 10);
	
	var lVl = 10;
    var graph = [];
    for (var i = 0; i < lVl; i++){
        graph.push(input[i + 1].map(e => parseInt(e, 10)));
	}
	var v_A = Array.from({length: lVl}, () => 0);
	var line;
	for (var i = 0; i < H; i++){
		line = input[i + 1 + lVl].map(e => parseInt(e, 10));
		for  (var x of line){
			if (x === -1) continue;
			v_A[x] ++;
		}
	}

//ここがコア
    for(var k = 0; k < lVl; k++){
        for(var i = 0; i < lVl; i++){
            for(var j = 0; j < lVl; j++) {
            graph[i][j] = Math.min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
//ここまで

	var ans = 0;

	for (var i = 0; i < lVl; i++){
		ans += graph[i][1] * v_A[i];
	}

	console.log(ans);

}


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


Measured memory_bytes: 34072
from math import atan2, pi

N, *XY = map(int, open(0).read().split())
XY = list(zip(*[iter(XY)] * 2))

for i, (x, y) in enumerate(XY):
    D = sorted(atan2(X - x, Y - y) for j, (X, Y) in enumerate(XY) if j != i)
    D.append(D[0] + 2 * pi)

    ans = 0
    for a, b in zip(D, D[1:]):
        if b - a >= pi:
            ans = (b - a) - pi

    print(ans / (2 * pi))

Measured memory_bytes: 3316
#include <stdio.h>


void sharea (long long *a, long long *b)
{
    if(*a % 2 == 0)  {
        *b += *a/2;
        *a = *a/2;
    }
    else{
        *b += (*a-1)/2;
        *a = (*a-1)/2;
    }
}
void shareb (long long *a, long long *b)
{
    if(*b % 2 == 0)  {
        *a += *b/2;
        *b = *b/2;
    }
    else{
        *a += (*b-1)/2;
        *b = (*b-1)/2;
    }
}

int main (void) {
    long long a,b,k;
    scanf("%lld %lld %lld",&a,&b,&k);
    for(int i= 0; i < k; i ++)  {
        if(i % 2 ==0 )    sharea(&a,&b);
        else    shareb(&a,&b);
    }
    printf("%lld %lld",a,b);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n-1));
    rep(i,n) {
        rep(j,n-1) {
            cin >> a[i][j];
            a[i][j]--;
        }
        reverse(a[i].begin(), a[i].end());  // vectorは末尾のアクセスが早いのれreverseしておく
    }
    vector<P> q;
    auto check = [&](int i) {   // iと試合できるペアをqに入れる
        if (a[i].size() == 0) return;
        int j = a[i].back();    // j: 対戦相手（末尾）
        if (a[j].size() == 0) return;
        if (a[j].back() == i) { // 対戦できる場合
            P p(i,j);
            if (p.second < p.first) swap(p.first, p.second);
            q.push_back(p);
        }
    };
    rep(i,n) {
        check(i);
    }
    int day = 0;
    while (q.size() > 0) {
        day++;
        sort(q.begin(), q.end());
        q.erase(unique(q.begin(), q.end()), q.end());   // 重複を削除
        vector<P> prevQ;
        swap(prevQ, q);
        for (P p : prevQ) {
            int i = p.first, j = p.second;
            a[i].pop_back();
            a[j].pop_back();
        }
        for (P p : prevQ) {
            int i = p.first, j = p.second;
            check(i);
            check(j);
        }
    }
    rep(i,n) {
        if (a[i].size() != 0) {     // 試合が残ってたら-1
        puts("-1");
        return 0;
        }
    }
    cout << day << endl;
    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	const ll answer = (m * 1900 + (n - m) * 100) * (1 << m);
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 256
import bisect
S=list(input())
T=list(input())
A=[[] for i in range(26)]
for i in range(len(S)):
  A[ord(S[i])-97].append(i+1)
a=0
b=0
for i in range(len(T)):
  k=ord(T[i])-97
  if len(A[k])==0:
    print(-1)
    exit()
  if b>=A[k][-1]:
    a=a+1
    b=A[k][0]
    continue
  else:
    b=A[k][bisect.bisect_right(A[k],b,lo=0,hi=len(A[k]))]
print(a*len(S)+b)

Measured memory_bytes: 9052
#include<bits/stdc++.h>
using namespace std;
#define fast                         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int                          long long int
#define double                       long double
#define ff                           first
#define ss                           second
#define pb                           push_back
#define eb                           emplace_back
#define all(x)                       (x).begin(), (x).end()
#define sz(x)                        ((int)(x).size())
#define len(x)                       ((int)(x).length())
#define pii                          pair<int,int>
#define vi                            vector<int>
#define vd                           vector<double>
#define vs                            vector<string>
#define mp                          map<int,int>

#define ump                         unordered_map<int,int>

#define lb                            lower_bound
#define ub                            upper_bound
#define nx                            cout<<"\n";
#define inf                           9223372036854775807
#define PI                            3.14159265

const int MOD = 1e9 + 7;

inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }
inline int add(int a, int b) {    return ((a % MOD) + (b % MOD)) % MOD;}

inline int multi(int a, int b) {   return ((a % MOD) * (b % MOD)) % MOD;}

inline int sub(int a, int b) {       a %= MOD; b %= MOD; a -= b; if (a < 0) a += MOD; return a;}

inline int power(int a, int b) {       a %= MOD; int res = 1; while (b > 0) {if (b & 1) {res = multi(res, a);} a = multi(a, a); b >>= 1;}  return res;}

bool isPrime(int  x) {      if (x <= 4 || x % 2 == 0 || x % 3 == 0) {return x == 2 || x == 3;} for (int i = 5; i * i <= x; i += 6) {if (x % i == 0 || x % (i + 2) == 0) { return 0;}} return 1;}

int solve(int i, int n, int h[], int dp[], int k)
{
// cout << i << endl;
  if (i > n)return INT_MAX;
  if (dp[i] != -1)return dp[i];
  if (i == n)return 0;
  int ans = inf;
  for (int j = 1; j <= k; j++)
  {
    if (i + j > n)break;
    ans = min(ans, solve(i + j, n, h, dp, k) + abs(h[i] - h[i + j]));
  }
  return dp[i] = ans;
}
int32_t main()
{
  fast ;


  int n, k; cin >> n >> k;
  int h[n + 5];
  for (int i = 0; i < n; i++)cin >> h[i];
  h[n] = INT_MAX;
  int dp[n];
  memset(dp, -1, sizeof(dp));

  cout << solve(0, n - 1, h, dp, k) << endl;


}



Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(ll i=a; i<= b; ++i)
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define vi vector<int>
#define pb push_back
#define MOD 1000000007
typedef long long ll;

ll solve(ll a,ll b)
{
    return a*2+b*4;
}

int main(){
    optimize();
    ll T=1;
    //cin>>T;
    while(T--)
    {
        ll x,n;
        cin>>x>>n;
        for(int i=0; i<=x/2; i++)
        {
            ll a=solve(i,x-i);
            ll b=solve(x-i,i);
            if(a==n || b==n)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3660
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N; string s; cin >> s;
    ll lc = 0;
    ll l = 0;
    REP(i, N){
        if(s[i] == '(') l++;
        else{
            if(l > 0) l--;
            else lc++;
        }
    }
    REP(i, lc) s = "(" + s;
    REP(i, l) s += ")";
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

const int NUM = 1000000;
bool prime[NUM];
int primeNum[NUM];

int main(){

  prime[0] = false;prime[1] = false;
  for(int i=2;i<NUM;i++)prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

	for(int i=0,c=0;i<NUM;i++){
		prime[i]&&c++;
		primeNum[i] = c;
	}
	for(int n;scanf("%d",&n)+1;printf("%d\n",primeNum[n]));
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
    char n[5];
    scanf("%s", n);
    if (n[0] == n[1] && n[1] == n[2]) printf ("Yes");
    else if (n[1] == n[2] && n[2] == n[3]) printf ("Yes");
    else printf ("No");
    return (0);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
string X,Y;
  cin>>X>>Y;
  if(X>Y){
  
  cout<<">"<<endl;
  }
  else if(X<Y){
  cout<<"<"<<endl;
  
  }
  else{
  cout<<"="<<endl;
  }


}

Measured memory_bytes: 256
N = int(input().rstrip())
a = [int(v) for v in input().rstrip().split()]
r = 0
pre = a[0]
for i in range(1, N):
	d = a[i] - pre
	if d >= 0:
		pre = a[i]
		pass
	else:
		d2 = abs(d)
		r += d2

print(r)



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

int main() {
  ll n,k;
  cin >> n >> k;
  vector<double> p(n);
  for(ll i=0;i<n;i++) {
    ll temp;
    cin >> temp;
    p[i]=(1+temp)/2.0;
  }
  vector<double> sp(n);
  for(ll i=0;i<n;i++) {
    if(i==0) {
      sp[i]=p[i];
    }
    else {
      sp[i]=sp[i-1]+p[i];
    }
  }
  double ans=sp[k-1];
  for(ll i=k;i<n;i++) {
    ans=max(ans,sp[i]-sp[i-k]);
  }
  printf("%.10f",ans);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N;
    cin >> N;
    vl A(N), B(N), C(N);
    rep(i, N){
        cin >> A[i];
    }
    sort(all(A));
    rep(i, N){
        cin >> B[i];
    }
    sort(all(B));
    rep(i, N){
        cin >> C[i];
    }
    sort(all(C));

    ll ans = 0;
    //中段を決めると全て決まる
    rep(i, N){
        ll a = lower_bound(all(A), B[i]) - A.begin();
        ll c = N - (upper_bound(all(C), B[i]) - C.begin());
        ans += a * c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head
vll fac(500001);

void init() {
    fac[0] = fac[1] = 1;
    FOR (i, 2, sz(fac))
        fac[i] = (i*fac[i-1])%mod;
}

ll ways(ll n, ll k) {
    return fac[n]*((modInverse(fac[k])*modInverse(fac[n-k]))%mod)%mod;
}

void solve() {
    init();

    ll n, m;
    cin >> n >> m;

    ll ans = 0, temp;
    FOR (i, 0, n+1) {
        temp = (fac[n-i]*ways(m-i, n-i))%mod;
        temp = (temp*temp)%mod;
        temp = (((((fac[i]*ways(n, i))%mod)*ways(m, i))%mod)*temp)%mod;
        if (i%2 == 0) {
            ans += temp;
        } else {
            ans -= temp;
        }
        ans = (ans + mod)%mod;
    }

    cout << ans << "\n";
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    int t = 1;
    tc(t) {
        solve();
    }

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << duration << "\n";
    #endif

}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


Measured memory_bytes: 6980
#include<iostream>
#include<algorithm>
#define LL long long
int N;
int A[3][101];
int main() {
	std::cin >> N;
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= N; j++) {
			std::cin >> A[i][j];
		}
	}
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= N; j++) {
			A[i][j] += std::max(A[i - 1][j], A[i][j - 1]);
		}
	}
	std::cout << A[2][N] << std::endl;
	return 0;
}

Measured memory_bytes: 256
local n,k=io.read("n","n")
local a={}
for i=1,n do
    a[i]=io.read("n")
end

local dp={}
for i=0,k do
    if not dp[i] then
        for j=1,n do
            dp[i+a[j]]=true
        end
    end
end
print(dp[k] and "First" or "Second")

Measured memory_bytes: 8616
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t K;
  cin >> K;
  vector<int64_t> result = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  while (true) {
    if (K <= static_cast<int64_t>(result.size())) {
      cout << result[K - 1] << endl;
      break;
    } else {
      K-= static_cast<int64_t>(result.size());
    }
    vector<int64_t> old;
    swap(result, old);
    for (int64_t &v : old) {
      for (int64_t d = -1; d <= 1; ++d) {
        if (v % 10 + d >= 0 && v % 10 + d < 10) {
          result.emplace_back(v * 10 + (v % 10 + d));
        }
      }
    }
  }
  // const int64_t L = static_cast<int64_t>(T.length());
  return 0;
}


Measured memory_bytes: 4612
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

typedef struct {
  ll to, cost;
} edge;

#define P pair<ll, int> //<最短距離, 頂点番号>
#define MAX_V 100000

int V;
vector<edge> Gy[MAX_V], Gs[MAX_V];
ll ds[MAX_V], dt[MAX_V];

void dijkstra(int s, vector<edge> *G, ll *d) {
  priority_queue< P, vector<P>, greater<P> > que;
  fill(d, d + V, LLONG_MAX);
  d[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;

    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
	d[e.to] = d[v] + e.cost;
	que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main(void) {

  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--; t--;
  V = n;

  int u, v; ll a, b;

  rep(i, m) {
    cin >> u >> v >> a >> b;
    u--; v--;
    edge x;
    x.to = v; x.cost = a;
    Gy[u].push_back(x);
    x.to = u;
    Gy[v].push_back(x);
    x.to = v; x.cost = b;
    Gs[u].push_back(x);
    x.to = u;
    Gs[v].push_back(x);
  }

  dijkstra(s, Gy, ds);
  dijkstra(t, Gs, dt);

  //rep(i, n) cout << ds[i] << endl;
  //cout << endl;
  //rep(i, n) cout << dt[i] << endl;

  pair<ll, int> aa[200100];
  for (int i = 0; i < n; i++) {
    aa[i].first = ds[i] + dt[i];
    aa[i].second = i;
  }

  sort(aa, aa + n);
  //rep(i, n) cout << aa[i].first  << " "; cout << endl;

  int j = 1, key = aa[0].second;
  for (int i = 1; i < n; i++) {
    if (key < aa[i].second) {
      aa[j++] = aa[i];
      key = aa[i].second;
    }
  }
  //rep(i, n) cout << aa[i].first  << " "; cout << endl;

  ll ans[100010];
  j = 0;
  for (int i = 0; i < n; i++) {
    while (j < n && j < aa[i].second + 1) {
      ans[j++] = aa[i].first;
    }
  }

  rep(i, n) cout << (ll)1e15 - ans[i] << endl;

  return 0;
  
}


Measured memory_bytes: 22268
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>;
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
  int n;cin >>n;
  map<ll, int> mp;
  for(int i = 0; i < n; ++i){
    int a;cin >>a;
    ++mp[-1*a];
  }
  ll ans=1;int count=0;
  for(auto it : mp){
    if(ans==1&&it.second/2>=2){
      ans = it.first * it.first;
      count=2;
      break;
    }
    if(it.second/2>=1){
      ans*=it.first;
      ++count;
      if(count==2){
      break;
      }
    }
  }
  if(count!=2)ans=0;
  cout << ans << endl;
}


Measured memory_bytes: 6528
H, W = map(int, input().split())
Map = []
for i in range(H):
    Map.append(input())
for i in range(H):
    for j in range(W):
        if Map[i][j] == 's':
            (sx, sy) = (j, i)
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)

def maxlen(sx, sy):
    visited = [[-1] * W for i in range(H)]
    stack = [(sx, sy)]
    visited[sy][sx] = 0
    c = 1
    while stack:
        st = []
        for a in stack:
            x = a[0]
            y = a[1]
            for i in range(4):
                nx = x + dx[i]
                ny = y + dy[i]
                if 0<=nx<W and 0<=ny<H and visited[ny][nx] == -1:
                    if Map[ny][nx] == '.':
                        visited[ny][nx] = c
                        st.append((nx, ny))
        stack = st
        c += 1
    return c-2
ans = -1
for i in range(H):
    for j in range(W):
        if Map[i][j] == '.':
            ans = max(ans, maxlen(j, i))
print(ans)

Measured memory_bytes: 3064
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
x = 0
y = 0
z = 0
        
for i in range(n):
  if p[i] <= a:
    x = x + 1
  if a < p[i] <= b:
    y = y + 1
  if b < p[i]:
    z = z + 1

print(min(x, y, z))

Measured memory_bytes: 3064
#include<iostream>
#include<map>
using namespace std;
int main() {
    int n; cin >> n;
    map<string, int> mp;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        mp[s]++;
    }
    int m; cin >> m;
    for (int i = 0; i < m; ++i) {
        string s; cin >> s;
        mp[s]--;
    }
    int ans = 0;
    for (auto x : mp) {
        if (ans < x.second) {
            ans = x.second;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
// AtCoder Grand Contest 013
// D - Piling Up

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


const int MAX_N = 3000;
const ll MOD = (ll)1e9 + 7;

int N, M;
ll dp[2][MAX_N + 1];

int main() {

    ll ans;

    cin >> N >> M;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        dp[1][i] = 1;
    }

    for (int k = 0; k < M - 1; k++) {
        for (int j = 0; j < 2; j++) {
            dp[j][N] = 0;
            for (int i = N; i > 0; i--) {
                dp[j][i] += dp[j][i - 1];
                dp[j][i] %= MOD;
            }
            for (int i = 0; i < N; i++) {
                dp[j][i] += dp[j][i + 1];
                dp[j][i] %= MOD;
            }
        }
        dp[0][0] += dp[1][0];
        dp[0][0] %= MOD;
        dp[1][0] = 0;
    }

    ans = 0;
    for (int i = 0; i < N; i++) {
        ans += dp[0][i];
        ans %= MOD;
    }
    ans *= 4;
    ans %= MOD;

    cout << ans << endl;

    return 0;

}





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

typedef long long int ll;

int main()
{
    ll n, m;
    cin >> n >> m;
    ll ans = 1;
    for(ll i = 1; i * i <= m;i++){
        if(m % i == 0){
            if(i * n <= m){
                ans = max(i, ans);
            }
            if(m / i <= m / n){
                ans = max(m / i, ans);
            }
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fread freopen("in.txt","r",stdin)
#define fwrite freopen("out.txt","w",stdout)
#define PI acos(-1.0)
#define Mx 100005
#define ll long long

using namespace std;

int main()
{
    //fread;
    //fwrite;

    ll k, x;
    cin >> k >> x;

    k *= 500;
    if(k >= x)
    {
      cout << "Yes\n";
    }
    else
    {
      cout << "No\n";
    }

    return 0;
}




Measured memory_bytes: 256
import math
N=int(input())
R=0

def gcd_3(a,b,c):
  return math.gcd(math.gcd(a,b), c)

for a in range(1,N+1):
  for b in range(1,N+1):
    for c in range(1,N+1):
      R+=gcd_3(a,b,c)

print(R)

Measured memory_bytes: 68216
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	int n;
	string s;
	cin >> n >> s;
	char a = 'a';
	int maxi = 0;
	for(int i=1; i<n-1; i++) {
		map<char, int> mp, mp2;
		for(int j=0; j<i; j++) {
			mp[s[j]]++;
		}
		for(int j=i; j<n; j++) {
			mp2[s[j]]++;
		}
		int count=0;
		rep(i,26) {
			if(mp[a+i] != 0 && mp2[a+i] != 0) count++;
		}
		chmax(maxi, count);
	}
	cout << maxi << endl;
	

  return 0;
}


Measured memory_bytes: 256