akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n;
    cin>>n;
    vector<long long> ans;
    for(int i = 1; i <= sqrt(n); i++){
        if(n%i == 0){
            ans.pb(i);
            ans.pb(n/i);
        }
    }
    long long mi = 1000000000000;
    for(int i = 0; i < ans.size()-1; i+= 2 ){
        if(abs(ans[i]- ans[i+1]) < mi){
            mi = ans[i] + ans[i+1];
        }
    }
/*
    rep(i, ans.size()){
        cout<<ans[i]<<endl;
    }
*/
    cout<<mi-2<<endl;
    return 0;
}

Measured memory_bytes: 384
from itertools import product
n, m = map(int, input().split())
c = list(map(int, input().split()))
dp = [i for i in range(n+1)]
for j, k in product(range(1, m), range(1, n+1)):
    if 0 <= k - c[j]:
        dp[k] = min(dp[k], dp[k-c[j]] + 1)
print(dp[-1])


Measured memory_bytes: 9624
#include <stdio.h>
#include <string.h>

int main(){
  char s[8];
  scanf("%s", s);
  char sunny[6] = "Sunny";
  char cloudy[7] = "Cloudy";
  char rainy[6] = "Rainy";
  if(strcmp(s, sunny) == 0){
    printf("Cloudy\n");
  }else if(strcmp(s, cloudy) == 0){
    printf("Rainy\n");
  }else if(strcmp(s, rainy) == 0){
    printf("Sunny\n");
  }
  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

char *demangle(const char *demangle)
{
    int status;
    return abi::__cxa_demangle(demangle, 0, 0, &status);
}

int main()
{
    int N;
    string S, T;
    cin >> N >> S >> T;

    string ans = "";
    rep(i, N)
    {
        ans += S[i];
        ans += T[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		dfs("", (char) ('a'-1), num);
	}

	private static void dfs(String s, char max, int num) {
		if (s.length()==num) {
			System.out.println(s);
			return;
		}

		for (char i = 'a'; i <= max + 1; i++) {
			String result = s + i;
			char t = max > i ? max : i;
			dfs(result, t, num);
		}
	}

}


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

int main(){
    int x,y;
    cin>>x>>y;
    if(x*2<=y&&x*4>=y&&y%2==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3616
//
//  AOJ 0033 Ball
//
//  Created by TaoSama on 2015-02-19
//  Copyright (c) 2014 TaoSama. All rights reserved.
//
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>
#define CLR(x,y) memset(x, y, sizeof(x))

using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;

int a[15];
bool dfs(int k, int b, int c) {
	if(k == 11) return true;
	if(a[k] > b) if(dfs(k + 1, a[k], c)) return true;
	if(a[k] > c) if(dfs(k + 1, b, a[k])) return true;
	return false;
}

int main() {
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
//	freopen("out.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(0);

	int t; cin >> t;
	while(t--) {
		for(int i = 1; i <= 10; ++i) cin >> a[i];
		if(dfs(1, 0, 0))	cout << "YES" << endl;
		else	cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

S = list(input().strip())
S.append("<")

L = [0] * len(S)
tmp = ">"

for i in range(len(S)):
    if tmp == ">" and S[i] == "<":
        L[i] == 0
    elif tmp == ">" and S[i] == ">":
        pass
    elif tmp == "<" and S[i] == "<":
        L[i] = L[i-1] + 1
    elif tmp == "<" and S[i] == ">":
        L[i] = L[i-1] + 1
    tmp = S[i]

tmp = S[-1]
for i in range(len(S)-2, -1, -1):
    if tmp == ">" and S[i] == "<":
        L[i+1] = max(L[i+1], L[i+2] + 1)
    elif tmp == ">" and S[i] == ">":
        L[i+1] = L[i+2] + 1
    elif tmp == "<" and S[i] == "<":
        pass
    elif tmp == "<" and S[i] == ">":
        pass
    tmp = S[i]

if S[0] == ">" and S[1] == ">":
    L[0] = L[1] + 1
elif S[0] == ">" and S[1] == "<":
    L[0] = max(L[0], L[1] + 1)

print(sum(L))

Measured memory_bytes: 26936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    int n, k;
    cin >> n >> k;
    cout << ceil(((double)n-1)/(k-1)) << endl;
}

Measured memory_bytes: 3776
# include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

double dp[3005][3005]={};

int main()
{
	fast;
int n;
cin>>n;
double arr[n+1];
arr[0]=0;
for(int i=0; i<n; i++){
    cin>>arr[i+1];
}
dp[1][0] = 1- (dp[1][1] = arr[1]);
for(int i=2; i<=n; i++){
    for(int j=0; j<=i; j++){
            if(j==0)dp[i][j] = dp[i-1][j]*(1-arr[i]);
            else if(j==i)dp[i][j] = dp[i-1][j-1]*(arr[i]);
            else dp[i][j] = dp[i-1][j]*(1-arr[i]) + dp[i-1][j-1]*(arr[i]);
    }
}
//for(int i=1; i<=n; i++){
//    for(int j=0; j<=i; j++){
//            cout<<dp[i][j]<<" ";
//    }
//    cout<<endl;
//}
double ans=0;
cout.precision(10);
for(int i=ceil((n+1)/2.0);i<=n;i++)ans+=dp[n][i];
cout<<fixed<<ans;
    return 0;
}



Measured memory_bytes: 69120
n=gets.split;x=n[1].to_i;n=n[0].to_i
m=[]
total=n
n.times do
	m << gets.to_i
end
m.sort!
m.each do |y|
	x -= y
end
while x > 0
	x -= m[0]
	total += 1 if x>=0
end
puts total

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int n; 
    string s; 
    cin >> n >> s;
    n %= 26;
    fo(i, s.size()) {
        s[i] = s[i] + n;
        if (s[i] > 'Z') s[i] -= 26;
    }
    cout << s;
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



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

    if((b-a) % 2 == 0){
        cout << (b-a)/2 << endl;
    }else{
        if(b-1<=n-a){
            cout << (b+a-1) / 2 << endl;
        }else{
            cout << (-a - b + 2 * n + 1) / 2 << endl;
        }
    }
}

Measured memory_bytes: 3544
#include <string>
#include <cstdint>
#include <sstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;


string readln()
{
    string str;
    getline(cin, str);
    return str;
}


template<typename T>
vector<T> splitConvTo(const string& str, const char c = ' ')
{
    vector<T> vec;
    auto bIter = str.begin(),
         eIter = str.end();


    while(bIter != eIter)
    {
        T elem;
        stringstream(string(bIter, find(bIter, eIter, c))) >> elem;
        vec.push_back(move(elem));

        bIter = find(bIter, eIter, ' ');
        if(bIter != eIter)
            ++bIter;
    }

    return vec;
}



uint32_t mcxiToValue(string str)
{
    uint32_t dst = 0;
    int32_t v = -1;

    for(auto c : str){
        if('0' <= c && c <= '9'){
            v = c - '0';
        }else{
            if(v == -1)
                v = 1;

            switch(c){
              case 'm': dst += 1000 * v; break;
              case 'c': dst += 100 * v; break;
              case 'x': dst += 10 * v; break;
              case 'i': dst += v; break;
              // default: assert(0);
            }
            v = -1;
        }
    }

    return dst;
}


string toMCXI(uint32_t value)
{
    stringstream dst;
    for(int32_t i = 3; i >= 0; --i){
        uint32_t m = value / pow(10, i);

        if(m == 0)
            continue;
        if(m != 1)
            dst << m;

        dst << (i == 3 ? 'm' :
                    (i == 2 ? 'c':
                        (i == 1 ? 'x' : 'i')));

        value -= m * pow(10, i);
    }

    string s;
    dst >> s;
    return s;
}


int main(void)
{
    const auto N = splitConvTo<uint32_t>(readln()).at(0);

    for(size_t i = 0; i < N; ++i){
        auto ss = splitConvTo<string>(readln());
        const auto v = mcxiToValue(ss.at(0)),
                   w = mcxiToValue(ss.at(1));

        cout << toMCXI(v + w) << endl;
    }

    return 0;
}

Measured memory_bytes: 1264
// B - Hina Arare
#include <bits/stdc++.h>
using namespace std;

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

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
    	Scanner sc=new Scanner(System.in);
    	int n=sc.nextInt();
    	int[] a=new int[n];
    	for(int i=0;i<n;i++) {
    		a[i]=sc.nextInt();
    	}
    	for(int i=0;i<n-1;i++) {
    		System.out.printf("%d ",a[n-i-1]);
    	}
    	System.out.printf("%d\n",a[0]);
        sc.close();
    }
}


Measured memory_bytes: 26424
from collections import defaultdict
N = int(input())
a = list(map(int,input().split()))
d = defaultdict(int)
for x in a:
    d[min(x//400, 8)] += 1
mi = len(d.keys())
if d[8] > 0 and mi >= 2:
    mi -= 1
mx = d[8]+len([i for i in range(8) if i in d])
print(mi, mx)

Measured memory_bytes: 9400
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

ll rec(ll a,ll b,ll c,ll z){
//	cout<<a<<endl;
	if(z==0){
		return b+rec(a,a-b,b,1);
	}
	else{
		if(b==0) return 0;
		else if(b/c>0){
			return (b/c)*2*c+rec(a-(b/c)*c,b-(b/c)*c,c,1);
		}
		else{
			return c+rec(max(b,c),min(b,c),0,0);
		}
	}
}

ll N,K;
int main()
{
	cin>>N>>K;
	cout<<K+rec(N,K,N-K,1)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;

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

  int sub,sq,count = 0;
  bool flag = true;

  for(int i = 0;i < size;i++){
      cin >> sub;
      flag = true;
      if(sub == 2){
       count++; continue;
     }
     if(sub < 2||sub % 2 == 0) continue;
      sq = (int)sqrt(sub);
      for(int j = 3;j <= sq;j+=2){
        if(sub % j == 0) {
        flag = false; break;
    }
      }if(flag == true) count++;
    }
  cout << count <<endl;
  return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  int L1=min(q*4,h*2);
  L1=min(L1,s);
  int L2=min(q*8,h*4);
  L2=min(L2,s*2);
  L2=min(L2,d);
  int ans=0;
  if(L1*2>L2){
    while(n-2>=0){
      ans+=L2;
      n-=2;
    }
    ans+=L1*n;
  }else{
    ans+=L1*n;
  }
  cout<<ans<<endl;
  
  return 0;
}


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

class DisjointSet {
public:
	vector<int>rank, p;

	DisjointSet() {}
	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		for (int i = 0; i < size; i++) makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}
	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}
	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
};
int main() {
	int n, a, b, q;
	int t;
	cin >> n >> q;
	DisjointSet ds = DisjointSet(n);

	for (int i = 0; i < q; i++) {
		cin >> t >> a >> b;
		if (t == 0) ds.unite(a, b);
		else if (t == 1) {
			if (ds.same(a, b)) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}
}


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

int main(void) {
	
	int S;
	int h, m, s;
	cin >> S;
	h = S / 3600;
	m = (S / 60) % 60;
	s = S % 60;
	
	cout << h << ":" << m << ":" << s << endl;

	return 0;
}


Measured memory_bytes: 3092
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	var t = parseInt(input[2], 10);
  	
  	var sum = 0;
  	for (var i = a; i < t + 0.5; i += a) {
      sum += b;
    }
	//出力
	console.log(sum);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}




    
void test_case() {

   int k;
   cin>>k;

   ll ans  =0;
   
   for(int i=1; i<=k; i++) {
       for(int j=1; j<=k; j++) {
           for(int l=1; l<=k; l++) {
               int val = gcd(i,j);
               val = gcd(val,l);
               ans+= val;
           }
       }
   }

   cout<<ans<<endl;



}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

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

int main() {
    int g[12] = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    cin >> x >> y;
    cout << (g[x-1] == g[y-1] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3592
import std.algorithm;
import std.array;
import std.conv;
import std.range;
import std.stdio;
import std.string;

enum S { E = 0, A = 1, B = 2 };

void main() {
  string s = readln.strip;
  immutable n = s.length;
  auto z = new dchar[n];
  s.copy(z);
  debug stderr.writeln(z);
  long res;
  int i;
  int cnt;

  S t = S.E;
  foreach (c; z) {
    debug stderr.writeln ("state: ", t, ", c = ", c, ", cnt = ", cnt);
    if (t == S.E) {
      if (c == 'A') {
        t = S.A;
        cnt = 1;
      } else if (c == 'B' || c == 'C') {
      }
    } else if (t == S.A) {
      if (c == 'A') {
        ++cnt;
      } else if (c == 'B') {
        t = S.B;
      } else if (c == 'C') {
        t = S.E;
      }
    } else if (t == S.B) {
      if (c == 'A') {
        t = S.A;
        cnt = 1;
      } else if (c == 'B') {
        t = S.E;
        cnt = 0;
      } else if (c == 'C') {
        res += cnt;
        t = S.A;
      }
    }
  }
  writeln (res);
}



Measured memory_bytes: 3256
#include <stdio.h>
//221 
int main(void){
  long long int n,m;
  long long int ans;
  long long int max = 0;
  long long int y = 0;
  int a[100000];
  int diff[100000];
  int i;
  scanf("%d %d",&m,&n);
  for (i=0; i<n; i++){
    scanf("%d", &a[i]);
  }
  int tmp;
  int j, increment, temp;
  increment = 4;
  int array_size = n;
  while (increment > 0){
    for (i=0; i < array_size; i++){
      j = i;
      temp = a[i];
      while ((j >= increment) && (a[j-increment] > temp)){
        a[j] = a[j - increment];
        j = j - increment;
      }
      a[j] = temp;
    }
    if (increment/2 != 0)
      increment = increment/2;
    else if (increment == 1)
      increment = 0;
    else
      increment = 1;
  }

  
  for(i=1;i<n;i++){
    diff[i-1] = a[i]-a[i-1];
  }
  increment = 4;
  while (increment > 0){
    for (i=1; i < array_size; i++){
      j = i;
      temp = diff[i];
      while ((j >= increment) && (diff[j-increment] > temp)){
        diff[j] = diff[j - increment];
        j = j - increment;
      }
      diff[j] = temp;
    }
    if (increment/2 != 0)
      increment = increment/2;
    else if (increment == 1)
      increment = 0;
    else
      increment = 1;
  }
  for(i=0;i<n;i++){
    ans = ans + diff[i];
  }
  for(i=0;i<m;i++){
    max = max + diff[n-i];
  }
  
  printf("%d",ans-max);
  
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<string>
#define rip(i,n,s) for(int i=(s);i<(int)(n);i++)
using namespace std;
int g[3],ans[100000];
string d[100001];
void j(int i,int x,int y){ans[i]=x;g[x]++;g[y]--;}
int main(){
    int n;cin>>n>>g[0]>>g[1]>>g[2];
    rip(i,n,0)cin>>d[i];
    d[n]="AB";
    rip(i,n,0){
        int x=d[i][0]-'A';
        int y=d[i][1]-'A';
        if(g[x]==g[y]){
            if(d[i+1][0]==d[i][0]||d[i+1][1]==d[i][0])j(i,x,y);
            else j(i,y,x);
            if(g[x]<0||g[y]<0){printf("No\n");return 0;}
        }
        else if(g[x]>g[y])j(i,y,x);
        else j(i,x,y);
    }
    printf("Yes\n");
    rip(i,n,0) printf("%c\n",ans[i]+'A');
}

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

int main(){

    int N;
    std::vector<int> nums;

    std::cin >> N;

    for(int i = 0; i < N; ++i){
        int input;
        std::cin >> input;
        nums.push_back(input);
    }

    std::sort(nums.begin(), nums.end());

    int sum = 0, prev = -1;
    for(auto &x : nums){
        if(prev == x){
            --sum;
            prev = -1;
        }
        else{
            ++sum;
            prev = x;
        }
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 892
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
using namespace std;

const int maxn=2010;

vector<int> s[maxn];
int n,m;
int sum;
int vis[maxn];

void dfs(int cnt,int num)
{
    if(num==n)
    {
        sum++;
        return;
    } 
    for(int i=0;i<s[cnt].size();i++)
    {
        if(vis[s[cnt][i]]==0)
        {
            vis[s[cnt][i]]=1;
            dfs(s[cnt][i],num+1);
            vis[s[cnt][i]]=0;
        }
    }
}
int main()
{
	int a,b;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for(int i=0;i<m;i++)
        {
            cin >> a >> b;
            s[a].push_back(b);
            s[b].push_back(a);
        }
        sum=0;
        vis[1]=1;
        dfs(1,1);
        cout << sum << endl;
    }
    return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    int n,q;
    while(cin>>n>>q){
        if(n==0 && q==0)break;
        int date[200];
        rep(i,200)date[i]=0;
        
        rep(i,n){
            int m;
            cin>>m;
            rep(j,m){
                int a;
                cin>>a;
                date[a]++;
            }
        }
        int maxi=-1;
        int day=-1;
        for(int i=1;i<100;i++){
            if(maxi<date[i]){
                day=i;
                maxi=date[i];
            }
        }
        if(maxi>=q)cout<<day<<endl;
        else cout<<"0"<<endl;
    }

    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int D, T, S; cin >> D >> T >> S;
    if ((D + S - 1) / S <= T) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
mod = 10**9+7
class RMQ:
    def __init__(self, N):
        self.N0 = 2**(N-1).bit_length()
        self.INF = float('inf')
        self.data = [self.INF]*(2*self.N0)
    def update(self, k, x):
        k+=self.N0-1
        self.data[k] = x
        while k>=0:
            k = (k-1)//2
            self.data[k] = min(self.data[2*k+1], self.data[2*k+2])
    def query(self, l, r):
        L = l+self.N0; R = r+self.N0
        s = self.INF
        while L<R:
            if R&1:
                R-=1
                s = min(s, self.data[R-1])
            if L&1:
                s = min(s, self.data[L-1])
                L+=1

            L >>= 1; R>>=1
        return s
N = int(input())
h = list(map(int, input().split()))
a = list(map(int, input().split()))
R = RMQ(N+1)
dp = [0]*N
dp[0] = a[0]
R.update(h[0], -dp[0])
for i in range(1, N):
    m = -R.query(0, h[i])
    if m == -float('inf'):
        m = 0
    dp[i] = m+a[i]
    R.update(h[i], -dp[i])
print(max(dp))




    








Measured memory_bytes: 123600
using System;

class B{
  static void Main(){
    int N = int.Parse(Console.ReadLine()), ans = 0;
    int[] Ar = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
    Array.Sort(Ar);
    if (N < 3) 
    { 
      Console.WriteLine(ans);
      return;
    }
    for (int i = 0; i < N; i++){
      for (int j = 1; j < N; j++){
        for (int k = 2; k < N; k++){
          if (Ar[i] != Ar[j] && Ar[j] != Ar[k] && Ar[i] != Ar[k]){
            if (Ar[i] <= Ar[j] && Ar[j] <= Ar[k])
            if (Ar[i] + Ar[j] > Ar[k]){
              ans++;
            }
          }
        }
      }
    }
    Console.WriteLine(ans);
  }
}

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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;



template <typename T>
struct SegmentTree{
    using F = function<T(T,T)>;
    int n;
    F f;
    T ti;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(F f,T ti):f(f),ti(ti){}
    void init(int n_){
        n=1;
        while(n<n_) n<<=1;
        dat.assign(n<<1,ti);
    }
    void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0;i<n_;i++) dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }
    void set_val(int k,T x){
        dat[k+=n]=x;
        while(k>>=1)
            dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
    }
    //[a,b)
    T query(int a,int b){
        T vl=ti,vr=ti;
        for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
            if(l&1) vl=f(vl,dat[l++]);
            if(r&1) vr=f(dat[--r],vr);
        }
        return f(vl,vr);
    }
};

ll dp[200010];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  vll h(N);
  for(ll i=0;i<N;i++){
    cin>>h[i];h[i]--;
  }
  vll A(N);
  for(ll i=0;i<N;i++)cin>>A[i];
  SegmentTree<ll> seg([](ll a,ll b){return max(a,b);},0ll);
  seg.init(N);
  for(ll i=0;i<N;i++){
    dp[i] = seg.query(0,h[i]+1)+A[i];
    seg.set_val(h[i],dp[i]);
  }
  cout<<seg.query(0,N)<<endl;
  return 0;
}


Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int X = cin.nextint;
        int Y = cin.nextint;
        int Z = cin.nextint;
        int ans = 0;
        X -= 2 * Z;
        while (X - Y >= 0)
        {
            ans++;
            X -= Y + Z;
        }
        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11092
func readTwoInts(separator: String.Element = " ") -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

/// 値が-なのがルート
struct UnionFind {

    // rootなら要素数*-1
    // それ以外はrootのindex
    var points: [Int]

    init(size: Int) {
        points = .init(repeating: -1, count: size)
    }

    /// a.k.a find
    /// rootのindex検索する
    /// find時にrootを繋ぎ直すことで構造を最適化
    mutating func getRoot(index: Int) -> Int {
        if points[index] < 0 { return index }

        // rootを繋ぎ直す
        let rootIndex = getRoot(index: points[index])
        points[index] = rootIndex
        return rootIndex
    }

    /// xとyのrootをつなぐ
    mutating func union(_ x: Int, and y: Int) {
        let xRoot = getRoot(index: x)
        let yRoot = getRoot(index: y)

        // すでに繋がれていたら何もしない
        if xRoot == yRoot { return }

        // 超点数が多い方につなぐ
        if points[xRoot] > points[yRoot] {
            points[yRoot] += points[xRoot]
            points[xRoot] = yRoot
        } else {
            points[xRoot] += points[yRoot]
            points[yRoot] = xRoot
        }
    }

    mutating func getSize(index: Int) -> Int {
        return -points[getRoot(index: index)]
    }

    mutating func isSameTree(_ x: Int, and y: Int) -> Bool {
        return getRoot(index: x) == getRoot(index: y)
    }
}

func mainD2() {
    let (N, M) = readTwoInts()
    let pairs = (0..<M).map { _ in readTwoInts() }

    var unionFind = UnionFind(size: N)
    for pair in pairs {
        unionFind.union(pair.a - 1, and: pair.b - 1)
    }

    print(-unionFind.points.min()!)
}
mainD2()

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

using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	vector<char> sta;
	for(int i = 0; i < 26; i++)
		sta.push_back('a'+i);
	for(int i = 0; i < 26; i++)
		sta.push_back('A'+i);

	while(1) {
		int n;
		cin >> n;
		if( n == 0 ) break;

		vector<int> key;
		for(int i = 0; i < n; i++) {
			int tmp;
			cin >> tmp;
			
			key.push_back( tmp );
		}

		string s;
		cin >> s;
		vector<int> v;
		for(int i = 0; i < s.length(); i++) {
			for(int j = 0; j < sta.size(); j++) {
				if( s.at(i) == sta.at(j) ) {
					v.push_back(j);
					break;
				}
			}
		}

		vector<int> ans;
		int indx = 0;
		for(int i = 0; i < v.size(); i++) {
			int tmp = v.at(i) - key.at(indx);
			indx = ( indx + 1 ) % key.size();
			if( tmp < 0 ) tmp += sta.size();
			ans.push_back( tmp );
		}

		for(int i = 0; i < ans.size(); i++) 
			cout << sta.at( ans.at(i) );
		cout << endl;
	}

	//while(1){}

	return 0;
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	ll D, T, S;
	cin >> D >> T >> S;

	ll dist = T * S;

	string ans = dist < D ? "No" : "Yes";
	cout << ans << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S = in.next();
		long K = in.nextLong();
		int ans = 1;
		for (int i = 0; i < Math.min(S.length(), K); i++) {
			if (S.charAt(i) >= '2') {
				ans = S.charAt(i) - '0';
				break;
			}
		}
		System.out.println(ans);
		in.close();
	}
}

Measured memory_bytes: 25172
#include "bits/stdc++.h"
using namespace std;

//27
typedef long long ll;

ll power(ll a , ll b) {
    ll ans = 1;
	while (b) {
		if (b & 1) {
			ans = ans  * a;
		}
		a = a * a;
		b  /= 2;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	int cnt = 0;
	while (1) {
		bool d = 1;
		int index = 0;
		for (int i = 0; i < n; ++i) {
			if (v[i]) {
				d = 0;
				index = i;
				break;
			}
		}
		if (d) {
			break;
		}
		for (int i = index; i < n; ++i) {
			if (v[i] == 0) {
				break;
			}
			v[i]--;
		}
		cnt++;
	}
	cout << cnt;     
} 	



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

using namespace std;
#define int long long
int mod = 1000000007;
int pw(int a, int b){
    if (b==0) return 1;
    if (b==1) return a%mod;
    if (b%2==1) return (a*pw(a,b-1))%mod;
    int r = pw(a,b/2);
    return (r*r)%mod;
}
vector<int> fact;
vector<int> obr;
int rev(int a){
    return pw(a, mod-2);
}
int C(int n, int k){
    if (k > n) return 0;
    int A = fact[n], B = (obr[k]*obr[n-k])%mod;
    return (A*B)%mod;
}
main(){
    fact.push_back(1);
    for (int i=1;i<250000;i++){
        fact.push_back((i*fact.back())%mod);
    }
    for (int i=0;i<250000;i++) obr.push_back(rev(fact[i]));
    int b, w;
    cin >> b >> w;
    int s = b+w;
    vector<int> prob(s);
    prob[0] = 0;
    int kek = 0;
    int pw = 1;
    for (int i=1; i < s; i++){
        kek = (kek*rev(2))%mod;
        pw = (2*pw)%mod;
        int P = (C(i, b) * rev(pw))%mod;
        P -= kek;
        if (P < 0) P += mod;
        prob[i] = (P+prob[i-1])%mod;
        kek = (kek+P)%mod;
    }
    vector<int> prob2(s);
    prob2[0] = 0;
    kek = 0;
    pw = 1;
    for (int i=1; i < s; i++){
        kek = (kek*rev(2))%mod;
        pw = (2*pw)%mod;
        int P = (C(i, w) * rev(pw))%mod;
        P -= kek;
        if (P < 0) P += mod;
        prob2[i] = (P+prob2[i-1])%mod;
        kek = (kek+P)%mod;
    }
    for (int i=0; i < s; i++){
       // cout << prob[i] << " " << prob2[i]<<endl;
        int ver = prob2[i] + ((1-prob[i]-prob2[i]) * rev(2)%mod);
        ver %= mod;
        if (ver<0) ver+=mod;
        cout << ver%mod << endl;
    }
}


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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

/*[DSU TEMPLATE] int dsu[501], ranks[501];

void resetDSU(){
    for(int i = 0; i < 501; ++i){
        dsu[i] = i; ranks[i] = 0;
    }
}
int find(int node){
    if(dsu[node] == node) return node;
    return dsu[node] = find(dsu[node]);
}
void combine(int a, int b){
    a = find(a); b = find(b);
    if(ranks[a] < ranks[b]){ dsu[a] = b; }
    else if(ranks[a] > ranks[b]){ dsu[b] = a; }
    else { dsu[a] = b; ranks[b]++; }
}*/

vector<int> arr;

int main(){

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    for(int i = 0; i < n; ++i){
        int j;
        cin >> j;
        arr.push_back(j - i - 1);
    }

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

    double median = arr[n / 2];

    long long tot = 0;
    for(int i : arr)
        tot += abs(median - i);

    cout << tot;

    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 50;
char a[maxn];
int f[maxn], sum[1 << 26];
int main(){
	scanf("%s", a + 1); int n = strlen(a + 1);
	memset(sum, 0x3f, sizeof(sum));
	int g = 0;
	f[0] = 0; sum[0] = 0;
	for (int i = 1; i <= n; ++i){
		int x = 1 << (a[i] - 'a');
		g ^= x;
		f[i] = sum[g];
		for (int j = 0; j < 26; ++j) f[i] = min(sum[g ^ (1 << j)], f[i]);
		++ f[i];
		sum[g] = min(sum[g], f[i]);
	}
	cout << f[n] << endl;
	return 0;
}

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

int main() {
	string s,t;
	cin >> s >> t;
	int mn = 500, mx = 0;
	int cnta = 1, cntb = 1;
	for(int i = 0 ; i < s.length(); ++i)
	{	mn = min(mn, (int)s[i]);
		if(s[i] != s[0])
			cnta++;
	}
	for(int i = 0 ;i < t.length(); ++i)
	{
		mx = max(mx, (int)t[i]);
		if(t[i] != t[0])
			cntb++;
	}
	if(mn < mx || (mn == mx && cnta == 1&& cntb==1&& s.length() < t.length()))
	cout << "Yes\n";
	else
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int GCD(int x, int y, int z)
{
    int min,gcd;
    if(x<y && x<z)
        min = x;
    else if(y<x && y<z)
        min = y;
    else
        min = z;
    for(int k=min;k>=1;--k)
    {
        if((x%k==0) && (y%k==0) && (z%k==0))
            {
                gcd = k;
                break;
            }
    }
    return gcd;
}
int main()
{
    int n,i,j,l,s=0;
    cin>>n;
    for(i=1;i<=n;++i)
    {
        for(j=1;j<=n;++j)
        {
            for(l=1;l<=n;++l)
                s = s + GCD(i,j,l);
        }
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 3624
n, m = map(int, input().split())
ans = 0
for i in range(1, int(m ** 0.5) + 1):
    if  m % i == 0 and i <= m / n:
        if m // i <= m / n:
            ans = m // i
            break
        else:
            ans = i

print(ans)


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

#define REP(A, H) for(int A = 0; A < H; A++)
#define RREP(A, B, H, W) for(int A = 0; A < H; A++) for (int B = 0; B < W; B++)
#define MAX(A, B) (A = std::max(A, B))
#define MIN(A, B) (A = std::min(A, B))

typedef long long ll;

struct POINT {
  int x; int y;
  POINT(int x, int y) : x(x), y(y) {}
};

POINT operator +(const POINT& a, const POINT& b) {
  return POINT(a.x + b.x, a.y + b.y);
}

POINT operator -(const POINT& a, const POINT& b) {
  return POINT(a.x - b.x, a.y - b.y);
}

/* std::cout << ;*/
/* std::cout << << std::endl; */

int main(void) {
  std::vector<int> aps;
  int N, L; std::cin >> N >> L;
  int original = 0;
  REP(i, N) original += L + i;
  
  int nearest = 0;
  REP(i, N) {
    int t = 0;
    REP(j, N) 
    {
      if (i != j) {
        t += L + j;
      }
    }
    if (abs(original - nearest) > abs(original - t)) {
      nearest = t;
    }
  } 

  std::cout << nearest << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

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


int main() {
	

	long long  A[3][3];
	cin >> A[0][0] >> A[0][1] >> A[0][2];
	cin >> A[1][0] >> A[1][1] >> A[1][2];
	cin >> A[2][0] >> A[2][1] >> A[2][2];

	long long N;
	cin >> N;

	vector<long long> v_b(N);
	rep(i, N) cin >> v_b[i];

	long long temp[3][3];

	for (long long i = 0; i < 3; i++)
	{
		for (long long j = 0; j < 3; j++)
		{
			temp[i][j] = 0;
		}
	}

	for (long long i = 0; i < 3; i++)
	{
		for (long long j = 0; j < 3; j++)
		{
			rep(k, N)
			{
				if (v_b[k] == A[i][j])
				{
					temp[i][j] += 1;
				}
			}
		}
	}

	long long f = 0;
	bool ans = false;

	for (long long j = 0; j < 3; j++)
	{
		if (temp[j][0] != 0 && temp[j][1] != 0 && temp[j][2] != 0)
		{
			ans = true;
		}
	}

	for (long long i = 0; i < 3;i++)
	{
		if (temp[0][i] != 0 && temp[1][i] != 0 && temp[2][i] != 0)
		{
			ans = true;
		}
	}

	if (temp[1][1] != 0 && temp[2][2] != 0 && temp[0][0] != 0)
	{
		ans = true;
	}

	if (temp[0][2] != 0 && temp[1][1] != 0 && temp[2][0] != 0)
	{
		ans = true;
	}
	
	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.summer_of_kmc", "r", stdin );
	int a, b;

	while (cin >> a >> b && a && b ){
		vector<int> bill (3, 0 );	// 100, 500, 1000 order

		bill[2] = (b-a)/1000;			
		b -= bill[2]*1000;
		int f = (b-a)/500;
		if (f >= 0 ){
			bill[1] = f;
			b -= f*500;
		} // end if
		int h = (b-a)/100;
		if (h >= 0 ){
			bill[0] = h;
		} // end if
		rep (i, 3 ){
			cout << bill[i] << (i != 2 ? ' ' : '\n' );
		} // end rep
	} // end while
		
	return 0;
}

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

int dp[1000001];

int main() {
    for (int i = 1; i < 1000001; i++) {
        int num = i;
        while (num % 2 == 0) num /= 2;
        while (num % 3 == 0) num /= 3;
        while (num % 5 == 0) num /= 5;
        if (num == 1) dp[i] = 1;
        dp[i] += dp[i-1];
    }

    int M, N;
    while (cin >> M, M) {
        cin >> N;
        cout << dp[N] - dp[M-1] << endl;
    }


    return 0;
}

Measured memory_bytes: 6896
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i=0; i<n; i++)cin >> a[i];
    string ans="Yes";
    a[0]--;
    for(int i=1; i<n; i++){
        if(a[i-1]<a[i])a[i]--;
        if(a[i-1]>a[i])ans="No";
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	 ll N;	cin>>N;
	 ll R_count=0;
	 vector<char> data(N);
	 char A;
	 FOR(i,0,N){
		 cin>>A;
		 data.at(i)=A;
		 if(A=='R')	R_count++;
	 }
	ll lR=0, rR=R_count, lW=0, rW=N-rR, M=INF; 
	if(rR==0){
		cout<<"0"<<endl;
		return 0;
	}
	FOR(i,0,R_count){
		if(data.at(i)=='R'){
			lR++;	rR--;
		}else{
			lW++;	rW--;
		}
		ll S=max(lW,rR);
		if(S<=M)	M=S;
	}

	cout<<M<<endl;

    return 0;
}



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

using namespace std;

typedef long long ll;



ifstream fin ("calafat.in");
ofstream fout ("calafat.out");


ll v[5002], f[5002];
ll n, x, m, ans, k, q;

int main()
{
  cin >> k >> q;
  for (ll i = 0; i < k; i++)
    cin >> v[i];
  while (q--) {
    cin >> n >> x >> m;
    n--;
    x %= m;
    ans = n;
    for (ll j = 0; j < k; j++) {
      f[j + 1] = f[j] + v[j]% m;
      if (!(v[j] %m))
        ans -= (n / k + (j < n % k));
    }
    ans -= (x + f[k] * (n / k) + f[n % k]) / m;
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 384
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
inner_cnt = 0
outer_cnt = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            outer_cnt += 1
            if j > i:
                inner_cnt += 1
ans = inner_cnt * K
ans %= MOD
ans += outer_cnt * K * (K - 1) // 2
ans %= MOD
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
int n,o=1,hd[N],A,B,dis[N];
struct Edge{int v,nt;}E[N<<1];
void adde(int u,int v){
	E[o]=(Edge){v,hd[u]};hd[u]=o++;
	E[o]=(Edge){u,hd[v]};hd[v]=o++;
}
void dfs(int u,int fa){
	dis[u]=dis[fa]+1;
	for(int i=hd[u];i;i=E[i].nt){
		int v=E[i].v;
		if(v==fa)continue;
		dfs(v,u);
	}
}
int main(){
	//freopen("C.in","r",stdin);
	//freopen("C.out","w",stdout);
	scanf("%d",&n);
	for(int i=1,u,v;i<n;++i)scanf("%d%d",&u,&v),adde(u,v);
	dfs(1,0);
	A=1;for(int i=1;i<=n;++i)if(dis[A]<dis[i])A=i;
	dfs(A,0);
	B=1;for(int i=1;i<=n;++i)if(dis[B]<dis[i])B=i;
	puts(dis[B]%3==2?"Second":"First");
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;
 
#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)
 
template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }
 
 
///////////////
 
#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])
 
template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;
 
int sgn(ld a, ld b = 0) {
    if (a > b + EPS) return 1;
    if (a < b - EPS) return -1;
    return 0;
}
 
ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }
 
int ccw(P a, P b, P c) {
    b -= a;
    c -= a;
    if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise or counter clockwise
    if (sgn(dot(b, c)) == -1) return 2;            // c--a--b
    if (sgn(norm(b), norm(c)) == -1) return -2;    // a--b--c
    return 0;                                      // a--c--b
}
 
struct L : public vector<P> {
    L(P a, P b) { push_back(a); push_back(b); }
};

P pLL(CR<L> l, CR<L> m) {
	ld a = cross(l[1] - l[0], m[1] - m[0]);
	ld b = cross(l[1] - l[0], l[1] - m[0]);
	assert(sgn(a)); // parallel or same line
	return m[0] + b / a * (m[1] - m[0]);
}
bool iLS(CR<L> l, CR<L> s, bool strict = false) {
	int c = sgn(cross(l[1] - l[0], s[0] - l[0])) * sgn(cross(l[1] - l[0], s[1] - l[0]));
	return c <= 0 && (!strict || c == -1);
}
G convex_cut(CR<G> g, CR<L> l) {
	G q;
	REP(i, g.size()) {
		if (ccw(l[0], l[1], g[i]) != -1) q.push_back(g[i]);
		L s = { g[i], g[(i + 1) % g.size()] };
		if (iLS(l, s, true)) q.push_back(pLL(l, s));
	}
	return q;
}
ld area2(CR<G> g) {
	ld s = 0;
	REP(i, g.size()) s += cross(g[i], NEXT(g, i));
	return s;
}

//////////////
 
int main() {
#ifdef INPUT_FROM_FILE
    ifstream cin("sample.in");
    ofstream cout("sample.out");
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
	ll n; cin >> n;
	G g(n);
	REP(i, n) {
		ld x, y;
		cin >> x >> y;
		g[i] = { x, y };
	}
	ll q; cin >> q;
	REP(i, q) {
		ld x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		cout << area2(convex_cut(g, { { x1, y1 }, { x2, y2 } })) / 2 << endl;
	}

    return 0;
}

Measured memory_bytes: 3336
#include<stdio.h>
int main(){float x,y,u,v,p,q;while(scanf("%f,%f,%f,%f,%f,%f",&x,&y,&u,&v,&p,&q)+1){float a=u-x,b=v-y,c=x*v-u*y,d=a*a,e=b*b,f=a*b,g=2/(d+e),h=d-e;printf("%.9f %.9f\n",g*(p/2*h+q*f+b*c),g*(-q/2*h+p*f-a*c));}}


Measured memory_bytes: 2740