akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int n;
bool sex[100000];

bool dis(int a,int b,bool s){
  return ((b-a)%2)^s;
}

int main(){
  string s;
  cin>>n;
  if(n<20){
    fr(i,n){
      cout<<i<<endl;
      cin>>s;
      if(s=="Vacant") return 0;
    }
  }
  int l=0,r=n,m;
  cout<<0<<endl;
  cin>>s;
  if(s=="Vacant") return 0;
  sex[0]=(s=="Male");
  while(r-l>1){
    m=(r+l)/2;
    cout<<m<<endl;
    cin>>s;
    if(s=="Vacant") return 0;
    sex[m]=(s=="Male");
    if(dis(l,m,sex[l]==sex[m])) l=m;
    else r=m;
  }
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    for(int i=0; i<H; i++) cin >> A[i];

    int cnt = 0;
    for(auto s : A) for(auto c : s) if(c=='#') cnt++;
    cout << (cnt == H+W-1 ? "Possible" : "Impossible") << endl;

    return 0;
}


Measured memory_bytes: 3592
n,t = map(int, input().split())
a = list(map(int, input().split()))
ans=0
last_start=0
for i in range(1,len(a)):
    if last_start + t > a[i]: # continuous
        ans += (a[i] - last_start)
    else: # stop -> start
        ans+=t
    last_start=a[i]
ans+=t

print(ans)

Measured memory_bytes: 26708
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s=sc.next();

		System.out.print(s.charAt(0));
		System.out.print(s.length()-2);
		System.out.print(s.charAt(s.length()-1));
	}
}

Measured memory_bytes: 35612
fun main(args: Array<String>) {
    val (h1,m1,h2,m2,k) = readLine()!!.split(' ').map(String::toLong)

    if (true) {
        println((h2-h1)*60 + (m2-m1) - k)
    } else {
        println("No")
    }
}

Measured memory_bytes: 36316
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#define re register
#define ll long long
using namespace std;
ll n,a[3005],s;
int main()
{
	cin>>n;
	for(re int i=1;i<=n;i++){
		cin>>a[i];
		s+=a[i];
	}
	s-=n;
	cout<<s;
}

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

int main(){
  int x_N, Ngate, x_s;
  cin >> x_N >> Ngate >> x_s;

  vector<int> data(Ngate);
  for(int i=0; i<Ngate; i++){
    cin >> data.at(i);
  }

  auto itr= lower_bound(data.begin(), data.end(), x_s);
  int cost_right= distance(itr, data.end());
  int cost_left = Ngate- cost_right;

  cout << min(cost_left, cost_right) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = (1LL<<60);
const int inf = (1<<29);

// editorial AC
// bitDP
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


// O(M2^N)
int main () {

    int N , M;
    cin >> N >> M;
    vector<ll> a(M), b(M);
    vector<int> c(M, 0); //c is bits
    ll dp[1100][5000];

    for(int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        for (int j = 0; j < b[i]; j++) {
            int t; cin >> t; t--;
            c[i] += (1<<t);
        }
    }

    for (int i = 0; i < 1100; i++) {
        for (int j = 0; j < 5000; j++) {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;

    for(int i = 0; i < M; i++) {
        for (int j = 0; j < (1<<N); j++) {
            chmin(dp[i+1][j], dp[i][j]);
        
            int nj = j | c[i];
            chmin(dp[i+1][nj], dp[i][j] + a[i]);
        }
    }

    // for(int i = 0; i < M; i++) {
    //     for (int j = 0; j < (1<<N); j++) {
    //         cout << dp[i][j];
    //     }
    //     cout << endl;
    // }

    cout << (dp[M][(1<<N)-1] < INF ? dp[M][(1<<N)-1] : -1) << endl;

    return 0;
}

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

int main(){
    string s;
    int m, h;
    while(cin>>s){
        if(s=="-")break;
        cin>>m;
        for(int i=0;i<m;i++){
            
            cin>>h;
            s = s.substr(h, s.size()-h)+ s.substr(0, h);
        }
        
        cout<<s<<endl;
    }
    return 0;
}



Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        if (a > b) {
            System.out.println("a > b");
        } else if (a < b) {
            System.out.println("a < b");
        } else {
            System.out.println("a == b");
        }

    }
    
    
}


Measured memory_bytes: 26088
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    ans = 1 if N == 0 else 0
    print(ans)


main()


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

const int maxN = 5e5 + 100, base = 13, m1 = 1e9 + 7, m2 = 1e9 + 9;

int n, a[maxN + 1], b[maxN + 1];
int ha[2][35][maxN + 1], hb[2][35], hc[2][35];
int pw[2][maxN + 1], ans[35][maxN + 1];

inline int read()
{
	int num = 0, f = 1;
	char ch = getchar();
	while( !isdigit( ch ) ) { if(ch == '-') f = -1; ch = getchar(); }
	while( isdigit( ch ) ) num = (num << 3) + (num << 1) + (ch ^ 48), ch = getchar();
	return num * f;
}

int main()
{
	n = read();
	for(int i = 1; i <= n; i++) a[i] = a[i + n] = read();
	for(int i = 1; i <= n; i++) b[i] = read();

	pw[0][0] = pw[1][0] = 1;
	for(int i = 1; i <= 2 * n; i++) pw[0][i] = 1ll * pw[0][i - 1] * base % m1, pw[1][i] = 1ll * pw[1][i - 1] * base % m2;

	for(int i = 1; i <= 2 * n; i++)
		for(int j = 0; j < 30; j++)
		{
			int x = (a[i] >> j) & 1;
			ha[0][j][i] = (1ll * ha[0][j][i - 1] * base % m1 + x) % m1;
			ha[1][j][i] = (1ll * ha[1][j][i - 1] * base % m2 + x) % m2;
		}

	for(int i = 1; i <= n; i++)
		for(int j = 0; j < 30; j++)
		{
			int x = (b[i] >> j) & 1;
			hb[0][j] = (1ll * hb[0][j] * base % m1 + x) % m1;
			hb[1][j] = (1ll * hb[1][j] * base % m2 + x) % m2;
		}

	for(int i = 1; i <= n; i++)
		for(int j = 0; j < 30; j++)
		{
			int x = ((~b[i]) >> j) & 1;
			hc[0][j] = (1ll * hc[0][j] * base % m1 + x) % m1;
			hc[1][j] = (1ll * hc[1][j] * base % m2 + x) % m2;
		}

	for(int i = 1; i <= n; i++)
		for(int j = 0; j < 30; j++)
		{
			int t1 = ((ha[0][j][i + n - 1] - 1ll * ha[0][j][i - 1] * pw[0][n] % m1) % m1 + m1) % m1;
			int t2 = ((ha[1][j][i + n - 1] - 1ll * ha[1][j][i - 1] * pw[1][n] % m2) % m2 + m2) % m2;
			if(t1 == hb[0][j] && t2 == hb[1][j]) ans[j][i] = 0;
			else if(t1 == hc[0][j] && t2 == hc[1][j]) ans[j][i] = 1;
				else ans[j][i] = -1;
		}

	for(int i = 1; i <= n; i++)
	{
		bool flag = true;
		for(int j = 0; j < 30; j++)
			if(ans[j][i] == -1) { flag = false; break; }
		if(!flag) continue;
		int res = 0;
		for(int j = 0; j < 30; j++) res |= (ans[j][i] << j);
		printf("%d %d\n", i - 1, res);
	}
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int x2 = 0, x4 = 0;
	rep(i, n) {
		if (a[i] % 4 == 0) x4++;
		else if (a[i] % 2 == 0) x2++;
	}
	if (x4 + x2 / 2 >= n / 2) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,a,b) for (int i = (a) ; i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int N, s1 = 0, s2 = 0;
	cin >> N;
	VI w(N);
	rep(i, N){
		cin >> w[i];
		s2 += w[i];
	}
	int ans = s2;

	rep(i, N-1){
		s2 -= w[i];
		s1 += w[i];
		ans = min(ans, abs(s1-s2));
	}


	cout << ans << endl;


}

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

  return 0;
}


Measured memory_bytes: 3536
#include <stdio.h>

int main(void)
{
	int a, b;
	char op;

	while (1)
	{
		scanf("%d %c %d", &a, &op, &b);
		if (op == '?') break;
		else if (op == '+') printf("%d\n", a + b);
		else if (op == '-') printf("%d\n", a - b);
		else if (op == '*') printf("%d\n", a * b);
		else if (op == '/') printf("%d\n", a / b);
	}
	return 0;
}

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


int main(){
	    ll X; cin >> X;
        ll ans = 0;
        ans += X / 500 *1000;
        X %= 500;
        ans += X / 5 * 5;
        cout << ans << endl;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<string> list(n);
  int i, j, k, l;
  for (i = 0; i < n; i++) {
    cin >> list[i];
  }
  int space;
  int result = 0;
  bool break_flag = false;
  for (i = 0; i < n; i++) {
    // cout << i << " list[i].length(" << list[i].length() << ") ";
    break_flag = false;
    for (j = 0; j < list[i].length(); j++) {
      if (list[i].at(j) == s.at(0)) {
        for (k = j + 1; k < list[i].length(); k++) {
          if (list[i].at(k) == s.at(1)) {
            space = k - j;
            // cout << space;
            // cout << "for(" << (l < s.length()) << (k + space * l < list[i].length()) << ' ' << k + space * l << ") ";
            for (l = 2; l < s.length() && k + space * (l - 1) < list[i].length(); l++) {
              if (s.at(l) != list[i].at(j + (space * l))) {
                // cout << l << list[i].at(j + space * l ) << ' ' ;
                break;
              }
              if (l == s.length() - 1) {
                result += 1;
                // cout << list[i] << endl;
                break_flag = true;
                break;
              }
            }
          }
          if (break_flag) {
            break;
          }
        }
      }
      if (break_flag) {
        break;
      }
    }
    // cout << endl;
  }
  cout << result << endl;
  return 0;
}



Measured memory_bytes: 3192
import numpy as np

N, M = map(int, input().split())

ac = 0
wa = 0
test = [0] * N
count = [0] * N
for i in range(M):
    p_i, s_i = input().split(" ")
    p_i = int(p_i) - 1
    if s_i == "AC":
        test[p_i] = 1
    elif test[p_i] != 1:
        count[p_i] += 1

test = np.array(test)
count = np.array(count)

score = np.sum(test)
pena = np.sum(test * count)
print(str(int(score)) + " " + str(int(pena)))

Measured memory_bytes: 14796
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1,-1, 0, 0};
int dy[4] = {0, 0, 1,-1};
int cnt[100005];
signed main() {
    int N,M;
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int a,b;
        cin >> a >> b;
        cnt[a]++;cnt[b]++;
    }
    for(int i = 1; i <= N; i++) {
        if(cnt[i]%2 == 1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n; cin >> n;
  string ans;
  while(n > 0) {
    n--;
    ans += 'a'+(n%26);
    n /= 26;
  }
  reverse(all(ans));
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3624
// Tazoe

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

int main()
{
	while(true){
		double a, b, c, d;
		cin >> a >> b >> c >> d;

		if(a==-1.0&&b==-1.0&&c==-1.0&&d==-1.0)
			break;

		a = a*M_PI/180.0;
		b = b*M_PI/180.0;
		c = c*M_PI/180.0;
		d = d*M_PI/180.0;

		double x = acos(sin(a)*sin(c)+cos(a)*cos(c)*cos(d-b));

		cout << (int)(6378.1*x+0.5) << '\n';
	}

	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#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;
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}



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

int main(){
    int n, m, x, y;
    cin >> n >> m;
    vector<int> a(n, -1);
    for(int i = 0; i < m; i++){
        cin >> x >> y;
        for(int j = x-1; j <= y-1; j++)   a[j] = max(a[j], y-1);
    }
    int ans = 0, cur = 0;
    while(cur < n){
        if(a[cur] == -1){
            cout << "Impossible" << endl;
            return 0;
        }
        ans++;
        cur = a[cur]+1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <iomanip>
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
const int AMAX = 100000; 
using namespace std;
#define rep(i, n) for (i64 i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define down(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
using LL = long long;
using ULL = unsigned long long;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main(void) {
    float n, k,a,b;
    string s;
    cin >> n;
    rep(i,n){
    if((i+1)%2==0){
    }else{
        a += 1;
    }
    }
    cout <<fixed<<setprecision(10)<<a / n;
}

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int x[m];
    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }
    sort(x, x+m);

    int d[m-1];
    for (int i = 0; i < m - 1; i++) {
        d[i] = x[i+1] - x[i];
    }
    sort(d, d+m-1);

    int ans = x[m-1] - x[0];
    for (int i = 0; i < n - 1 && i < m - 1; i++) {
        ans -= d[m-2-i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
from itertools import permutations
Minute=[int(input()) for _ in range(5)]

ans_l=set()
for M in permutations(Minute):
    res=0
    ans=0
    for i in range(5):
        res+=M[i]
        if i==4:
            break
        if res%10!=0:
            res=-(-res//10)*10
    ans_l.add(res)

print(min(ans_l))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl;
#define STOP assert(false);
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


int main(){
	int n, m;
	cin >> n >> m;
	vector<vi> a(n, vi(m));
	rep(i, n) rep(j, m) cin >> a[i][j], --a[i][j];
	set<int> st;	//消したものリスト
	vi curr(n);
	int ans = 1e9;
	while(st.size()< m) {
		int erase = -1, num = -INF;
		vi cnt(m);
		rep(i, n) {
			while(st.count(a[i][curr[i]])) curr[i]++;
			cnt[a[i][curr[i]]]++;
		}
		rep(i, m) if(cnt[i] > num) erase = i, num = cnt[i];
		ans = min(ans, num);
		st.insert(erase);
	}	
	cout << ans << endl;
}


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

int main(void) {
      int n;
      int k;
      int ans = 0;
      cin >> n >> k;

      for (int i = 0; i < n; i++) {
            int hi;
            cin >> hi;
            if (hi >= k) {
                  ans++;
            }
      }
      cout << ans << endl;
      return 0;
}


Measured memory_bytes: 256
import numpy as np
 
n, t = map(int, input().split())
a = []
b = []

for _ in range(n):
  a_tmp, b_tmp = map(int, input().split())
  a.append(a_tmp)
  b.append(b_tmp)
    
arg = np.argsort(a)
a = np.array(a)[arg]
b = np.array(b)[arg]
dp = np.zeros((n, t), dtype=np.int)
    
for i in range(n - 1):
  dp[i+1, :a[i]] = dp[i, :a[i]]
  dp[i+1, a[i]:] = np.maximum(dp[i, a[i]:], dp[i, :-a[i]] + b[i])
  
print(np.max(dp[:, -1] + b))

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

int sum(vector<int> n){
  int l = n.size();
  int s = 0;
  for(int i = 0;i<l;i++){
    s += n[i];
  }
  return s;
}
  

int main() {
  int N;
  cin >> N;
  vector<int> t(N);
  for(int i=0;i<N;i++){
    cin >> t[i];
  }
  int M;
  cin >> M;
  for(int i=0;i<M;i++){
    int p,x,c;
    cin >> p >> x;
    c = t[p-1];
    t[p-1] = x;
    cout << sum(t) << endl; 
    t[p-1] = c;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> w(n);
  for(int i=0;i<n;i++)cin>>w[i];
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=w[i];
  }
  int mi=sum;
  for(int i=0;i<n;i++){
    int k=0;
    for(int j=0;j<=i;j++){
      k+=w[j];
    }
    mi=min(abs(sum-2*k),mi);
  }
  cout<<mi<<endl;
}

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

using namespace std;

int dp[100001];
int main() {
    int n,m;
    cin>>n;
    vector<int>h;
    int k;
    cin>>k;
    for(int i=0;i<n;i++){int l;cin>>l;h.push_back(l);}
    for(int i=0;i<100001;i++) dp[i] = 2e9;
    
    int pos;
 //  h.push_back(0);
  dp[n]=0;
   reverse(h.begin(),h.end());
    for(int i=n;i>1;i--)
    {  
      
        for(int j=i-1;j>=max(1,i-k);j--)
        {  
            dp[j]=min(dp[i]+abs(h.at(j-1)-h.at(i-1)),dp[j]);
         //   cout<<dp[j]<<'('<<j<<')';
        //    cout<<m<<" ";
          //  if(m<=mini)mini=m,pos=j;
            
        }//cout<<endl;
        // dp[pos]=mini;
        // i=pos++;
        // cout<<pos<<' ';
    }
    cout<<dp[1];
    
}


Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  string s;
  cin>>n>>s;
  int rcnt=0;
  rep(i,s.size() ){
    if(s[i]=='R') rcnt++;
  }
  int a1=0,a2=rcnt;
  rep(i,s.size() ){
    if(i<rcnt && s[i]=='R') a1++;
  }
  cout<<rcnt-a1<<endl;

  return 0;
}


Measured memory_bytes: 3760
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
#define pii pair<int,int>
using namespace std;


int main() {

	ll n, a[200];
	int ans = 0;

	cin >> n;
	rep(i, 0, n)cin >> a[i];
	while (1) {
		rep(i, 0, n) {
			if (a[i] % 2 == 0)a[i] /= 2;
			else {
				cout << ans << endl;
				return 0;
			}
		}
		ans++;
	}

	return 0;
}

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

int main(){
  
  int n;
  cin >> n;
  
  int house[4][3][10]={{{}}};
  for(int i=0; i<n; i++){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    house[a-1][b-1][c-1]+=d;
  }
  for(int j=0; j<4; j++){
    for(int k=0; k<3; k++){
      for(int l=0; l<10; l++){
        cout << ' ' << house[j][k][l];
      }
      cout << endl;
    }
    if(j!=3)
    cout << "####################" << endl;
  }
}


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

int main(){
	int n,x,f=1;
	cin>>n;
	while(n--){
		cin>>x;
		if (x%2==0 && x%3!=0 && x%5!=0)f=0;
	}
	if(f)cout<<"APPROVED"<<endl;
	else cout<<"DENIED"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<b;i++)
#define f(i,n) for(int i=0;i<n;i++)
typedef unsigned long long ull;
typedef long long ll;
#define vint vector<int>
#define pb(a) push_back(a);
#define bug(x) cout<<#x<<" = "<<x<<endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);

const int M=1e9+7;

ull pow(ull a,ull p){
    if(p==1){return a%M;}
    if(p%2==0){
        ull temp=pow(a,p/2);
        return (temp*temp)%M;
    }
    return ((pow(a,p-1)%M)*a)%M;
    
}

int main(){
	// fastio;
	ull n,k;
    cin>>n>>k;

    ull a = n-k+2,ans=0;
    // bug(a);
    for(;k<=n+1;k++){
        ull m = ((k*(k-1))/2), MM = ((k*(2*n-k+1))/2);
        // bug(m); bug(MM);
        ans+= (MM-m+1);
        ans %=M;
    }
    
    // ull ans = a;
    // if(ans%2==0){
    //     ans/=2;
    //     ans%=M;
    //     ans = (ans*((a+1)%M))%M;
    // }
    // else{
    //     ans = (ans * ((a+1)/2)%M)%M;
    // }    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e3+1000;
ll a,b,c,k;
string s;
int main(){
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>a>>b>>c>>k;
    ll ans=0;
    while(b<=a){
        b*=2;ans++;
    }while(c<=b){
        c*=2;ans++;
    }if(ans<=k) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main()
{
   int N;
   cin >> N;
   ll S[N];
   FORV(s, S)
   {
      cin >> s;
   }

   ll ans = 0;
   ll score;
   REP(C, 1, N - 1)
   {
      score = 0;
      set<int> L;
      for (int k = 1; C * (k + 1) < N; k++)
      {
         if (L.count(k * C) || k * C == N - 1 - k * C)
            break;
         score += S[k * C];
         score += S[N - 1 - k * C];
         L.insert(N - 1 - k * C);
         ans = max(ans, score);
      }
   }
   cout << ans << endl;
}

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


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    for (int i = 0; i < 3; i++) {
        string s;
        cin >> s;
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
 
typedef signed long long ll;
const int MX = 1e6 + 5;

int main() {
	int k, x;
	cin >> k >> x;
	((500 * k) >= x) ? cout << "Yes\n" : cout << "No\n";
    return 0;
}

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

signed main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  int ans = 1;
  string abc = "abcdefghijklmnopqrstuvwxyz";
  for( int i = 0; i < abc.size(); i++ ){
    int cnt = 0;
    for( int j = 0; j < N; j++ ){
      if( S.at(j) == abc.at(i) ) cnt++;
    }
    ans *= (cnt+1);
    ans = ans % MOD;
  }
  cout << ans - 1 << endl;
  
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<string>
#include<stdio.h>
#include<cmath>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(), (x).end()
#define lint long long


int main(){
    long n,m; cin>>n>>m;
    long g = m/n;
    while(g >= 1){
        if (m % g == 0){
            cout << g << endl;
            return 0;
        }
        g--;
    }
    cout << 1 << endl;
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
using namespace std;
long dp[3],a;
char op;
int n;
main()
{
	cin>>n>>dp[0];
	dp[1]=dp[2]=-1e18;
	for(int i=1;i<n;i++)
	{
		cin>>op>>a;
		if(op=='+')
		{
			dp[0]+=a;
			dp[2]+=a;
			dp[1]=max(dp[1]-a,dp[2]);
		}
		else
		{
			dp[2]=dp[1]+a;
			dp[1]=max(dp[1]+a,dp[0]-a);
			dp[0]=max(dp[0]-a,dp[1]);
		}
	}
	cout<<dp[0]<<endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 10**9 + 7
count = 0
for n in range(K, N+2):
  maxSum = (n*(N + N-n+1))//2
  minSum = (n*(n-1))//2
  count += maxSum - minSum + 1
  count %= mod

print(count)

Measured memory_bytes: 9184
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "cmath"
#include "random"

using namespace std;

const long long int MOD = 1000000007;

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

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

	cin >> N >> M;
	vector<int>v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	for (int i = 1; i <= M; i++) {
		for (int j = 0; j < N - 1; j++) {
			if (v[j] % i > v[j + 1] % i) {
				swap(v[j], v[j + 1]);
			}
		}
	}
	for (int i = 0; i < N; i++) {
		cout << v[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>

using namespace std;

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

    double prob = 0.0;
    for (int x = 1; x <= N; ++x)
    {
        int score = x;
        int coinNum = 0;
        for (;;)
        {
            if (score >= K)
            {
                break;
            }
            ++coinNum;
            score *= 2;
        }
        prob += 1.0 / static_cast<double>(N) * pow(0.5, coinNum);
    }
    cout << setprecision(12) << prob;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
M = sorted(L,reverse=True)
flag = 1
for i in range(N) :
    if i % 2 == 0 :
        l = M[i]
        if l != (N-i-1) :
            flag = 0
            break
    else :
        if M[i] != l :
            flag = 0
            break
if flag == 0 :
    ans = 0
else :
    ans = (2**(N//2)) % (10**9+7)
print(ans)


Measured memory_bytes: 13880
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int n,m;
vector<vector<int>> all;
vector<int> now;

void go(int pos, int v){
	if(pos==n) all.pb(now);
	else{
		fore(i,v,m+1){
			now.pb(i);
			go(pos+1,i);
			now.pop_back();
		}
	}
}


int main(){FIN;
	int q; cin>>n>>m>>q;
	vector<pair<ii,ii>> qs(q);
	fore(i,0,q){
		int a,b,c,d; cin>>a>>b>>c>>d; a--; b--;
		qs[i]={{a,b},{c,d}};
	}
	go(0,1);
	int ans=0;
	for(auto v:all){
		int now=0;
		for(auto x:qs) if(v[x.fst.snd]-v[x.fst.fst]==x.snd.fst)now+=x.snd.snd;
		ans=max(ans,now);
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 9828
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n,a,b,c;
int a_values[100005];
int b_values[100005];
int c_values[100005];
int dp_a[100005];
int dp_b[100005];
int dp_c[100005];

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

    cin >> n;
    for(int i = 0;i < n;i++)
    {
        cin >> a >> b >> c;
        a_values[i] = a;
        b_values[i] = b;
        c_values[i] = c;
    }

    dp_a[0] = a_values[0];
    dp_b[0] = b_values[0];
    dp_c[0] = c_values[0];

    for(int i = 1;i < n;i++)
    {
        dp_a[i] = max(dp_b[i-1],dp_c[i-1]) + a_values[i];
        dp_b[i] = max(dp_a[i-1],dp_c[i-1]) + b_values[i];
        dp_c[i] = max(dp_b[i-1],dp_a[i-1]) + c_values[i];
    }

    int r =  max(dp_a[n-1],dp_b[n-1]);
    cout << max(r,dp_c[n-1]) << endl;

    return 0;
}


Measured memory_bytes: 2560
# coding: utf-8
# Your code here!

X,N = map(int,input().split())

if N == 0:
    print(X)
    exit(0)

p = list(map(int,input().split()))

abs_diff = 1000000000
ans = 0
for i in range(1000,-1001,-1):
    if i in p:
        continue
    else:
        if abs_diff >= abs(X-i):
            abs_diff = abs(X-i)
            ans = i
        
print(ans)

Measured memory_bytes: 9116
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let d: usize = iter.next().unwrap().parse().unwrap();

    let mut xs = Vec::with_capacity(n);

    for _ in 0..n {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        xs.push(buf.split_whitespace()
            .map(|x| x.parse::<i64>().unwrap())
            .collect::<Vec<_>>());
    }

    let mut ans = 0;

    for i in 0..(n-1) {
        for j in (i+1)..n {
            let mut dist = 0f64;
            for k in 0..d {
                let t = xs[i][k] - xs[j][k];
                dist += (t*t) as f64;
            }
            dist = dist.sqrt();
            let dist_int = dist as i64;
            if (dist_int as f64) == dist {
                ans += 1;
            }
            // println!("{} {} {} {}", i, j, dist, dist_int);
        }
    }

    println!("{}", ans);
}


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

int main() {
  int n, m, ac, wa;
  cin >> n >> m;
  ac = 0;
  wa = 0;
  
  vector<int> vec(n, 1), wa_count(n, 0);
  
  for (int i = 0; i < m; i++) {
    int p;
    string s;
    cin >> p >> s;
    if (vec.at(p-1) == 1) {
      if (s == "AC") {
        ac++;
        wa += wa_count.at(p-1);
        vec.at(p-1) = 0;
      } else if (s == "WA") {
        wa_count.at(p-1)++;
      }
    }
  }
  
  cout << ac << ' ' << wa << endl;
}

Measured memory_bytes: 1024
// https://beta.atcoder.jp/contests/abc084

#define SUBMIT

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <map>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_N = 100000;
int dp[MAX_N + 1];

bool is_prime(int x) {
    if (x <= 1) return false;
    if (x <= 3) return true;
    if (x % 2 == 0 || x % 3 == 0) return false;

    for (int i = 5; i * i <= x; i+= 6) {
        if (x % i == 0 || x % (i + 2) == 0) return false;
    }

    return true;
}

int main() {
    int Q;
    vector<int> left;
    vector<int> right;
#ifdef SUBMIT
    cin >> Q;
    left.resize(Q);
    right.resize(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> left[i] >> right[i];
    }
#else
    Q = 6;
    left = {1, 13, 37, 19, 73, 13};
    right = {53, 91, 55, 51, 91, 49};
#endif

    memset(dp, 0, sizeof(dp));

    for (int i = 0; i < MAX_N + 1; ++i) {
        if (is_prime(i) && is_prime((i + 1) / 2)) dp[i] = dp[i - 1] + 1;
        else dp[i] = dp[i - 1];
//        cout << "[" << i << "]: " << dp[i] << endl;
    }

    for (int i = 0; i < Q; ++i) cout << dp[right[i]] - dp[left[i] - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int a, b, k; cin >> a >> b >> k;
  vector<int> res;
  for (int i = 1; i <= 100; i++) {
    if (a%i==0 && b%i==0) {res.push_back(i);}
  }
  int N = res.size();
  cout << res[N-k] << endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.PriorityQueue
import java.util.Comparator

val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

fun func() {
    var Q = nextInt()
    var q1 = PriorityQueue<Long>(Q, Comparator { a, b ->  b.compareTo(a) })
    var q2 = PriorityQueue<Long>(Q, Comparator { a, b ->  a.compareTo(b) })
    var s1 = 0L; var s2 = 0L; var B = 0L
    for (n in 0 until Q) {
        var t = listOfLong()
        if (t[0] == 1L) {
            var a = t[1]; var b = t[2]
            B += b
            q1.add(a); q2.add(a)
            var l = q1.peek(); var r = q2.peek()
            if (l > r) {
                q1.poll(); q1.add(r)
                q2.poll(); q2.add(l)
                s1 += r
                s2 += l
            } else {
                s1 += l
                s2 += r
            }
        } else {
            var a = q1.peek()
            println("${a} ${s2 - s1 + B}")
        }
    }
}

fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { it.toLong() }


Measured memory_bytes: 90756
def main():
    if size == 1:
        index_lis = [(0,0),(0,-1),(0,1),(-1,0),(1,0)]
    elif size == 2:
        index_lis = [(0,0),(0,-1),(0,1),(-1,-1),(-1,0),(-1,1),(1,-1),(1,0),(1,1)]
    elif size == 3:
        index_lis = [(0,0),(0,-1),(0,-2),(0,1),(0,2),(-1,-1),(-1,0),(-1,1),
                     (1,-1),(1,0),(1,1),(-2,0),(2,0)]
    drop(index_lis, x, y)
    
def drop(index_lis, x, y):
    for add_x, add_y in index_lis:
        _x = x + add_x
        _y = y + add_y
        if 0 <= _x <= 9 and 0 <= _y <= 9:
            sheet[_x][_y] = sheet[_x][_y] + 1
            
def check():
    total = 0
    max_num = 0
    for x in range(10):
        for y in range(10):
            if sheet[x][y] == 0:
                total += 1
            else:
                if sheet[x][y] > max_num:
                    max_num = sheet[x][y]
    print total
    print max_num

sheet = []
for i in range(10):
    lis = []
    for i in range(10):
        lis.append(0)
    sheet.append(lis)
    
while True:
    try:
        x, y, size = map(int, raw_input().split(','))
        main()
    except EOFError:
        check()
        break

Measured memory_bytes: 4340
/*input

*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;

int main()
{
  ifalse;
  int n;
  cin >> n;
  vector < ll > v(n);
  for(auto &x: v) {
    cin >> x;
  }

  ll cnt = 0;
  ll ans = 0;
  for(int i = 1; i < n; i ++) {
    if(v[i - 1] >= v[i]) {
      cnt ++;
    } else {
      cnt = 0;
    }
    ans = max(ans, cnt);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define N 100
int n, a[N];

int main() {
    //freopen("sample.in", "r", stdin);
    cin >> n;
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    sort(a + 1, a + 1 + n);
    for(int i = 1; i < n; i++) a[n] -= a[i];
    cout << ((a[n] < 0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define EPB emplace_back
#define MP make_pair
#define deb(x) cerr << #x << ":" << x << endl;
#define deba(x) cerr << #x << ":\n"; for(auto i: x) cerr << i << " ";cout << endl;
const int INF = 1e7 + 7, MOD = 1e9 + 7;
#define float double
const float EPS = 0.001;
bool feq(float a, float b) { return abs(a - b) < EPS; }
bool fgt(float a, float b) { return a - b > EPS; }
bool flt(float a, float b) { return a - b < EPS; }



int main() {
	fastio();
	int n;
	cin >> n;
	int d[n][2];
	for(int i=0; i<n; i++) {
		cin >> d[i][0] >> d[i][1];
	}
	int count = 0, i;
	for(i=2; i<n; i++) {
		if(d[i][0] == d[i][1] &&
			d[i-1][0] == d[i-1][1] &&
			d[i-2][0] == d[i-2][1])
				break;
	}
	cout << (i == n ? "No" : "Yes") << '\n';
	return 0;
}



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

int h1, m1, h2, m2, k;

int main(){
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	printf("%d\n", (h2 - h1) * 60 + m2 - m1 - k);
	
	return 0;
}


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

int main() {
    std::string S;
    std::cin >> S;

    size_t cnt = 1;
    char c = S[0];
    for (size_t i = 1; i < S.size(); ++i) {
        if (c != S[i]) {
            c = S[i];
            ++cnt;
        }
    }

    std::cout << cnt - 1 << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100
#define MMAX 5001
int X, Y, Z, A[MAX], V[MAX], E[MAX];
void compute() {
	float P[MMAX][MAX];
	for (int i = 0; i < MMAX; i++) {
		for (int j = 0; j <= Y; j++)
			P[i][j] = 0;
	}
	P[0][0] = 1.0;
	int np, nv;
	for (int j = 0; j < Y; j++) {
		for (int i = 0; i < MMAX; i++) {
			if (P[i][j] == 0)
				continue;
			for (int k = 0; k < X; k++) {
				np = min(Y, j + V[k]);
				nv = i;
				if (E[np] == 1) {
					np = min(Y, np + A[np]);
				} else if (E[np] == 2) {
					nv = i + A[np];
				} else if (E[np] == 3) {
					nv = max(0, i - A[np]);
				}
				P[nv][np] += P[i][j] * (1.0 / X);
			}
		}
	}
	double ex = 0;
	for (int i = 0; i < MMAX; i++)
		ex += P[i][Y] * i;
	cout << (int) ex << endl;
}
int main() {
	int n, e, a;
	while(1) {
		cin >> X >> Y >> Z;
		if ( X == 0 && Y == 0 && Z == 0 ) break;
		for ( int i = 0; i <= Y; i++ ) A[i] = E[i] = 0;
		for ( int i = 0; i < X; i++ ) cin >> V[i];
		for ( int i = 0; i < Z; i++ ) {
			cin >> n >> e >> a;
			A[n] = a;
			E[n] = e;
		}
		compute();
	}
	return 0;
}

Measured memory_bytes: 5036
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r*r*pi;
        double length = 2*r*pi ;
        System.out.printf("%f %f\n", area, length);
    }
}


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

vector<vector<int>> graph;
vector<int> ans;
vector<int> parent;
vector<int> state;
vector<bool> in_path;

void helper(int u)
{
    for (int i = 0; i != in_path.size(); ++i)
        in_path[i] = 0;
    
    int tmp = -1;
    for (int x = u; x != tmp; x = parent[x])
    {
        in_path[x] = 1;
        
        if (tmp == -1)
            tmp = u;
    }
    
    tmp = -1;
    for (int x = u; x != tmp; x = parent[x])
    {
        for (int v : graph[x])
        {
            if (in_path[v] && parent[v] != x)
            {
                parent[v] = x;
                helper(v);
                return;
            }
        }
        
        if (tmp == -1)
            tmp = u;
    }
    
    for (int i = 0; i != in_path.size(); ++i)
        if (in_path[i])
            ans.push_back(i);
}

bool dfs(int u, int p)
{
    state[u] = 0;
    parent[u] = p;
    
    for (int v : graph[u])
    {
        if (state[v] == -1)
        {
            if (dfs(v, u))
                return 1;
        }
        else if (state[v] == 0)
        {
            parent[v] = u;
            helper(u);
            return 1;
        }
    }
    
    state[u] = 1;
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    
    graph.resize(n);
    for (int i = 0; i != m; ++i)
    {
        int u, v;
        cin >> u >> v;
        
        graph[u - 1].push_back(v - 1);
    }
    
    parent.resize(n);
    state.resize(n, -1);
    in_path.resize(n);
    
    for (int u = 0; u != n; ++u)
        if (state[u] == -1)
            if (dfs(u, -1))
            {
                cout << ans.size() << '\n';
                for (int x : ans)
                    cout << x + 1 << '\n';
                return 0;
            }
    
    cout << -1 << '\n';
    
    return 0;
}


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

using LL = long long;

int main(){
    LL r,d,x;
    cin>>r>>d>>x;

    for(int i=0; i<10; i++){
        x = r*x - d;
        cout<<x<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    wsv = []
    for _ in range(N):
        w, s, v = map(int, input().split())
        wsv.append((w, s, v))
    wsv.sort(key=lambda x: x[0] + x[1])

    inf = 1000000007
    dp = [[-inf] * 20001 for _ in range(N+1)]
    dp[0][0] = 0
    for i in range(N):
        w, s, v = wsv[i]
        for j in range(20001):
            if dp[i][j] != -inf:
                dp[i+1][j] = max(dp[i+1][j], dp[i][j])
                if j <= s:
                    dp[i+1][j+w] = max(dp[i+1][j+w], dp[i][j] + v)
    print(max(dp[-1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 189980
#include <bits/stdc++.h>
    using namespace std;
    #define INF 2000000000
    typedef long long int ll;
    typedef pair<ll,ll> ii;
    typedef pair<ii,ll> iii;
    typedef vector<ll> vi;
    typedef vector<ii> vii;
    #define getbit(n,i) (((n)&(1<<(i)))!=0)
    #define setbit0(n,i) ((n)&(~(1<<(i))))
    #define setbit1(n,i) ((n)|(1<<(i)))
    #define togglebit(n,i) ((n)^(1<<(i)))
    #define lastone(n) ((n)&(-(n)))
    #define read freopen("debug\\in.txt","r",stdin)
    #define write freopen("debug\\out.txt","w",stdout)
    #define fi first
    #define se second
    #define getI(a) scanf("%d",&a)
    #define getII(a,b) scanf("%d%d",&a,&b)
    #define PI (acos(-1))
    #define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define mod (1000000007)
    #define asz 500005
    #define pb push_back
    #define ppf pop_front
    #define ppb pop_back
    #define pf push_front
    ll a[200005];
    int main()
    {
        fastread;
        ll n,i,j,k,l,m;
        cin>>n;
        ll kola=log2(n);
        ll sum=0;
        ll gun=1;
        for(i=0;i<=kola;i++){
        	sum+=gun;
        	gun*=2;
		}
		cout<<sum;
    	return 0;
    }

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		int f = 0;
		for(int i = 0; i < n.length(); i++) {
			f += n.charAt(i) - '0';
		}
		if(Integer.parseInt(n) % f == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A[5];int k,count=0;
	for(int i=0;i<5;i++){
		cin>>A[i];
	}cin>>k;
	for(int i=0;i<5;i++){
		for(int j=i+1;j<5;j++){
			if(A[j]-A[i]>k){
				cout<<":("<<endl;
				return 0;
			}
		}
	}cout<<"Yay!"<<endl;
}

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

int main(){

    string S;

    cin >> S;

    int count = 0;
    // std::cout << "S:" << S << endl;
    for( int n = 0; n < S.length()/2; ++n ){
        //std::cout << (char)S[n] << "," << (char)S[S.length()-1-n] << endl;
        if( S[n] != S[S.length()-1-n] ){
            ++count;
        }
    }

    std::cout << count << endl;

    return 0;
}

Measured memory_bytes: 760
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define frl(i,c,b) for(ll i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 100001
#define M 1000000007
#define pb push_back

typedef long long int ll;

using namespace std;

int main()
{
    si(n);
    si(k);
    ll a[n+1];
    fr(i,1,n+1)   cin>>a[i];
    ll dp[n+1];
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k;j++)
        {
            if(j<i)
                dp[i]=min(dp[i-j]+abs(a[i-j]-a[i]),dp[i]);
        }
    }
    cout<<dp[n];
}

Measured memory_bytes: 5196