akhauriyash/Code-Regression huggingface dataset:
def p_c():
    from itertools import combinations
    n = int(input())
    d = [[set() for _ in range(2)] for _ in range(n)]
    for i in range(n):
        a = int(input())
        for _ in range(a):
            x, y = map(int, input().split())
            d[i][y].add(x-1)
    ans = []
    for i in reversed(range(1, n + 1)):
        for cmb in combinations(range(n), i):
            true_set = set()
            false_set = set()
            for j in range(n):
                if j in cmb:
                    true_set = true_set | d[j][1]
                    false_set = false_set | d[j][0]
                else:
                    false_set.add(j)
            if not true_set & false_set:
                ans.append(n - len(false_set))
    if ans:
        print(max(ans))
    else:
        print(0)
        
p_c()

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

using namespace std;

int arr[100005];

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

	long long sum = 0;

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

		sum += p;
	}

	cin >> Q;

	for (int i = 0; i < Q; i++) {
		int u, v;
		cin >> u >> v;

		sum += (v - u) * arr[u];
		arr[v] += arr[u];
		arr[u] = 0;

		cout << sum << endl;
	}
}


Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

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

using namespace std;

int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    while(1){
        C-=B;
        if(C<=0){
            cout<<"Yes";
            break;
        }
        A-=D;
        if(A<=0){
            cout<<"No";
            break;
        }
    }
}



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

using std::cin;
using std::cout;
using std::endl;
using std::vector;

struct key
{
  int price;
  int bits;
};
  
static int N, M;
static vector<vector<int>> match_keys;
static vector<key> keys;

static int memo[1 << 12];

static int min_price_dp(int n, int bits);

static int
min_price(int n, int bits)
{
  int bit = (1 << n);
  while (n < N && (bits & bit))
  {
    n++;
    bit <<= 1;
  }
  if (N <= n)
  {
    return 0;
  }
  vector<int> &v = match_keys[n];
  int min_cost = -1;
  for (auto key_index = v.begin(); key_index != v.end(); key_index++)
  {
    key &k = keys[*key_index];
    int cost = k.price + min_price_dp(n + 1, bits | k.bits);
    if (min_cost == -1 || cost < min_cost)
    {
      min_cost = cost;
    }
  }
  return min_cost;
}

static int
min_price_dp(int n, int bits)
{
  if (memo[bits] == 0)
  {
    memo[bits] = min_price(n, bits);
  }
  return memo[bits];
}

int
main()
{
  cin >> N >> M;
  match_keys.resize(N);
  keys.resize(M);
  for (int i = 0; i < M; i++)
  {
    struct key &k = keys[i];
    int nbits;
    cin >> k.price >> nbits;
    int bits = 0;
    for (int j = 0; j < nbits; j++)
    {
      int n;
      cin >> n;
      bits |= (1 << (n - 1));
      match_keys[n - 1].push_back(i);
    }
    k.bits = bits;
  }
  for (int n = 0; n < N; n++)
  {
    if (match_keys[n].size() == 0)
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << min_price_dp(0, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define INF 1e7
using namespace std;

const int MAX_V=200;

struct edge{int to,cap,rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
	G[from].pb((edge){to,cap,G[to].size()});
	G[to].pb((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
	if(v==t)return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		edge &e=G[v][i];
		if(!used[e.to] && e.cap>0){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow=0;
	for(;;){
		memset(used,0,sizeof(used));
		int f=dfs(s,t,INF);
		if(f==0)return flow;
		flow+=f;
	}
}

int main(){
	int n,m,u,v,c;
	cin>>n>>m;
	rep(i,m){
		cin>>u>>v>>c;
		add_edge(u,v,c);
	}
	cout<<max_flow(0,n-1)<<endl;
	return 0;
}

Measured memory_bytes: 3212
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

int main(void){
    int N;
    scanf("%d",&N);

    //A[0]~A[N-1]に格納する
    int* A;
    NEW(A,N);
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }

    long ans=0;
    for(int i=0;i<N;i++){
        while(A[i]%2==0){
            A[i]/=2;
            ans++;
        }
    }
    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;

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

vector<int> v;

void calc(){
    for(int i=2; i<=300000; i++){
        bool isMSprime;

        if((i+1)%7==0 || (i-1)%7==0) isMSprime=true;
        else continue;

        for(int j=2; j*j<=i; j++){
            if(i%j==0){
                if((j+1)%7==0 || (j-1)%7==0) isMSprime=false;
                if((i/j+1)%7==0 || (i/j-1)%7==0) isMSprime=false;
            }
        }

        if(isMSprime){
            v.eb(i);
        }
    }
}

int main(){
    calc();

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

        vector<int> ans;
        for(int i=0; i<v.size(); i++){
            if(n<v[i]) break;

            if(n%v[i]==0){
                ans.eb(v[i]);
            }
        }

        cout << n << ": ";
        for(int i=0; i<ans.size(); i++){
            if(i==ans.size()-1) cout << ans[i] << endl;
            else cout << ans[i] << " ";
        }
    }
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j) for(int i=0;i<j;i++)
#define print(a) cout<<a<<endl
typedef long long ll;
typedef string str;
typedef unsigned long long ul;
#define vint vector<int>

int main() {
	int n,k;cin>>n>>k;
	long double dn=n,dk=k,sum=0;
	rep(i,n){
		long double di=i+1,d=ceil(log2(dk/di));
		if(dk<=di){
			d=0;
		}
		sum+=(1/dn)*pow(0.5,d);
	}
	cout<<setprecision(16)<<sum<<endl;
	return 0;
}

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

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
	int N; cin >> N;
  	if(N%EDSum(N)==0) cout << "Yes" << endl; else cout << "No" << endl;
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n;cin>>n;
  ll a[2][n];rep(i,0,2)rep(j,0,n)cin>>a[i][j];

  ll dp[2][n];
  dp[0][0]=a[0][0];
  dp[1][0]=a[0][0]+a[1][0];

  rep(j,1,n){
    dp[0][j]=dp[0][j-1]+a[0][j];
    dp[1][j]=a[1][j];

    dp[1][j]+=max(dp[0][j],dp[1][j-1]);
  }

  out(dp[1][n-1]);


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();

		if(d == 25) {
			System.out.println("Christmas");
		} else if(d == 24) {
			System.out.println("Christmas Eve");
		} else if(d == 23) {
			System.out.println("Christmas Eve Eve");
		} else if(d == 22) {
			System.out.println("Christmas Eve Eve Eve");
		}
		sc.close();
	}
}

Measured memory_bytes: 22228
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal

INF = 1 << 50


def run():
    X, K, D = map(int, sysread().split())
    ans = INF
    if abs(X) > K * D:
        ans = abs(X) - K * D
        print(ans)
        return

    i = abs(X) // D
    if not (K - i) % 2:
        ans = abs(X) % D
        print(ans)
        return
    else:
        ans = D - (abs(X) % D)
        print(ans)




if __name__ == "__main__":
    run()

Measured memory_bytes: 9244
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef pair<int,P> Pii;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[6] = {1,0,0,-1,1,-1};
int dy[6] = {0,1,-1,0,1,-1};
#define INF 100000007
#define MOD 1000000007
#define ARRAY_MAX 1000005
//const ll INF = 1e17;

int dp[ARRAY_MAX];//dp[i]:数字iを作るのに必要な数字の個数
int dp2[ARRAY_MAX];
int num[300];

int main(){


    REP(i,ARRAY_MAX){
        dp[i] = dp2[i] = INF;
    }
    vector<int> odd;
    REP(i,200){
        num[i] = (i+1)*(i+2)*(i+3)/6;
        if(num[i] % 2 == 1){
            //奇数
            odd.push_back(num[i]);
        }
    }

    dp[0] = 0;
    for(int i = 0;i < 200;i++){
        for(int j = num[i];j < ARRAY_MAX;j++){
            dp[j] = min(dp[j],dp[j-num[i]]+1);
        }
    }

    dp2[0] = 0;//奇数のみ
    for(int i = 0;i < 200;i++){
        for(int j = num[i];j < ARRAY_MAX;j++){
            dp[j] = min(dp[j],dp[j-num[i]]+1);
        }
    }

    for(int i = 0;i < odd.size();i++){
        for(int j = odd[i];j < ARRAY_MAX;j++){
            dp2[j] = min(dp2[j],dp2[j-odd[i]]+1);
        }
    }

    int n;
    while(cin >> n,n){
        cout << dp[n] << " " << dp2[n] << endl;
    }



    return 0;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  if (N * A > B) {
    cout << B << endl;
  }
  if (N * A < B) {
    cout << N * A << endl;
  }
  if (N * A == B) {
    cout << B << endl;
  }
  
}




Measured memory_bytes: 256
o = str(input())
e = str(input())
length = min(len(o), len(e))
ans = ""
for i in range(length):
  ans = ans + o[i] + e[i]
if len(o) > len(e):
  ans += o[length]
elif len(e) > len(o):
  ans += e[length]
print(ans)

Measured memory_bytes: 3064
import java.util.*;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        BigInteger A = sc.nextBigInteger();
        BigInteger B = sc.nextBigInteger();
        //String str = sc.next();
        
        if(A.compareTo(B)==0){
            System.out.println("EQUAL");
        }else if(A.compareTo(B)>0){
            System.out.println("GREATER");
        }else if(A.compareTo(B)<0){
            System.out.println("LESS");
        }
        //System.out.println(ans);
    }
}


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

int main(){
    int n ;
    cin >> n;
    vector<tuple<string,int,int>> p(n);
    for (int i = 0; i < n; i++)
    {
        string x;
        int a;
        cin >> x >> a;
        tuple<string,int,int> t(x,-a,i+1);
        p[i] = t;
    }
    sort(p.begin(),p.end());
    for (int i = 0; i < n; i++)
    {
        cout << get<2>(p[i]) << endl;
    }
    

    

}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>

#define MIN(X,Y) ((X)<(Y)?(X):(Y))

#define N 26

int main(void){
    char buf[51];
    int usable[N], chrcnt[N];
    int n;
    
    scanf("%d", &n);
    memset(usable, 0, sizeof(usable));
    scanf("%s", buf);
    for (char *p=buf; *p != '\0'; p++){
        usable[*p-'a']++;
    }
    for (int i=1; i<n; i++){
        scanf("%s", buf);
        memset(chrcnt, 0, sizeof(chrcnt));
        for (char *p=buf; *p != '\0'; p++){
            chrcnt[*p-'a']++;
        }
        for (int j=0; j<N; j++){
            usable[j] = MIN(usable[j], chrcnt[j]);
        }
    }
    
    for (int i=0; i<N; i++){
        for (int j=0; j<usable[i]; j++){
            putchar('a'+i);
        }
    }
    puts("");
    
    return 0;
}
        

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int con = 0;
    if(a==b)
        con++;
    if(a==c)
        con++;
    if(b==c)
        con++;
    if(con == 1)
        puts("Yes");
    else
    {
        puts("No");
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  rep(i, n) {
    if(i < k) continue;
    if(a[i-k] < a[i]) cout << "Yes" << endl;
    else cout << "No" <<endl;
  }
  return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
  int n, ans=0;
  cin >> n;
  vector<int> v(100001, 0), a(n);
  rep(i, n){
    cin >> a.at(i);
    v.at(a.at(i))++;
  } 
  REP(i, 99999){
    ans = max(ans, v.at(i)+v.at(i-1)+v.at(i+1));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std; 
const int maxn = 100500;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    cout << n - k + 1 << '\n';
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

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

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

ll N,buf,ans;
int main() {
    cin>>N;
    REP(i,N){
        cin>>buf;
        while(buf%2==0){
            buf/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<list>
#include<algorithm>

int main(){
	int q, x;
	char com[20];
	std::list<int> v;
	scanf("%d", &q);
	for (int i = 0; i < q; ++i){
		scanf("%s", com);
		if (com[0] == 'i'){
			scanf("%d", &x);
			v.push_front(x);
		}
		else if (com[6] == 'L'){
			v.pop_back();
		}
		else if(com[6] == 'F'){
			v.pop_front();
		}
		else if(com[0] == 'd'){
			scanf("%d", &x);
			for (auto it = v.begin(); it != v.end(); ++it){
				if (*it == x){
					v.erase(it);
					break;
				}
			}
		}
	}
	int i = 0;
	for (auto it = v.begin(); it != v.end(); ++it){
		if (i++)printf(" ");
		printf("%d", *it);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 32084
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<limits.h>

void Sort(int A[], int N);

int main()
{
	int A = 0, B = 0;
	
	scanf("%d%d", &A, &B);

	int ans = (A - 1)*(B - 1);



	printf("%d", ans);

	return 0;
}

void Sort(int A[], int N) {
	for (int j = 0; j < N ; j++) {
		for (int i = 0; i < N - j; i++) {
			if (A[i] < A[i + 1]) {
				int tmp = A[i];
				A[i] = A[i + 1];
				A[i + 1] = tmp;
			}
		}
	}
}

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

using namespace std;

int main()
{
    int no_of_students, height;
    cin >> no_of_students >> height;

    int tall_students = 0;
    while(no_of_students--)
    {
        int height_here;
        cin >> height_here;

        tall_students += (height_here >= height);
    }

    cout << tall_students;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;

void solve() {
  ll n;
  cin >> n;
  vector<bool> a(n, false);
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    a[i] = (x == y);
  }
  bool ok = false;
  for (ll i = 0; i + 2 < n; i++) {
    if (a[i] && a[i+1] && a[i+2])
      ok = true;
  }
  if (ok) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

int main() {
  //ll T;
  //cin >> T;
  //rep(_,T)
    solve();
  return 0;
}


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

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;
ll func(int n, int k) {
    if (k == 0) {
        return 1;
    }

    ll ans = n;
    while (k > 1) {
        ans *= n;
        k--;
    }
    return ans;
}

string func2(ll _val) {
    if (_val <= 0) {
        return "";
    }

    ll n   = (_val % 26 == 0) ? 26 : _val % 26;
    char c = (char)('a' + n - 1);
    string ret{c};
    if (_val == n) {
        return ret;
    } else {
        return func2((_val - n) / 26) + ret;
    }
}

int main() {
    ll n;  // < 10^15+1
    cin >> n;

    cout << func2(n) << endl;
    return 0;
}


Measured memory_bytes: 3632
MOD = 1000000007

n, a, b = map(int, input().split())

# https://tex2e.github.io/blog/crypto/modular-mul-inverse
def xgcd(a, b):
	x0, y0, x1, y1 = 1, 0, 0, 1
	while b != 0:
		q, a, b = a // b, b, a % b
		x0, x1 = x1, x0 - q * x1
		y0, y1 = y1, y0 - q * y1
	return a, x0, y0

# https://tex2e.github.io/blog/crypto/modular-mul-inverse
def modinv(a, m):
	g, x, y = xgcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def combination(n, r):
	ans = 1
	for i in range(n - r + 1, n + 1):
		ans *= i
		ans %= MOD
	for i in range(1, r + 1):
		ans *= modinv(i, MOD)
		ans %= MOD
	return ans

ans = 0
ans += pow(2, n, MOD) - 1
ans += MOD - combination(n, a)
ans += MOD - combination(n, b)
ans %= MOD

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cstring>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int wf[10][10];
int main(){
    for(int e; cin >> e;){
        if(e == 0) return 0;
        rep(i, 10) rep(j, 10)
          if(i == j) wf[i][j] = 0; else wf[i][j] = INF;
        set <int> town;
        rep(i, e){
            int x, y, z;
            scanf("%d%d%d", &x, &y, &z);
            wf[x][y] = wf[y][x] = z;
            town.insert(x); town.insert(y);
        }
        int n = town.size();
        rep(k, n) rep(i, n) rep(j, n)
          wf[i][j] = min(wf[i][j], wf[i][k] + wf[j][k]);
        int nans = 0, tans = INF;
        rep(i, n){
            int temp = 0;
            rep(j, n) temp += wf[i][j];
            if(tans > temp){
                tans = temp;
                nans = i;
            }
        }
        cout << nans << " " << tans << endl;
    }
    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    P a[5];

    rep(i, 5) cin >> a[i].second;
    int b[5];
    rep(i, 5){
        if(a[i].second % 10 == 0) a[i].first = 10;
        else a[i].first = a[i].second % 10;
    }
    sort(a, a + 5);
    reverse(a, a + 5);


    int d = 0;
    rep(i, 4){
        if(a[i].second % 10 != 0) d += (a[i].second / 10 + 1) * 10;
        else d += a[i].second;
    }
    cout << d + a[4].second << endl;


}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<ll, int> pll;

int main()
{
  int M,T,P,R;
  while(cin>>M>>T>>P>>R,M||T||P||R) {
    int A[T+1],times[T+1],pena[T+1],miss[T+1][P+1];
    CLR(A);CLR(times);CLR(pena);CLR(miss);
    FOR(i,0,R) {
      int m, t, p, j;
      cin >> m >> t >> p >> j;
      if(j==0) {
        A[t]++;
        times[t] += m;
        pena[t] += miss[t][p] * 20;
      } else {
        miss[t][p]++;
      }
    }
    vector<pll> score(T);
    FOR(i,1,T+1) {
      ll s = A[i] * 1000000 - pena[i] - times[i];
      score[i-1] = pll(s, i);
    }
    sort(score.rbegin(), score.rend());
    int j = 1;
    ll now = score[0].first;
    vector<vector<int> > ans(T+1);
    FOR(i,0,T) {
      if(now > score[i].first) {
        j++;
        now = score[i].first;
      }
      ans[j].push_back(score[i].second);
    }
    FOR(i,1,T+1) {
      if((int)ans[i].size() > 0) {
        if(i!=1) cout << ',';
        vector<int> pr;
        FOR(j,0,(int)ans[i].size()) {
          pr.push_back(ans[i][j]);
        }
        sort(pr.rbegin(), pr.rend());
        FOR(j,0,(int)pr.size()) {
          if(j!=0) cout<<'=';
          cout << pr[j];
        }
      }
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FI          freopen("input.txt", "r", stdin)
#define FO          freopen("output.txt", "w", stdout)
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 3e3 + 5;
const ll mod = 1e8 + 7;
const double E = 1e-9;
//int dx[] = {0, -1}, dy[] = {-1, 0};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
string a, b;
int dp[N][N];
int f(int i, int j){
    if(i == sz(a) or j == sz(b))return 0;
    int &ans = dp[i][j];
    if(ans == -1){
        ans = 0;
        if(a[i] == b[j])
            ans = max(ans, f(i + 1, j + 1) + 1);
        else
            ans = max({ans, f(i + 1, j), f(i, j + 1)});
    }
    return ans;
}

void r(int i, int j){
    if(i == sz(a) or j == sz(b))return;
    int ans = f(i, j);

        if(a[i] == b[j] && ans == f(i + 1, j + 1) + 1){
            cout << a[i];
            r(i + 1, j + 1);
            return ;
        }
        else{
            if(ans == f(i + 1, j)){
                r(i + 1, j);
            }else r(i, j + 1);
        }
}
void solve(){
    cin >> a  >> b;
    cls(dp, -1);
    f(0, 0);
    r(0, 0);
}  
int main(){
    FIN;
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve(); 
    }
    EjecuteTime;
    return 0;
}       

Measured memory_bytes: 39360
#include <bits/stdc++.h>
#define PB push_back
#define ll long long
using namespace std;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	
	ll a[n+1], p = 1, ind = 0, m;
	bool vis[n+1];
	
	vector<ll> pe;
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
		vis[i] = 0;
	}
	while (vis[p] == 0) {
		pe.PB(p);
		vis[p] = 1;
		p = a[p];
	}
	while (pe[ind] != p) ind++;
	if (k < pe.size())
		cout << pe[k];
	else
		cout << pe[(k - ind) % (pe.size() - ind) + ind];
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100001

int N,M,S,T;
vi adj[maxn];
vpi adj2[maxn];
bool vis[maxn][3];
int dist[maxn][3];
vpi nodes[3];

int main(){
	fast;
	
	cin>>N>>M;
	
	FOR(i,0,M-1){
		int a,b; cin>>a>>b; adj[a].pb(b);
	}
	
	cin>>S>>T;
	

		
	queue <pi> q;
	q.push(pi(S,0));
		
	while (!q.empty()){
		pi cur = q.front(); q.pop();
			
		if (vis[cur.f][cur.s%3]) continue;
		vis[cur.f][cur.s%3] = 1;
		
		dist[cur.f][cur.s%3] = cur.s;
		aFOR(i,adj[cur.f]){
			q.push(pi(i,cur.s+1));
		}
	}
	
	if (vis[T][0] == 1) cout<<dist[T][0]/3;
	else cout<<-1;

		
}

Measured memory_bytes: 9600
// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl;
typedef unsigned long long ull;

int main() {
	IOS
	ull n, x, y, cnt=0;
	cin >> n >> x >> y;
	for(int i=0; i<n; i++) {
		ull t, k;
		cin >> t >> k;
		if(t>=x && k>=y) cnt++;
	}
	cout << cnt;
	return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
ll n,a,b,x,y;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>a>>b;
    if(a>b){
        cout<<0<<endl;
        return 0;
    }
    if(a==b){
        cout<<1<<endl;
        return 0;
    }

    if(n==1){
        if(a!=b) cout<<0<<endl;
        else cout<<1<<endl;
        return 0;
    }
    x=(n-2)*b;
    y=(n-2)*a;
    cout<<x-y+1<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int d,L,i=0;
	int a;
	scanf("%d%d",&d,&L);
	a=d%L;
	if(a==0){
		i=d/L;
	}
	else{
		i=d/L+a;
	}
	printf("%d\n",i);
	return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>
#include<time.h>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;


/*vectorの要素を全部確認するやつだよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; i++) {
	for (int j = 0; j < w; j++) {

	}
}

*/

/*まだ使えないテクニックのメモだよ。
for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ
*/


int main() {
	string a, b;
	cin >> a >> b;
	ll n = stoi(a + b);


	if (n == (ll)sqrt(n) * (ll)sqrt(n)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    v = tuple(map(int, input().split()))

    c_odd_most =  Counter(v[1::2]).most_common(2)
    c_even_most =  Counter(v[::2]).most_common(2)

    c_odd = c_odd_most[0][1]
    c_odd2 = c_odd_most[1][1] if len(c_odd_most) > 1 else 0
    c_even = c_even_most[0][1]
    c_even2 = c_even_most[1][1] if len(c_even_most) > 1 else 0

    if c_odd_most[0][0] == c_even_most[0][0]:
        if c_odd + c_even2 > c_odd2 + c_even:
            c_even = c_even2
        else:
            c_odd = c_odd2
    
    print(n - c_odd - c_even)

if __name__ == '__main__':
    main()


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

//create arrays outside of main()
int a[3] = {};

stack<char> s;


int main() {

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

    sort(a, a+3, greater<int>());

    cout << a[0]*10+a[1]+a[2];

    return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    string s, t;
    cin >> s >> t;
    if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)


int gcd(int a, int b) {
    if (a == 0 || b == 0) {
        return 0;
    }
    int tmp; int r;
    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int k;
    cin >> k;
    int r = 0;
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            for (int l = 1; l <= k; ++l) {
				r += gcd(gcd(i, j), l);
            }
        }
    }
    cout << r;
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

class Main {

    static int score(int iwana, int yamame, int a, int b, int c, int d) {
        return a * iwana + b * yamame + iwana / 10 * c + yamame / 20 * d;
    }

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

        int h1 = scan.nextInt();
        int h2 = scan.nextInt();
        int k1 = scan.nextInt();
        int k2 = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int d = scan.nextInt();

        int hiroshiScore = score(h1, h2, a, b, c, d);

        int kenjiroScore = score(k1, k2, a, b, c, d);

        if (hiroshiScore > kenjiroScore) {
            System.out.println("hiroshi");
        } else {
            if (hiroshiScore < kenjiroScore) {
                System.out.println("kenjiro");
            } else {
                System.out.println("even");
            }
        }
    }
}



Measured memory_bytes: 26224
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n, ans = 0;
    string s;
    cin >> n >> s;
    for(int i = 2; i < n; ++i){
        if(s.at(i - 2) == 'A' && s.at(i - 1) == 'B' && s.at(i) == 'C') ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

int main()
{
    int n, k; std::cin >> n >> k;
    int h, t;
    for (int i = 0; i < n; i++)
    {
        int a; std::cin >> a;
        if (a == 1)
        {
            h = t = i;
        }
    }
    k--; n--;

    std::cout << (n + k - 1) / k << std::endl;

    return 0;
}


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

int main(){
  int N;cin >> N;
  bool jud = false;
  
  if(N%1000 == 0){
    jud = true;
  }
  
  else if(N%1000%111 == 0){
    jud = true;
  }
  
  else if(N/10 %111 == 0){
    jud = true;
  }
  
  if(jud){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
int main() {
  int N;
  cin >> N;
  vector<int64_t> X(N + 1);
  X.at(0) = 2;
  X.at(1) = 1;
  rep2(i, 2, N) {
    X.at(i) = X.at(i - 1) + X.at(i - 2);
  }
  cout << X.at(N) << endl;
}


Measured memory_bytes: 3576
#include "bits/stdc++.h"
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1286
using namespace std;
#define ll long long
int n, m, k;
void dfs(int now, int Sum,map<int,int>& M) {
	if (now == n) {
		M[max(Sum - k, 1)]++;
		return;
	}
	else {
		for (int i = 1; i <= m;i++) {
			dfs(now + 1, Sum + i, M);
		}
	}
	return;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	while (cin >> n >> m >> k) {
		if (n == 0 && m == 0 && k == 0)break;
		map<int, int> M;
		dfs(0, 0, M);
		double ans = 0;
		for (auto it = M.begin();it != M.end();it++) {
			//cout << it->first << " " << it->second << endl;
			ans += ((double)it->first) / (double)pow(m,n) *(it->second);
		}
		cout << fixed << setprecision(10) << ans << endl;
	}
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=998244353,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  cin >> s;
  if(s.size()==3) reverse(all(s));
  pr(s);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MAX=1000000007;



signed main() {
   int n,m;
   cin>>n>>m;
   int a[m];
   for(int i=0;i<m;i++)cin>>a[i];
   int t=0,ans0=1,ans1=1,p;
   if(a[t]==1){
       t++;
       ans1=0;
   }
   for(int i=2;i<=n;i++){
       p=ans1;
       ans1=(ans1+ans0)%MAX;
       ans0=p;
       if(t<m){if(a[t]==i){
           t++;
           ans1=0;
       }
       }

   }
   cout<<ans1;
   return 0;

}


Measured memory_bytes: 1024
import sys
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))

near = sys.maxsize
ans = 0

for i in range(n):
  if abs(a - (t-h[i]*0.006)) < near:
    ans = i+1
    near = abs(a - (t-h[i]*0.006))

print(ans)

Measured memory_bytes: 9260
s = list(input())
sc = [0]*(len(s)+1)
key = 0
pre = ''
n = len(s)
        
if s[0] == '<':
    sc[0] = 0
    sc[1] = 1
    pre = 'l'
else:
    key += 1
    pre = 'r'
    
for i in range(1,n):
    if pre == 'l':
        if s[i] == '<':# <a<
            sc[i] = sc[i-1] + 1
            pre = 'l'
        else:#<a>
            sc[i] = sc[i-1] + 1
            key += 1
            pre = 'r'
    else:
        if s[i] == '<':# > a <
            while key > 0:
                sc[i-key] = max(key,sc[i-key])
                key = key -1
            sc[i] = 0
            sc[i+1] = 1
            pre = 'l'
        else:# > a >
            key += 1
            pre = 'r' 
    
if pre == 'l':
    sc[n] = sc[n-1] + 1
else:
    while key > 0:
        sc[n-key] = max(key,sc[n-key])
        sc[n] = 0
        key = key -1
        
print(sum(sc))

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

int main() {
  string a, b;

  cin >> a >> b;

  if (a == "H" && b == "H") cout << "H" << endl;
  if (a == "H" && b == "D") cout << "D" << endl;
  if (a == "D" && b == "H") cout << "D" << endl;
  if (a == "D" && b == "D") cout << "H" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);


char al[5]={'a','i','u','e','o'};
int main() {
int n;
while(true){
    cin>>n;
    if(n==0)break;
    map<string,int> m;
    int mstr=0;
    rep(i,n){
        string s;
        cin>>s;
        string st;
        st+=s[0];
        for(int j=0;j<s.size()-1;j++){
            rep(k,5) {
                if (s[j]==al[k]){
                    st+=s[j+1];
                    break;
                }
            }
        }
        mstr=max(mstr,int(st.size()));
        m[st]++;
    }
    bool ll=true;


    if(ll) {
        int kk = 1;
        while (true) {
            if(kk==mstr+1){cout<<-1<<endl;break;}
            map<string, int> mm;
            for (auto &&a:m) {
                string sl;
                sl = a.first.substr(0, kk);
                mm[sl]++;
            }

            if (mm.size() == n ) {
                cout << kk << endl;
                break;
            } else {
                kk++;
            }

        }
    }


}



    return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int sum=0;
  vector<int>a(n);
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  sort(a.begin(),a.end());
  for(int o=0;o<k;o++)
  {
      sum=sum+a[n-1-o];
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 256
/**akshaykumar01**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+2;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;

int main()
{
    IOS();
  
    int n,i;
    cin>>n;
    int a[n];
    f(i,0,n)
      cin>>a[i];
    int ans=0,mx=0;
    f(i,0,n-1)
    {
      if(a[i]>=a[i+1])
        ans++;
      else
      {
        mx=max(ans,mx);
        ans=0;
      }

    }
    mx=max(ans,mx);
    cout<<mx;
    return 0;
  
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		char c = saori.nextHayami().charAt(0);
		if(c == 'z'){
			System.out.println("z");
		} else {
			c = (char)(c+1);
			System.out.println(c);
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
from heapq import heapify, heappop, heappush


class MaxHeap:
    def __init__(self, li):
        self.hp = []
        for e in li:
            heappush(self.hp, -e)

    def push(self, x):
        heappush(self.hp, -x)

    def pop(self):
        ret = heappop(self.hp)
        ret *= -1
        return ret

    def seak(self):
        return -self.hp[0]

    def sum(self):
        return -sum(self.hp)


n = int(input())
a = list(map(int, input().split()))

f = a[:n]
s = a[n:2*n]
t = a[2*n:]

heapify(f)
t = MaxHeap(t)

f_sm = sum(f)
f_sm_li = [f_sm]
for e in s:
    heappush(f, e)
    f_sm += e
    pp = heappop(f)
    f_sm -= pp
    f_sm_li.append(f_sm)

t_sm = t.sum()
t_sm_li = [t_sm]
for e in s[::-1]:
    t.push(e)
    t_sm += e
    pp = t.pop()
    t_sm -= pp
    t_sm_li.append(t_sm)

t_sm_li = t_sm_li[::-1]
ans = -float("inf")
for ef, et in zip(f_sm_li, t_sm_li):
    ans = max(ans, ef - et)

print(ans)


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

const int mod = 1000000007;

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


Measured memory_bytes: 3680