akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define db double
#define For(i,j,k) for(int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for(int i=(int)(j);i>=(int)(k);i--)
inline ll read(){
	ll x=0;char ch=getchar();bool f=0;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return f?-x:x;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);putchar(x%10+'0');
}
void writeln(ll x){write(x);puts("");}
void writep(ll x){write(x);putchar(' ');}

int const N=1e5+3;
int top,n,m,cnt,sta[N];
struct point{
	db x,y;
    point operator - (point A) const{return (point){x-A.x,y-A.y};}
    point operator + (point A) const{return (point){x+A.x,y+A.y};}
    void print(){printf("%.10lf %.10lf\n",x,y);}
}A,B,C,c[N],p1[N],p2[N];

point operator *(db x,point A){return (point){x*A.x,x*A.y};}
db CJ(point A,point B){return A.x*B.y-B.x*A.y;}//叉积 
db DJ(point A,point B){return A.x*B.x+A.y*B.y;}//点积 
db dis(point A){return sqrt(A.x*A.x+A.y*A.y);}//向量长度 
bool cmp(point A,point B){return (CJ(A,B)>0 || CJ(A,B)==0 && dis(A)<dis(B));}//按极角排序 
void Convex(point *A,int &n){//求凸包 
	for (int i=1;i<=n;i++)
	  if (A[i].y<A[1].y || A[i].y==A[1].y && A[i].x<A[1].x) swap(A[i],A[1]);
    point base=A[1];top=0;
	for (int i=1;i<=n;i++) A[i]=A[i]-base;
	sort(A+2,A+n+1,cmp);
	sta[++top]=1;
	for (int i=2;i<=n;sta[++top]=i,i++)
	  while (top>1 && CJ(A[i]-A[sta[top-1]],A[sta[top]]-A[sta[top-1]])>=0) top--;
	for (int i=1;i<=top;i++) A[i]=A[sta[i]]+base;
	n=top;A[n+1]=A[1];
}
void Minkowski(point A[],point B[]){//闵可夫斯基（凸包合并） 
	for (int i=1;i<=n;i++) p1[i]=A[i+1]-A[i];
	for (int i=1;i<=m;i++) p2[i]=B[i+1]-B[i];
	int i=1,j=1;c[cnt=1]=A[1]+B[1];
	while (i<=n && j<=m)
	  if (CJ(p1[i],p2[j])>=0) cnt++,c[cnt]=c[cnt-1]+p1[i++];
	  else cnt++,c[cnt]=c[cnt-1]+p2[j++];
	while (i<=n) cnt++,c[cnt]=c[cnt-1]+p1[i++];
	while (j<=m) cnt++,c[cnt]=c[cnt-1]+p2[j++];	
}
int check(point p){//判断一个点是否在凸包内 
	if (CJ(p,c[2])>0 || CJ(c[cnt],p)>0) return 0;
	int pos=lower_bound(c+1,c+cnt+1,p,cmp)-c-1;
	return CJ(c[pos%cnt+1]-c[pos],p-c[pos])>=0; 
}

point CGL_1_A(point A,point B,point C){//点在直线上的投影点
	db d=dis(B-A);
	return (A+(DJ(C-A,B-A)/d/d*(B-A)));
}
point CGL_1_B(point A,point B,point C){//点关于直线的对称点
	point P=CGL_1_A(A,B,C);
	return (C+2*(P-C));
}
int CGL_1_C(point A,point B,point C){//向量的位置关系(向量AC和向量AB) 
    if (CJ(B-A,C-A)>0) return 1;//逆时针 
    if (CJ(B-A,C-A)<0) return 2;//顺时针 
    if (DJ(C-A,B-A)<0) return 3;//方向相反
	if (dis(C-A)>dis(B-A)) return 4;//方向相同 AC>AB
	if (dis(C-A)<=dis(B-A)) return 5;//方向相同 AB>AC
}


signed main(){
	scanf("%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y);
	for (int q=read();q;q--){
		scanf("%lf%lf",&C.x,&C.y);
		int ans=CGL_1_C(A,B,C);
		if (ans==1) puts("COUNTER_CLOCKWISE");
		if (ans==2) puts("CLOCKWISE");
		if (ans==3) puts("ONLINE_BACK");
		if (ans==4) puts("ONLINE_FRONT");
		if (ans==5) puts("ON_SEGMENT");
	}
	return 0;
}


Measured memory_bytes: 3256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  Scanner sc;

  Main() {
    sc = new Scanner(System.in);
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void run() {
    while (true) {
      int n = sc.nextInt();
      int m = sc.nextInt();

      if ((n | m) == 0) {
        break;
      }

      int[] ta = new int[n];
      int[] ha = new int[m];

      int ts = 0;
      for (int i = 0; i < n; ++i) {
        ta[i] = sc.nextInt();
        ts += ta[i];
      }
      int hs = 0;
      for (int i = 0; i < m; ++i) {
        ha[i] = sc.nextInt();
        hs += ha[i];
      }

      boolean flag = false;
      for (int t = 0; t < n; ++t) {
        for (int h = 0; h < m; ++h) {
          if (!flag) {
            if (ts - ta[t] + ha[h] == hs + ta[t] - ha[h]) {
              flag = true;
              System.out.println(ta[t] + " " + ha[h]);
            }
          }
        }
      }

      if (!flag) {
        System.out.println(-1);
      }
    }
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 21044
import sys
from scipy.optimize import fmin

input = sys.stdin.readline

n = int(input())

XR = []
XL = []
XS = []
YU = []
YD = []
YS = []

for _ in range(n):
    x, y, d = input().split()
    x = int(x)
    y = int(y)
    if d == "D":
        XS.append(x)
        YD.append(y)
    elif d == "U":
        XS.append(x)
        YU.append(y)
    elif d == "R":
        XR.append(x)
        YS.append(y)
    elif d == "L":
        XL.append(x)
        YS.append(y)


max_YD = max(YD + [float("-inf")])
max_YS = max(YS + [float("-inf")])
max_YU = max(YU + [float("-inf")])
min_YD = min(YD + [float("inf")])
min_YS = min(YS + [float("inf")])
min_YU = min(YU + [float("inf")])

max_XR = max(XR + [float("-inf")])
max_XL = max(XL + [float("-inf")])
max_XS = max(XS + [float("-inf")])
min_XR = min(XR + [float("inf")])
min_XL = min(XL + [float("inf")])
min_XS = min(XS + [float("inf")])


def diff_xy(t):
    diff_y = max(max_YD - t, max_YU + t, max_YS) - min(min_YD - t, min_YU + t, min_YS)
    diff_x = max(max_XL - t, max_XR + t, max_XS) - min(min_XL - t, min_XR + t, min_XS)
    return diff_x * diff_y


options = [
    max_YD - max_YS,
    max_YS - max_YU,
    (max_YD - max_YU) / 2,
    min_YD - min_YS,
    (min_YD - min_YU) / 2,
    min_YS - min_YU,
    max_XL - max_XS,
    max_XS - max_XR,
    (max_XL - max_XR) / 2,
    min_XL - min_XS,
    (min_XL - min_XR) / 2,
    min_XS - min_XR]

ans = diff_xy(0)

for option in options:
    if option >= 0:
        ans = min(ans, diff_xy(option))

print(ans)


Measured memory_bytes: 26832
n=int(input())
A=[int(i) for i in input().split()]+[0]
m=max(A)
import collections
C=collections.Counter(A)
chk=True
if m%2==0:
  for i in range(m//2,m+1):
    if i==m//2:
      if C[i]!=1:
        chk=False
    else:
      if C[i]<2:
        chk=False
else:
  for i in range((m+1)//2,m+1):
    if i==(m+1)//2:
      if C[i]!=2:
        chk=False
    else:
      if C[i]<2:
        chk=False
print("Possible" if chk else "Impossible")

Measured memory_bytes: 3316
//https://atcoder.jp/contests/agc037/tasks/agc037_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    string S; cin>>S;
    ll ans=0;
    string prev{S.at(0)}; ++ans;
    string cur;
    FOR(i,1,S.size()){
        cur.push_back(S.at(i));
        if (cur!=prev){
            prev=cur;
            cur.clear();
            ++ans;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
/*________________________Bismillahir Rahmanir Rahim___________________
                                                                      |
|                    /\     |     | |\    |     /\     |-------        |
|                   /  \    |     | | \   |    /  \    |               |
|                  /----\   |-----| |  \  |   /----\   |-----          |
|                 /      \  |     | |   \ |  /      \  |               |
|                /        \ |     | |    \| /        \ |               |
|                     14th batch CSE , ID : 12008029                   |
|                     Comilla University                               |
|                     Email : sheikhahnafshifat@gmail.com              |
|______________________________________________________________________*/
#include<bits/stdc++.h>
#include<string>
#include<iostream>
using namespace std;
#define ll                      long long
#define MAX                     1000007
#define pb(x)                   push_back(x)
#define mp(x,y)                 make_pair(x,y)
#define vii                     vector<int>
#define vll                     vector<long long>
#define vp                      vector<pair<ll, ll> >
#define v_min(a)                *min_element(a.begin(),a.end())
#define v_max(a)                *max_element(a.begin(),a.end())
#define v_sum(a)                accumulate(a.begin(),a.end(),0)
#define un(a)                   a.erase(unique(a.begin(),a.end()),a.end())
#define SORT(a)                 sort(a.begin(),a.end())
#define AHNAF                   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define gcd(a,b)                __gcd(a,b)
#define lcm(a,b)                ((a)*(b))/gcd(a,b)
#define YES                     cout<<"YES"<<endl
#define NO                      cout<<"NO"<<endl
#define testcase(t)             int t;cin>>t;while(t--)
#define reverse(a)              reverse(a.begin(),a.end())
#define ff                      first
#define ss                      second

int main()
{
    AHNAF;
    int n;cin>>n;
    string a;cin>>a;
    if(n>=a.size()) cout<<a;
    else
    {
        for(int i=0; i<n; i++) cout<<a[i];
        cout<<"...";
    }
}




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

int main(){
  char s[105];
  int cnt[27];
  int i,n;

  for(i = 0;i <= 26;i++) cnt[i] = 0;
  scanf("%s", s);
  n = strlen(s);
  for(i = 0;i < n;i++) cnt[s[i] - 'a']++;

  int f = 0;
  for(i = 0;i <= 25;i++){
    if(cnt[i] % 2 == 1) f = 1;
  }

  if(f == 1) printf("No\n");

  else printf("Yes\n");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    string s; cin >> s;
    if(s.at(0)==s.at(1) || s.at(2)==s.at(3) || s.at(1)==s.at(2)) cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;   
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> data(N);
  for(int i=0; i<K; i++){
    int d;
    cin >> d;
    vector<int> A(d);
    for(int k=0; k<d; k++){
      cin >> A.at(k);
      data.at(A.at(k)-1)++;
    }
  }
  int count=0;
  for(int i=0; i<N; i++){
    if(data.at(i) == 0){
      count++;
    }
  }
  cout << count << endl;
    
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
  int k;
  cin >> k;
  int now=7;
  rep(i,k){
    if(now%k==0){
      cout << i+1 << endl;
      return 0;
    }
    now*=10;
    now+=7;
    now%=k;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3608
import math
def main():
    a,b,h,m = tuple([int(t)for t in input().split()])

    radh = 2*math.pi/12*h+2*math.pi/720*m
    radm = 2*math.pi/60*m
    rad = abs(radh-radm)
    rad = min(rad,2*math.pi-rad)


    ans2 = a**2+b**2-2*a*b*math.cos(rad)
    print(ans2**0.5)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9516
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
typedef pair<int, int> P;
vector<P> G[100010];

int d[100010];

void dfs(int x, int p = -1, int c = 0) {
    d[x] = c;
    for(auto to: G[x]) {
        if(to.first == p) continue;
        dfs(to.first, x, c + to.second);
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    rep(i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }
    int Q, K;
    cin >> Q >> K;
    K--;
    dfs(K);
    while(Q--) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << d[x] + d[y] << endl;
    }


    return 0;
}


Measured memory_bytes: 14336
using System;
public class Hello{
    public static void Main(){
        
        string str;
        int kaisu;
        int kosu;
        
        while(true){
            str=Console.ReadLine();
            if(str=="-")break;
            kaisu=int.Parse(Console.ReadLine());
            for(int i=0;i<kaisu;i++)
            {
                kosu=int.Parse(Console.ReadLine());
                str=str.Remove(0,kosu)+str.Remove(kosu,str.Length-kosu);
            }
            Console.WriteLine(str);
        }
        
    }
}



Measured memory_bytes: 15916
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

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

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    s = input()
    ss = ['2','0','1','8']
    for i in range(10):
        if i<4:
            continue
        ss.append(s[i])
    print(''.join(ss))
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38508
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

//-----end of template-----//

int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	auto v = make_v<i64>(n, 3);
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < 3; ++j) cin >> v[i][j];
	}
	auto dp = make_v<i64>(n + 1, 3);
	fill_v(dp, -1 * INF<i64>);
	dp[0][0] = dp[0][1] = dp[0][2] = 0;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < 3; ++j){
			dp[i + 1][j] = v[i][j] + max(dp[i][(j + 1) % 3], dp[i][(j + 2) % 3]);
		}
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}

Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N;
    string S[200000];
    map<string,int> hoge;
    vector<string> ans;
    cin>>N;
    rep(i,N){
        cin>>S[i];
        hoge[S[i]] += 1;
    }
    int max_val = 0;
    rep(i,N){
        max_val = max(hoge[S[i]],max_val);
    }
    rep(i,N){
        if(hoge[S[i]] == max_val){
            ans.push_back(S[i]);
            hoge[S[i]]=0;
        }
    }
    sort(ans.begin(),ans.end());
    rep(i,ans.size()){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 28404
#include <stdio.h>
#define DOT(v1, v2) (v1.x * v2.x + v1.y * v2.y)
#define CROSS(v1, v2) (v1.x * v2.y - v1.y * v2.x)
#define NORM(v) (v.x * v.x + v.y * v.y)

typedef struct { double x, y; } point_t;
typedef point_t vector_t;
typedef struct { point_t p0, p1; } segment_t;
typedef segment_t line_t;

static vector_t minus(vector_t v1, vector_t v2) {
  vector_t ret = { v1.x - v2.x, v1.y - v2.y };
  return ret;
}

static int clockwise(segment_t s, point_t p) {
  vector_t a = minus(s.p1, s.p0);
  vector_t b = minus(p, s.p0);
  double c = CROSS(a, b);
  double d = DOT(a, b);
  double na = NORM(a);
  double nb = NORM(b);
  if (c > 0.0) return 1;
  if (c < 0.0) return -1;
  if (d < 0.0) return 1;
  if (nb > na) return -1;
  return 0;
}

int main(int argc, char **argv) {
  int q, i, k, l;
  segment_t s1, s2;

  scanf("%d", &q);
  for (i = 0; i < q; ++i) {
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
        &s1.p0.x, &s1.p0.y, &s1.p1.x, &s1.p1.y,
        &s2.p0.x, &s2.p0.y, &s2.p1.x, &s2.p1.y);
    k = clockwise(s1, s2.p0) * clockwise(s1, s2.p1);
    l = clockwise(s2, s1.p0) * clockwise(s2, s1.p1);
    printf("%d\n", k <= 0 && l <= 0);
  }
}


Measured memory_bytes: 2148
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;

constexpr int32_t MAX_N = 300000;//頂点数
constexpr int32_t MAX_LOGN = 30;//log2頂点数
std::unordered_map<int32_t, double> graph[MAX_N];//木
double get(int32_t v, int32_t p) {
	auto& memo = graph[v][p];
	if (memo >= 0 && p != -1) {
		return memo;
	}
	int32_t count = 0;
	double sum = 0;
	for (auto& c : graph[v]) {
		if (c.first != p && c.first != -1) {
			++count;
			sum += get(c.first, v) + 1;
		}
	}
	if (count == 0) {
		return memo = 0;
	}
	return memo = sum / count;
}
bool CASE_HACK_MODE = true;
int32_t center1 = -1;
int32_t center2 = -1;
void input_tree()
{
	in >> N;
	for (int32_t i = 0; i < N - 1; ++i)
	{
		int a, b;
		in >> a >> b; --a; --b;
		graph[a][b] = -1;
		graph[b][a] = -1;
		if (center1 == -1) { center1 = a; center2 = b; }
		else {
			if (a == center1 || a == center2) {
				center1 = a;
			}
			else if (b == center1 || b == center2) {
				center1 = b;
			}
			else {
				CASE_HACK_MODE = false;
			}

			center2 = -1;
		}
	}
}


int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	out << std::fixed << std::setprecision(9);
	input_tree();
	if (!CASE_HACK_MODE)
	{
		for (int32_t i = 0; i < N; ++i)
		{
			out << get(i, -1) << endl;
		}

		return 0;
	}

	for (int32_t i = 0; i < N; ++i)
	{
		out << ((i == center1) ? 1.0 : 2.0) << endl;
	}
}
#endif

Measured memory_bytes: 44160
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b)
{ return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b)
{ return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main(void) {
  int n, k, q;
  scanf("%d %d %d", &n, &k, &q);

  int a[100001], correct[100001] = {0};;
  rep(i, q) {
    scanf("%d", &a[i]);
    correct[a[i]]++;
  }

  int i;
  for (i = 1; i <= n; i++) {
    printf((k - q + correct[i]) > 0 ? "Yes\n" : "No\n");  
  }
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <array>
#include <queue>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n, m, l;
    cin >> n >> m >> l;

    vector<vector<pair<ll, ll>>> net(n);
    REP(i, m){
        ll ai, bi, ci;
        cin >> ai >> bi >> ci;
        ai--; bi--;
        net.at(ai).push_back(make_pair(bi, ci));
        net.at(bi).push_back(make_pair(ai, ci));
    }

    ll q;
    cin >> q;
    vector<ll> ans(q, 0);
    vector<vector<pair<ll, ll>>> dists(
        n, vector<pair<ll, ll>>(n, make_pair(-1, -1)));
    REP(i, q){
        ll si, ti;
        cin >> si >> ti;
        si--; ti--;
        if(ti > si){
            swap(si, ti);
        }
        if(dists.at(si).at(ti) != make_pair(-1LL, -1LL)){
            ans.at(i) = dists.at(si).at(ti).first;
            continue;
        }

        // vector<pair<ll, ll>> dists(n, make_pair(-1, -1));
        dists.at(si).at(si) = make_pair(0, l);
        // num, rest, pos
        priority_queue<array<ll, 3>> que;
        que.push({0, l, si});
        while(!que.empty()){
            auto a = que.top(); que.pop();
            const ll num = - a.at(0);
            const ll rest = a.at(1);
            const ll cur = a.at(2);
            for(auto nxt : net.at(cur)){
                ll num_nxt, rest_nxt;
                if(rest >= nxt.second){
                    num_nxt = num;
                    rest_nxt = rest - nxt.second;
                }else if(l >= nxt.second){
                    num_nxt = num + 1;
                    rest_nxt = l - nxt.second;
                }else{
                    continue;
                }

                bool is_ok = false;
                if(dists.at(si).at(nxt.first) == make_pair(-1LL, -1LL)){
                    is_ok = true;
                }else{
                    const ll num_nxt2 = dists.at(si).at(nxt.first).first;
                    const ll rest_nxt2 = dists.at(si).at(nxt.first).second;
                    if(num_nxt < num_nxt2){
                        is_ok = true;
                    }else if(num_nxt == num_nxt2 && rest_nxt2 < rest_nxt){
                        is_ok = true;
                    }
                }
                if(!is_ok){ continue; }
                dists.at(si).at(nxt.first) = make_pair(num_nxt, rest_nxt);
                que.push({
                    - num_nxt, rest_nxt, nxt.first
                });
            }
        }
        ans.at(i) = dists.at(si).at(ti).first;
    }

    REP(i, q){
        cout << ans.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
object Main extends App {
  import scala.io.StdIn.readLine
  
  	val k = readLine.split(" ").head.toInt;
  	val homes =readLine.split(" ").map(_.toInt).toList;
  	println((k - (homes zip (homes.tail :+ (k+homes.head))).map{case (x, y) => scala.math.abs(y - x)}.max).toString)
}

Measured memory_bytes: 81160
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
using namespace std;

int main(){
	int n,k;
	cin>>n>>k;
	
	vector<int> a(k);
	REP(i,k){
		cin>>a[i];
	}
	
	while(1){
		string ans=to_string(n);
		REP(i,ans.size()){
			if(find(ALL(a),ans[i]-'0')!=a.end()) goto Exit;
		}
		cout<<ans<<endl;
		return 0;
		
Exit:
		n++;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int[] W = new int[N];
		
		W[0] = in.nextInt();
		for(int i=1; i<N; i++) {
			W[i] = W[i-1]+in.nextInt();
			
		}
		
		int min = W[N-1];
		int sub;
		for(int i=0; i<N-1; i++) {
			sub = Math.abs(W[N-1] - W[i] - W[i]);
			if(sub < min) {
				min = sub;
			}else {
				break;
			}
		}
		System.out.println(min);
		in.close();
	}
}


Measured memory_bytes: 21844
n = int(input())
ABC = []

for _ in range(n):
  ABC.append(list(map(int, input().split())))
  
dp = [[0]*3 for _ in range(n)]

for n_i in range(n):
  if n_i == 0:
    dp[n_i][0] = ABC[n_i][0]
    dp[n_i][1] = ABC[n_i][1]
    dp[n_i][2] = ABC[n_i][2]
  else:
    dp[n_i][0] = max(ABC[n_i][0]+dp[n_i-1][1], ABC[n_i][0]+dp[n_i-1][2])
    dp[n_i][1] = max(ABC[n_i][1]+dp[n_i-1][0], ABC[n_i][1]+dp[n_i-1][2])
    dp[n_i][2] = max(ABC[n_i][2]+dp[n_i-1][0], ABC[n_i][2]+dp[n_i-1][1])
    
print(max(dp[-1]))

Measured memory_bytes: 50292
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  // int MAX = (int)1e6;
  int MAX = *max_element(a.begin(), a.end());
  vector<int> cnt(MAX + 1);
  for (int i = 0; i < n; i++) {
    cnt[a[i]]++;
  }
  vector<bool> good(MAX + 1, true);
  for (int i = 0; i < n; i++) {
    if (cnt[a[i]] != 0) {
      for (int j = a[i] + a[i]; j <= MAX; j += a[i]) {
        good[j] = false;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (good[a[i]] && cnt[a[i]] == 1) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  uint64_t a,b,c;
  uint64_t count = 0;
  cin >> a >> b >> c;
  for(uint64_t i = a; i<=b; i++){
      if(c%i==0) count++;
  }
  
  cout << count << endl;
 
  return 0;
}


Measured memory_bytes: 3096
package main

import(
	"fmt"
	"math"
)

func main(){
	var N, M, Y int
	var ans = 1 
	fmt.Scanf("%v%v",&N, &M)
	for X := 1; X*X <= M; X++ {
		if M % X != 0 {continue}
		
		Y = M / X
		
		if X * N <= M {
			ans = int(math.Max(float64(ans),float64(X)))
		}
		if Y * N <= M {
			ans = int(math.Max(float64(ans),float64(Y)))
		}
	}
	fmt.Printf("%v\n",ans)
}

Measured memory_bytes: 512
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,a[100111];
ll tot,dp[100111];
vector<int> con[100111];
void dfs(int x,int pre=-1)
{
//	cerr<<"dfs:"<<x<<endl;
	if(con[x].size()==1)
	{
		dp[x]=a[x];
		return;
	}
	ll st=0;
	for(int i=0;i<con[x].size();i++)
	{
		if(con[x][i]==pre)continue;
		dfs(con[x][i],x);
		dp[x]+=dp[con[x][i]];
	}
	for(int i=0;i<con[x].size();i++)
	{
		if(con[x][i]==pre)continue;
		st=max(st,2*dp[con[x][i]]-dp[x]);
	}
	
	if(a[x]>dp[x])
	{
		puts("NO");
		exit(0);
	}
	ll comb=dp[x]-a[x];
	if(2*comb>dp[x]-st)
	{
		puts("NO");
		exit(0);
	}
	dp[x]-=2*comb;
//	cerr<<x<<":"<<dp[x]<<endl;
}
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)geti(a[i]);
	if(n==1)
	{
		puts("YES");
		return 0;
	}
	if(n==2)
	{
		if(a[1]==a[2])puts("YES");
		else puts("NO");
		return 0;
	}
	for(int i=1;i<n;i++)
	{
		int x,y;
		getii(x,y);
		con[x].PB(y);
		con[y].PB(x);
	}
	for(int i=1;i<=n;i++)
	{
		if(con[i].size()==1)
		{
			tot+=a[i];
		}
	}
	if(tot&1)
	{
		puts("NO");
		return 0;
	}
	tot/=2;
	int rt=1;
	while(con[rt].size()==1)rt++;
	dfs(rt);
	if(dp[rt]==0)puts("YES");
	else puts("NO");
	return 0;
}

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

int Q;
priority_queue<long long> qa;
priority_queue<long long, vector<long long>, greater<long long>> qb;
long long sa, sb, s;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> Q;
	int c, a, b;
	cin >> c >> a >> b;
	qa.push(a);
	s += b;
	--Q;
	while(Q--){
		cin >> c;
		if(c == 2){
			cout << qa.top() << " " << sa + sb + s << "\n";
//			cout << "sa sb s " << sa << " " << sb << " " << s << "\n";
//			if(!qa.empty()) cout << "a " << qa.top() << "\n";
//			if(!qb.empty()) cout << "b " << qb.top() << "\n";
		}else{
			cin >> a >> b;
			s += b;
			if(a <= qa.top()){
				if(qa.size() > qb.size()){
					qb.push(qa.top());
					qa.pop();
					if(!qa.empty()){
						if(a <= qa.top()){
							sa -= (qb.top() - qa.top()) * qa.size();
							sb += (qb.top() - qa.top()) * qb.size();
							qa.push(a);
							sa += qa.top() - a;
						}else{
							sa -= (qb.top() - a) * qa.size();
							sb += (qb.top() - a) * qb.size();
							qa.push(a);
						}
					}else{
						sb += qb.top() - a;
						qa.push(a);
					}
				}else{
					sa += qa.top() - a;
					qa.push(a);
				}
			}else if(!qb.empty() && a <= qb.top()){
				if(qa.size() > qb.size()){
					sb += a - qa.top();
					qb.push(a);
				}else{
					sa += (a - qa.top()) * qa.size();
					sb -= (a - qa.top()) * qb.size();
					qa.push(a);
				}
			}else{
				if(qa.size() > qb.size()){
					sb += a - qa.top();
					qb.push(a);
				}else{
					sa += (qb.top() - qa.top()) * qa.size();
					sb -= (qb.top() - qa.top()) * qb.size();
					qa.push(qb.top());
					qb.pop();
					qb.push(a);
					sb += a - qa.top();
				}
			}
		}
	}
}

Measured memory_bytes: 3828
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ll n, k;
  cin >> n >> k;
  n %= k;
  cout << min(n, abs(n - k)) << endl;

  return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
// #include"testlib.h"

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e6 + 10;
// const int mod = (int)1e9 + 7;


int main(int argc, char* argv[]){

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

    ll h, w, x, y;
    cin >> w >> h >> x >> y;

    cout << fixed << setprecision(9) << h * w / 2.0 << " ";

    cout << (w / 2.0 == x && h / 2.0 == y ? 1 : 0)  << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
 
$m = 0;
for($i=0; $i<5; $i++){
  $t[$i] = trim(fgets(STDIN));
  if (ceil($t[$i]/10)*10 - $t[$i] > $m) {
    $m = ceil($t[$i]/10)*10 - $t[$i];
    $mk = $i;
  }
}
$l = $t[$mk];
 
unset($t[$mk]);
$t = array_values($t);
 
$sum = 0;
for($i=0; $i<count($t); $i++){
  $sum += ceil($t[$i]/10)*10;
}
 
echo $sum + $l;
 
?>

Measured memory_bytes: 4604
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	ans := exec(s)
	fmt.Println(ans)
}

func exec(s string) string {
	ws := s
	l := [4]string{"dream", "dreamer", "erase", "eraser"}
FOR:
	for len(ws) >= 5 {
		for _, word := range l {
			if len(ws) < len(word) {
				continue
			}
			w := ws[len(ws)-len(word):]
			if w == word {
				ws = ws[:len(ws)-len(word)]
				continue FOR
			}
		}
		break
	}

	if len(ws) == 0 {
		return "YES"
	}
	return "NO"
}


Measured memory_bytes: 1280
//41
#include<iostream>
#include<vector>

using namespace std;

int main(){
  for(;;){
    vector<int> num(10);
    for(int i=0;i<10;i++){
      char c;
      if(!(cin>>c))return 0;
      num[i]=c-'0';
    }
    while(num.size()!=1){
      vector<int> temp;
      for(int i=1;i<num.size();i++){
	temp.push_back((num[i-1]+num[i])%10);
      }
      num=temp;
    }
    cout<<num[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
from heapq import heappop, heappush
from collections import Counter


class Node:
    
    def __init__(self, weight):
        self.weight = weight
    
    def set_parent(self,parent):
        self.parent = parent
        
    def get_length(self):
        try:
            tmp = 1 + self.parent.get_length()
        except AttributeError:
            tmp = 0
        return tmp
        
    def get_weight(self):
        return self.weight

    def __lt__(self, other):
        return self.weight < other.weight
    

S = input()
d = Counter(S)
tree_dic = {}
h = []
num = 0
for i in d:
    tree_dic[i] = Node(d[i])
    heappush(h,tree_dic[i])
while(len(h) > 1):
    tmp0 = heappop(h)
    tmp1 = heappop(h)
    tree_dic[num] = Node(tmp0.get_weight() + tmp1.get_weight())
    tmp0.set_parent(tree_dic[num])
    tmp1.set_parent(tree_dic[num])
    heappush(h,tree_dic[num])
    num+=1

ans = 0
for i in S:
    ans += tree_dic[i].get_length()
if len(S) == 1:
    print(1)
elif len(d) == 1:
    print(len(S))
else:
    print(ans)


Measured memory_bytes: 6176
n = int(raw_input())
S = map(int, raw_input().split())
cnt = 0

def merge(A, left, mid, right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    L = [0] * (n1+1) 
    R = [0] * (n2+1)
    L[:n1] = A[left:mid]
    R[:n2] = A[mid:right]
    #for i in xrange(n1):
    #    L[i] = A[left + i]
    #for i in xrange(n2):
    #    R[i] = A[mid + i]
    L[n1] = float('inf')
    R[n2] = float('inf')
    i = 0
    j = 0
    for k in xrange(left,right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
            cnt += 1
        else:
            A[k] = R[j]
            j += 1
            cnt += 1
    return 0

def mergeSort(A, left, right):
    if right - left > 1:
        mid = int((left + right) / 2)
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
    return 0

def main():
    mergeSort(S, 0, len(S))
    print ' '.join(map(str, S))
    print cnt
    return 0

main()

Measured memory_bytes: 54688
#include<bits/stdc++.h>
using namespace std;
const int N=55;
int n,ans;
struct Graph { 
	int head[N],deg[N],fa[N],ce;
	struct edge{ int to,nxt; } e[N<<1];
	void clearGraph() { memset(head,0,sizeof(head)), memset(deg,0,sizeof(deg)); ce=0; }
	void lnk(int a,int b) { e[++ce]=(edge){b,head[a]}, head[a]=ce, ++deg[b]; }
	void dfs(int u,int lst) {
		fa[u]=lst;
		for(int i=head[u];i;i=e[i].nxt) {
			int v=e[i].to;
			if(v == lst) continue;
			dfs(v,u);
		}
	}
}A,B,D;

int remove() {
	D.clearGraph();
	int res=0,cnt=0;
	for(int i=1;i<=n;++i)
		if(A.fa[i] == B.fa[i]) {
			if(A.fa[A.fa[i]] != B.fa[B.fa[i]]) return 1e9;
		}
		else {
			++res;
			if(A.fa[A.fa[i]] != B.fa[A.fa[i]]) D.lnk(i,A.fa[i]);
			if(A.fa[B.fa[i]] != B.fa[B.fa[i]]) D.lnk(B.fa[i],i);
		}
	queue<int> q;
	for(int i=1;i<=n;++i)
		if(!D.deg[i]) q.push(i), ++cnt;
	while(!q.empty()) {
		int u=q.front(); q.pop();
		for(int i=D.head[u];i;i=D.e[i].nxt) {
			int v=D.e[i].to;
			if(!--D.deg[v]) q.push(v), ++cnt;
		}
	}
	if(cnt == n) return res;
	return 1e9;
}
int main() {
	int T; scanf("%d",&T);
	while(T--) {
		scanf("%d",&n); ans=1e9;
		A.clearGraph(), B.clearGraph();
		for(int i=2,a,b;i<=n;++i)
			scanf("%d%d",&a,&b), A.lnk(a,b), A.lnk(b,a);
		for(int i=2,c,d;i<=n;++i)
			scanf("%d%d",&c,&d), B.lnk(c,d), B.lnk(d,c);
		for(int i=1;i<=n;++i) {
			A.dfs(i,0), B.dfs(i,0), ans=min(ans,remove());
			if(A.deg[i] != 1) continue;
			for(int j=1;j<=n;++j) {
				if(i == j) continue;
				A.dfs(j,i), A.fa[i]=0, ans=min(ans,remove()+1);
			}
		}
		if(ans == 1e9) puts("-1");
		else printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <cstdio>
using namespace std;
char a[100][101];
int h,w;
 
int main() {
        while(1){
     cin>>h>>w;
     bool flag=true;
     if(!h&&!w)break;
     for(int i=0;i<h;i++){
         scanf("%s",a[i]);
     }
     int x=0,y=0;
     for(int i=0;i<h*w+1;i++){
         if(a[y][x]=='>')x++;
         if(a[y][x]=='<')x--;
         if(a[y][x]=='^')y--;
         if(a[y][x]=='v')y++;
         if(i==h*w&&a[y][x]!='.')flag=false;
     }
     if(flag)cout<<x<<" "<<y<<endl;
     else cout<<"LOOP"<<endl;
        }
        return 0;
}

Measured memory_bytes: 3048
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    int n,m,x;
    vector<int> a;
    
    cin >> n >> m >> x;

    int t;
    for (int i = 0; i < m; i++)
    {
        cin >> t;
        a.push_back(t);
    }

    int count1 = 0;
    for (int i = x; i <= n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (a[j] == i) {
                count1++;
                break;
            }
        }
    }

    int count2 = 0;
    for (int i = x; i > 0; i--)
    {
        for (int j = 0; j < m; j++)
        {
            if (a[j] == i) {
                count2++;
                break;
            }
        }
    }

    cout << min(count1, count2) << endl;
    
    return 0;
}

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

typedef long long ll;
const int N = 3022;
int n, mod, C[N][N], S[N][N], ans;
int qpow(int b, int p, int d) {
  int r = 1;
  for (; p; p >>= 1, b = (ll) b * b % d) if (p & 1) {
    r = (ll) r * b % d;
  }
  return r;
}
int main() {
  scanf("%d%d", &n, &mod);
  C[0][0] = S[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    C[i][0] = 1;
    S[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
      S[i][j] = (S[i - 1][j - 1] + (ll) S[i - 1][j] * (j + 1)) % mod;
    }
  }
  for (int i = 0; i <= n; i++) {
    int c = qpow(2, qpow(2, n - i, mod - 1), mod), coef = qpow(2, n - i, mod);
    for (int j = 0; j <= i; j++, c = (ll) c * coef % mod) {
      ans = (ans + (ll) (i & 1 ? mod - 1 : 1) * C[n][i] % mod * S[i][j] % mod * c) % mod;
    }
  }
  printf("%d\n", ans);
}


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


using namespace std ;

int main () {
int sum=0,a,b,c,x;
cin>>a;
int s[2][200];
for(int i=0;i<2;i++)
    for(int j=0;j<a;j++)
    cin>>s[i][j];
if(a==1)
{
cout<<s[0][0]+s[1][0];return 0;
}
s[1][0]+=s[0][0];
for(int i=1;i<a;i++)
{s[0][i]+=s[0][i-1];
s[1][i]+=max(s[0][i],s[1][i-1]);

}

cout<<s[1][a-1]<<endl;
return 0;
}



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

const int64_t MOD = 1e9+7;

vector<int64_t> famod, simod, fimod;

void create_fact_mod(int num){
    famod[0] = 1;
    famod[1] = 1;
    for(int i=2; i<=num; i++){
        famod[i] = famod[i-1] * i % MOD;
    }
}

void create_seq_inv_mod(int num){
    simod[0] = 1;
    simod[1] = 1;
    for(int i=2; i<=num; i++){
        simod[i] = (MOD - MOD/i) * simod[MOD%i] % MOD;
    }
}

void create_fact_inv_mod(int num){
    fimod[0] = 1;
    fimod[1] = 1;
    for(int i=2; i<=num; i++){
        fimod[i] = fimod[i-1] * simod[i] % MOD;
    }
}

void create_mod_tables(int num){
    famod.resize(num+1);
    simod.resize(num+1);
    fimod.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return famod[n] * fimod[n-k] % MOD * fimod[k] % MOD;
}

int main(){
    int N, pos[100001], side;
    cin >> N;
    fill(pos, pos+N+1, -1);
    for(int i=0; i<N+1; i++){
        int a;
        cin >> a;
        if(pos[a] >= 0){
            side = pos[a] + N-i;
        }else{
            pos[a] = i;
        }
    }

    create_mod_tables(N+1);

    for(int i=1; i<=N+1; i++){
        int64_t all = comb_mod(N+1, i);
        int64_t dub = (side >= i-1 ? comb_mod(side, i-1) : 0);
        int64_t ans = (all-dub+MOD) % MOD;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3968
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
using namespace std;

#define ll long long int
#define ld long double
#define reps(i,f,n) for(int i=f;i<n;i++)
#define rep(i,n) reps(i,0,n)
#define m1 cout<<"move1"<<endl
#define m2 cout<<"move2"<<endl
#define m3 cout<<"move3"<<endl
#define m4 cout<<"move4"<<endl


int main(void){
  ld R,W,C,r;
  ll sum=0;

  while(cin>>R>>W>>C>>r,R,W,C,r){
    sum =0;
    while(1){
    if(R/W >= C){
      cout<<sum<<endl;
      break;
    }
    R+=r;
    sum++;
    }
  }
  return 0;
}
      

  

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

int n, cnt = 0;
vector<long long> p, v;

int main() {
  cin >> n;
  p.resize(n);
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> p[i];
  for(int i = 0; i < n; ++i) v[i] = p[i];
  sort(v.begin(), v.end());
  for(int i = 0; i < n; ++i)
    if(v[i] != p[i]) ++cnt;
  if(cnt <= 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\s/);

const abs = (num: number) => Math.abs(num);
const med = (arr: number[]) => {
  let half = Math.floor(arr.length/2);
  arr.sort((a,b) => a-b);
  return arr[half];
}

const N = +input[0];
let A = input.splice(1,input.length-1).map((mp) => +mp);
let arr: number[] = [];
let ans = 0;

for(let i=0; i<N; i++ ) arr.push(A[i] - (i+1));
let mid = med(arr);
for(let i=1; i<=N; i++) ans += abs(A[i-1] - (mid + i));
console.log(ans);

Measured memory_bytes: 44792
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  int r, d, xi;
  cin >> r >> d >> xi;
  rep(i, 10) {
    xi = (r * xi) - d;
    cout << xi << endl;
  }
  return 0;
}

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

int main(){
int N;
   cin>>N;
  vector<char>S(N);
  for(int i=0; i<N; i++){
    cin>>S[i];  }
  
  for(int i=0; i<N; i++){
  if(S[i]=='Y'){cout<<"Four"; return 0;}
  }
  
  cout<<"Three";
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, A, B, C, D = LI()
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = SS()

    ## 移動経路に2連続以上の岩があったらダメ
    if '##' in S[A:C+1] or '##' in S[B:D+1]:
        print('No')
    else:
        ## ふぬけ君を先に移動させればいい
        if C < D:
            print('Yes')
        ## ふぬけ君を飛び越えられる瞬間が存在すればいい
        else:
            # どこかに3以上の隙間があること
            if '...' in S[B-1:D+2]:
                print('Yes')
            else:
                print('No')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10412
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

class Creature {
    final int size;
    final int color;

    Creature(int size, int color) {
        this.size = size;
        this.color = color;
    }
}

class Solver {

    private final PriorityQueue<Creature> creatures;

    Solver(Scanner in) {
        int N = in.nextInt();
        creatures = new PriorityQueue<>(Comparator.comparingInt((Creature c) -> c.size));
        for (int i = 0; i < N; i++) {
            creatures.add(new Creature(in.nextInt(), i));
        }
    }

    void solve() {
        Creature s = creatures.remove();
        int streak = 0;
        long size = 0;
        for (; s != null; s = creatures.poll()) {
            if (size * 2 < s.size) {
                streak = creatures.size();
            }
            size += s.size;
        }
        System.out.println(streak + 1);
    }
}

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

        new Solver(in).solve();

        in.close();
    }
}

Measured memory_bytes: 59580
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    A, B, C = MI()

    print(min(B // A, C))


if __name__ == '__main__':
    main()


Measured memory_bytes: 64620
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, h, w, ans = 0;
  scanf("%lld%lld", &h, &w);
  ll c[10][10];
  for(i = 0; i < 10; ++i) for(j = 0; j < 10; ++j) scanf("%lld", &c[i][j]);
  ll dis[10];
  for(i = 0; i < 10; ++i) dis[i] = 10e8;
  dis[1]= 0;
  for(i = 0; i < 10; ++i) for(j = 0; j < 10; ++j) for(k = 0; k < 10; ++k) if(dis[j] + c[k][j] < dis[k]) dis[k] = dis[j] + c[k][j];
  for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) {
    ll a;
    scanf("%lld", &a);
    if(a != -1) ans += dis[a];
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,Y; cin>>N>>Y;

    for(int i=0;i<=N;i++){
        for(int j=0;i+j<=N;j++){
            int k=N-(i+j);
            int sum=10000*i+5000*j+1000*k;
            if(sum==Y){
                cout<<i<<' '<<j<<' '<<k<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<' '<<-1<<' '<<-1<<endl;

}


Measured memory_bytes: 256