akhauriyash/Code-Regression huggingface dataset:
import math
from collections import deque
n=int(input())
a=[0]*n
sum=0
for i in range(n):
    a[i]=list(map(int,input().split()))
for i in range(n-1):
    for j in range(i+1,n):
        sum+=math.sqrt((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)
print(sum*2/n)

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

int main(){

	string input,output;
	cin >> input;
	for(int i=0;i< input.size(); i++){
		if(input[i] == '0' || input[i]=='1' ){
			output += input[i];	
		}
		else if(input[i]=='B'){
			if(output==""){
				
			}
			else{
				output.pop_back();
			}
		}			
	}
	
	cout << output << endl;
 	return 0;
 }

Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char *argv[])
{
	int t;
	scanf("%d",&t);
	int a[1000];
	int count=0;
	for(int i=1;i<=t;i++){
		scanf("%d",&a[i]);
		if(i%2==1&&a[i]%2==1) count++;
	}
	printf("%d",count);
	return 0;
}

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

int main(){
    
    size_t s;

    std::cin >> s;

    size_t s1 = s / 100;
    size_t s2 = s % 100;

    if(s1 >= 1 && s1 <= 12){
        if(s2 >= 1 && s2 <= 12){
            std::cout << "AMBIGUOUS" << std::endl;
        }else{
            std::cout << "MMYY" << std::endl;
        }
    }else{
        if(s2 >= 1 && s2 <= 12){
            std::cout << "YYMM" << std::endl;
        }else{
            std::cout << "NA" << std::endl;
        }
    }
    
    return 0;
}


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

int main()
{
    int a, b;
    cin >> a >> b;

    const int n = 100;
    bool g[n][n] = {};

    cout << n << " " << n << endl;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i < 50) {
                if (i * j % 2 && --a > 0) g[i][j] = !g[i][j];
            } else {
                g[i][j] = !g[i][j];
                if (i * j % 2 && --b > 0) g[i][j] = !g[i][j];
            }
            cout << (g[i][j] ? '.' : '#');
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int n,a,b,c,d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  a--,b--,c--,d--;

  bool flag = true;
  if(c > d){
    flag = false;
    for(int i = b;i <= d;i++){
      if(s[i-1] == '.' && s[i+1] == '.' && s[i] == '.')flag = true;
    }
  }
    
  vector<int> dpa(n,0);
  for(int i = 0;i < n;i++){
    if(s[i] == '#')dpa[i] = -1;
  }

  dpa[a] = 1;
  int now_a = a;
  while(now_a < n){
    if(dpa[now_a] == 1){
      if(now_a + 1 < n && dpa[now_a+1] == 0)dpa[now_a+1] = 1;
      if(now_a + 2 < n && dpa[now_a+2] == 0)dpa[now_a+2] = 1;
    }
    now_a++;
  }

  vector<int> dpb(n,0);
  for(int i = 0;i < n;i++){
    if(s[i] == '#')dpb[i] = -1;
  }

  dpb[b] = 1;
  int now_b = b;
  while(now_b < n){
    if(dpb[now_b] == 1){
      if(now_b + 1 < n && dpb[now_b+1] == 0)dpb[now_b+1] = 1;
      if(now_b + 2 < n && dpb[now_b+2] == 0)dpb[now_b+2] = 1;
    }
    now_b++;
  }

  if(flag == true && dpa[c] == 1 && dpb[d] == 1)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint l(n);
    rep(i, n) cin >> l[i];
    sort(all(l));

    int ans = 0;
    rep(i, n-2) {
        srep(j, i+1, n-1) {
            int t = lower_bound(all(l), l[i]+l[j]) - l.begin();
            ans += t-j-1;
        }
    }

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

Measured memory_bytes: 256
#include<stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{int a[101][101], b[101][101];
	long long c[101][101], s;
	int i, j, k;
	int n, m, l;

	scanf("%d%d%d", &n, &m, &l);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) scanf("%d", &b[i][j]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			s = 0;
			for (k = 0; k < m; k++) {
				s += a[i][k] * b[k][j];
			}
			c[i][j] = s;
		}
	}

	for (i = 0; i < n; i++) {
		printf("%lld", c[i][0]);
		for (j = 1; j < l; j++) printf(" %lld", c[i][j]);
		putchar('\n');
	}


 return 0;
}


Measured memory_bytes: 2128
#include <iostream>
#include <iterator>
#include <algorithm>
#include <map>
using namespace std;

int main(void){
    // Your code here!
    string s;
    cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
        cout << "Bad";
    }else{
        cout << "Good";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	int a = n % 10;
	int b = n/100;

	if (a == b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    ll d[n];
    rep(0,i,n)cin>>d[i];
    sort(d,d+n);
    cout<<d[n/2]-d[n/2-1]<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>

#define rep(i,n) for(int (i)=0;i < (n);(i)++)
#define ll long long
#define INF 9223372036854775807

using namespace std;

// input
int a,b,c;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> c;

  bool flag = false;

  if(a == b && b != c) flag = true;
  if(a == c && a != b) flag = true;
  if(b == c && a != b) flag = true;

  if(flag) {
	cout << "Yes" << endl;
  } else {
	cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/


int main(){
    vector<ll> l;
    l.push_back(2);
    l.push_back(1);

    int N; cin >> N;
    for(int i=2; i<=N; i++){
        l.push_back(l[i-2]+l[i-1]);
    }

    cout << l[N] << endl;
}

Measured memory_bytes: 256
def main():
    while True:
        s = int(input())
        if s == 0:
            break
        cnt = 0
        s = 1000 - s
        if s//500 != 0:
            cnt += s//500
            s %= 500
        if s//100 != 0:
            cnt += s//100
            s %= 100
        if s//50 != 0:
            cnt += s//50
            s %= 50
        if s//10 != 0:
            cnt += s//10
            s %= 10
        if s//5 != 0:
            cnt += s//5
            s %= 5
        if s//1 != 0:
            cnt += s//1
            s %= 1
        print(cnt)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5596
# main

input_str = input()
input_num = int(input_str)

input_num_digits = len(input_str) - 1

if input_num == 10 ** input_num_digits:
    min_digit_sums = [10]

else:
    former_num = 10 ** input_num_digits
    latter_num = input_num - former_num

    digit_sum = 0
    for char in str(former_num):
        digit_sum += int(char)
    for char in str(latter_num):
        digit_sum += int(char)
    min_digit_sums = [digit_sum]

for i in range(1, input_num // 2):
    former_num = i
    latter_num = input_num - i

    digit_sum = 0
    for char in str(former_num):
        digit_sum += int(char)
    if digit_sum >= min(min_digit_sums):
        continue
    for char in str(latter_num):
        digit_sum += int(char)
    if digit_sum < min(min_digit_sums):
        min_digit_sums.append(digit_sum)

print(str(min(min_digit_sums)))




Measured memory_bytes: 3064
import math

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

# 1の位が０を除く最も小さい数の注文は一番最後
# それ以外は、切り上げていく。4つの注文は順不同で、1の位を切り上げてスタート

array = [a, b, c, d, e]
# print(array)

# print(array[0])

skip = int()
last = 9
for i in range(5):
    if array[i] % 10 == 0:
        # print(array[i])
        #array_begin = array[i]
        # print(array[i])
        pass
    else:
        # print(array[i])
        if array[i] % 10 <= last:
            # print(array[i])
            last = array[i] % 10
            skip = i
        else:
            pass
# print(last)
# print(skip)
counter = 0
for i in range(5):
    if i == skip:
        pass
    else:
        counter += 10*math.ceil(array[i] / 10)

counter = counter + array[skip]

print(counter)


Measured memory_bytes: 3064
#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
int gcd(int a, int b) {
    if (b > a) return gcd(b, a);
    else if (b == 0) return a;
    else return gcd(b, a % b);
}
int cnt[64];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    int A[100010];
    rep(i, N) cin >> A[i];
    int L = 1;
    rep(i, N) {
        int tmp = A[i];
        int c = 0;
        while(tmp % 2 == 0 && tmp > 0){
            c++;
            tmp /= 2;
        }
        cnt[c]++;
        L *= A[i] / gcd(L, A[i]);
        if (L > M * 4) {
            cout << 0 << endl;
            return 0;
        }
    }
    int k = 0;
    rep(i, 60) {
        if (cnt[i]) k++;
        if (k >= 2) {
            cout << 0 << endl;
            return 0;
        }
    }
    //cout << L << endl;
    cout << (M + L / 2)/L << endl;




    return 0;
}


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

int d,score,i,j,k,pscore,cscore,id;
int c[26],s[365][26],last[26],t[365];
int day1,day2,v1,v2,csize,f,check[4];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> d;
  for(i=0;i<26;i++) {
    cin >> c[i];
  }
  for(i=0;i<d;i++) {
    for(j=0;j<26;j++) {
      cin >> s[i][j];
    }
  }
  for(i=0;i<d;i++) {
    for(j=0;j<26;j++) {
      int tscore=s[i][j];
      for(int k=0;k<26;k++) {
        if(k==j) continue;
        tscore-=c[k]*(i+1-last[k]);
      }
      if(j==0) score=tscore;
      else if(tscore>score) {
        score=tscore;
        t[i]=j;
      }
    }
    last[t[i]]=i+1;
  }
  int cnt=400000;
  while(cnt--) {
    day1=rand()%d;
    v1=rand()%26;
    while(t[day1]==v1) {
      v1=rand()%26;
    }
    check[0]=t[day1];
    check[1]=v1;
    csize=2;
    f=0;
    if(cnt<100000) {
      f=1;
      day2=rand()%d;
      while(day2==day1) {
        day2=rand()%d;
      }
      v2=rand()%26;
      while(v2==t[day2]) {
        v2=rand()%26;
      }
      if(t[day1]!=t[day2]&&v1!=t[day2]) {
        check[csize++]=t[day2];
      }
      if(t[day1]!=v2&&v1!=v2) {
        check[csize++]=v2;
      }
    }
    pscore=0;
    cscore=0;
    for(i=0;i<csize;i++) last[check[i]]=0;
    for(i=0;i<d;i++) {
      pscore+=s[i][t[i]];
      last[t[i]]=i+1;
      for(j=0;j<csize;j++) {
        int id=check[j];
        pscore-=c[id]*(i+1-last[id]);
      }
    }
    for(i=0;i<csize;i++) last[check[i]]=0;
    for(i=0;i<d;i++) {
      if(day1==i) {
        cscore+=s[i][v1];
        last[v1]=i+1;
      }
      else if(f&&day2==i) {
        cscore+=s[i][v2];
        last[v2]=i+1;
      }
      else {
        cscore+=s[i][t[i]];
        last[t[i]]=i+1;
      }
      for(j=0;j<csize;j++) {
        id=check[j];
        cscore-=c[id]*(i+1-last[id]);
      }
    }
    if(pscore<cscore) {
      t[day1]=v1;
      if(f) t[day2]=v2;
    }
  }
  for(i=0;i<d;i++) {
    printf("%d\n",t[i]+1);
  }
}

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  rep(i, N) cin >> L[i];

  int ans = 1, total = 0;
  for (int D: L) {
    total += D;
    if (total <= X) ans++;
    else break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
#13:57
h,w = map(int,input().split())
inf = 10**9
wf = []
for i in range(10):
  wf.append(list(map(int,input().split())))
for k in range(10):
  for i in range(10):
    for j in range(10):
      wf[i][j] = min(wf[i][j],wf[i][k]+wf[k][j])
z1 = []
for i in range(10):
  z1.append(wf[i][1])
cnt = [0 for _ in range(10)] 
for _ in range(h):
  tmp = list(map(int,input().split()))
  for y in range(w):
    if tmp[y] != -1:
      cnt[tmp[y]] += 1
ans = 0
for i in range(10):
  ans += z1[i] * cnt[i]
#print(wf)
#print(z1)
#print(cnt)
print(ans)

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n;
    cin >> n;

    ll res = 0;
    for(ll a=1; a*a<n; a++)
        for(ll b=a; a<=b&&a*b<n; b++)
            if(a!=b) res+=2;
            else res++;
    cout << res << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
  int a,b,c;
  int con=1;
  
  scanf("%d %d %d",&a,&b,&c);
  
  if(b!=a) con++;
  if(c!=a&&c!=b) con++;
  
  printf("%d",con);
  
  return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#define LOCAL
#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int INF = 100000;
const pii ng = mp(INF, -1);

int a[18][2];
pii dp[1<<18][18];

int main() {
	int N; cin >> N;
	rep(j, 2) rep(i, N) cin >> a[i][j];
	rep(i, 1<<N) rep(j, N) dp[i][j] = ng; 
	rep(i, N) dp[1<<i][i] = mp(0, a[i][i&1]);


	rep(i, 1<<N) {
		int num = __builtin_popcount(i);

		rep(j, N) {
			if (dp[i][j] == ng) continue;

			int bk = num;
			int fr = 0;

			rep(k, N) {
				if (!((i >> k) & 1)) {
					int nx = a[k][(fr + bk) & 1];

					if (nx >= dp[i][j].se) {
						chmin(dp[i|(1<<k)][k], mp(dp[i][j].fi + bk, nx));
					}
					++fr;
				} else {
					--bk;
				}
			}
		}
	}

	pii ans = ng;
	rep(i, N) {
		chmin(ans, dp[(1<<N)-1][i]);
	}

	if (ans == ng) {
		puts("-1");
	} else {
		cout << ans.fi << endl;
	}

	return 0;
}

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

using namespace std;

#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second

typedef long long ll;

const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;
const int mod = N9 + 2;

string s;

int main()
{
    cin >> s;
    for1 (i, s.size() - 1, 0)
    {
        string f = s.substr(0, i);
        if (f.size() % 2 == 0)
        {
            if (f.substr(0, f.size() / 2) == f.substr(f.size() / 2, f.size() / 2))
            {
                cout << i;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

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

const ll mod = 1e9 + 7;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<string> g;

int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    long double l = max((long double)30.0 * h + (long double)0.5 * m, (long double)6.0 * m);
    long double s = min((long double)30.0 * h + (long double)0.5 * m, (long double)6.0 * m);
    long double d = l - s;
    long double ret = sqrt(a * a + b * b - (long double)2.0 * a * b * cos(M_PI * (d / (long double)180.0)));
    
    cout << fixed << setprecision(12) << ret << endl;

    return 0;
}

Measured memory_bytes: 4208
//#include <GOD>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define len length	
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define freo freopen("output.txt","w",stdout)
#define frei freopen("input.txt","r",stdin)

const ll mod=1e9+7;
const ll maxn=1e5+10,maxp=10110;

ll n,x,t;

int main(){
	FAST_IO;
	cin>>n>>x>>t;
	ll a=(n+x-1)/x;
	cout<<a*t<<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
ll h , w , k ;
bool inarea(ll x,ll y){
  return x >= 0 && y >= 0 && x < h && y < w ;
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main()
{
cin >> h >> w >> k ;
ll xs , xg , ys , yg ;
cin >> xs >> ys >> xg >> yg ;
xs--;xg--;ys--;yg--;
vector<vector<ll>> v(h, vector<ll>(w,0) );
vector<vector<ll>> d(h, vector<ll>(w,10000000) );
rep(i,h)rep(j,w){
  char a ;
  cin >> a ;
  if(a=='@')v[i][j]=1;
}
queue<pair<ll,ll>> q;
q.push({xs,ys});
d[xs][ys]=0;
while(!q.empty()){
  auto p=q.front();
  q.pop();
  rep(l,4){
    rep(i,k){
      if(!inarea(p.first+dx[l]*(i+1),p.second+dy[l]*(i+1)))break;
      if(v[p.first+dx[l]*(i+1)][p.second+dy[l]*(i+1)])break;
      if(d[p.first+dx[l]*(i+1)][p.second+dy[l]*(i+1)]<=d[p.first][p.second])break;
      if(d[p.first+dx[l]*(i+1)][p.second+dy[l]*(i+1)]>d[p.first][p.second]+1){
        d[p.first+dx[l]*(i+1)][p.second+dy[l]*(i+1)]=d[p.first][p.second]+1;
        q.push({p.first+dx[l]*(i+1),p.second+dy[l]*(i+1)});
      }
    }
  }
}
cout << (d[xg][yg]==10000000?-1:d[xg][yg]) << endl;
return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

vpll G[100005];
bool ans[100005];

void dfs(ll v, ll p, bool flg){
  if(flg) ans[v]=true;
  for(auto nv:G[v]){
    if(nv.first==p) continue;
    
    dfs(nv.first,v, nv.second%2?(!flg):flg);
  }
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  rep(i,n-1){
    ll u,v,c; cin>>u>>v>>c;
    u--,v--;
    G[u].push_back({v,c});
    G[v].push_back({u,c});
  }
  dfs(0,-1,true);
  rep(i,n){
    cout<<ans[i]<<endl;
  }
}

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

int main(){

    int n;
    cin >> n;

    vector<int> x(n),y(n),h(n);
    int id;
    rep(i,n){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i]>0)id=i;
    }
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            int top=h[id]+abs(x[id]-j)+abs(y[id]-i);            
            for(int k=0;k<n;k++){
                if(h[k]>0){
                    if(top!=h[k]+abs(x[k]-j)+abs(y[k]-i)){
                        break;
                    }
                }else{
                    if(top-abs(x[k]-j)-abs(y[k]-i)>0){
                        break;
                    }
                }
                if(k==n-1){
                    cout << j << " " << i << " " << top << endl;
                    return 0;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MAX = 1e12 + 5;
int main(void) {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n), f(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> f[i];
  sort(a.begin(), a.end());
  sort(f.begin(), f.end(), greater<int>());

  ll xl = -1, xr = MAX;
  while(xl + 1 < xr) {
    ll x = (xl + xr) / 2;
    ll sum = 0;
    rep(i, n) {
      if(x / f[i] < a[i]) {
        sum += a[i] - x / f[i];
      }
    }
    if(sum > k) {
      xl = x;
    } else {
      xr = x;
    }
  }
  cout << xr << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define MAX_N 103
#define MAX_V 10
#define MAX_M 101
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"

signed main(){
	string ab;
	
	cin>>ab;
	
	int a = ab[0]-'0', b = ab[1]-'0', c = ab[2]-'0', d = ab[3]-'0';
	
	for(int i = 0; i <= 1; i++){
		for(int j = 0; j <= 1; j++){
			for(int k = 0; k <= 1; k++){
				int ans = a;
				//cout<<a<<(i?"+":"-")<<b<<(j?"+":"-")<<c<<(k?"+":"-")<<d<<"=7"<<endl;
				if(i) ans =ans+b;
				else ans = ans-b;
				
				if(j) ans+=c;
				else ans-=c;
				
				if(k) ans+=d;
				else ans-=d;
				//cout<<"ans "<<ans<<endl;
				if(ans == 7){
					cout<<a<<(i?"+":"-")<<b<<(j?"+":"-")<<c<<(k?"+":"-")<<d<<"=7"<<endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

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

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

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

    vector<int> c(4, 0);
    rep(i, 6) {
        int ab; cin >> ab;
        c[ab - 1]++;
    }
    cout << (find(c.begin(), c.end(), 3) == c.end() ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
#define DBG(X) cout << #X << " = " << (X) << endl;
#define SAY(X) cout << (X) << endl;
#include <filesystem>
namespace fs = std::filesystem;
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using pii = pair<int, int>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }

int N;
vector<ll> A;
vector<vector<int>> G;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;
    G.resize(N);
    for (int i = 0; i < N; i++)
    {
        ll a; cin >> a;
        A.push_back(a);
    }
    
    for (int i = 0; i < N-1; i++)
    {
        int u,v; cin >> u >> v;
        u--,v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }   
}

// ll dp[220000];
// ll ans[220000];
vector<ll> dp,ans;
int dfs(int u, int p=-1){
    auto tmp = lower_bound(dp.begin(),dp.end(),A[u]);
    ll tmp_v = *tmp;
    *tmp = A[u];
    ans[u] = lower_bound(dp.begin(),dp.end(),INT_INF)-dp.begin();
    for(int v:G[u]){
        if(v==p) continue;
        dfs(v,u);
    }
    *tmp = tmp_v;
    return 0;
}


int solve(){
    // memset(dp,INT_INF,sizeof(dp));
    // memset(ans,0,sizeof(ans));
    dp.assign(N,INT_INF);
    ans.assign(N,INT_INF);
    dfs(0);
    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }
    return 0;
}   

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


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

using namespace std;

using ll = long long;

int flag[100000];

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    flag[u - 1]++;
    flag[v - 1]++;
  }
  for (int i = 0; i < 100000; ++i) {
    if (flag[i] & 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 640
import kotlin.math.pow

fun main() {
    val N = readLine()!!
    val n = N.length
    var cnt = 0

    for (i in 1..n) {
        if (i % 2 == 1) {
            val high = 10.0.pow(i).toInt()
            val low = 10.0.pow(i - 1).toInt()
            cnt += if (i == n) {
                N.toInt() - low + 1
            } else {
                high - 1 - low + 1
            }
        }
    }

    println(cnt)
}

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

int main(){
    int a[3];
    for(int i=0;i<3;i++) scanf("%d",&a[i]);
    sort(a,a+3);
    int ans=abs(a[1]-a[2])+abs(a[0]-a[1]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	string S, T,C;
  	int A, B;

  	cin >> S >> T >> A >> B >> C;

  	if(S==C){
  		cout << A-1 << " " << B <<endl;
  		return 0;
  	}
  	cout << A << " " << B-1 <<endl;
    
  	return 0;
}













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

int main()
{
	int a,b;
	cin>>a>>b;
	if(a==b)cout<<"Draw"<<endl;
	else if(a>b&&b!=1)cout<<"Alice"<<endl;
	else if(a<b&&a!=1)cout<<"Bob"<<endl;
	else if(a==1)cout<<"Alice"<<endl;
	else if(b==1)cout<<"Bob"<<endl;
	return 0;
}

Measured memory_bytes: 256
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

a = list(mi()) + list(mi()) + list(mi())
cnts = [a.count(i) for i in range(1,5)]

if max(cnts) == 3: print('NO')
else: print('YES')



Measured memory_bytes: 38384
S = input()
T = input()
f = "UNRESTORABLE"

# 後ろから見ていって、部分文字列を当てはめる
S_r = S[::-1]
T_r = T[::-1]
for i in range(len(T),len(S)+1):
    S_ = S_r[i-len(T):i]
    flg = True
    for t,s in zip(T_r, S_):
        if s != "?" and s != t:
            flg = False
    if flg:
        ans = S_r[:i-len(T)] + T_r + S_r[i:]
        print(ans[::-1].replace("?","a"))
        exit()
print(f)


Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;
/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
long double PI = acos(-1);
int main(){
  long double A,B,H,M;
  cin >> A >> B >> H >> M;
  long double rad = PI*2*((long double)H / 12.0+((long double)M/60.0) / 12.0 - (long double)M/60.0);
  long double res = abs(A*A+B*B-2.0*A*B*cosl(rad));
  res = sqrtl(res);
  
  printf("%20.20Lf\n",res);
}






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

int main()
{
   int A,B,C,D;
   cin >> A >> B >> C >> D;
   int L = A + B;
   int R = C + D;
   if(L>R) cout << "Left" << endl;
   else if (R>L) cout << "Right" << endl;
   else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
typedef pair<int,int> P;
int main(){
	int x;
	int t;
	cin>>x>>t;
	cout<<max(0,x-t)<<endl;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    
    if(n == m){
        cout << "Yes" << endl;
    }

    if(n != m){
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Ord
import Data.List
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  r <- forM [1..n] $ \i -> do
    [s,ps] <- BS.words <$> BS.getLine
    return (s, Down (read (BS.unpack ps) :: Int), i :: Int)
  let ss = sort r
  forM_ ss $ \(_,_,i) -> print i


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

int main() {
  long long a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  
  if(a<b){
    if(a+v*t>=b+w*t){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
  else if(a>b){
    if(a-v*t<=b-w*t){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  }
  else{
    cout<<"YES"<<endl;
  }
  
  
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

// a(x%b)-(ax%b)

void test_case(){
	ll a ,b , n;
	cin >> a >> b >> n;
	ll x = n;
	if(n >= b-1) x = b-1;
	ll ans = a*x/b - a*(x/b);
	cout<<ans<<"\n";
	}

 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3584
import java.util.*;

public class Main{

public static void main(String[] args) {


    Scanner scan = new Scanner(System.in);
    String[] elem = scan.nextLine().split(" ");

    int a = Integer.parseInt(elem[0]);
    int b = Integer.parseInt(elem[1]);

    if (a + b >= 10){
      System.out.println("error");
    }
    else {
      System.out.println(a+b);
    }

    }
}


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

int main(){
	while(true){
		string s1;
		cin>>s1;
		if(s1=="."){
			break;
		}
		string s2;
		cin>>s2;
		if(s1==s2){
			cout<<"IDENTICAL"<<endl;
			continue;
		}
		string t1=s1;
		string t2=s2;
		while(true){
			size_t d1b=t1.find('\"');
			if(d1b==string::npos){
				break;
			}
			t1.replace(d1b,1,"@");
			size_t d1e=t1.find('\"');
			t1.replace(d1e,1,"@");

			size_t d2b=t2.find('\"');
			if(d2b==string::npos){
				break;
			}
			t2.replace(d2b,1,"@");
			size_t d2e=t2.find('\"');
			t2.replace(d2e,1,"@");

			string u1=s1;
			u1.replace(d1b+1,d1e-d1b-1,"");
			string u2=s2;
			u2.replace(d2b+1,d2e-d2b-1,"");

			if(u1==u2){
				t1=u1;
				t2=u2;
				break;
			}
		}
		if(t1==t2){
			cout<<"CLOSE"<<endl;
		}
		else{
			cout<<"DIFFERENT"<<endl;
		}
	}
	return 0;
}

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

int main(int argc, char const *argv[]) {
  string s, t;
  cin >> s >> t;
  int count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == t[i])
      count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    let stdin = std::io::stdin();
    stdin.lock().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let h = iter.next().unwrap().parse::<usize>().unwrap();
    let a = iter.next().unwrap().parse::<usize>().unwrap();

    let mut ans = h/a;
    if h%a > 0 { ans += 1; }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define REP(i,b,e) for(int i=b;i<e;i++)

int main(){
        int n;
        scanf("%d", &n);
        std::vector<int> a(n);
        REP(i, 0, n) scanf("%d", &a[i]);
        std::vector<int> b(a);
        std::sort(b.begin(), b.end());

        int cnt = 0;
        bool match[n];
        REP(i, 0, n){
                match[i] = (a[i]==b[i]);
                cnt += (a[i]==b[i]);
        }
        if(cnt==n){
                puts("0");
                return 0;
        }

        int q;
        scanf("%d", &q);
        REP(i, 0, q){
                int x, y;
                scanf("%d %d", &x, &y);
                x--, y--;
                cnt -= (a[x]==b[x]) + (a[y]==b[y]);
                cnt += (a[x]==b[y]) + (a[y]==b[x]);
                std::swap(a[x], a[y]);
                if(cnt==n){
                        printf("%d\n", i+1);
                        return 0;
                }
        }

        puts("-1");
        return 0;
}



Measured memory_bytes: 5508
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

    ll a,b;cin>>a>>b;
    ll g = __gcd(a,b);
    ll ans = a*b/g;
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String S = sc.next();

		sc.close();

		char[] c = new char[S.length()];
		S.getChars(0, S.length(), c, 0);

		Arrays.sort(c);

		if (c[0] == c[1] && c[2] == c[3] && c[0] != c[2]) {
			out.println("Yes");
		} else {
			out.println("No");
		}

	}

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


Measured memory_bytes: 21844
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;


int my[] = {0, 0, 1, -1};
int mx[] = {1, -1, 0, 0};
int wt[] = {1, 3, 2, 0};
int wv[] = {3, 1, 0, 2};

bool ok(char a, char b){
  char la = tolower(a), lb = tolower(b);
  if(la != lb) return false;
  if((islower(a) && isupper(b)) || (isupper(a) && islower(b))) return true;
  return false;
}

bool check(int y, int x, int cnt, vector< vector<string> > &v, string &p){
  REP(i, 4){
    int ny = y + my[i], nx = x + mx[i], nc = ny * 3 + nx;
    if(ny < 0 || nx < 0 || ny >= 3 || nx >= 3 || nc < 0 || nc > 8 || nc > cnt) continue;
    if(!ok(p[wt[i]], v[ny][nx][wv[i]])) return false;
  }
  return true;
}

int dfs(vector<string> &ps, vector< vector<string> > &v, int cnt, vector<bool> &used){
  int res = 0;
  if(cnt >= 9){
    //cout <<"-----------" <<endl; REP(i, 3){ REP(j, 3) cout <<v[i][j] <<" "; cout <<endl; }
    return 1;
  }
  int y = cnt / 3, x = cnt % 3;
  REP(i, 9){
    if(used[i]) continue;
    REP(j, 4){
      if(check(y, x, cnt, v, ps[i])){
        used[i] = true; v[y][x] = ps[i];
        res += dfs(ps, v, cnt + 1, used);
        used[i] = false; v[y][x] = ps[i];;
      }
      ps[i] = ps[i].substr(1) + ps[i].substr(0, 1);
    }
  }
  return res;
}

int main() {
  int N; cin >>N;
  REP(n, N){
    vector<string> ps(9); REP(i, 9) cin >>ps[i];
    vector<bool> used(9, false);
    vector< vector<string> > v(3, vector<string>(3, "...."));
    int ans = dfs(ps, v, 0, used);
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int K;
		K = scan.nextInt();

		int oddCount;
		int evenCount;

		if (K % 2 == 0) {
			evenCount = K / 2;

		} else {
			evenCount = (K - 1) / 2;

		}

		oddCount = K - evenCount;

		System.out.println(evenCount * oddCount);

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27060
import math

H, W = map(int, input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
    exit()

min_num = 100000000000
for i in range(1, H):
    a = i*W
    b = W//2 * (H-i)
    c = math.ceil(W/2) * (H-i)
    _max_num = max(a, max(b, c))
    _min_num = min(a, min(b, c))
    n = _max_num - _min_num
    if n < min_num:
        min_num = n

for i in range(1, H):
    a = i*W
    b = (H-i)//2 * W
    c = math.ceil((H-i)/2) * W
    _max_num = max(a, max(b, c))
    _min_num = min(a, min(b, c))
    n = _max_num - _min_num
    if n < min_num:
        min_num = n

for i in range(1, W):
    a = i*H
    b = H//2 * (W-i)
    c = math.ceil(H/2) * (W-i)
    _max_num = max(a, max(b, c))
    _min_num = min(a, min(b, c))
    n = _max_num - _min_num
    if n < min_num:
        min_num = n

for i in range(1, W):
    a = i*H
    b = (W-i)//2 * H
    c = math.ceil((W-i)/2) * H
    _max_num = max(a, max(b, c))
    _min_num = min(a, min(b, c))
    n = _max_num - _min_num
    if n < min_num:
        min_num = n


print(min_num)


Measured memory_bytes: 3188
N, A, B = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
for i in range(1, N):
    if A * (X[i] - X[i-1]) < B:
        ans += A * (X[i] - X[i-1])
    else: ans += B
print(ans)

Measured memory_bytes: 14252
unittest
{
	assert( [ "aabbaa" ].parse.expand.solve == 4 );
	assert( [ "aaaccacabaababc" ].parse.expand.solve == 12 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	s = "  " ~ s ~ " ";
	auto dp = new long[][]( s.length, 2 );
	for( auto i = 1L; i + 2 < dp.length; i++ )
	{
		// 1文字取った後に1文字取る場合
		if( s[ i ] != s[ i + 1 ] )
		{
			dp[ i + 1 ][ 0 ] = max( dp[ i + 1 ][ 0 ], dp[ i ][ 0 ] + 1 );
		}
		
		// 2文字取った後に1文字取る場合
		dp[ i + 1 ][ 0 ] = max( dp[ i + 1 ][ 0 ], dp[ i ][ 1 ] + 1 );
		
		// 1文字取った後に2文字取る場合
		dp[ i + 2 ][ 1 ] = max( dp[ i + 2 ][ 1 ], dp[ i ][ 0 ] + 1 );
		
		// 2文字取った後に2文字取る場合
		if( s[ i - 1 .. i + 1 ] != s[ i + 1 .. i + 3 ] )
		{
			dp[ i + 2 ][ 1 ] = max( dp[ i + 2 ][ 1 ], dp[ i ][ 1 ] + 1 );
		}
	}
	return max( dp[ $ - 2 ][ 0 ], dp[ $ - 2 ][ 1 ] );
}


Measured memory_bytes: 17336
using System;
class Program {
  static void Main(string[] args) {
    string[] val = Console.ReadLine().Split();
    int A = int.Parse(val[0]);
    int B = int.Parse(val[1]);
    int C = int.Parse(val[2]);
    int X = int.Parse(val[3]);
    int Y = int.Parse(val[4]);
    int common = Math.Min(X, Y);
    int single = Math.Abs(X - Y);
    int bigger = X > Y ? A : B;
    int ans = Math.Min((A+B)*common, C*common*2) + Math.Min(bigger*single, C*single*2);
    Console.WriteLine(ans);  
  }
}


Measured memory_bytes: 13268
A=list(input())
B=list(input())
C=list(input())
D={"a":A, "b":B, "c":C}
X=A
while True:
    d=X[0]
    X.pop(0)
    X=D[d] 
    if len(X)==0:
        print(d.upper())   
        break 

Measured memory_bytes: 3060
def solver(x, y):
    ans1 = abs(x) + abs(y)
    ans2 = abs(abs(x) - abs(y))
    res = 0
    if x < y:
        if x * y >= 0:
            res = ans2
        else:
            res = 1 + ans2
    else:
        if 0 < y:
            res = 2 + ans2
        elif x * y <= 0:
            res = 1 + ans2
        else:
            if abs(x) <= abs(y):
                res = 2 + ans2
            else:
                res = 1 + ans1
    return res

x, y = map(int, input().split())
print(solver(x, y))

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-6;
const int MAX=1e5+10;
const ll mod=1e9+7;
int main()
{
	int n,s;
	char a[111];
	while(~scanf("%d",&n))
	{
		sprintf(a,"%d",n);
		s=0;
		for(int i=0;i<strlen(a);i++) s+=a[i]-'0';
		if(n%s==0) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,i;
	cin >> a;
	map<int,int> m;
	for(i=0;i<a;i++)
	{
		cin >> b;
		m.insert(pair<int,int>(b,i+1));
	
	}
		map<int, int>::iterator itr; 
   // cout << "\nThe map gquiz1 is : \n"; 
    //cout << "\tKEY\tELEMENT\n"; 
    for (itr = m.begin(); itr != m.end(); ++itr) { 
        cout << itr->second << " " ; 
}
}

Measured memory_bytes: 5504