akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n; cin >> n;
    vector<int> b(n - 1);
    REP(i, n - 1) cin >> b[i];
    int prev = b[0];
    int ans = 2 * prev;
    FOR(i, 1, n - 1) {
        if (prev <= b[i]) ans += b[i];
        else ans = ans - prev +  2 * b[i];
        prev = b[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
int main(){
  int n,a;
  map<int,int>data;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(data.count(a)==0)data[a]=1;
    else data.erase(a);
  }
  cout<<data.size()<<endl;
  return(0);
}

Measured memory_bytes: 4864
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
using namespace std;


int main(){

    string s,t;
    cin>>s>>t;

    int count = 0;
    int i;

    for(i=0;i<3;i++){
        if(s[i]==t[i]){
            count++;
        }
    }

    cout<<count<<endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<long long> A(n);
    long long max_a = 0;
    for (int i = 0; i < n; i++) {
        long long a;
        cin >> a;
        max_a = max(max_a, a);
        A[i] = a;
    }

    long long mid_a = 0, min_diff = 1LL << 60;
    for (int i = 0; i < n; i++) {
        long long diff = abs(A[i] - max_a / 2);
        if (diff < min_diff && A[i] != max_a) {
            min_diff = diff;
            mid_a = A[i];
        }
    }

    cout << max_a << " " << mid_a << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
int main()
{
	char a[4];
	scanf("%s",a);int b=0;
	if(a[0]==a[1] and a[2]==a[3]){b=b+1;}
	else if(a[1]==a[2] and a[0]==a[3]){b=b+1;}
	else if(a[0]==a[2] and a[1]==a[3]){b=b+1;}
	if(a[0]==a[1] and a[1]==a[2] and a[2]==a[3]){b=0;}
	if(b>=1){printf("Yes\n");}
	if(b<=0){printf("No\n");}
	system("pause");
	return 0;
}

Measured memory_bytes: 376
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
using vs= vector<string>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  bool in;
  int n,d,ans=0,tmp,diff;
  cin >> n >> d;
  vvd x(n, vd(d));
  rep(i,0,n){
    rep(j,0,d){
      cin >> x[i][j];
    }
  }
  rep(i,0,n){
    rep(j,i+1,n){
      tmp=0;
      rep(k,0,d){
        diff= abs(x[i][k]-x[j][k]);
        tmp+= diff*diff;
      }
      in=false;
      rep(k,0,tmp+1){
        if(tmp==k*k){
          in=true;
        }
      }
      if(in){
        ans++;
      }
    }
  }
  cout << ans;

  return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    bool l=0,r=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='C')l=1;
        if(s[i]=='F'&&l)r=1;
    }
    if(l&&r)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        cout << "x";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, K;
    cin >> N >> K;
    vvc<ll> G(N);
    rep(i,N-1){
        ll a, b;
        cin>>a>>b;
        a--, b--;
        G[a].eb(b);
        G[b].eb(a);
    }
    ll ans = K;
    vl ecnt(N, 0);
    rep(i, N) ecnt[i] = G[i].size();

    vc<bool> used(N, false);
    vc<ll> usedcnt(N, 0);
    queue<pair<ll,ll>> q;
    q.emplace(0,-1);
    while(!q.empty()){
        pair<ll, ll> pa = q.front();
        q.pop();
        ll now, parent;
        tie(now, parent) = pa;
        used[now] = true;

        ll cnt = K - 2;
        if (parent == -1) cnt++;
        for (auto e : G[now]){
            if (used[e]) continue;
            q.emplace(e, now);
            ans = ans * cnt % MOD;
            cnt--;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
	vector<int>s, x;
	int n, l;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> l;
		x.push_back(l);
		s.push_back(l);
	}
	sort(s.begin(), s.end());

	for (int i = 0; i < n; i++) {
		if (x[i] < s[n / 2])
			cout << s[n / 2] << endl;
		else
			cout << s[n / 2 - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    ll N, D;
    cin >> N >> D;

    int n = 0;
    for(int i = 0; i < N; i++){
        ll X, Y;
        cin >> X >> Y;
        if(X * X + Y * Y <= D * D) n++;
    }


    cout << n << endl; 
}


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

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

vector<string> split(const string& str, const string& seps) {
  char *p, *str_buff = new char[str.size() + 1];
  vector<string> res;
  strcpy(str_buff, str.c_str());
  p = strtok(str_buff, seps.c_str());
  while (p) {
    res.emplace_back(p);
    p = strtok(NULL, seps.c_str());
  }
  delete str_buff;
  return res;
}

const int INF = 1 << 30;
int W, n;
vector<int> r;
double dp[1 << 12][12];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  while (getline(cin, s)) {
    auto v = split(s, " ");
    W = stoi(v[0]), n = v.size() - 1;
    r.clear();
    for (int i = 1; i < (int)v.size(); i++) {
      r.emplace_back(stoi(v[i]));
    }
    fill_n(*dp, (1 << 12) * 12, INF);
    for (int i = 0; i < n; i++) {
      dp[1 << i][i] = 2 * r[i];
    }
    for (int i = 0; i < 1 << n; i++) {
      for (int j = 0; j < n; j++) {
        if (i >> j & 1) {
          for (int k = 0; k < n; k++) {
            dp[i][j] = min(dp[i][j], dp[i - (1 << j)][k] - r[k] + 2 * sqrt(r[k] * r[j]) + r[j]);
          }
        }
      }
    }
    auto d = dp[(1 << n) - 1];
    cout << (W - *min_element(d, d + n) > -1e-10 ? "OK" : "NA") << endl;
  }

  return 0;
}


Measured memory_bytes: 3552
/*<----------------------------------------------------------------------->

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
void solve(){
    int k ; cin >> k ;ll ans =0 ;
    Rep(a,k)
        Rep(b,k)
            Rep(c,k)
                ans+=__gcd(a,__gcd(b,c)) ;
    pf(ans) ;
    
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


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

int main() {
  int a; 
  int b;
  cin >> a;
  cin >> b;
  
  if ((a + b) % 2 == 1) {
    cout << (a + b) / 2 + 1 << endl;
  }
  
  else {
    cout << (a + b) / 2 << endl;
  }
}

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()
    {
        this.inpt = Reader.ReadLine();

        string ans = GetAns(0, inpt[0].ToString(), this.inpt[0] - '0');
        Console.WriteLine(ans + "=7");
    }

    private string inpt;

    private string GetAns(int idx, string subAns, int subTotal) {
        if(idx>=3) {
            if(subTotal == 7) {
                return subAns;
            } else {
                return string.Empty;
            }
        }

        string ans = GetAns(idx + 1, subAns + "+" + inpt[idx + 1], subTotal + this.inpt[idx + 1] - '0');
        if(!string.IsNullOrEmpty(ans)) {
            return ans;
        }
        return GetAns(idx + 1, subAns + "-" + inpt[idx + 1], subTotal - (this.inpt[idx + 1] - '0'));
    }

    public class Reader
    {
        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 = @"


3242


";
    }

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

Measured memory_bytes: 13140
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int total = 700;
  if (s[0] == 'o')
    total=total+100;
  if (s[1] == 'o')
    total=total+100;
  if(s[2] == 'o')
    total=total+100;
  cout<< total <<endl;
}

Measured memory_bytes: 256
#ABC077-C
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

ans=0
for i in range(N):
    b=B[i]
    left=0
    right=N-1
    if A[-1]<b:
        a_comb=N
    elif A[0]>=b:
        a_comb=0
    elif A[0]<b and A[1]>=b:
        a_comb=1
    else:
        a_comb=0
        while left<=right:
            mid=(left+right)//2
            if A[mid]<b and A[mid+1]>=b:
                a_comb=mid+1
                break
            elif A[mid]<b and A[mid+1]<b:
                left=mid+1
            elif A[mid]>=b:
                right=mid-1

    left=0
    right=N-1
    if C[0]>b:
        c_comb=N
    elif C[-1]<=b:
        c_comb=0
    elif C[-1]>b and C[-2]<=b:
        c_comb=1
    else:
        c_comb=0
        while left<=right:
            mid=(left+right)//2
            if C[mid]>b and C[mid-1]<=b:
                c_comb=N-mid
                break
            elif C[mid]>b and C[mid-1]>b:
                right=mid-1
            elif C[mid]<=b:
                left=mid+1
    ans+=a_comb*c_comb
print(ans)

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> beg, end;
  for (int i = 0, a; i < n; i++) {
    cin >> a;
    if (i % 2 == 0) {
      beg.emplace_back(a);
    } else {
      end.emplace_back(a);
    }
  }
  vector<int> ans(n);
  int m = (int)beg.size();
  for (int i = 0; i < m; i++) {
    ans[i] = beg[m - i - 1];
  }
  for (int i = m; i < n; i++) {
    ans[i] = end[i - m];
  }
  if (n % 2 == 0) reverse(ans.begin(), ans.end());
  cout << ans[0];
  for (int i = 1; i < n; i++) {
    cout << ' ' << ans[i];
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 5200
#include<iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<pair<int,int>> pairA(n);
    int a;
    for(int i=0;i<n;i++){
        cin >> a;
        pairA[i] = make_pair(a,i+1);
    }
    sort(pairA.begin(),pairA.end());
    for(int i=0;i<n;i++){
        cout << (i? " " : "")<< pairA[i].second;
    }
}

Measured memory_bytes: 1536
#include <iostream>

using namespace std;
 
int main(){
  int n,h,m,s;
  cin >> n;
 
  h = n / 3600;
  m = n % 3600 / 60;
  s = n % 3600 % 60;
 
  cout << h << ':' << m << ':' << s << endl;
}

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

int main() {
    int n;
    int max = 0, min = 1145141919;
    int num;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> num;
        if(max < num){
            max = num;
        }
        if(min > num){
            min = num;
        }
    }
    cout << max - min;
}


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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/

double dist(pair<int,int> s,pair<int,int> t){
  return sqrt(pow(s.first-t.first,2) + pow(s.second-t.second,2));
}

int fac(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
  int  N;
  cin >> N;
  
  vector<pair<int,int> > x(N);
  
  rep(i,N) cin >> x[i].first >> x[i].second;
  
  int M = N * (N-1) / 2;
  
  vector<double> r;
  
  rep(i,N){
    for(int j = 1; j != i && j < N;j++){
      r.PB(dist(x[i],x[j]));
    }
  }
    
  double total_dis = accumulate(ALL(r),0.0);
  
  cout << fixed << setprecision(7)<< 2 * total_dis /(double)N << endl;
    
}
  

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

int main()
{
	int s1, s2;
	
	while (cin >> s1 >> s2, s1 || s2){
		
		int max = s1 + s2, max_n = 0 + 'A';
		
		for (int i = 1; i < 5; i++){
			cin >> s1 >> s2;
			if (max < s1 + s2){
				max = s1 + s2;
				max_n = i + 'A';
			}
		}
		
		printf("%c %d\n", max_n, max);
	}
	return (0);
}

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

int main() {
  double r,s,a,b;
  cin>>r;
  s=3.14159265358979;
  a=r*r*s;
  b=2*r*s;
  cout<<fixed<<setprecision(6);
  cout<<a<<" "<<b<<endl;
}


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

int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if(a[0] == 5 && a[1] == 5 && a[2] == 7){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 256
use std::convert::TryInto;
use proconio::input;
use num::{pow, One};
use std::ops::{Div, MulAssign, Sub};

fn main() {
    input! {
        n: usize,
        p: usize
    }
    
    let vec = factor(p);

    let ans = {
        let mut ans = 1;
        for &(q,k) in &vec {
            ans *= q.pow(((k/n) as u32).try_into().unwrap());
        }
        ans
    };

    println!("{}",ans)

}

/// Make bool table by using Sieve of Eratosthenes
pub fn sieve(n: usize) -> Vec<bool> {
    let mut tbl = vec![true; n];
    tbl[0] = false;
    tbl[1] = false;
    for i in 2..n {
        if tbl[i] {
            let mut j = i + i;
            while j < n {
                tbl[j] = false;
                j += i;
            }
        }
    }
    tbl
}


/// Returns all primes less than `n`
pub fn primes(n: usize) -> Vec<usize> {
    let mut tbl = vec![true; n];
    let mut ps = vec![];
    tbl[0] = false;
    tbl[1] = false;
    for i in 2..n {
        if tbl[i] {
            ps.push(i);
            let mut j = i + i;
            while j < n {
                tbl[j] = false;
                j += i;
            }
        }
    }
    ps
}


/// Prime factorization
pub fn factor(n: usize) -> Vec<(usize, usize)> {
    let mut n = n;
    let mut ret = vec![];
    let ps = primes((n as f64).sqrt() as usize + 2);
    for p in ps {
        let mut cnt = 0;
        while n % p == 0 {
            n /= p;
            cnt += 1;
        }
        if cnt > 0 {
            ret.push((p, cnt));
        }
    }
    if n > 1 {
        ret.push((n, 1));
    }
    ret
}


/// Number of divisors
pub fn num_of_divisors(factors: &[(usize, usize)]) -> usize {
    factors.iter().map(|r| r.1 + 1).product()
}



/// Sum of divisors
pub fn sum_of_divisors<
    T: From<usize> + Sub<Output = T> + Div<Output = T> + MulAssign + One<Output = T> + Clone,
>(
    factors: &[(usize, usize)],
) -> T {
    let mut ret = T::from(1_usize);
    for &(p, n) in factors {
        ret *= (pow(T::from(p), n + 1) - T::from(1_usize)) / T::from(p - 1);
    }
    ret
}


/// Returns all divisors of `n`
pub fn divisors(n: usize) -> Vec<usize> {
    let fs = factor(n);
    let mut ret = vec![];
    gen_divisors(&fs[..], 1, &mut ret);
    ret
}

fn gen_divisors(s: &[(usize, usize)], cur: usize, ret: &mut Vec<usize>) {
    if s.is_empty() {
        ret.push(cur);
        return;
    }

    let mut cur = cur;
    for _ in 0..=s[0].1 {
        gen_divisors(&s[1..], cur, ret);
        cur = cur.wrapping_mul(s[0].0);
    }
}

Measured memory_bytes: 3700
#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);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int K;
    cin >> K;
    rep(i, N){
        if(S[i] != S[K - 1]) S[i] = '*';

    }
    cout << S << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
#define CLR(a)     memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)    cerr << #x << " = " << (x) << endl;//debug
#define debug(x)   cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define EPS        1e-10//sample:if((double)>=(double)+EPS)
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);

using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

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

int MDT[N2][N2];

struct puzzle {
  int f[N2],space,MD;
};
puzzle state;
int limit=100;
int path[100];

int getallmd(puzzle pz){
  int sum=0;
  rep(i,N2){
    if(pz.f[i]==N2)continue;
    sum+=MDT[i][pz.f[i]-1];
  }
  return sum;
}
bool isSolved(){
  rep(i,N2)if(state.f[i]!=i+1)return 0;
  return 1;
}
bool dfs(int depth,int prev){
  if(state.MD==0){
    return 1;
  }
  if(depth+state.MD>limit)return 0;
  int sx=state.space/N;
  int sy=state.space%N;
  puzzle tmp;
  rep(r,4){
    int tx=sx+dx[r];
    int ty=sy+dy[r];
    if(tx<0||ty<0||tx>=N||ty>=N)continue;
    if(max(prev,r)-min(prev,r)==2)continue;
    tmp=state;
    state.MD -= MDT[tx*N+ty][state.f[tx*N+ty]-1];
    state.MD += MDT[sx*N+sy][state.f[tx*N+ty]-1];
    swap(state.f[tx*N+ty],state.f[sx*N+sy]);
    state.space = tx*N+ty;
    if(dfs(depth+1,r)){
      path[depth]=r;
      return 1;
    }
    state=tmp;
  }
  return 0;
}

int iterative_deeping(puzzle in){
  in.MD=getallmd(in);
  for(limit=in.MD;limit<=LIMIT;limit++){
    state=in;
    if(dfs(0,-100)){
      int ans=0;
      rep(i,limit)ans+=1;
      return ans;
    }
  }
  return -1;
}



int main(){
  rep(i,N2)rep(j,N2)MDT[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
  puzzle in;
  rep(i,N2){
    cin>>in.f[i];
    if(in.f[i]==0){
      in.f[i]=N2;
      in.space=i;
    }
  }
   int ans = iterative_deeping(in);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();

		if(k % 2 == 0 || k % 2 == 5){
			System.out.println(-1);
			return;
		}

		int result = 1;
		int sevens = 7;
		while(true){
			if(sevens % k == 0){
				System.out.println(result);
				return;
			}

			sevens *= 10;
			sevens += 7;
			sevens %= k;

			result++;

			if(result > k){
				System.out.println(-1);
				return;
			}
		}
	}
}

Measured memory_bytes: 27268
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	while (1){
		int n; 
		scanf("%d", &n);
		if (n == 0)break;
		int card[201] = {0}, temp;
		for (int i = 0; i < n; i++){
			scanf("%d", &temp);
			card[temp] = 1;
		}
		int point[2] = {0};
		bool p = 1;
		while (1){
			if (point[0] == n || point[1] == n)break;
			for (int i = 1; i <= 2*n; i++){
				if (card[i] == p){
					card[i] = -1;
					point[p]++;
					p = !p;
				}
			}
			p = !p;
		}
		printf("%d\n", n-point[0]);
		printf("%d\n", n-point[1]);
	}
	return 0;
}

Measured memory_bytes: 3220
void main()
{
    dchar[] s = rdDchar;
    dchar[] t = rdDchar;

    long len = s.length;
    foreach (i; 0 .. len)
    {
        if (s == t)
        {
            "Yes".writeln;
            return;
        }
        s = s[$-1] ~ s[0..$-1];
    }
    "No".writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 380
// n段目の上り方の総数を記録する?
#include<iostream>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll ans[100005]; // n段目の上り方の総数
ll A[100005]; // 上ってはいけない階段であるかどうか記録する配列
int main(){
  ll n,m; cin >> n >> m;
  for(ll i=1;i<=n;i++){
    ans[i] = -1;
  }
  
  for(ll i=0;i<m;i++){
    ll a; cin >> a;
    A[a] = 1;
  }
    
  ans[1] = (A[1] ? 0 : 1);
  ans[2] = ans[1] + (A[2] ? 0 : 1);
  for(ll i=3;i<=n;i++){
    ans[i] = ((A[i-1] ? 0 : ans[i-1]) + (A[i-2] ? 0 : ans[i-2])) % mod;
    ans[i] %= mod;
  }
  
  cout << ans[n] % mod << endl;
  return 0;
}
    
  
  

Measured memory_bytes: 1792
package main

import (
  "fmt"
)

func main() {
  var n, m, c int
  fmt.Scan(&n, &m, &c)
  bs := make([]int, m)
  for i := 0; i < m; i++ {
    fmt.Scan(&bs[i])
  }
  ass := make([][]int, n)
  for i := 0; i < n; i++ {
    ass[i] = make([]int, m)
    for j := 0; j < m; j++ {
      fmt.Scan(&ass[i][j])
    }
  }
  result := 0
  for _, as := range ass {
    sum := 0
    for j, a := range as {
      sum += a*bs[j]
    }
    if 0 < sum+c {
      result++
    }
  }
  fmt.Println(result)
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>

void swap(int *p, int *q){
	int temp = *p;
	*p = *q;
	*q = temp;
}

int main(){
	int a[3]={1,0,0};
	char x, y;
	while( scanf(" %c,%c", &x, &y) != EOF ){
		//printf("x=%c, y=%c\n", x, y);
		swap(&a[(int)(x-'A')], &a[(int)(y-'A')]);
	}

	for(int i=0; i<3; ++i)
		if(a[i]==1) printf("%c\n", 'A'+i);

	return 0;
}

Measured memory_bytes: 1136
#include<iostream>
using namespace std;
int main(){
  int n,m,xa,ya,xmax=-101,ymin=101,flag=0;
  cin >> n >> m >> xa >> ya;
  int x[n],y[m],i;
  for(i=0;i<n;i++){
    cin >>x[i];
    xmax=(xmax>x[i])?xmax:x[i];
  }
  xmax++;
  for(i=0;i<m;i++){
     cin >>y[i];
     ymin=(ymin<y[i])?ymin:y[i];
   }
  // cout << xmax << " " << ymin << endl;
   for(i=xmax;i<=ymin;i++){
     if(i>xa&&ya>=i){
       flag=1;
       break;
     }
   }
  if(flag)cout << "No War"<<endl;
  else cout <<"War" << endl;

}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    string A,B; cin >> A >> B;
    if(A.size()>B.size()) cout << "GREATER" << endl;
    else if(A.size()<B.size()) cout << "LESS" << endl;
    else{
        int ptr=0;
        while(ptr < A.size() && A[ptr] == B[ptr]) ptr++;
        if(ptr == A.size()) cout << "EQUAL" << endl;
        else if(A[ptr]>B[ptr]) cout << "GREATER" << endl;
        else cout << "LESS" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
 * Spreadsheet.cpp
 *
 *  Created on: 2014/08/03
 *      Author: WanWan1985
 */
#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>
using namespace std;

// for util
#define FOR(i, a, b) 	for(int i = (a); i < (b); i++)
#define REP(i, n)		FOR(i, 0, n)
#define PB				push_back
#define CL				clear
#define MP				make_pair

typedef unsigned int u_int;
typedef long long ll;

ll GetRowSum(vector<ll> a_vecRow);
ll GetColSum(ll a_iIndex, vector<vector<ll>> a_vecVal);
ll GetAllSum(vector<vector<ll>> a_vecVal);

int main(void) {
	ll n, m;
	cin >> n >> m;
	vector<vector<ll>> vecVal;
	REP(i, n) {
		vector<ll> vecRow;
		REP(j, m) {
			ll a = 0;
			cin >> a;
			vecRow.PB(a);
		}
		vecVal.PB(vecRow);
	}

	ll NewMatrix[n + 1][m + 1];
	REP(i, n + 1) {
		vector<ll> vecRow;
		if (i != n) {
			vecRow = vecVal.at(i);
		}
		REP(j, m + 1) {
			if ((i != n) && (j != m)) {
				NewMatrix[i][j] = vecRow.at(j);
			} else if (i != n) {
				NewMatrix[i][j] = GetRowSum(vecRow);
			} else if ((i == n) && (j != m)) {
				NewMatrix[i][j] = GetColSum(j, vecVal);
			} else if  ((i == n) && (j == m)) {
				NewMatrix[i][j] = GetAllSum(vecVal);
			}
		}
	}

	REP(i, n + 1) {
		REP(j, m + 1) {
			cout << NewMatrix[i][j];
			if (j != m) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

ll GetAllSum(vector<vector<ll>> a_vecVal) {
	ll iResult = 0;
	REP(i, a_vecVal.size()) {
		vector<ll> tmp = a_vecVal.at(i);
		REP(j, tmp.size()) {
			iResult += tmp.at(j);
		}
	}
	return iResult;
}

ll GetRowSum(vector<ll> a_vecRow) {
	ll iResult = 0;
	REP(i, a_vecRow.size()) {
		iResult += a_vecRow.at(i);
	}
	return iResult;
}

ll GetColSum(ll a_iIndex, vector<vector<ll>> a_vecVal) {
	ll iResult = 0;
	REP(i, a_vecVal.size()) {
		vector<ll> tmp = a_vecVal.at(i);
		iResult += tmp.at(a_iIndex);
	}
	return iResult;
}

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

int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a == b)
    {
        printf("%d\n", c);
    }
    else if (a == c)
    {
        printf("%d\n", b);
    }
    else
    {
        printf("%d\n", a);
    }
    return 0;
}

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    int ans = 0;
    cin>>n>>k;
    rep(i, n)
    {
        int temp;
        cin >> temp;
        ans += min(abs(k - temp), temp) * 2;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3664
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

// Queue is for bfs
type Queue struct {
	data []interface{}
}

// Push adds a value to queue
func (q *Queue) Push(v interface{}) {
	q.data = append(q.data, v)
}

// Pop removes the last element and return it
func (q *Queue) Pop() (interface{}, error) {
	if q.Empty() {
		return nil, fmt.Errorf("queue is empty")
	}
	v := q.data[0]
	q.data = q.data[1:]
	return v, nil
}

// Empty returns true if queue is empty
func (q *Queue) Empty() bool {
	return len(q.data) == 0
}

// NewQueue generates a new queue
func NewQueue() *Queue {
	return &Queue{make([]interface{}, 0)}
}

type node struct {
	Val    int
	Neigh  []*node
	Parent *node
}

func main() {
	n, m := nextInt(), nextInt()
	nodes := make(map[int]*node)
	for i := 0; i < n; i++ {
		nodes[i] = &node{i, nil, nil}
	}

	for i := 0; i < m; i++ {
		a, b := nextInt()-1, nextInt()-1
		nodes[a].Neigh = append(nodes[a].Neigh, nodes[b])
		nodes[b].Neigh = append(nodes[b].Neigh, nodes[a])
	}

	q := NewQueue()
	q.Push(nodes[0])
	visited := make(map[int]bool)
	for !q.Empty() {
		t, _ := q.Pop()
		top := t.(*node)
		visited[top.Val] = true
		for _, ne := range top.Neigh {
			if !visited[ne.Val] {
				ne.Parent = top
				q.Push(ne)
				visited[ne.Val] = true
			}
		}
	}
	if len(visited) != n {
		fmt.Println("No")
		return
	}

	fmt.Println("Yes")
	for i := 1; i < n; i++ {
		fmt.Println(nodes[i].Parent.Val + 1)
	}
}


Measured memory_bytes: 31964
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin

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

	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n));
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < n; ++j)
			cin >> a[i][j];

	vector<int> dp(1 << n); // dp[mask] = numer of ways to match girls in mask with boys [0, ..., popcount(mask))
	dp[0] = 1;

	for(int mask = 1; mask < (1 << n); ++mask) {
		int boy = -1;
		for(int i = 0; i < n; ++i)
			if(mask & (1 << i))
				++boy;

		for(int girl = 0; girl < n; ++girl)
			if(mask & (1 << girl))
				if(a[boy][girl])
					dp[mask] = (dp[mask] + dp[mask ^ (1 << girl)]) % int(1e9 + 7);
	}
	cout << dp[(1 << n) - 1] << '\n';
}


Measured memory_bytes: 8448
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 1e9;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;

int i,n,m,ans[N],vis[N];
vi g[N];

void solve(){
    cin>>n>>m;
    for(i=0;i<m;++i){
        int a,b;
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    queue<int> q;
    q.push(1);
    vis[1]=1;
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(int u:g[v]){
            if(!vis[u]){
                vis[u]=1;
                q.push(u);
                ans[u]=v;
            }
        }
    }
    cout<<"Yes"<<endl;
    for(i=2;i<=n;++i){
        cout<<ans[i]<<endl;
    }
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 16160
#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define REP(i, y) rep(i, 0, y - 1)
#define eps 1e-9
using namespace std;
const db pi = acos(-1.0);
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
const int N = 510;
int a[N][N];
int main()
{
	int n = read();
	rep(i, 1, n)
		rep(j, 1, n)
			a[i][j] = read();
	ll ans = 0;
	rep(i, 1, n)
		rep(j, i + 1, n)
		{
			bool flag = 0;
			rep(k, 1, n)
			{
				if(k == i || k == j) continue;
				if(a[i][j] > a[i][k] + a[k][j])
				{
					puts("-1");
					return 0;
				}
				if(a[i][j] == a[i][k] + a[k][j]) flag = 1;
			}
			if(!flag ) ans += a[i][j];
		}
	cout << ans;
	return 0;
}


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

int main()
{
    int n;
		cin >> n;
		vector<int> a(n,0);
		vector<int> b(n,0);
		vector<int> c(n,0);
		for (int i=0;i<n;i++){
			cin >> a[i];
			cin >> b[i];
		}
		for (int i=0;i<n;i++){
			if (a[i]==b[i]){
				c[i]=1;
			}
		}
		int f=0;
		int f2=-1;
		for (int i=0;i<n;i++){
			if (c[i]==1){
				f=f+1;
			}
			else {
				f=0;
			}
			if (f==3){
				f2=1;
				break;
			}
		}
		if (f2==1){
			cout << "Yes";
		}
		else {
			cout << "No";
		}
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

class Graph {
private:
    list<int> *adj;
    int V;
    void tSortUtil(int v, bool visited[], vector<int> &w);
public:
    Graph(int n) {
        V = n;
        adj = new list<int>[V];
    }
    void addEdge(int key, int to) {
        adj[key].push_back(to);
    }
    vector<int> tSort();
};

void Graph::tSortUtil(int v, bool visited[], vector<int> &w) {
    visited[v] = true;
    for (auto itr = adj[v].begin(); itr != adj[v].end(); ++itr) {
        if (!visited[*itr]) tSortUtil(*itr, visited, w);
    }
    w.push_back(v);
}

vector<int> Graph::tSort() {
    vector<int> w;
    bool *visited = new bool[V];
    REP(i,V) visited[i] = false;
    REP(i,V) {
        if (visited[i] == false) tSortUtil(i, visited, w);
    }
    reverse(ALL(w));
    return w;
}

int main() {
    int m, n;
    cin >> m >> n;
    Graph graph = Graph(m);
    REP(i,n) {
        int x, y;
        cin >> x >> y;
        graph.addEdge(x-1, y-1);
    }
    vector<int> v = graph.tSort();
    REP(i,m) cout << v[i]+1 << endl;
}

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

using namespace std;
using ll = long long;

const ll INF = 1e18;

inline char get_another(char c) {
	if (c == 'U') {
		return 'D';
	} else if (c == 'D') {
		return 'U';
	} else if (c == 'L') {
		return 'R';
	} else if (c == 'R') {
		return 'L';
	}
	return 0;
}

inline ll solve(vector<pair<int, char>> a) {
	int n = a.size();
	ll ans = INF;

	map<char, set<int>> cur;
	for (auto &el :a) {
		cur[el.second].insert(el.first);
	}

	for (auto &el : a) {
		int c = get_another(el.second);

		if (!cur[c].size() || c == 'R' || c == 'U') {
			continue;
		}

		auto it = cur[c].lower_bound(el.first);
		if (it != cur[c].end() && el.first < *it) {
			ans = min(ans, 5ll * (*it - el.first));
		}
		if (it != cur[c].begin() && el.first < *(--it)) {
			ans = min(ans, 5ll * (*it - el.first));
		}
	}

	return ans;
}

inline char get_another1(char c) {
	if (c == 'U') {
		return 'L';
	} else if (c == 'D') {
		return 'R';
	} else if (c == 'L') {
		return 'U';
	} else if (c == 'R') {
		return 'D';
	}
	return 0;
}

ll solve1(vector<pair<int, char>> a) {
	int n = a.size();
	ll ans = INF;

	map<char, set<int>> cur;
	for (auto &el :a) {
		cur[el.second].insert(el.first);
	}

	for (auto &el : a) {
		int c = get_another1(el.second);

		if (!cur[c].size() || c == 'U' || c == 'R') {
			continue;
		}

		auto it = cur[c].lower_bound(el.first);
		if (it != cur[c].end() && el.first < *it) {
			ans = min(ans, 10ll * (*it - el.first));
		}
		if (it != cur[c].begin() && el.first < *(--it)) {
			ans = min(ans, 10ll * (*it - el.first));
		}
	}

	return ans;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	vector<int> x(n), y(n);
	vector<char> type(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> type[i];
	}

	ll ans = INF;

	map<int, vector<pair<int, char>>> each;
	for (int i = 0; i < n; i++) {
		if (type[i] == 'U' || type[i] == 'D') {
			each[x[i]].emplace_back(y[i], type[i]);
		}
	}
	for (auto &el : each) {
		ans = min(ans, solve(el.second));
	}

	each.clear();

	for (int i = 0; i < n; i++) {
		if (type[i] == 'L' || type[i] == 'R') {
			each[y[i]].emplace_back(x[i], type[i]);
		}
	}
	for (auto &el : each) {
		ans = min(ans, solve(el.second));
	}

	map<int, vector<pair<int, char>>> mapa;
	for (int i = 0; i < n; i++) {
		mapa[x[i] - y[i]].emplace_back(x[i], type[i]);
	}
	for (auto &el : mapa) {
		ans = min(ans, solve1(el.second));
	}

	mapa.clear();

	for (int i = 0; i < n; i++) {
		y[i] *= -1;

		if (type[i] == 'U') {
			type[i] = 'D';
		} else if (type[i] == 'D') {
			type[i] = 'U';
		}

		mapa[x[i] - y[i]].emplace_back(x[i], type[i]);
	}
	for (auto &el : mapa) {
		ans = min(ans, solve1(el.second));
	}

	if (ans == INF) {
		cout << "SAFE";
	} else {
		cout << ans;
	}
}

Measured memory_bytes: 39460
#include <stdio.h>

int main(void)
{
    char buffer[256];
    int input[3000][2], counter=0, x=1, y=1;

    while (!(x == 0 && y == 0))
    {
        fgets(buffer, 256, stdin);
        sscanf(buffer, "%d %d", &x, &y);
        if (x < y)
        {
            input[counter][0] = x;
            input[counter][1] = y;
        }
        else
        {
            input[counter][0] = y;
            input[counter][1] = x;
        }
        counter++;
    }

    counter = 0;
    while (!(input[counter][0] == 0 && input[counter][1] == 0))
    {
        printf("%d %d\n", input[counter][0], input[counter][1]);
        counter++;
    }

    return(0);
}


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

int N, M;
int adj[20][20];
int prec[1 << 15];

int cc[20][1 << 15][2];
int dp(int u, int mask, int t) {
    int &ret = cc[u][mask][t];
    if(ret != -1) return ret;
    if(u == N - 1) return ret = prec[mask ^ (1 << u)];
    if(!(mask & (1 << (N - 1)))) return ret = 1e9;

    ret = 1e9;
    if(t) {
        for(int i = mask;; i = (i - 1) & mask) {
            ret = min(ret, dp(u, mask ^ i, 0) + prec[i ^ (1 << u)]);
            if(!i) break;
        }
    }
    else {
        for(int v = 0; v < N; v++) {
            if(!adj[u][v]) continue;
            if(mask & (1 << v)) {
                ret = min(ret, dp(v, mask ^ (1 << v), 1) - 2 * adj[u][v]);
            }
        }
    }
    return ret;
}

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

    for(int i = 0; i < M; i++) {
        int u, v, w; scanf("%d %d %d", &u, &v, &w);
        u--; v--;
        adj[u][v] = adj[v][u] = w;
    }

    for(int i = 0; i < (1 << N); i++) {
        for(int j = 0; j < N; j++) {
            if(!(i & (1 << j))) continue;

            for(int k = 0; k < N; k++) {
                if(i & (1 << k)) continue;

                prec[i] += adj[j][k];
            }
        }
    }

    memset(cc, -1, sizeof(cc));
    printf("%d", dp(0, (1 << N) - 2, 1) / 2);
}


Measured memory_bytes: 5504
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;

int main()
{
    int a,b,x,y;
    while(scanf("%d %d %d %d",&a,&b,&x,&y)!=EOF)
    {
        for(int i=0;i<y-b;++i)
            cout<<'U';
        for(int i=0;i<x-a;++i)
            cout<<'R';
        for(int i=0;i<y-b;++i)
            cout<<'D';
        for(int i=0;i<x-a;++i)
            cout<<'L';
        cout<<'L';
        for(int i=0;i<y-b+1;++i)
            cout<<'U';
        for(int i=0;i<x-a+1;++i)
            cout<<'R';
            cout<<"DR";
        for(int i=0;i<y-b+1;++i)
            cout<<'D';
        for(int i=0;i<x-a+1;++i)
            cout<<'L';
        cout<<'U'<<endl;
    }
    return 0;
}


Measured memory_bytes: 256