akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports)]

use std::cmp::*;

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
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, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        H : usize,
        W : usize,
        S : [chars; H],
    }
    // 横軸集計
    let mut count_c = vec!(vec!(0; W); H);
    for y in 0..H {
        for x in 0..W {
            if '#' == S[y][x] {continue;}
            if count_c[y][x] != 0 {continue;}
            let mut l = x;
            let mut r = x;
            while 0 < l && '.' == S[y][l - 1] {l -= 1;}
            while r < (W - 1) && '.' == S[y][r + 1] {r += 1;}
            for n in l..r + 1 {count_c[y][n] = r - l + 1}
        }
    }
    // 縦軸集計
    let mut count_v = vec!(vec!(0; W); H);
    for x in 0..W {
        for y in 0..H {
            if '#' == S[y][x] {continue;}
            if count_v[y][x] != 0 {continue;}
            let mut t = y;
            let mut b = y;
            while 0 < t && '.' == S[t - 1][x] {t -= 1;}
            while b < (H - 1) && '.' == S[b + 1][x] {b += 1;}
            for n in t..b + 1 {count_v[n][x] = b - t + 1}
        }
    }
    // for l in &count_c {
    //     println!("{:?}", l);
    // }
    // println!("");
    // for l in &count_v {
    //     println!("{:?}", l);
    // }
    // 横縦集計
    let mut max_score = 0;
    for y in 0..H {
        for x in 0..W {
            //println!("y:{} x:{}", y, x);
            let score = count_c[y][x] + count_v[y][x];
            max_score = max(max_score, score);
        }
    }
    println!("{}", max_score - 1);
}


Measured memory_bytes: 102652
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	map<string,ll> mp;
	ll sum = 0;
	rep(i,n){
		string s; ll t;
		cin >> s >> t;
		sum += t;
		mp[s] = sum;
	}
	string ss; cin >> ss;
	cout << sum - mp[ss] << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

//constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

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

	cin>>N;
	vector<int>v(N+1);
	for(int i=1;i<=N;i++){
		cin>>M;
		v[M]=i;
	}
	for(int i=1;i<=N;i++){
		cout<<v[i]<<" ";
	}
	cout<<endl;
	return 0;
}

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

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

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

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

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



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


int main() {
    long long N,K;
    long long vec[1 << 18]; 
    cin>> N;
    cin>> K;
    for(int i=1;i<=N;i++){
        cin>> vec[i];
        
    }
    for (int i=K+1;i<=N;i++){
        if(vec[i-K]<vec[i]){
            cout<< "Yes"<<endl;
        }
        else
            cout<< "No"<<endl;
    }
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

vector<bool> proceed_dp(vector<bool> &dp, int n, int N){

    vector<bool> dp2(2 * N + 1, false);
    FOR(i, n, 2 * N - n + 1){
        if(dp[i]){
            dp2[i + n] = true;
            dp2[i - n] = true;
        }
    }

    return dp2;

}

signed main(){

    string s;
    int x, y;
    cin >> s >> x >> y;
    int N = s.size();

    vector<bool> dpx(2 * N + 1, false), dpy(2 * N + 1, false);
    bool x_direction = true;
    int count = 0;
    //dpx[N] = true;
    dpy[N] = true;
    bool first = true;

    REP(i, N){
        if(s[i] == 'F'){
            count++;
        }
        if(s[i] == 'T' || i == N - 1){
            if(first){
                dpx[N + count] = true;
                first = false;
            }else{
                if(x_direction){
                    dpx = proceed_dp(dpx, count, N);
                }else{
                    dpy = proceed_dp(dpy, count, N);
                }
            }
            x_direction = !x_direction;
            count = 0;
        }
    }

    if(dpx[x + N] && dpy[y + N]){
        cout << "Yes";
    }else{
        cout << "No";
    }


    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
from itertools import accumulate

def get_prime_number_list(N):
    # N以下の素数のリストを返す
    primes = [2]
    limit = int(N**0.5)
    data = [i+1 for i in range(2, N, 2)]
    while 1:
        p = data[0]
        if limit <= p:
            return primes + data
        primes.append(p)
        data = [e for e in data if e%p != 0]

def main():
    Q=int(input())
    primes = get_prime_number_list(10**5)
    prime_lst = [0]*(10**5+10)
    tmp = [0]*(10**5+10)
    for prime in primes:
        prime_lst[prime] = 1
    for i in range(3, 10**5+10, 2):
        if prime_lst[i] and prime_lst[(i+1)//2]:
            tmp[i] = 1
    ans = list(accumulate(tmp))
    l_r = []
    for _ in range(Q):
        l_r.append(map(int,input().split()))
    for l,r in l_r:
        print(ans[r] - ans[l-1])

main()

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll n, k;
  string s;
  cin >> n >> k >> s;

  s[k - 1] = tolower(s[k - 1]);

  cout << s << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	std::fill((T *)array, (T *)(array + N), val);
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//素因数分解
map<ll, ll> prime_factor(ll n)
{
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++)
	{
		while (n % i == 0)
		{
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1)
		ret[n] = 1;
	return ret;
}

int main()
{
	ll n;
	cin >> n;
	ll ans = LINF;
	for (ll i = 1; i * i <= n; i++)
	{
		if(n%i ==0){
			ans = min(ans, i + n / i);
		}
	}
	cout << ans-2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;

int main(){
    char c;
    cin >> c;
    char d = c + 1;
    p(d);
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

// http://docs.oracle.com/javase/jp/6/api/java/util/PriorityQueue.html

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;

	void run() {
		int n = sc.nextInt();
		int q = sc.nextInt();
		PriorityQueue<Info> queue = new PriorityQueue<Info>(1,
				new ComparatorInfo());
		Map<Integer, Info> map = new HashMap<Integer, Info>();
		while (q-- > 0) {
			int a = sc.nextInt();
			int v = sc.nextInt();
			if (!map.containsKey(a)) {
				Info newData = new Info(a, v);
				queue.add(newData);
				map.put(a, newData);
			} else {
				Info now = map.get(a);
				queue.remove(now);
				now.cnt += v;
				queue.add(now);
			}
			System.out.println(queue.peek().id + " " + queue.peek().cnt);
		}
	}

	class Info {
		int id;
		int cnt;

		public Info(int id, int cnt) {
			super();
			this.id = id;
			this.cnt = cnt;
		}
	}

	class ComparatorInfo implements Comparator<Info> {
		@Override
		public int compare(Info arg0, Info arg1) {
			// TODO 自動生成されたメソッド・スタブ
			if (arg0.cnt == arg1.cnt) {
				return arg0.id - arg1.id;
			} else {
				return arg1.cnt - arg0.cnt;
			}
		}
	}

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

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 66556
#include<stdio.h>


int main(){
	int i,j;
	while(scanf("%d %d",&i,&j)!=EOF){;
		int count=0;
		i=i+j;
		while(i>0){
			i=i/10;
			count++;
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll N, K;
  cin >> N >> K;
  vll a(N);
  rep(i,N) {
    cin >> a[i];
    a[i]--;
  }
  ll logk = 1;
  while((1LL << logk) < K) logk++;
  vector<vll> doubling(logk, vll(N));
  rep(i,N) doubling[0][i] = a[i];
  rep(k,logk-1) {
    rep(i,N) doubling[k+1][i] = doubling[k][doubling[k][i]];
  }
  int now = 0;
  for(int k = 0; K>0; k++) {
    if(K&1) now = doubling[k][now];
    K = K >> 1;
  }
  cout << now+1 << endl;
  return 0;
}

Measured memory_bytes: 100132
#include <iostream>
using namespace std;
using llong = long long;

llong w;
llong pt[15];
char ans[15];

bool dfs(int i, llong d) {
	if (i == 15 && d == w) return true;
	else if (i == 15) return false;
	
	bool f = false;
	
	if (dfs(i + 1, d + pt[i])) ans[i] = '+', f = true;
	
	if (dfs(i + 1, d)) ans[i] = '0', f = true;
	
	if (dfs(i + 1, d - pt[i])) ans[i] = '-', f = true;
	
	return f;
}

int main() {
	cin >> w;
	
	pt[0] = 1;
	for (int i = 1; i < 15; i++) {
		pt[i] = pt[i - 1] * 3;
	}
	
	dfs(0, 0);
	
	bool f = false;
	for (int i = 14; i >= 0; i--) {
		if (ans[i] != '0') f = true;
		
		if (f) cout << ans[i];
	}
	cout << endl;
	
	return 0;
}


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

int main(){
	long long n;
  	cin >> n;
  vector<long long> l(n);
  for (int i = 0; i < n ; i++){
  	cin >> l[i];
  }
  
  long long res = 0;
  for (int i = 0 ; i < n-2; i++){
  	for (int j = i+1; j < n-1; j++){
    	for (int k = j+1; k < n; k++){
          	vector<long long> check;
        	set<long long> ms;
          	check.push_back(l[i]);
          	check.push_back(l[j]);
          	check.push_back(l[k]);
    		ms.insert(l[i]);
          	ms.insert(l[j]);
            ms.insert(l[k]);
          	if (ms.size() != 3) continue;
          	sort(check.begin(),check.end());
          	if (check[0] + check[1] > check[2]) res ++;
          	//if (check[0] + check[1] > check[2]) cout << i+1 << " " << j+1 << " " << k+1 << endl;
        }
    }
  }
  cout << res;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
using Graph=vector<vector<int>>;
template<class T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main(){
    long long a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if(a==b){
        cout<<"YES"<<endl;
        return 0;
    }
    long long ba=max(b-a,a-b);
    long long x=ba+(w-v)*t;
    string ans=x<=0?"YES":"NO";
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i,first,last) for(int i=first;i<=last;++i)
#define DOW(i,first,last) for(int i=first;i>=last;--i)
using namespace std;
inline int Read()
{
	int x(0),f(1);
	char c(getchar());
	while(c<'0'||'9'<c)
	{
		if(c=='-')
		{
			f=-1;
		}
		c=getchar();
	}
	while('0'<=c&&c<='9')
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return f*x;
}
void Write(int x)
{
	if(x<0)
	{
		printf("-");
		x=-x;
	}
	if(9<x)
	{
		Write(x/10);
	}
	putchar(x%10+'0');
}
inline void Writeln(int x)
{
	Write(x);
	puts("");
}
struct Point
{
	double x,y;
	Point(double fx=0,double fy=0)
	{
		x=fx;
		y=fy;
	}
	void Read()
	{
		scanf("%lf%lf",&x,&y);
	}
	void Write(int len=2)
	{
		printf("%.9lf %.9lf",x,y);
	}
	double operator ^(Point const b)const
	{
		return x*b.x+y*b.y;
	}
	double operator |(Point const b)const
	{
		return x*b.y-b.x*y;
	}
	double operator ==(Point const b)const
	{
		return sqrt((x-b.x)*(x-b.x)+(y-b.y)*(y-b.y));
	}
	Point operator *(double const b)const
	{
		return Point(x*b,y*b);
	}
	Point operator +(Point const b)const
	{
		return Point(x+b.x,y+b.y);
	}
	Point operator -(Point const b)const
	{
		return Point(x-b.x,y-b.y);
	}
};
Point Symmetrical(Point a,Point m=Point(0,0))
{
	return Point(m.x*2-a.x,m.y*2-a.y);
}
/**
 *      /
 *   a /
 *    m
 *   / b
 * return b;
 */
struct Vector
{
	Point a,b;
	Vector(Point f=Point(0,0),Point e=Point(0,0))
	{
		a=f;
		b=e;
	}
	double operator ^(Vector const c)const
	{
		return (a.x-b.x)*(c.a.x-c.b.x)+(c.a.y-c.b.y)*(a.y-b.y);
	}
	double operator |(Vector const c)const
	{
		return (a.x-b.x)*(c.a.y-c.b.y)-(c.a.x-c.b.x)*(a.y-b.y);
	}
};
bool InRectangle(Point a,Point b,Point c)
{
	return
	min(b.x,c.x)<=a.x&&a.x<=max(b.x,c.x)
	&&
	min(b.y,c.y)<=a.y&&a.y<=max(b.y,c.y);
}
/**
 *   a
 *  b---*
 *  |   |
 *  *---c
 *  return 0;
 *
 *  b---*
 *  |a  |
 *  *---c
 *  return 1;
 */
bool RectangleIntersection(Point a0,Point a1,Point b0,Point b1)
{
	int zx=fabs(a0.x+a1.x-b0.x-b1.x);
	int zy=fabs(a0.y+a1.y-b0.y-b1.y);
	int x=fabs(a0.x-a1.x)+fabs(b0.x-b1.x);
	int y=fabs(a0.y-a1.y)+fabs(b0.y-b1.y);
	if(zx<=x&&zy<=y)
	{
		return 1;
	}
	return 0;
}
/**
 *  *---*
 *  |   |
 *  *---*
 *
 *    *--*
 *    |  |
 *    |  |
 *    *--*
 * return 0;
 *
 *  *---*
 *  | *-+*
 *  *-+-*|
 *    |  |
 *    *--*
 * return 1;
 */
bool Intersect(Vector a,Vector b)
{
	double a_aa=a|Vector(a.a,b.a);
	double a_ab=a|Vector(a.a,b.b);
	double b_aa=b|Vector(b.a,a.a);
	double b_ab=b|Vector(b.a,a.b);
	if(
		(
			a_aa==0
			||
			a_ab==0
			||
			((a_aa<0)^(a_ab<0))
		)
		&&
		(
			b_aa==0
			||
			b_ab==0
			||
			((b_aa<0)^(b_ab<0))
		)
	)
	{
		return RectangleIntersection(a.a,a.b,b.a,b.b);
	}
	return 0;
}
/**
 * \  /
 *   /
 *  /  \
 * /    \
 * return 0;
 *
 *    /
 *  \/
 *  /\
 * /  \
 * return 1;
 */
Point p0,p1,p2,p3;
const int MAXN=1e5+5;
void Work()
{
	p0.Read();
	p1.Read();
	p2.Read();
	p3.Read();
	printf("%d\n",Intersect(Vector(p0,p1),Vector(p2,p3)));
}
int main()
{
	int q;
	scanf("%d",&q);
	REP(i,1,q)
	{
		Work();
	}
	return 0;
}


Measured memory_bytes: 3228
#include<stdio.h>

int main(void){
    
    int S,h,m,s;
    
    scanf("%d",&S);
    
    h = S/3600;
    S = S-h*3600;
    m = S/60;
    s = S-m*60;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


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

int main() {
    long long  N; cin >> N; long long ans;
    for(long long i=1;i<100000;i++){
      if(i*i > N) break;
      else ans = i*i;  
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  int N, M, X;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  REP(i,M) {
    cin >> L.at(i) >> R.at(i);
  }
  sort ALL(L);
  sort ALL(R);
  X=R.at(0)-L.at(M-1);
  if(X<0) cout << 0 << endl;
  else cout << X+1 << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int res = 0;
  int l = 0, r = (int)S.size() - 1;
  while (l < r) {
    while (l < N && S[l] != 'W') {
      l++;
    }
    while (r >= 0 && S[r] != 'R') {
      r--;
    }
    if (l < r) res++;
    l++, r--;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll A, B, C;
  std::cin >> A >> B >> C;

  if (A > B) std::swap(A, B);
  if (C > A && C < B) print("Yes");
  else print("No");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }




vector<int> n_prime(int n) {
	vector<int> ret;
	vector<bool> is_prime(n + 1, 1);
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			ret.push_back(i);
			for (int j = i + i; j <= n; j += i) is_prime[j] = 0;
		}
	}
	return ret;
}

int main() {
	vci primes = n_prime(50000 * 2);
	int n;
	
	while (cin >> n) {		
		vci::iterator it = upper_bound(all(primes), n), it_ = it;
		it_--;
		if ((*it_)==n) it_--;
		cout << (*it_) << " " << (*it) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1332
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

  int N,M,L;
  cin>>N>>M>>L;
  //vector<int> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int>> A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  if(N==M&&M==L)cout<<"No"<<endl;
  else if(N!=M&&M!=L&&N!=L)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}



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

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

//qsort(array, n, size, cmp)
int cmp(const void *a,const void *b){ 
    if(*(int*)a < *(int*)b){
        return 1;
    }
    else if(*(int*)a == *(int*)b){
        return 0;
    }
    return -1;
}


int main(void){
	int n, k;
	int i;
	long long cnt = 0;
	scanf("%d%d",&n ,&k);
	int h[n];
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}

	qsort(h, n, sizeof(int), cmp);
//	for(i=1;i<=n;i++){
//		printf("%d\n",h[i-1]);
//	}

	for(i=1;i<=n;i++){
		if(i <= k){

		}
		else{
			cnt += h[i-1];
		}
	}
	printf("%lld\n",cnt);
    return 0; 
}


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

using namespace std;

#define F 		first
#define S 		second
#define ll 		unsigned long long
#define ld 		long double
#define pii		pair<int, int>
#define vi 		vector<int>
#define mii 	map<int, int>
#define umii 	unordered_map<int, int>
#define pb		push_back
#define mk		make_pair
#define all(a)	a.begin(), a.end()
#define ask(x) 	cerr << #x << " = " << x << "\n";
#define INF 	1000000007
#define hell 	998244353

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ll n, res = 1LL;
	bool z = 0;
	cin >> n;

	vector<ll> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (a[i] == 0)
			z = 1;
	}

	if (z) {
		cout << 0;
		return 0;
	}

	for (int i = 0; i < n; ++i) {
		if (a[i] <= 1000000000000000000LL / res)
			res *= a[i];
		else {
			cout << -1;
			return 0;
		}
	}

	cout << res;

	return 0;
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
} 

void solve()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  while(c>0 and a>0)
  {
  	c-=b;
    a-=d;
  } 
  if(c<=0) cout<<"Yes";
  else cout<<"No";
}


int main()       
{
  fastio
  ll tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>

int main(){
	int n,i,m,j;
	char *map,*ans;
	scanf("%d",&n);
	while(n>0){
	map=(char*)malloc(sizeof(char)*n*2);
	for(i=0;i<n;i++){
		scanf(" %c",&map[i*2]);
		scanf(" %c",&map[i*2+1]);
	}
	scanf("%d",&m);
	ans=(char*)malloc(sizeof(char)*m);
	for(i=0;i<m;i++){
		scanf(" %c",&ans[i]);
		j=0;
		while(j<n){
			if(ans[i]==map[j*2]){
				ans[i]=map[j*2+1];
				j=n;
			}else{
				j++;
			}
		}
	}
	for(i=0;i<m;i++){
		printf("%c",ans[i]);
	}
	printf("\n");
	free(ans);
	free(map);
	scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 668
n,*a=`dd`.split.map &:to_i;a.sort!
r=0
#(1<<n).times{|i|
b=[0]+n.times.map{|j|a[j]*(-1)**j%24}
s=24
(n+1).times{|j|(j+1..n).each{|k|s=[s,(b[j]-b[k])%24,(b[k]-b[j])%24].min}}
r=[r,s].max
#}
p r

Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
int main() {
	ll k,ans=0,slen,tmp=1,ss=1,se=1;
	string s;
	cin >> s >> k;
	slen=sz(s);
	for(ll i=0;i<slen;i++){
		if(slen==1) break;
		if(s.at(i)==s.at(i+1)) {
			tmp++;
		}
		else{
			ans+=tmp/2;
			tmp=1;
		}
		if(i+2>=slen) break;
	}
	se=tmp;
	ans+=tmp/2;
	ans*=k;
	if(s.at(0)==s.at(slen-1)){
		if(slen==1) ans=k/2;
		else if(slen==tmp){
			if(tmp%2==1) ans=(slen*k)/2;
		}
		else{
			for(ll i=0;i<slen-1;i++){
				if(s.at(0)==s.at(i+1)) ss++;
				else break;
			}
			if(ss%2==1 && se%2==1) ans+=k-1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    string s;
    cin >> s;
    int t = s.size();
    cout << s[0] << t-2 << s[t-1] << "\n";
    return 0;
}

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

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

    int cntF = 0;
    vector<vector<int>> dist(2, vector<int>(0));
    int index = 0;
    for (int i = 0; i < (int)s.size(); i++)
    {
        if (s.at(i) == 'F') cntF++;
        else {
            dist.at(index % 2).push_back(cntF);
            index++;
            cntF = 0;
        }
    }
    dist.at(index % 2).push_back(cntF);
    dist.at((index + 1) % 2).push_back(0);
    
    vector<vector<bool>> dpX((int)dist.at(0).size() + 1, vector<bool>(16001));
    if ((int)dist.at(0).size() == 0) dpX.at(0).at(8000) = true;
    else dpX.at(0).at(8000 + dist.at(0).at(0)) = true;
    for (int i = 1; i < (int)dist.at(0).size(); i++)
    {
        for (int j = 0; j <= 16000; j++)
        {
            int d = j - dist.at(0).at(i);
            if (d >= 0 && d <= 16000) {
                if (dpX.at(i - 1).at(d)) dpX.at(i).at(j) = true;
            }

            d = j + dist.at(0).at(i);
            if (d >= 0 && d <= 16000) {
                if (dpX.at(i - 1).at(d)) dpX.at(i).at(j) = true;
            }
        } 
    }
    vector<vector<bool>> dpY((int)dist.at(1).size() + 1, vector<bool>(16001));
    if ((int)dist.at(1).size() == 0) dpY.at(0).at(8000) = true;
    else {
        dpY.at(0).at(8000 + dist.at(1).at(0)) = true;
        dpY.at(0).at(8000 - dist.at(1).at(0)) = true;
    }
    for (int i = 1; i < (int)dist.at(1).size(); i++)
    {
        for (int j = 0; j <= 16000; j++)
        {
            int d = j - dist.at(1).at(i);
            if (d >= 0 && d <= 16000) {
                if (dpY.at(i - 1).at(d)) dpY.at(i).at(j) = true;
            }

            d = j + dist.at(1).at(i);
            if (d >= 0 && d <= 16000) {
                if (dpY.at(i - 1).at(d)) dpY.at(i).at(j) = true;
            }
        } 
    }

    if (dpX.at((int)dist.at(0).size() - 1).at(x + 8000) && dpY.at((int)dist.at(1).size() - 1).at(y + 8000)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 16256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.StringBuilder;
public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		char[] c = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
		int[] count = new int[c.length];
		String st;
		while((st = sc.readLine())!=null){
			st = st.toLowerCase();
			char[] ch = st.toCharArray();
			for(int i = 0;i < c.length;i++){
				for(int k = 0;k < ch.length;k++){
					if(ch[k]==c[i]){
						count[i]++;
					}
				}
			}
		}
		for(int i = 0;i < c.length;i++){
			sb.append(c[i]+" : "+count[i]+"\n");
		}
		System.out.print(sb);
	}
}

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

using namespace std;

int main()
{
	int i, s;
	string str;

	cin >>str;

	for(i=0; str[i] != NULL; i++)
	{
		if(str[i] == '+') s++;
		else s--;
	}
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;

int table[1 << 10];

// n 残りの残数
// s 合計
// bit mask
void solve(int mask, int n, int s) {
  if (table[mask] != 0) return;
  if (s == 0 && n == 0) {
    table[mask] = 1;
    return;
  }
  if (s < 0 || n <= 0) return;
  int sum = 0;
  for (int i = 0; i <= 9; i++) {
    if (((mask >> i) & 1) == 0) {
      solve(mask | 1 << i, n - 1, s - i);
    }
  }
  return;
}

void main() {
  while(true) {
    foreach(ref t; table) t = 0;
    auto line = readln.chomp.split(" ").map!(to!(int));
    int n = line[0];
    int s = line[1];
    if (n == 0 && s == 0) break;
    int sum;
    solve(0, n, s);
    foreach(t; table) sum += t;
    writeln(sum);
  }
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(n)for (int i=1;i<=n;++i)
const int N =1e5+10;
int n,ans,x[N],y[N],a,cnt;
map<int,int > mp,bo;
signed main()
{
	scanf("%lld",&n);
	rep(n)
	{
		scanf("%lld",&a);x[i]=y[i]=1;
		for(int j=2;j*j*j<=a;++j)
		{
			cnt=0;while (a%j==0) a/=j,++cnt;
			if (cnt%3==1) x[i]*=j,y[i]*=j*j;
			if (cnt%3==2) x[i]*=j*j,y[i]*=j;
		}
		x[i]*=a;
		y[i]*= (int)sqrt(a)*(int)sqrt(a)==a? sqrt(a) :a*a;
		++mp[x[i]];
	}
	rep(n) if (bo.count(x[i])==0)
	{
		bo[x[i]]=bo[y[i]]=1;
		if (x[i]==1) ++ans;
		else ans+=max(mp[x[i]],mp[y[i]]);
	}	
	return printf("%lld",ans),0;
}

Measured memory_bytes: 22400
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
    int a,b;
    scanf("%d %d",&a,&b);

    if(a<b)
    printf("0");
    else
    printf("10");
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int MAX=100000;
int n,nx[MAX+1],ny[MAX+1];
vector<int>xs,ys;
vector<pair<int,int>>nxs,nys;
void print(const vector<int>&xs){
  for(const auto&x:xs)cout<<x<<",";
  cout<<endl;
}
void print(const vector<pair<int,int>>&xs){
  for(const auto&x:xs)cout<<x.first<<"_"<<x.second<<",";
  cout<<endl;
}
main(){
  cin>>n;
  for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    if(i%2==1)
      xs.push_back(x);
    else
      ys.push_back(x);
  }
  // print(xs);
  // print(ys);
  for(const auto&x:xs)nx[x]++;
  for(const auto&y:ys)ny[y]++;
  for(int i=0;i<=MAX;i++){
    if(nx[i]){
      nxs.push_back({nx[i],i});
    }
  }
  for(int i=0;i<=MAX;i++){
    if(ny[i]){
      nys.push_back({ny[i],i});
    }
  }
  sort(nxs.begin(),nxs.end(),greater<pair<int,int>>());
  sort(nys.begin(),nys.end(),greater<pair<int,int>>());
  // print(nxs);
  // print(nys);
  int ans=-1;
  if(nxs[0].second!=nys[0].second){
    ans=n-nxs[0].first-nys[0].first;
  }else{
    int x_frequency=0;
    if(nxs.size()>=2)x_frequency=nxs[1].first;
    int y_frequency=0;
    if(nys.size()>=2)y_frequency=nys[1].first;
    const int x_moved=n-x_frequency-nys[0].first;
    const int y_moved=n-nxs[0].first-y_frequency;
    ans=min(x_moved,y_moved);
  }
  printf("%d\n",ans);
}

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

using namespace std;

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

    vector<int> p(N, 0);
    for(int i = 0; i < N; i++) cin >> p[i];

    int count = 0;
    bool status = false;
    for(int i = 0; i < N; i++) {
        if(p[i] == i+1 && status == false) {
            status = true;
            continue;
        }
        if(status == true) {
            count++;
            status = false;
        }
    }
    if(status == true) count++;

    cout << count << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,X;
    cin >> N >> X;
    vector<int> L(N);
    for (int i=0;i<N;i++){
        cin >> L.at(i);
        ///cout << L[i];
    }
    int D=0;
    int cnt=1;
    for (int i=0;i<N;i++){
        D+=L[i];
        if (D<=X){
            cnt++;
        }
        ///cout << D;
    }
    cout << cnt;
}

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

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

using namespace std;

int64_t replaceing(int64_t n, int64_t k) {
  if (n >= k) {
    return replaceing(n % k, k);
  } else {
    if (n <= (k / 2)) {
      return n;
    } else {
      return k - n;
    }
  }
}

int main() {
  int64_t n, k;
  cin >> n >> k;
  cout << replaceing(n, k) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
using Pa = pair<int, int>;
ll mod = 1000000007;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
int main() {
	int n; cin >> n;
	vector<bool>r(n,false);
	rip(i, n) {
		int a, b; cin >> a >> b;
		if (a == b)r[i] = true;
	}
	rip(i, n - 2) {
		if (r[i] && r[i + 1] && r[i + 2]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    repi(i,1,b+1){
        if(a*i%b==c){
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
}

Measured memory_bytes: 3644
ans_list = list()

while True:
    a,op,b = map(str,input().split())
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        ans_list.append(a+b)
    elif op == '-':
        ans_list.append(a-b)
    elif op == '*':
        ans_list.append(a*b)
    elif op == '/':
        ans_list.append(a//b)

for ans in ans_list:
    print(ans)



Measured memory_bytes: 5596
D, G = map(int, input().split())
P = [0]*D
C = [0]*D
for d in range(D):
    P[d], C[d] = map(int, input().split())

ans = 10000
for f in range(2**D):
    score_tot = 0
    q = 0
    for d in range(D):
        if f>>d&1:
            score_tot += C[d]+P[d]*(d+1)*100
            q += P[d]

    for d in range(D-1, -1, -1):
        if G <= score_tot: break
        if f>>d&1: continue
        score_d = (d+1)*100
        k = (G-score_tot-1)//score_d+1
        score_tot += min(k, P[d]) * score_d
        q += min(k, P[d])

    ans = min(ans, q)

print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int a[3],cnt=0,i;
	for(i=0;i<3;i++)
		scanf("%d",&a[i]);
	while(a[0]!=a[1]||a[1]!=a[2]){
		sort(a, a+3);
		if(a[0]<a[2]&&a[1]<a[2]){
			a[0]++;
			a[1]++;
		}
		else
			a[0]+=2;
		cnt++;
	}
	printf("%d\n",cnt);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    vector<int> num(3);
    rep(i, 3) cin >> num[i];
    sort(num.begin(), num.end());
    cout << num[0] + num[1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
	ll h,w,k;
	cin>>h>>w>>k;
    COMinit();	
	ll ans=0;
	ll H=(h-1)*h*(h+1)/6%inf*w%inf*w%inf;
	H*=COM(h*w-2,k-2);
	H%=inf;
	ll W=(w-1)*w*(w+1)/6%inf*h%inf*h%inf;
	W*=COM(h*w-2,k-2);
	W%=inf;
	ans+=H+W;
	ans%=inf;
    cout <<ans;
    // 計算例
//    cout << COM(100000, 50000) << endl;	
	// your code goes here
	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<double>v(n);

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

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

    for(int i = 0;i < n-1;i++){
        v[i+1] = (v[i]+v[i+1])/2;
        sort(v.begin(),v.end());
    }

    cout << v[n-1] << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args){
            int n = int.Parse(Console.ReadLine());
            for(int i=0;i<n;i++) {
                string[] str = Console.ReadLine().Split();
                Console.WriteLine(Math.Abs((double.Parse(str[2])-double.Parse(str[0]))*(double.Parse(str[7])-double.Parse(str[5]))-(double.Parse(str[3])-double.Parse(str[1]))*(double.Parse(str[6])-double.Parse(str[4])))<1e-10?"YES":"NO");
            }
        }
    }
}

Measured memory_bytes: 5716
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
char a[100001];
int main(){
	scanf("%s",a);
	int bj=0,bj1=0,ans=0,n=strlen(a);
    for(int i=0;i<n;i++)
		if(bj==bj1){
			bj++;
			if(a[i]=='p')
				ans--;
		}
		else{
			bj1++;
			if(a[i]=='g')
				ans++;
		}
    printf("%d\n",ans);                     
    return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    print(int(input())//3)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <cstdio>

using namespace std;

int main(void){
  int a[3] = {0,0,0};
  
  for (int i=0; i<3; i++){
    char c;
    scanf("%c", &c);
    a[c-'a'] = 1;
  }
  
  printf("%s\n", a[0]*a[1]*a[2]?"Yes":"No");
  return 0;
}

Measured memory_bytes: 128
object Main {
  def main(args:Array[String]) {
    val X = readLine().toInt
    val max = 100003
    var num = List.range(2, 100004)
    var prime = List[Int]()

    var n = num(0)
    while(n <= math.sqrt(max)) {
      prime = prime :+ n
      num = num.filter(_ % n != 0)
      n = num(0)
    }
    prime  = prime ::: num
    var ans = 0
    ans = prime.filter(_ >= X)(0)
    println(ans)
  }
}


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

int main(){
  int N;
  cin >> N;
  int A, B;
  int Ans=100000000;
  int subans=0;
  string S, T;
  int L, M;
  for(int i=1; i<=N/2; i++){
    subans=0;
    A=i;
    B=N-i;
    S=to_string(A);
    T=to_string(B);
    L=S.size();
    M=T.size();
    for(int i=0; i<L; i++){
      subans+=S.at(i)-'0';
    }
    for(int i=0; i<M; i++){
      subans+=T.at(i)-'0';
    }
    Ans=min(Ans, subans);
  }
  cout << Ans << endl;
}

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

int main(){
  int a,b,N,M;
  cin >> N >> M;
  int road[N+1];
  for(int i=1;i<=N;i++){
    road[i]=0;
  }
  for(int i=0;i<M;i++){
    cin >> a >> b;
    road[a]++;road[b]++;
  }
  for(int i=1;i<=N;i++){
    cout << road[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main()
{
	int n; cin >> n;
	string s; cin >> s;
	int countmp = 0;
	for (int i = 1; i < n; i++) {
		string a, b;
		a = s.substr(0, i);
		sort(a.begin(), a.end());
		b = s.substr(i, n - i);
		sort(b.begin(), b.end());
		//cout << a << endl << b << endl;
		int c = -34;
		int count = 0;
		for (int j = 0; j <= i-1; j++) {
			int tmp=b.find(a[j]);
			//cout << tmp << endl;
			if (tmp != c && tmp != -1) {
				c = tmp;
				count++;
			}
			//cout <<"count"<< count << endl;
		}
		if (count > countmp) {
			countmp = count;
		}
	}
	cout << countmp << endl;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  //for(int i = 0; i <= s.size(); i += 2) cout << s[i];
  REP(i,s.size()) {if(i % 2 == 0) cout << s[i];}
  cout << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 592
#include<iostream>
#include<vector>
using namespace std;
using pint=pair<int,int>;

int N;
vector<vector<pint>> v;

bool judge(int bit){
  for(int i=0;i<N;i++){
    if(!(bit&(1<<i))) continue;
    
    for(pint xy:v[i]){
      int x=xy.first;
      int y=xy.second;
      
      if(y==1&&!(bit&(1<<x))) return false;
      if(y==0&&(bit&(1<<x))) return false;
    }
       }
       return true;
       }
   
int main(){
  cin>>N;
  v.resize(N);
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    v[i].resize(A);
    for(int j=0;j<A;j++){
      cin>>v[i][j].first>>v[i][j].second;
      --v[i][j].first;
    }
  }
  int res=0;
  for(int bit=0;bit<(1<<N);bit++){
     if(judge(bit)){
       int count=0;
       for(int i=0;i<N;i++){
         if(bit&(1<<i)) ++count;
       }
  res=max(res,count);
     }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256