akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
long long int a,b,n;
int main(){
	scanf("%lld %lld %lld",&n,&a,&b);
	long long int c=a+b;
	long long int k=n/c;
	long long int ans=a*k;
	ans+=(n%c<a?n%c:a);
	printf("%lld",ans);
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)

	n := nextInt()
	d := int64(nextInt())
	cnt := 0

	for i := 0; i < n; i++ {
		x := int64(nextInt())
		y := int64(nextInt())

		if x*x+y*y <= d*d {
			cnt++
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 5864
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=1005;

int n,m,k;
ll a[maxn],b[maxn],c[maxn],ans=0,d[maxn];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%lld%lld%lld",a+i,b+i,c+i);
	
	for(int j=0;j<8;j++){
		ll now=0;
		k=0;
		
		for(int i=1;i<=n;i++){
			d[++k]=((j&1)?-a[i]:a[i])+((j&2)?-b[i]:b[i])+((j&4)?-c[i]:c[i]);
		}
		
		sort(d+1,d+k+1);
		
		for(int i=k-m+1;i<=k;i++) now+=d[i];
		
		ans=max(ans,now);
	}
	
	printf("%lld\n",ans);
	
	return 0;
}

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

int main()
{
    int N, M, R;
    std::cin >> N >> M >> R;
    std::vector<int> r(R);
    for (int i = 0; i < R; i++) {
        std::cin >> r[i];
        r[i]--;
    }

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

    constexpr int INF = 1e9;
    std::vector<std::vector<int>> d(N, std::vector<int>(N, INF));
    for (int i = 0; i < N; i++)
        d[i][i] = 0;

    for (int i = 0; i < M; i++) {
        int A, B, C;
        std::cin >> A >> B >> C;
        A--; B--;
        d[A][B] = d[B][A] = C;
    }

    for (int k = 0; k < N; k++)
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);

    int min_dist = INF;
    do {
        int dist = 0;
        for (int i = 1; i < (int)r.size(); i++)
            dist += d[r[i - 1]][r[i]];

        min_dist = std::min(min_dist, dist);
    } while (std::next_permutation(r.begin(), r.end()));

    std::cout << min_dist << std::endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,v,l[200005],b,e;
int main(){
	cin>>n;
	b=ceil((double)(n+1)/2);
	e=(n%2==0)?(-1):(1);
	for(int i=1;i<=n;i++){
		cin>>v;
		l[b]=v;
		b+=i*e;
		e*=-1;
	}
	for(int i=1;i<=n;i++)
	cout<<l[i]<<" ";
	return 0;
}


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

  
int main() {
  int N;
  cin >> N;
  vector<int > d(N);
  for(int i=0;i<N;i++){
   cin >> d[i]; 
  }
  int ans =0;
  for(int i=0;i<N;i++){
   for(int j=0;j<N;j++){
    if(i !=j){
	ans += d[i]*d[j];
    }
   }
  }
  cout << ans/2 <<endl;
}

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

#define fi first
#define se second

typedef long long ll;
typedef pair<int,int> pii;
ll dp[1 << 10][1000];
ll ans[11][1000];

int main() {
	vector<pii> v;
	for(int i = 0; i < (1 << 10); i++) {
		int tmp = i;
		pii a = pii(0,i);
		while(tmp) {
			tmp -= tmp & (-tmp);
			a.fi++;
		}
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	dp[0][0] = 1;
	for(int i = 0; i < v.size(); i++) {
		for(int j = 0; j < 1000; j++) {
			for(int k = 0; k < 10; k++) {
				if(!(v[i].se & (1 << k)) && j+k*(v[i].fi+1) < 1000) {
					dp[v[i].se | (1 << k)][j+k*(v[i].fi+1)] += dp[v[i].se][j];
				}
			}
		}
	}
	for(int i = 0; i < v.size(); i++) {
		for(int j = 0; j < 1000; j++) {
			ans[v[i].fi][j] += dp[v[i].se][j];
		}
	}
	int n, s;
	while(cin >> n >> s) {
		cout << ans[n][s] << endl;
	}
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int w,a,b;cin>>w>>a>>b;

    if(a<b){
        cout<<max(b-(a+w),0)<<endl;
    }
    else{
        cout<<max(a-(b+w),0)<<endl;
    }

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    int size = s.size();
    int count = 0;
    for(int i = 0; i < size; i++){
        if(s[i] >= '0' && s[i] <= '9'){
            count++;
        }else if(s[i] == '-'){
            if(count != a){
                cout << "No\n";
                return 0;
            }
            count = 0;
        }else{
            cout << "No\n";
            return 0;
        }
    }
    if(count != b){
        cout << "No\n";
        return 0;
    }
    
    cout << "Yes\n";
}


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

const string words[] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string s, result = "YES";
    cin >> s;
    for (int i = s.size(); i > 0; ) {
        bool found = false;
        for (auto& w : words) {
            if (i >= w.size() && s.compare(i - w.size(), w.size(), w) == 0) {
                found = true;
                i -= w.size();
                break;
            }
        }
        if (!found) {
            result = "NO";
            break;
        }
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Solution
{
    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int whiteN = vals[0];
        int blackN = vals[1];

        int n = 100;

        var field = Enumerable.Range(0, n).Select(_ => new char[n]).ToArray();
        whiteN--;
        blackN--;
        for (int i = 0; i < n / 2; i++)
        {
            for (int j = 0; j < n; j++)
            {
                field[i][j] = '#';
            }
        }
        for (int i = n / 2; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                field[i][j] = '.';
            }
        }

        for (int i = 0; i < n / 2; i += 2)
        {
            for (int j = 0; j < n; j += 2)
            {
                if (whiteN > 0)
                {
                    field[i][j] = '.';
                    whiteN--;
                }
                else
                {
                    goto black;
                }
            }
        }

        black:
        for (int i = 1 + n / 2; i < n; i += 2)
        {
            for (int j = 0; j < n; j += 2)
            {
                if (blackN > 0)
                {
                    field[i][j] = '#';
                    blackN--;
                }
                else
                {
                    goto end;
                }
            }
        }

        end:
        var answer = new StringBuilder();

        for (int i = 0; i < n; i++)
        {
            answer.AppendLine(new string(field[i]));
        }

        Console.WriteLine($"{n} {n}");
        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 13460
import java.util.*;
import java.io.*; 
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void solve(int TC) throws Exception{
        String s = n();
        for(int i = 0; i< s.length(); i++)p('9'-s.charAt(i)+1);
    }
    //SOLUTION ENDS
    long mod = (int)1000000001, IINF = (long)1e14;
    final int MAX = (int)1e6+1, INF = (int)1e14, root = 3;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = true;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{    
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }   
            return str;
        }
    }
}   

Measured memory_bytes: 25556
#include<iostream> 
#include<vector>
#include<cmath>
#include<cstdio>

using namespace std;

int cont = 0;

void Smethod(int a)
{
	if(cont == 10) return;
	int y[8];
	for(int i = 0; i < 8; i++)
	{
		y[i] = a % 10;
		a = floor(a / 10);
	}
	int b = y[5]*1000 + y[4]*100 + y[3]*10 + y[2];
	cout << b << endl;
	cont++;
	Smethod(b*b);
}

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

	for(int i = 1; i <= n; i++)
	{
		cin >> a;
		printf("Case %d:\n",i);
		Smethod(a*a);
		cont = 0;
	}
}

Measured memory_bytes: 0
#include <cstdio>

int main()
{
    int n, i;
    int arr[100];
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf(" %d", &arr[i]);
    }
    for (i = 0; i < n; i++)
    {
        if (i)
            printf(" ");
        printf("%d", arr[n - i - 1]);
    }
    printf("\n");
}


Measured memory_bytes: 2716
#include <stdio.h>

#define MAX 100005
#define NIL -1

typedef struct { int p, l, r;} Node;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if( T[u].p == NIL ) printf("root, ");
  else if( T[u].l == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0, c=T[u].l; c != NIL; i++, c=T[c].r) {
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}

int main(void) {
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++) {
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r =c;
      l = c;
      T[c].p = v;
    }
  }
  for(i=0;i<n;i++) {
    if(T[i].p == NIL) r = i;
  }
  
  rec(r,0);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 7268
def num_from_stdin():
    import sys
    return int(sys.stdin.readline())
def nums_from_stdin():
    import sys
    return [ int(num) for num in sys.stdin.readline().strip().split(' ')]

nums = nums_from_stdin()

num = max(nums)

if nums[0] == nums[1]:
    print(num*2)
else:
    print(num*2-1)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

string S;
int indeg[60],outdeg[60];
vector<int> g[60];
bool vis[60];
int N;

int char2v(char c){
  if('A'<=c&&c<='Z')return c-'A';
  else return c-'a'+26;
}

bool dfs(int v){
  vis[v]=true;
  for(int nv : g[v]){
    if(nv==char2v(S[N-1]))return true;
    if(vis[nv])continue;
    if(dfs(nv))return true;
  }
  return false;
}

bool check(int v){
  int cnt=0;
  for(int nv : g[v]){
    memset(vis,0,sizeof(vis));
    vis[v]=true;
    if(nv==char2v(S[N-1])){
      cnt++; continue;
    }
    if(v==nv)continue;
    if(dfs(nv))cnt++;
  }
  return cnt>=2;
}

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

  while(1){
    cin>>S;
    if(S=="#")break;
    N=S.size();
    if(N<=2){
      cout<<"No Results"<<endl;
      continue;
    }
    int V=26*2;
    rep(i,V)g[i].clear();
    memset(indeg,0,sizeof(indeg)); memset(outdeg,0,sizeof(outdeg));
    memset(vis,0,sizeof(vis));

    map<string,bool> used;
    bool deled=false;
    int res=0;
    rep(i,N-1){
      if(used[S.substr(i,2)]){
        deled=true;
        continue;
      }
      res++;
      used[S.substr(i,2)]=true;
      outdeg[char2v(S[i])]++; indeg[char2v(S[i+1])]++;
      g[char2v(S[i])].push_back(char2v(S[i+1]));
    }

    if(!deled){
      if(S[0]==S[N-1]){
        cout<<N<<endl;
        continue;
      }
      bool ok=false;
      rep(i,V)if(outdeg[i]>=3||check(i))ok=true;
      if(ok)cout<<N<<endl;
      else cout<<N+1<<endl;
    }else{
      int cnt=0;
      rep(i,V)if(indeg[i]>outdeg[i])cnt+=indeg[i]-outdeg[i];
      cnt=max(0,cnt-1);
      cout<<res+cnt+1<<endl;
    }
  }

  return 0;
}



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

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

constexpr int MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;

  mp::int128_t ans = 0;
  bool ok = true;
  for (int i = 0; i < n; ++i) {
    mp::int128_t a;
    cin >> a;
    if (a == 0) {
      ans = 0;
      break;
    }
    if (ok) {
      if (i == 0) {
        ans += a;
      } else {
        ans *= a;
      }
      if (ans > 1000000000000000000) {
        ans = -1;
        ok = false;
      }
    }
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3680
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long K, X, Y, x, y, ori_X, ori_Y;
vector<pair<int, int> > ans;

pair<int, int> fun(pair<int, int> x, pair<int, int> y, pair<int, int> u, pair<int, int> v)
{
	int ta = x.fi + x.se, tb = u.se - u.fi;
	int l = x.fi, r = y.fi + 1;
	while (l + 1 < r) {
		int mx = (l + r) / 2;
		int my = ta - mx;
		if (my - mx >= tb) {
			l = mx;
		}
		else {
			r = mx;
		}
	}
	return { l, ta - l };
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> K >> X >> Y;
	ori_X = X; ori_Y = Y;
	X = abs(X); Y = abs(Y);
	if (K % 2 == 0 && (X + Y) % 2) {
		cout << -1 << E;
		return 0;
	}
	while (1) {
		if (x + K >= X || (abs(x - X) + abs(y - Y)) <= 2 * K) break;
		x += K;
		ans.pb({ x, y });
	}
	while (1) {
		if (y + K >= Y || (abs(x - X) + abs(y - Y)) <= 2*K) break;
		y += K;
		ans.pb({ x, y });
	}
	bool ok = false;
	if ((abs(x - X) + abs(y - Y)) == K) {
		ok = true;
		ans.pb({ X, Y });
	}
	int l, r;
	if (!ok) {
		if (K % 2 && (abs(x - X) + abs(y - Y)) % 2) {
			y = y + K;
			ans.pb({ x, y });
			if (abs(x - X) >= abs(y - Y)) {
				ans.pb(fun({ x, y + K }, { x + K, y }, { X - K, Y }, { X, Y + K }));
			}
			else {
				ans.pb(fun({ x - K, y }, { x, y - K }, { X - K, Y }, { X, Y + K }));
			}
		}
		else {
			if (abs(x - X) >= abs(y - Y)) {
				ans.pb(fun({ X - K, Y }, { X, Y - K }, { x, y - K }, { x + K, y }));
			}
			else {
				ans.pb(fun({ X - K, Y }, { X, Y - K }, { x - K, y }, { x, y + K }));
			}
		}
		ans.pb({ X, Y });
	}

	cout << ans.size() << E;
	for (int i = 0; i < (int)ans.size(); i++) {
		if (ori_X < 0) ans[i].fi = -ans[i].fi;
		if (ori_Y < 0) ans[i].se = -ans[i].se;
		cout << ans[i].fi << " " << ans[i].se << E;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define popb pop_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define reprev(i,n) for(ll i=n;i>=0;i--)
#define all(c) c.begin(),c.end()

const int N = 3e5+1;

using namespace std;

// vector <int> adj[N];
// int arr[N];

void solve(){
	int n;
	cin >> n;
	cout << 180*(n-2);

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

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

    int N,M; cin >> N >> M;
    vc<pi> ans;
    int a=(M+1)/2,b=a+1;
    rep(i,(M+1)/2){
        ans.eb(a--,b++);
    }
    b=N-M/2+1; a=b-2;
    rep(i,M/2){
        ans.eb(a--,b++);
    }
    for(auto an:ans){
        cout << an.fi << " " << an.se << endl;
    }
}

Measured memory_bytes: 5272
//ABC093 A
#include <iostream>
using namespace std;

int main(){
string s;
cin>>s;
if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba"){
    cout<<"Yes"<<endl;
    }
else{
    cout<<"No"<<endl;
    }
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> Ateam(N+1);
  vector<int> Bteam(M+1);
  cin >> Ateam.at(0) >> Bteam.at(0);
  for(int i=1;i<=N;i++){
    cin >> Ateam.at(i);
  }
  sort(Ateam.begin(), Ateam.end());
  for(int i=1;i<=M;i++){
    cin >> Bteam.at(i);
  }
  sort(Bteam.begin(), Bteam.end());
  if(Ateam.at(N)<Bteam.at(0)){
    cout << "No War" << endl;
  }
  else cout << "War" << endl;
}
  
  

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
#define NIL NULL
 
struct node {
  int key;  
  struct node *right;
  struct node *left;
  struct node *parent;
};

struct node *root;
struct node *find(int);

void inOrder(struct node *);
void preOrder(struct node *);
void insert(int);
void delete(struct node *);

struct node *min(struct node *);
struct node *successor(struct node *);
 
 
int main()
{
  int i, x, n, key;
  char s[10];
 
  scanf("%d", &n);
  for(i=0; i<n; i++) {
    scanf("%s", s);
    if(strcmp("insert", s) == 0) {
      scanf("%d", &x);
      insert(x);
    }
    else if(strcmp("print", s) == 0) {
      inOrder(root);
      printf("\n");
      preOrder(root);
      printf("\n");
    }
    else if(strcmp("find", s) == 0) {
      scanf("%d", &key);
      if(find(key) != NIL){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
    else if(strcmp("delete", s) == 0) {
      scanf("%d", &key);
      delete(find(key));
    }
  }
  return 0;
}
 
void inOrder(struct node *T)
{
  if(T != NIL) {
    if(T->left != NIL)
      inOrder(T->left);
    printf(" %d", T->key);
    if(T->right != NIL)
      inOrder(T->right);
  }
}
 
void preOrder(struct node *T)
{
  printf(" %d", T->key);
  if(T != NIL) {
    if(T->left != NIL)
      preOrder(T->left);
    if(T->right != NIL)
      preOrder(T->right);
  }
}
 
void insert(int key)
{
  struct node *y = NIL;
  struct node *x = root;
  struct node *z;
 
  z = (struct node *)malloc(sizeof(struct node));
  z->key = key;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL) {
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;
  if(y == NIL)
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;
}
 
struct node *find(int key)
{
  struct node *x = root;
  while((x != NIL) && (key != x->key)) {
    if(key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  return x;
}
 
struct node *min(struct node *x)
{
  while(!(x->left == NIL)){
    x = x->left;
  }
  return x;
}
 
struct node *successor(struct node *x)
{
  if(!(x->right == NIL)){
    return min(x->right);
  }

  struct node *y = x->parent;

  while((y != NIL) && (x == y->right)) {
    x = y;
    y = y->parent;
  }
  return y;
}
 
void delete(struct node *z)
{
  struct node *y;
  struct node *x;
 
  if((z->left == NIL) || (z->right == NIL)){
    y = z;
  }
  else{
    y = successor(z);
  }
  if(y->left != NIL){
    x = y->left;
  }
  else{
    x = y->right;
  }
 
  if(x != NIL){
    x->parent = y->parent;
  }
  if(y->parent == NIL){
    root = x;
  }
  else {
    if(y == y->parent->left){
      y->parent->left = x;
    }
    else{
      y->parent->right = x;
    }
  }
   
  if(y != z){
    z->key = y->key;
  }
  free(y);
}

Measured memory_bytes: 19364
import math
import itertools

N = int(input())
X, Y = [], []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

D = [[0 for _ in range(N)] for _ in range(N)]

for i in range(N):
    for j in range(N):
        D[i][j] = math.sqrt((X[i] - X[j]) ** 2 + (Y[i] - Y[j]) ** 2)


res = 0
for t in itertools.permutations([i for i in range(N)]):
    for j in range(1, N):
        res += D[t[j]][t[j - 1]]
print(res / math.factorial(N))


Measured memory_bytes: 3188
A = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
n, *D = map(int, open(0).read().split())
for b, f, r, d in zip(*[iter(D)]*4):
    A[b-1][f-1][r-1] += d
for i in range(4):
    for j in range(3):
        print(' '+' '.join(map(str, list(A[i][j]))))
    if i + 1 in range(4):
        print('#'*20)



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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

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

  string ret = S;
  ret[K - 1] = S[K - 1] - 'A' + 'a';
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
from math import factorial
from math import sqrt
from math import ceil
from itertools import permutations
from heapq import *
from collections import defaultdict
from copy import deepcopy
from math import log
from itertools import accumulate


N=int(input())
A=list(map(int,input().split()))
sums=list(accumulate([0]+A))
def nCr(n,r):
    a=factorial(n)
    b=factorial(n-r)
    c=factorial(r)
    return int(a//(b*c))
dic=defaultdict(int)
for i in sums:
    dic[i]+=1
ans=0
for i in dic.keys():
    if dic[i]>=2:
        ans+=nCr(dic[i],2)
print(ans)


Measured memory_bytes: 113856
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};



int main() {
    string s,t;cin>>s>>t;
    for(auto i = 0; i<t.size();i++){
        if(s==t){cout<<"Yes"<<endl; return 0;}
        rotate(t.begin(),t.begin()+1,t.end());
    }
    cout<<"No"<<endl;
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    string s;
    cin >> s;
    ll l[3] = {0}; // a, b, c
    rep(i, s.length()){
        l[s[i] - 'a' ]++;
    }
    ll mi = min(min(l[0], l[1]), l[2]);
    if(s.length() == 1) cout << "YES" << endl;
    else if(s.length() == 2){
        if(s[0] == s[1]) cout << "NO" << endl;
        else cout << "YES" << endl;
    }else if((s.length() - mi*3) > 2) cout << "NO" << endl;
    else{
        ll cnt = 0;
        rep(i, 3){
            l[i] -= mi;
            if(l[i] == 0) cnt++;
        }
        if(cnt == 1 || cnt == 0 || (s.length() - mi*3) == 1 || (s.length() - mi*3) == 0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int x;
  cin >> x;
  cout << (x == 7 || x == 5 || x == 3 ? "YES" : "NO") << endl;
}



Measured memory_bytes: 256
n = gets.chomp.to_i
queue = Array.new
n.times do
  order = gets.split(" ")
  case order[0]
    when "insert"
      queue.unshift(order[1].to_i)
    when "delete" 
      queue.index(order[1].to_i) == nil ? (next): (queue.delete_at(queue.index(order[1].to_i)))
    when "deleteFirst"
    queue.shift
    when "deleteLast"
    queue.pop
  end
end
(queue.size).times do |num|
  print queue[num]
  num+1 == (queue.size) ? (print "\n") : (print " ")
end


Measured memory_bytes: 21288
using System;
using System.Collections.Generic;

namespace Atc_0020
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            string str = Console.ReadLine();

            var nums = str.Split(' ');

            List<ulong> numList = new List<ulong>();

            for (int i = 0; i < nums.Length; i++)
            {
                numList.Add(ulong.Parse(nums[i]));
            }

            ulong ans = 0;

            for (int i = 0; i < numList.Count - 1; i++)
            {
                if (numList[i] > numList[i + 1])
                {
                    ulong d = numList[i] - numList[i + 1];

                    numList[i + 1] += d;

                    ans += d;
                 }
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 49412
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						(int)2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	ll N;
	cin >> N;
	if (IsOdd(N)) {
		cout << 0 << endl;
		return 0;
	}

	ll divVal = 5 * 2;
	ll cnt = 0;
	while (divVal <= N) {
		cnt += (N / divVal);
		divVal *= 5;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = 3;
    int[][] c = new int[n][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        c[i][j] = sc.nextInt();
      }
    }
    int a1, a2, a3, b1, b2, b3;
    String ans = "No";
    for (int i = 0; i < n; i++) {
      a1 = i;
      b1 = c[0][0] - a1;
      b2 = c[0][1] - a1;
      b3 = c[0][2] - a1;
      a2 = c[1][0] - b1;
      a3 = c[2][0] - b1;
      if (a2 + b2 == c[1][1] && a2 + b3 == c[1][2] && a3 + b2 == c[2][1] && a3 + b3 == c[2][2]) {
        ans = "Yes";
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35688
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    vector<int> as(5);
    rep(i, 0, 5) {
        cin >> as[i];
    }
    sort(all(as));
    int ans = INF;

    do {
        int tmp = 0;
        rep(i,0,5){
            int rem = (tmp % 10);
            if(rem != 0) {
                tmp += 10 - rem;
            }
            tmp += as[i];
        }
        chmin(ans,tmp);
    } while(next_permutation(all(as)));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;

const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll n, m, k;

// modを維持しながらべき乗。
ll mod_pow(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 逆元。オイラーの定理から？
// 有限体上での割り算に利用
// 3/4 = 3*(1/4) = 3x(4の逆数) = 3x3 mod 11
// 4の逆数はかけると1になるので、この場合は3
ll mod_inverse(ll x) {
    return mod_pow(x, mod-2);
}

const int max_n = 1000000;
ll fact[max_n];
ll fact_inv[max_n];

void calc_fact() {
    fact[0] = 1;
    //階乗の算出。かける度にmodを取る。
    for (ll i = 1; i < max_n; i++)
        fact[i] = (fact[i-1] * i) % mod;
    //階乗の逆元の算出。
    //1*2*3 => 1/(1*2*3)
    //1*2 => 1/(1*2*3)*3
    fact_inv[max_n-1] = mod_inverse(fact[max_n-1]);
    for (ll i = max_n-2; i >= 0; i--) 
        fact_inv[i] = (fact_inv[i+1] * (i+1)) % mod;
}

//mod付き組み合わせ
// nCk= n!/(n-k)!k! を、modをかませながら演算
ll mod_comb(ll n, ll k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return (fact[n] * fact_inv[k] % mod) * fact_inv[n-k] % mod;
}

//本編
//X方向,y方向に分割して計算
ll solve() {
    ll b = 0;
    // まずは列を横断
    // 興味があるのは、違う列にあるものだけ。
    // m-i: m列ある中でi列離れているときの、組み合わせの数
    // n*n: 2つの列の、行の組み合わせの数
    // i: Xの差の絶対値(2コマのX方向の距離)
    // m: 1,2,3,4の時
    // n: 1,2,3,4の時
    // n*n: 行1~4から2つ選ぶ
    // m-i: iが1の時1-2, 2-3, 3-4の3つ。
    for (int i = 1; i < m; i++) {
    	//行の位置(2コマ) * 列の組み合わせ + 距離スコア
        b += n * n * (m-i) * i;
        b %= mod;
    }
    for (int i = 1; i < n; i++) {
        b += m * m * (n-i) * i;
        b %= mod;
    }

    calc_fact();
    // 最初に2つを固定してそのほかの組み合わせ数Cをかける。
    // コマ1,2の距離はb。ほかのコマの組み合わせがどうであれ、bは変わらない。となるとb*Cで、コマ1,2についての距離の総和が求まる
    return b * mod_comb(n*m-2, k-2) % mod;
}

void input() {
    cin >> n >> m >> k;
}

int main() {
    input();
    cout << solve() << endl;
}


Measured memory_bytes: 15872
#include <stdio.h>
typedef struct
{
    char *suit;
	int value;
}card;
int main (void)
{
	int i,j,k,n,m,count;
	scanf("%d",&n);
	card A[36], B[36];
	card z;
	
	card y;
	j=n;
	for(i=0;i<n;i++)
	{
		scanf(" %c%d",&A[i].suit, &A[i].value);
		B[i] =A[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=n-1;j>=i+1;j--)
		{
			if(A[j].value<A[j-1].value)
			{
				z=A[j-1];
				A[j-1]=A[j];
				A[j]=z;
			}
		}
	}
	for(k=0;k<n;k++)
			{
				printf("%c%d",A[k].suit, A[k].value);
				if(k==n-1)
				{
					printf("\n");
					break;
				}
				printf(" ");
			}
		printf("Stable\n");

for(i=0;i<n;i++)
	{
		m=i;
		for(j=i;j<n;j++)
		{
			if(B[j].value<B[m].value)
			{
				m=j;
			}
		}
		if(B[i].value!=B[m].value)
		{
		y=B[i];
		B[i]=B[m];
		B[m]=y;
		}
	}
	for(k=0;k<n;k++)
		{
			printf("%c%d",B[k].suit,B[k].value);
			if(k==n-1)
			{
				printf("\n");
				break;
			}
			printf(" ");
		}
	for(k=0;k<n;k++)	
		{
		if(A[k].suit==B[k].suit)
			{
				count++;
			}
		}
	if(count==k)
	{
		printf("Stable\n");
	}
	else
	{
		printf("Not stable\n");
	}

}



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

const int mod = 1e9+7;

int dp[110][4][4][4];

int main(){
  int n;
  cin >> n;
  dp[0][3][3][3] = 1;
  rep(d,n) {
    rep(i,4) {
      rep(j,4) {
        rep(k,4) {
          if (dp[d][i][j][k] == 0) continue;
          rep(a,4) {
            if(a == 2 && i == 1 && j == 0)continue; //AGC
            if(a == 2 && i == 0 && j == 1)continue; //GAC
            if(a == 1 && i == 2 && j == 0)continue; //ACG
            if(a == 2 && i == 1 && k == 0)continue; //A○GC
            if(a == 2 && j == 1 && k == 0)continue; //AG○C
            (dp[d+1][a][i][j] += dp[d][i][j][k]) %= mod;
          }
        }
      }
    }
  }
  int res = 0;
  rep(i,4) rep(j,4) rep(k,4) (res += dp[n][i][j][k]) %= mod;
  cout << res << endl;
  return 0;
} 

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

public class Program
{

	public void Proc()
	{
        string inpt = Reader.ReadLine();
        string ans = inpt.First().ToString() + (inpt.Length - 2) + inpt.Last();
        Console.WriteLine(ans);

    }



    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"



internationalization


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 11220
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
        cout << it << " ";        \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
#define deb3a(v)                               \
    cout << #v << "-->" << endl;               \
    for (auto it : v)                          \
    {                                          \
        cout << it.fi << " " << it.se << endl; \
    }
#define mod 1000000007
#define so(v) sort(v.begin(), v.end())
#define fi first
#define se second
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int mI(int a, int m)
{
    return power(a, m - 2, m);
}
vector<vector<int>> dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
#define double long double


void solve()
{
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    fo(i,n){
        cin >> v[i].fi >> v[i].se;
    }
    foo(i,2,n){
        if (v[i].fi == v[i].se && v[i-1].fi == v[i-1].se && v[i-2].fi == v[i-2].se){
            cout << "Yes";
            return;
        }
    }
    cout << "No\n";
    return;
}


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    srand(time(0));

    // FILE *fin = freopen("ip.txt","r",stdin);
    // FILE *fout = freopen("op.txt","w",stdout);
    int t = 1, nn = 1;
    //cin >> t;
    while (t--)
    {
        // cout << "Case #" << nn << ":"
        //      << " ";
        // nn++;

        solve();
    }
}

Measured memory_bytes: 3656
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();
            var c = cin.nextInt();

            var arr = new int[] { a, b, c};
            Array.Sort(arr);
            Array.Reverse(arr);
            
            Console.WriteLine(int.Parse("" + arr[0] + arr[1]) + arr[2]);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11220
X = int(input())
if X == 2:
    print(2)
elif X == 3:
    print(3)
else:
    i = X
    while True:
        flag = 0
        for j in range(2,int(i**0.5+1)):
            if i%j==0:
                flag = 1
        if flag==0:
            print(i)
            break
        i+=1

Measured memory_bytes: 3188
// AOJ 1020
#include<iostream>
#include<iomanip>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

typedef long double number;
int n;
int sx, sy, tx, ty, bx, by;
number room[3][3];

void init() {
  REP(x, 3) REP(y, 3) {
    room[x][y] = 0;
  }
  room[sx][sy] = 1;
}

bool is_depot(int x, int y) {
  return x == bx && y == by;
}

number in(int x, int y) {
  if (x < 0 or 2 < x or y < 0 or 2 < y) return 0;
  if (is_depot(x, y)) return 0;
  return room[x][y];
}

bool legal(int x, int y) {
  if (x < 0 or 2 < x or y < 0 or 2 < y) return false;
  return not is_depot(x, y);
}

number solve() {
  init();
  REP(i, n) {
    number future[3][3];
    REP(x, 3) REP(y,3) {
      future[x][y] = 0;
    }
    
    REP(x, 3) REP(y,3) {
      if (is_depot(x, y)) continue;
      number prob = room[x][y] / 4;
      if (legal(x + 1, y)) { future[x + 1][y] += prob; } 
      else { future[x][y] += prob; }
      
      if (legal(x - 1, y)) { future[x - 1][y] += prob; } 
      else { future[x][y] += prob; }
      
      if (legal(x, y + 1)) { future[x][y + 1] += prob; } 
      else { future[x][y] += prob; }
      
      if (legal(x, y - 1)) { future[x][y - 1] += prob; } 
      else { future[x][y] += prob; }
    }
    
    REP(y, 3) { REP(x, 3) {
        room[x][y] = future[x][y];
    }}
  }
  return room[tx][ty];
}

int room2x(char r) {
  switch (r) {
    case 'A': case 'D': case 'G':
      return 0; break;
    case 'B': case 'E': case 'H':
      return 1; break;
    case 'C': case 'F': case 'I':
      return 2; break;
    default:
      break;
  }
}

int room2y(char r) {
  switch (r) {
    case 'A': case 'B': case 'C':
      return 0; break;
    case 'D': case 'E': case 'F':
      return 1; break;
    case 'G': case 'H': case 'I':
      return 2; break;
    default:
      break;
  }
}

int main() {
  while (cin >> n and n) {
    char s, t, b;
    cin >> s >> t >> b;
    sx = room2x(s); sy = room2y(s);
    tx = room2x(t); ty = room2y(t);
    bx = room2x(b); by = room2y(b);

    cout << fixed << setprecision(10) << solve() << endl;
  }
}

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

int main() {
    int a[9];
    bool b[9];
    int n, x;
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> a[i*3+j];
        }
    }

    for(int i = 0; i < 9; i++) {
        b[i] = false;
    }

    cin >> n;
    
    for(int i = 0; i < n; i++) {
        cin >> x;
        for(int j = 0; j < 9; j++) {
            if (a[j] == x) {
                b[j] = true;
            }
        }
    }

    if (
        (b[0] && b[1] && b[2]) ||
        (b[3] && b[4] && b[5]) ||
        (b[6] && b[7] && b[8]) ||
        (b[0] && b[3] && b[6]) ||
        (b[1] && b[4] && b[7]) ||
        (b[2] && b[5] && b[8]) ||
        (b[0] && b[4] && b[8]) ||
        (b[2] && b[4] && b[6])
    ) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

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

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

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

	string S; cin >> S;

	if(S[S.size()-1] == '3') cout << "bon" << endl;
	else if(S[S.size()-1] == '0' || S[S.size()-1] == '1' || S[S.size()-1] == '6' || S[S.size()-1] == '8' ) cout << "pon" << endl;
	else cout << "hon" << endl;

	return 0;

}


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

int main(){
	int n;
	cin >>n;
	
	for (int i=1; i<=n; i++){
		if (i%3==0)cout <<" "<< i;
		else {
			int x =i;
			while (1){
				if (x%10==3){
					cout <<" "<<i;
					break;
				}
				x/=10;
				if (x==0) break;
			}
		}
	}
	cout <<"\n";
	
	return 0;
}

Measured memory_bytes: 1164