akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define NIL -2
#define INF 1000000001
#define EPS 1e-10
#define equals(a,b) (fabs((a) - (b)) < EPS)

using namespace std;
class Point{
    public:
    double x,y;

    Point(double x = 0,double y = 0): x(x), y(y) {}

    Point operator + (Point p){ return Point(x+p.x, y+p.y); }
    Point operator - (Point p){ return Point(x-p.x, y-p.y); }
    Point operator * (double k){ return Point(x*k,y*k);     }
    Point operator / (double k){ return Point(x/k,y/k);     }

    double norm(){ return x*x + y*y;}
    double abs(){ return sqrt(norm());}
    double dot(Point p){
        return x*p.x + y*p.y;
    }
    double prod(Point p){
        return x*p.y - y*p.x;
    }

    bool operator < (Point &p){
        return x != p.x ? x < p.x : y < p.y;
    }
    bool operator == (Point &p){
        return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
    }
  
};
typedef Point Vector;

int main(){
    double p0x,p0y,p1x,p1y;
    double p2x,p2y;
    int q;
    scanf("%lf %lf %lf %lf",&p0x,&p0y,&p1x,&p1y);
    Vector p10(p1x-p0x,p1y-p0y);
    
    scanf("%d",&q);
    for(int i = 0;i < q;i++){
        scanf("%lf %lf",&p2x,&p2y);
        Vector p20(p2x-p0x,p2y-p0y);
        double prod = p10.prod(p20);
        if( prod > 0) printf("COUNTER_CLOCKWISE\n");
        else if(prod < 0) printf("CLOCKWISE\n");
        else {
            if(p10.dot(p20) < 0) printf("ONLINE_BACK\n");
            else{
                if(p10.abs() < p20.abs()) printf("ONLINE_FRONT\n");
                else printf("ON_SEGMENT\n"); 
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3248
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[allow(dead_code)]
const MOD: u64 = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}

fn main() {
    input!{
        sx: isize, sy: isize, tx: isize, ty: isize,
    }
    print!("{}", 'L');
    for _ in 0..(ty-sy+1) {
        print!("{}", 'U');
    }
    for _ in 0..(tx-sx+1) {
        print!("{}", 'R');
    }
    print!("{}", 'D');
    for _ in 0..(tx-sx) {
        print!("{}", 'L');
    }
    for _ in 0..(ty-sy) {
        print!("{}", 'D');
    }
    print!("{}", 'D');
    for _ in 0..(tx-sx+1) {
        print!("{}", 'R');
    }
    for _ in 0..(ty-sy+1) {
        print!("{}", 'U');
    }
    print!("{}", 'L');
    for _ in 0..(ty-sy) {
        print!("{}", 'D');
    }
    for _ in 0..(tx-sx) {
        print!("{}", 'L');
    }
    println!("");
}


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

int main(){

    int K,A,B,x;
    cin>>K;
    cin>>A>>B;
    x=1;
    while(K*x<=1000){
        if(A<=K*x && K*x <=B){
            cout<<"OK"<<endl;
            return 0;
        }else{
            x++;
        }
    }
    
    cout<<"NG"<<endl;


    return 0;
}

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

int main() {
  string str, ans;
  cin >> str;
  if (str.at(1) == str.at(2)) {
    if(str.at(0) == str.at(1)) {
      ans = "Yes";
    } else if (str.at(2) == str.at(3)) {
      ans = "Yes";
    } else {
      ans = "No";
    }
  } else {
    ans = "No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    bool check[10005];
    rep(i,10001){
        check[i] = true;
    }
    check[0] = check[1] = false;
    rep(i,105){
        if(check[i]){
            for(int j = i * i; j < 10001; j += i){
                check[j] = false;
            }
        }
    }

    int n;
    while(cin >> n){
        for(int i = n; i >= 2; i--){
            if(check[i] && check[i - 2]){
                cout << i- 2 << ' ' << i << endl;
                break;
            }
        }
    }
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int N;
	cin >> N;
	map<int, int> cnt;
	while (N--) {
		int a;
		cin >> a;
		++cnt[a];
	}
	vector<int> key, val;
	for (const auto& p : cnt) { key.emplace_back(p.first); val.emplace_back(p.second); }
	int res = 0, size = cnt.size();
	switch (size) {
	case 1 :
		res |= key.front() == 0;
		break;
	case 2 :
		res |= key.front() == 0 && abs((val.front() << 1) - val.back()) <= 2;
		break;
	case 3 :
		res |= !(key[0] ^ key[1] ^ key[2]) && *min_element(val.begin(), val.end()) + 1 >= *max_element(val.begin(), val.end());
		break;
	}
	cout << (res ? "Yes" : "No") << endl;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> dist(n+1);
    ll sumdist =0;
    a[0]=0;
    //dist
    rep(i,1,n+1){
        cin >> a[i];
        dist[i-1] = abs(a[i]-a[i-1]);
        sumdist += dist[i-1];
    }
    dist[n] = abs(a[n]-a[0]);
    sumdist += dist[n];
    rep(i,1,n){
        cout << sumdist - dist[i-1] - dist[i] + abs(a[i-1]-a[i+1]) << endl;
    }
        cout << sumdist - dist[n-1] - dist[n] + abs(a[n-1]-a[0]) << endl;
}

Measured memory_bytes: 2816
f=lambda:map(int,input().split())
N,Q=f()
a,b=N,N
black=(N-2)*(N-2)
B=[-1]*(N+1)
W=[-1]*(N+1)
for _ in range(Q):
    q,x=f()
    if q==1:
        if B[x]>0:
            black-=B[x]
            B[x]=0
        else:
            black-=b-2
            a=x
            for j in range(a+1,N+1):
                if B[j]==-1:
                    B[j]=b-2
                else:
                    break
                if j==N-1:
                    break
    else:
        if W[x]>0:
            black-=W[x]
            W[x]=0
        else:
            black-=a-2
            b=x
            for j in range(b+1,N+1):
                if W[j]==-1:
                    W[j]=a-2
                else:
                    break
                if j==N-1:
                    break
print(black)

Measured memory_bytes: 74780
#include<iostream>

using namespace std;

//入力文字列
char str_input[8][9];
int h_do[3] = {90 , 180 , 270};

//横向きに
void f_yoko();

int main(void)
{
	for (int i = 0; i < 8; i++)
	{
		cin >> str_input[i];
	}

	for (int i = 0; i < 3; i++)
	{
		f_yoko();

		cout << h_do[i] << endl;
		for (int i = 0; i < 8; i++)
		{
			cout << str_input[i] << endl;
		}
	}

	return 0;
}






//横向きに
void f_yoko()
{
	//交換文字列
	char str_change[8][9] = {NULL};

	for (int i = 0; i < 8; i++)
	{
		for (int j = 0; j < 8; j++)
		{
			str_change[j][7 - i] = str_input[i][j];
		}
	}

	for (int i = 0; i < 8; i++)
	{
		for (int j = 0; j < 8; j++)
		{
			str_input[i][j] = str_change[i][j];
		}
	}
}

Measured memory_bytes: 1144
n = int(input())
s = input()
ans = 0
for i in range(1,n-1):
    count = 0
    a = list(set(s[:i]))
    b = list(set(s[i:]))
    for j in range(len(a)):
        if a[j] in b:
            count += 1
    if ans < count :
        ans = count

print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys


def solve(N: int, d: "List[int]"):
    s=0
    for i in range(N):
        s=s+d[i]*(sum(d)-d[i])
    print(int(s/2))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[105]={0};
  cin>>n;
  double sum=0;
  for(int i=0;i<n;i++){
  	cin>>a[i];
  	sum+=1.0/a[i];
  }
  cout<<1.0/sum;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
using namespace std;
 
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d)cout<<"Yes"<<endl;
    else if(abs(a-b)<=d && abs(b-c)<=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int A[SIZE],dp[SIZE];
VI e[SIZE];
bool dfs(int x){
    if(dp[x])return dp[x]==1?1:0;
    dp[x]=-1;
    REP(i,SZ(e[x])){
        int y=e[x][i];
        if(A[y]<A[x]){
            if(!dfs(y))dp[x]=1;
        }
    }
    return dp[x]==1?1:0;
}
int main(){
    DRI(n);
    REPP(i,1,n+1)RI(A[i]);
    REPP(i,1,n){
        DRII(x,y);
        e[x].PB(y);
        e[y].PB(x);
    }
    VI ans;
    REPP(i,1,n+1){
        if(dfs(i))ans.PB(i);
    }
    REP(i,SZ(ans)){
        printf("%d%c",ans[i]," \n"[i==SZ(ans)-1]);
    }
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    string S, T, U;
    ll A, B;
    cin >> S >> T >> A >> B >> U;
    if(S==U) A--;
    else B--;
    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>

//find out the use of the below
#include <list>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-100
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int n,d ;
    scanf("%d%d", &n, &d);
    vector<vector<int> > ar(n);
    
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < d; ++j){
            int x;
            scanf("%d", &x);
            ar[i].pb(x);
        }
    }
    long long so;
    int ans=0;
    for (int i = 0; i < n; ++i){
        for (int j = i+1; j < n; ++j){
            so = 0;
            for (int k = 0; k < d; ++k){
                so += (ar[i][k]-ar[j][k])*(ar[i][k]-ar[j][k]);
            }
            //cout << i << ' ' << j << ' ' << abs(sqrt(so)*sqrt(so)-so) << '\n';
            if (((int)sqrt(so))*((int)sqrt(so)) == so)
                ans++;

        }
    }
    cout << ans; 
                


    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
  int main() {
  int N;
  cin >>N ;
  string S;

  for(int i=0 ; i<N ; i++)
 {
  cin >>S;
  //Yが入っているなら4種類なのでfourを出力し終了
  if(S=="Y")
  {
    cout <<"Four" <<endl;
    break;
  }
  //最終ループまでYがなければThree
  if(i==N-1)cout <<"Three" <<endl;
 }

}

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

int main()
{
	int n;
	float a[1005],b[1005];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	float sum = 0.0;
	for(int i = 0;i < n;i++){
		b[i] = 1/a[i];
	}
	float s = 0.0;
	for(int i = 0;i < n;i++){
		s = s + b[i];
	}
	cout << 1/s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
    int n;
    cin >> n;
    char s[n];
    for(int i=0;i<n;i++)cin >> s[i];

    int min = 0;
    int count = 0;
    for(int i=0;i<n;i++){
        if(s[i]=='(')count++;
        if(s[i]==')')count--;
        if(min>count)min = count;
    }

    for(int i=0;i<(-min);i++)cout << "(";
    for(int i=0;i<n;i++)cout << s[i];
    for(int i=0;i<count-min;i++)cout << ")";
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,s=0,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        if(i!=3&&i!=5)
        {
            if(i%3!=0&&i%5!=0)
            {
                s=s+i;
            }
        }

    }
    cout<<s;

return 0;}


Measured memory_bytes: 3564
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

#define ll long long
#define IN(type, name) type name; cin >> name
#define VEC2(type, name, dim0, dim1) vector<vector<type>> name(dim0, vector<type>(dim1))
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VPair(type1, type2, name, size) vector<pair<type1, type2>> name(size); for(auto& x: name) cin >> x.first >> x.second
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name)

#define REP(name, start, end) for(ll name = (start); (name) < (end); ++(name))
#define ALL(iterable) (iterable).begin(), (iterable).end()

int main()
{
	cout << fixed << setprecision(6);
	IN(ll, n);
	vector<ll> als(n), bls(n), cls(n);
	REP(i, 0, n)cin >> als[i] >> bls[i] >> cls[i];
	VEC2(ll, cost_dp, n, 3);

	cost_dp[0][0] = als[0];
	cost_dp[0][1] = bls[0];
	cost_dp[0][2] = cls[0];
	REP(i, 1, n) {
		cost_dp[i][0] = max(cost_dp[i - 1][1] + als[i], cost_dp[i - 1][2] + als[i]);
		cost_dp[i][1] = max(cost_dp[i - 1][2] + bls[i], cost_dp[i - 1][0] + bls[i]);
		cost_dp[i][2] = max(cost_dp[i - 1][0] + cls[i], cost_dp[i - 1][1] + cls[i]);
	}

	cout << *max_element(ALL(cost_dp[n - 1])) << endl;
	return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<string>
#include<vector>
using namespace std;
char CaesarChar(char );
string CaesarString(string s);
vector<string> CaesarVector(vector<string> v);
vector<string> SolveCaesar(vector<string> v);
int main() {
  string s;
  while( getline(cin,s)) {  
    vector<string> array;
    int space=0;
    int next_space=0;    
    for(int i=0;i<(int)s.size();i++) {
      if(s[i]== ' '){
	next_space=i;
	string tmp="";
	for(int j=space;j<next_space;j++)
	  tmp+=s[j];
	space=next_space+1;
	array.push_back(tmp);
      }
    }
    string tmp="";
    for(int i=next_space+1;i<(int)s.size();i++) 
      tmp+=s[i];
    array.push_back(tmp);
    vector<string> answer=SolveCaesar(array);
    for(int i=0;i<(int)answer.size();i++){
      cout<<answer[i];
      if(i!=(int)answer.size()-1)
	cout<<" ";
    } 
    cout<<endl;
  }
  return 0;
}
char CaesarChar(char c) {
  if(c=='z')
    return 'a';
  if(int('a')<=int(c) && int(c)<int('z'))
  return char(c+1);
  return c;
}
string CaesarString(string s) {
  string tmp="";
  for(int i=0;i<(int)s.size();i++)
    tmp+=CaesarChar(s[i]);
  return tmp;
}
vector<string> CaesarVector(vector<string> v) {
  vector<string> tmp;
  for(int i=0;i<(int)v.size();i++) 
    tmp.push_back(CaesarString(v[i]));
  return tmp;
}
vector<string> SolveCaesar(vector<string> v) {
  for(int i=0;i<(int)v.size();i++) {
    if(v[i]=="the" || v[i]=="this" || v[i]=="that")
      return v;
  } 
  return SolveCaesar(CaesarVector(v));
}



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


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;

/*mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int power(int a,int n)
{
    a %= mod;
    if(n == 1) return a;
    if(n == 0) return 1;
    if(n%2) return (a*(power((a*a)%mod,n/2)%mod))%mod;           //n is odd
    return power((a*a)%mod,n/2)%mod;                             //n is even
}

const int inf = (int) 1e18;

int inverse(int x)
{
    return power(x,mod-2)%mod;     //Fermat's little theorem
}*/


int main()
{
    SAM;
    int n;
    cin>>n;
    int arr[n],a[n];
    FOR(i,0,n)
    {
        cin>>arr[i]>>a[i];
    }
    
    int count=0;
    bool temp=false;
    FOR(i,0,n)
    {
        if(arr[i]==a[i])
        {
            count++;
            if(count==3)
            {
                temp=true;
                break;
            }
        }
        else
        {
            temp=false;
            count=0;
        }
    }
    
    if(temp==true)
        cout<<"Yes";
    else
        cout<<"No";
    
    
    
    
    
    
    return 0;
}




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

int main()
{
    int n,min,max;
    long long sum;
    cin >> n;
    long long a[n];
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    max=a[0];
    for(int i=0;i<n;i++)
    {
        if(max<a[i])
        {
            max=a[i];
        }
    }
    min=max;
    for(int i=0;i<n;i++)
    {
        if(min>a[i])
        {
            min=a[i];
        }
    }
    sum=0;
    for(int i=0;i<n;i++)
    {
        sum=sum+a[i];
    }
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3168
import java.util.*;

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

    String S = scn.nextLine();
    int firstHalf = Integer.parseInt(S.substring(0, 2), 10);
    int secondHalf = Integer.parseInt(S.substring(2, 4), 10);

    boolean isYYMM = false;
    boolean isMMYY = false;
    if (secondHalf >= 1 && secondHalf <= 12) {
      isYYMM = true;
    }
    if (firstHalf >= 1 && firstHalf <= 12) {
      isMMYY = true;
    }

    String ans;
    if (isYYMM && isMMYY) {
      ans = "AMBIGUOUS";
    } else if (isYYMM) {
      ans = "YYMM";
    } else if (isMMYY) {
      ans = "MMYY";
    } else {
      ans = "NA";
    }

    System.out.println(ans);
  }

}

Measured memory_bytes: 21716
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[0])

cnt = 0
ans = 0
for ai, bi in ab:
    if cnt + bi <= m:
        ans += ai * bi
        cnt += bi
    elif cnt <= m:
        ans += ai * (m - cnt)
        break
print(ans)


Measured memory_bytes: 18128
#include <stdio.h>
 
int main()
{
    int a = 0, b= 0;

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

    if(a==b)
    {
        printf("a == b\n");
        return 0;
    }
    else if(a < b)
    {
        printf("a < b\n");
        return 0;
    }
    else
    {
        printf("a > b\n");
        return 0;
    }

    return 0;
}

Measured memory_bytes: 1008
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x * (-1), a))
heapq.heapify(a)
for _ in range(m):
    min = ((heapq.heappop(a) * (-1)) // 2) * (-1)
    heapq.heappush(a, min)
print(sum(a)*(-1))

Measured memory_bytes: 14184
#include<iostream>
using namespace std;
int main(){
  int r0,r,w,c,n;
  while(1){
    n=0;
    cin>>r0>>w>>c>>r;
    if(r0+r+c+w==0)break;
    while(1){
      if(r0+n*r-c*w>=0)break;
      n++;
    }
    cout<<n<<endl;
  }
  return 0;
}

Measured memory_bytes: 3036
a, b, c, x, y = map(int, input().split())
r = []
r.append(a * x + b * y)
r.append(c * min(x, y) * 2 + (max(x, y) - min(x, y)) * (a if x > y else b))
r.append(c * max(x, y) * 2)
print(min(r))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
  
struct P{
  int x,y;
  bool operator <(const P &a) const{
    return y<a.y;
  };
};
  
int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[4];
int l[3];
int j[3];


long long x,y,z,mod=1000000007;
//string r,r1,r2,r3,r4,r5;
char r[1];
vector<int> v[1],v1;
queue<int> q;
stack<int> s;
map<int,int> p;
P u[1];
  
bool as(P a,P b)
{
  if(a.x!=b.x)
  return a.x<b.x;
  return a.y<b.y;
}

int main()
{
  scanf("%d",&a);
  for(int t=1;t<=a;t++)
  {
    scanf("%d",&n);
    if(n%2==0&&n%3&&n%5)
    {
      puts("DENIED");
      return 0;
    }
  }
  puts("APPROVED");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
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; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int H,W;cin >> H >> W;
    vector<vector<bool>> on(H+1,vector<bool>(W+1,false));
    rep(i,H)rep(j,W){
        char t;cin >> t;
        if(t == '.')on[i][j] = false;
        else on[i][j] = true;
    }


    int lim = H+W-2;
    on[0][0] = false;
    on[H-1][W-1] = false;
    int x = 0;
    int y = 0;
    rep(i,lim-1){
        if(x != H-1){
            if(on[x+1][y]){
                on[x+1][y] = false;
                x += 1;
//                cout << "(" << x << "," << y << ")";
                continue;
            }
        }
        if(y != W-1){
            if(on[x][y+1]){
                on[x][y+1] = false;
                y += 1;
//                cout << "(" << x << "," << y << ")";
                continue;
            }
        }
    }


    bool pos = true;
    rep(i,H)rep(j,W){
        if(on[i][j]) pos = false;
    }

    if(pos)cout << "Possible" << endl;
    else cout << "Impossible" << endl;

/*    rep(i,H){
        rep(j,W){
            if(on[i][j])cout << '#';
            else cout << '.';
        }
        cout << endl;
    }
*/
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator &itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator &begin() {return i;}
  Iterator &end() {return n;}
};

template<class T> T at(vector<T> v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

const int INF = 1e9;

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

int main() {
  int h, w;
  cin >> h >> w;
  string area[16][h];
  for (int i : range(h)) cin >> area[0][i];
  int n;
  cin >> n;
  int t[n];
  for (int i : range(n)) {
    cin >> t[i];
    for (int j : range(h)) cin >> area[i + 1][j];
  }
  int dp[1000][h][w];
  for (int i : range(1000)) for (int j : range(h)) for (int k : range(w)) dp[i][j][k] = INF;
  for (int i : range(h)) for (int j : range(w)) if (area[0][i][j] == 'S') dp[0][i][j] = 0;
  int s = 0, res = INF;
  for (int i : range(999)) {
    if (s < n && t[s] == i + 1) ++s;
    for (int y : range(h)) for (int x : range(w)) if (dp[i][y][x] != INF) {
      for (int k : range(4)) {
        int yy = y + dy[k];
        int xx = x + dx[k];
        if (yy < 0 || h <= yy) continue;
        if (xx < 0 || w <= xx) continue;
        if (area[s][yy][xx] == '#') continue;
        dp[i + 1][yy][xx] = min(dp[i + 1][yy][xx], dp[i][y][x] + 1);
        if (area[0][yy][xx] == 'G') res = min(res, dp[i][y][x] + 1);
      }
      if (area[s][y][x] != '#') dp[i + 1][y][x] = min(dp[i + 1][y][x], dp[i][y][x]);
    }
  }
  if (res == INF) cout << -1 << endl;
  else cout << res << endl;
}


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

int main(){
  string str;
  char S;
  while(1){
    cin>>str;
    cin>>S;

    if(S=='X') break;

    else  if(S=='L'){
      if(str[0]>='A' && str[0]<='Z') str[0]+=32;
      for(int i=0;i<str.size()-1;i++){
	if(str[i]=='_' && str[i+1]>='a' && str[i+1]<='z' ) str[i+1]-=32;
      }
      for(int i=0;i<str.size();i++){
	if(str[i]=='_') continue;
	else cout<<str[i];
      }
      cout<<endl;
    }
    
    else  if(S=='U') {
      if(str[0]>='a' && str[0]<='z') str[0]-=32;
    
    for(int i=0;i<str.size()-1;i++){
    if(str[i]=='_'&& str[i+1]>='a' && str[i+1]<='z') str[i+1]-=32;
  }
  for(int i=0;i<str.size();i++){
	if(str[i]=='_') continue;
	else cout<<str[i];
      }
      cout<<endl;
      
    }
    
  else  if(S=='D'){
    for(int i=0;i<str.size();i++){
      if(str[i]>=65 && str[i]<=90){
	str[i]+=32;
      }
      if(i>=0 && i<str.size()-1 && str[i+1]>=65 && str[i+1]<=90){
	cout<<str[i]<<"_";
      }
      else cout<<str[i];
    }
    cout<<endl;
  }
  }
  return 0;
  }

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

using namespace std;
const int N = 5e3 + 3;
char s[N];
pair<int, int> val[N][N];
int n;
bool get(int len) {
	for (int i = 0; i + len - 1 < n; ++i)
		for (int j = i + len; j + len - 1 < n; ++j)
			if (val[i][len] == val[j][len])
				return true;
	return false;
}
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
#endif
	scanf("%d %s", &n, s);
	for (int i = 0; i < n; ++i) {
		int h1 = 0, h2 = 0;
		for (int j = i; j < n; ++j) {
			h1 *= 127;
			h1 += s[j];
			h1 %= 2000000011;
			h2 *= 131;
			h2 += s[j];
			h2 %= 2000000033;
			val[i][j - i + 1] = {h1, h2};
		}
	}
	int lo = 1, hi = n / 2, res = 0;
	while (lo <= hi) {
		int mid = (lo + hi) / 2;
		if (get(mid)) {
			res = mid;
			lo = mid + 1;
		} else {
			hi = mid - 1;
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 194944
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		Set<Integer>  set = new HashSet<Integer> ();
		int count =1;
		set.add(s);
		while (true) {
			if (s%2==0) {
				s=s/2;
			} else {
				s=3*s+1;
			}
			if (set.contains(s)==true) {
				System.out.println(count+1);
				break;
			}
			set.add(s);
			count++;
		}
	}
}

Measured memory_bytes: 35700
/* Don't try to hack it :|
 
            _/﹋\_
            (҂`_´)
            <,︻╦╤─҉- - - - - - - - - - - - - - -
            _/﹋\_
*/

#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   // 1 * 10^9+ 7
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define fo(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n; cin >> n;
	if(n>81) cout <<"No";
	else {
		int flag=0;
		int a[9]= {1,2,3,4,5,6,7,8,9};
		for(int i=0;i<9;i++){
			if(n % a[i]==0 &&  (n/a[i])<10 ){
				flag =1;
				break;
			}
		}
		if(flag) cout <<"Yes";
		else cout << "No";
	}
	return 0;
}



Measured memory_bytes: 256
import sys


class Node():

	def __init__(self,id,key):
		
		self.id = id
		self.key = key
		self.root = -1
		self.left = -1
		self.right = -1
		self.parent = -1
		self.sibling = -1
		self.degree = 0
		self.depth = 0
		self.height = 0

def print_nodes(Nodes,node_id,type,output):

	#TYPE
	#0 : Preorder
	#1 : Inorder
	#2 : Postorder

	if node_id == -1:
		return

	if type == 0:
		output.append(Nodes[node_id].key)

	print_nodes(Nodes,Nodes[node_id].left,type,output)
	if type == 1:
		output.append(Nodes[node_id].key)
	print_nodes(Nodes,Nodes[node_id].right,type,output)
	if type == 2:
		output.append(Nodes[node_id].key)

def insert(T,z):

	if len(T) == 1:
		return


	y = -1
	x = T[0]

	while True:
		y = x
		if z.key < x.key:
			if x.left == -1:
				break
			else:
				x = T[x.left]
		else:
			if x.right == -1:
				break
			else:
				x = T[x.right]

	z.parent = y.id
	if z.key < y.key:
		y.left = z.id
	else:
		y.right = z.id

def test():

	n = int(sys.stdin.readline())
	T = [Node(0,0)] * n
	root = 0
	id = 0

	for i in range(n):

		inputs = sys.stdin.readline().split()

		if inputs[0] == "insert":
			if id == 0:
				T[id] = Node(id,int(inputs[1]))
				id += 1
				continue

			key = int(inputs[1])
			tmp_node = Node(id,key)
			T[id] = tmp_node
			insert(T,tmp_node)
			id += 1

		if inputs[0] == "print":
			output = []
			#In-order
			print_nodes(T,T[0].id,1,output)
			for j in range(len(output)-1):
				print(f" {output[j]}",end = '')
			print(f" {output[j+1]}")

			#Pre-order
			output2 = []
			print_nodes(T,T[0].id,0,output2)
			for j in range(len(output2)-1):
				print(f" {output2[j]}",end = '')
			print(f" {output2[j+1]}")

if __name__ == "__main__":
	test()



Measured memory_bytes: 153060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n;cin>>n;
	ll a[n],b[n+1];
	rep(i,n+1) b[i]=0;
	rep(i,n){
		cin>>a[i];
		b[a[i]]++;
	}

	ll sum=0;
	rep(i,n+1) if(b[i]>0) sum+=b[i]*(b[i]-1)/2;

	rep(i,n){
		cout<<sum-(b[a[i]]-1)<<endl;//b[a[i]]個の組合せからb[a[i]]-1個の組合せまで減らせば良い
	}
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int A, B;

    scanf("%d%d", &A, &B);

    if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0){
        printf("Possible\n");
    }else{
        printf("Impossible\n");
    }

    return 0;
}

Measured memory_bytes: 1608
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long Int;
 
class Fraction{
public:
    Int numerator,denominator;
};
 
void reduce(Fraction &);
Int gcd(Int,Int);
 
ostream &operator << (ostream &os,Fraction f){
    reduce(f);
    if(f.numerator == 0){
	os << "0";
    }else if(f.denominator == 1){
	os << f.numerator;
    }else{
	os << f.numerator << "/" << f.denominator;
    }
    return os;
}
 
Int gcd(Int a,Int b){
    return (b == 0 ? a : gcd(b,a%b));
}
 
Int lcm(Int a,Int b){
    return a*b/gcd(a,b);
}
 
void reduce(Fraction &f){
    Int x = gcd(f.numerator,f.denominator);
    f.numerator /= x;
    f.denominator /= x;
}
 
Fraction sub(Fraction f,Int num,Int den){
    Fraction g = {num,den}; reduce(g);
    Int nd = lcm(f.denominator,g.denominator);
    f.numerator *= (nd/f.denominator);
    g.numerator *= (nd/g.denominator);
    f.denominator = g.denominator = nd;
    f.numerator -= g.numerator;
    return f;
}
 
Fraction add(Fraction f,Int num,Int den){
    Fraction g = {num,den}; reduce(g);
    Int nd = lcm(f.denominator,g.denominator);
    f.numerator *= (nd/f.denominator);
    g.numerator *= (nd/g.denominator);
    f.denominator = g.denominator = nd;
    f.numerator += g.numerator;
    return f;
}
 
int main(){
    string in;
 
    while(cin >> in, in != "#"){
	string s;
	int size = 0;
	for(int i = 0 ; i < (int)in.size() ; size++){
	    if(in[i] == 'n'){
		s += 'n';
		i += 5;
	    }else{
		s += 'w';
		i += 4;
	    }
	}
	reverse(s.begin(),s.end());
	Fraction f;
	int n = 1;
	if(s[0] == 'n'){
	    f.numerator = 0;
	    f.denominator = 1;
	}else{
	    f.numerator = 90;
	    f.denominator = 1;
	}
	for(int i = 1 ; i < size ; i++,n++){
	    if(s[i] == 'n'){
		f = sub(f,90,(Int)pow(2.,n));
	    }else{
		f = add(f,90,(Int)pow(2.,n));
	    }
	    reduce(f);
	}
	cout << f << endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i = l; i <= r; ++i) {
    if(i%d == 0) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3556
use std::io;
use std::cmp;
use std::collections::HashSet;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn main() {
    let n = read_t_in_line::<usize>()[0];
    let v = (0..n).map(|_| read_line()).collect::<Vec<String>>();

    if v.clone().into_iter().collect::<HashSet<String> >().len() != v.len() {
            println!("No");
            return;
    }

    for i in 1..n {
        if v[i-1].as_bytes().last().unwrap() != v[i].as_bytes().first().unwrap() {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
  	a*=100;b*=100;
  	int maxa=f/a,maxc=f/c;
  	set<int> water;
    set<int> sugar;
  	double temp=0;
  	int wans,sans;
  
  	//何グラムの水があるのか
  	for(int i=0;i<=maxa;i++){
    	for(int j=0;j<=(f-a*i)/b;j++){
        	water.insert(i*a+j*b);
        }
    }
  	//何グラムの砂糖を入れるのか
  	for(int i=0;i<=maxc;i++){
    	for(int j=0;j<=(f-c*i)/d;j++){
        	sugar.insert(i*c+j*d);
        }
    }
  
   //waterとsugarの組み合わせ
  	for(auto w : water){
      for(auto s : sugar){
        if(w!=0){
  			if((w+s)<=f && 1.0*(s*100)/w<=e){
              	if(temp<=1.0*(s*100)/w){
            		temp=1.0*(s*100)/w ;wans=w; sans=s;
                }
            }
          }
    	}    
    }
  	cout<<wans+sans<<" "<<sans<<endl;
}

Measured memory_bytes: 384
class Dice
	TOP=0
	FRONT=1
	RIGHT=2
	LEFT=3
	BACK=4
	BOTTOM=5
	
	def initialize( nums )
		@face = nums
	end
	
	def rolltoTop( num )
		from = 0
		for i in ( 0 ... @face.length )
			if num == @face[i]
				from = i
				break
			end
		end
		case from
		when FRONT
			roll( "N" )
		when RIGHT
			roll( "W" )
		when LEFT
			roll( "E" )
		when BACK
			roll( "S" )
		when BOTTOM
			roll( "NN" )
		when TOP
		end
	end
	
	def roll( actions )
		for i in ( 0 ... actions.length )
			t = 0
			case actions[i]
			when "E"
				t =   @face[ TOP  ]
				@face[ TOP  ] =   @face[ LEFT  ]
				@face[ LEFT  ] =   @face[ BOTTOM  ]
				@face[ BOTTOM  ] =   @face[ RIGHT  ]
				@face[ RIGHT  ] = t
			when "N"
				t =   @face[ TOP  ]
				@face[ TOP  ] =   @face[ FRONT  ]
				@face[ FRONT  ] =   @face[ BOTTOM  ]
				@face[ BOTTOM  ] =   @face[ BACK  ]
				@face[ BACK  ] = t
			when "S"
				t =  @face[ TOP  ]
				@face[ TOP  ] =  @face[ BACK  ]
				@face[ BACK  ] =  @face[ BOTTOM  ]
				@face[ BOTTOM  ] =  @face[ FRONT  ]
				@face[ FRONT  ] = t	
			when "W"
				t =  @face[ TOP  ]
				@face[ TOP  ] =  @face[ RIGHT  ]
				@face[ RIGHT  ] =  @face[ BOTTOM  ]
				@face[ BOTTOM  ] =  @face[ LEFT  ]
				@face[ LEFT  ] = t	
			when "M"
				t =  @face[ FRONT  ]
				@face[ FRONT  ] =  @face[ RIGHT  ]
				@face[ RIGHT  ] =  @face[ BACK  ]
				@face[ BACK  ] =  @face[ LEFT  ]
				@face[ LEFT  ] = t				
			end
		end
	end
	attr_accessor :face
end

diceface = gets.split( " " ).map { |val| val.to_i }
dice = Dice.new( diceface )
q = gets.to_i
q.times {
	topnum, frontnum = gets.split( " " ).map { |val| val.to_i }
	dice.rolltoTop( topnum  )
	while dice.face[Dice::FRONT] != frontnum
		dice.roll( "M" )
	end
	puts( dice.face[Dice::RIGHT] )
}

Measured memory_bytes: 6156
#include<iostream>
#include<string>
#include<time.h>
using namespace std;

struct Dice{
    int s[6];
    void move(char c){
        int tmp;
        if(c=='N'){
            tmp=s[0];
            s[0]=s[1];
            s[1]=s[5];
            s[5]=s[4];
            s[4]=tmp;
        }
        else if(c=='S'){
            tmp=s[0];
            s[0]=s[4];
            s[4]=s[5];
            s[5]=s[1];
            s[1]=tmp;
        }
        else if(c=='E'){
            tmp=s[0];
            s[0]=s[3];
            s[3]=s[5];
            s[5]=s[2];
            s[2]=tmp;
        }
        else if(c=='W'){
            tmp=s[0];
            s[0]=s[2];
            s[2]=s[5];
            s[5]=s[3];
            s[3]=tmp;
        }
        else if(c=='R'){
            tmp=s[1];
            s[1]=s[2];
            s[2]=s[4];
            s[4]=s[3];
            s[3]=tmp;
        }
    }
    int get_top(){
        return s[0];
    }
    int get_right(){
        return s[2];
    }
};

bool same(Dice a,Dice b){
    for(int i=0;i<6;i++){
        if(a.s[i]!=b.s[i])return false;
    }
    return true;
}

int main(){
    Dice d[100];
    int n,count;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<6;j++)cin>>d[i].s[j];
    }
    bool flag=false,f=true;
    
    count=0;
    while(count<n-1){
        for(int i=0;i<4;i++){
            d[count+1].move('R');
            for(int j=0;j<4;j++){
                d[count+1].move('N');
                if(same(d[0],d[count+1]))flag=true;
            }
        }
        d[count+1].move('E');
        for(int i=0;i<4;i++){
            d[count+1].move('N');
            if(same(d[0],d[count+1]))flag=true;
        }
        d[count+1].move('W');
        d[count+1].move('W');
        for(int i=0;i<4;i++){
            d[count+1].move('N');
            if(same(d[0],d[count+1]))flag=true;
        }
        if(flag==true){
            if(f)f=false;
        }
        count++;
    }
    cout<<(f?"Yes":"No")<<endl;

    return 0;
}


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

int main(void){
    int N;
    cin>>N;
    vector<string> W(N);

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

    for(int i=0;i<N-1;i++){
        for(int j=1;j<N;j++){
            if(j==i)
                continue;
            if(W[i]==W[j]){
                cout<<"No"<<endl;
                return 0;
            }
        }
        if(W[i][W[i].size()-1]!=W[i+1][0]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var a = inputs[0] == "H";
            var b = inputs[1] == "H";
            var result = a == b ? "H" : "D";

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 25872
#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字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    string s; cin >> s;
    int x, y; cin >> x >> y;

    vector<int> dx, dy;
    int Tcnt = 0, Fcnt = 0;

    for(int i=0; i<s.size(); ++i){
        if(i == s.size()-1 && s[i] == 'F'){
            ++Fcnt;
            if(Tcnt%2 == 0) dx.push_back(Fcnt);
            else dy.push_back(Fcnt);
        }
        else if(s[i] == 'F') ++Fcnt;
        else if(s[i] == 'T') {
            if(Tcnt%2 == 0){
                dx.push_back(Fcnt);
                Fcnt = 0;
                ++Tcnt;
            } else if(Tcnt%2 == 1){
                dy.push_back(Fcnt);
                Fcnt = 0;
                ++Tcnt;
            }
        }
    }

    // for(auto e:dx) cout << " " << e;
    // cout << endl;
    // for(auto e:dy) cout << " " << e;
    // cout << endl;

    vector<vector<bool>> dpx(dx.size()+5, vector<bool>(16005, false)), dpy(dy.size()+5, vector<bool>(16005, false));
    dpx[0][dx[0]+8000] = true;
    
    if(dy.size()){
        dpy[0][8000+dy[0]] = true;
        dpy[0][8000-dy[0]] = true;
    }

    for(int i=0; i<dx.size()-1; ++i){
        for(int j=0; j<=16000; ++j){
            if(dx[i+1] <= j) dpx[i+1][j-dx[i+1]] = dpx[i+1][j-dx[i+1]] || dpx[i][j];
            if(j+dx[i+1] <= 16000) dpx[i+1][j+dx[i+1]] = dpx[i+1][j+dx[i+1]] || dpx[i][j];
        }
    }

    for(int i=0; i<(int)dy.size()-1; ++i){
        for(int j=0; j<=16000; ++j){
            if(dy[i+1] <= j) dpy[i+1][j-dy[i+1]] = dpy[i+1][j-dy[i+1]] || dpy[i][j];
            if(j+dy[i+1] <= 16000) dpy[i+1][j+dy[i+1]] = dpy[i+1][j+dy[i+1]] || dpy[i][j];
        }
    }

    if(dy.size() == 0){
        if(dpx[dx.size()-1][x+8000] && y == 0){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if(dpx[dx.size()-1][x+8000] && dpy[dy.size()-1][y+8000]){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 16256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			if(n==0)break;
			int[] kaidan = new int[n+1];
			for(int i=0;i<n;i++)kaidan[i]=0;
			kaidan[0]=1;
			for(int s=0;s<n+1;s++)for(int i=s+1;i<=s+3;i++){
					if(i>=n+1)continue;
					kaidan[i]+=kaidan[s];
			}
			System.out.println((kaidan[n]/3650)+1);
		}
	}
}

Measured memory_bytes: 15352