akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000
using ll=long long;


int main(){
  int H,W;
  cin>>H>>W;
  int Ch,Cw,Dh,Dw;
  cin>>Ch>>Cw>>Dh>>Dw;
  Ch--;Cw--;Dh--;Dw--;
  vector<vector<char>> S(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>S[i][j];
    }
  }

  vector<vector<int>> dist(H,vector<int>(W,INF));
  dist[Ch][Cw]=0;
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  queue<pair<int,int>> q1,q2;
  q1.push(make_pair(Ch,Cw));


  while(true){
  while(!q1.empty()){
    int i=q1.front().first;
    int j=q1.front().second;
    q1.pop();
    q2.push(make_pair(i,j));
    //cout<<i<<" "<<j<<endl;
    for(int k=0;k<4;k++){
      int ni=i+dx[k];
      int nj=j+dy[k];
      if(ni<0||nj<0||ni>=H||nj>=W){
        continue;
      }
      if(S[ni][nj]=='#'){
        continue;
      }
      if(dist[i][j]<dist[ni][nj]){
        dist[ni][nj]=dist[i][j];
        //cout<<ni<<" "<<nj<<" : "<<dist[ni][nj]<<endl;
        q1.push(make_pair(ni,nj));
      }
    }
  }

  while(!q2.empty()){
    int i=q2.front().first;
    int j=q2.front().second;
    q2.pop();
    for(int di=-2;di<=2;di++){
      for(int dj=-2;dj<=2;dj++){
        int ni=i+di;
        int nj=j+dj;

        if(ni<0||nj<0||ni>=H||nj>=W){
          continue;
        }
        if(S[ni][nj]=='#'){
          continue;
        }
        if(dist[i][j]+1<dist[ni][nj]){
          dist[ni][nj]=dist[i][j]+1;
          q1.push(make_pair(ni,nj));
        }
      }
    }
  }
  if(q1.empty()){
    break;
  }
  }


  if(dist[Dh][Dw]==INF){
    cout<<-1<<endl;
  }else{
    cout<<dist[Dh][Dw]<<endl;
  }

}


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

using namespace std;

int main()
{
    vector<string> s = {
        "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "1"
    };
    string a, b;
    cin >> a >> b;
    int ai = distance(s.begin(), find(s.begin(), s.end(), a));
    int bi = distance(s.begin(), find(s.begin(), s.end(), b));
    if(ai < bi)
        cout << "Bob" << endl;
    else if(ai > bi)
        cout << "Alice" << endl;
    else
        cout << "Draw" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

vector<P> state[15];

int main(){
  int n;
  cin >> n;
  rep(i,n){
    int a;
    cin >> a;
    rep(j,a){
      int x,y;
      cin >> x >> y;
      x--;
      state[i].push_back(make_pair(x,y));
    }
  }
  int ans = 0;
  rep(bit,1<<n){//honest or unhonest
    bool flag = 1;
    rep(i,n){// check each state
      if (bit & (1 << i)){//if honest
        for(P p:state[i]){//check
          if(((bit >> p.first) & 1)!=p.second)flag=0;
        }
      }
    }
    if(flag){
      chmax(ans,__builtin_popcountll(bit));
      //cout << bit << endl;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve(string a,string b)
{
    ll n=a.size();
    ll m=b.size();
    ll dp[n+1][m+1];
    for(int i=0;i<=n;++i)
    {
        dp[i][0]=0;
    }
    for(int i=0;i<=m;++i)
    {
        dp[0][i]=0;
    }

    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
        {
            if(a[i-1]==b[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
//    for(int i=0;i<=n;++i)
//    {
//        for(int j=0;j<=m;++j)
//        {
//            cout<<dp[i][j]<<" ";
//        }
//        cout<<"\n";
//    }
    ll index=dp[n][m];
    //cout<<index<<"\n";
    char lcs[index+1];
    lcs[index]='\0';
    ll i=n,j=m;
    while(i>0 and j>0)
    {
        if(a[i-1]==b[j-1])
        {
            lcs[index-1]=a[i-1];
            --i;
            --j;
            --index;
            
        }
        else if(dp[i-1][j]>dp[i][j-1])
        {
            i--;
        }
        else
            j--;
    }
    cout<<lcs<<endl;
    

}
int main()
{
    string a,b;
    cin>>a;
    cin>>b;
    solve(a, b);
    cout<<"\n";
}


Measured memory_bytes: 73996
import java.util.Scanner;

public class Main {
    public static String process(int a, int b) {
        return String.valueOf(a*b-a-b+1);
    }

    // Util Func

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        // process
        final String result = process(a, b);

        // output
        System.out.println(result);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, M; cin >> N >> M;
    vector<int> gate(N+2, 0);
    for(int i=0; i<M; i++){
        int l, r; cin >> l >> r;
        gate[l]++;
        gate[r+1]--;
    }

    int ans = 0;
    for(int i=1; i<=N; i++){
        gate[i] = gate[i-1]+gate[i];
    }

    for(int i=1; i<=N; i++) if(gate[i] == M) ans++;

    cout << ans << endl;
}

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

int main()
{
	int m,n;
	cin>>m>>n;
	char a[m][n];
	for(int i=0;i<m;++i)
        for(int j=0;j<n;++j)
        cin>>a[i][j];
	for(int i=1;i<=n+2;++i) cout<<"#";
	cout<<"\n";
	for(int i=0;i<m;i++)
    {
        cout<<"#";
        for(int j=0;j<n;j++)
            cout<<a[i][j];
        cout<<"#\n";
    }
    for(int i=1;i<=n+2;++i) cout<<"#";
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

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

func main() {
	a := nextInt()
	b := nextInt()
	fmt.Println(a * b)
}


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


using namespace std;


const int MAXN = 100 * 1000 + 123;








int num[MAXN];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        num[u]++, num[v]++;
    }
    for (int i = 0; i < n; i++)
        if (num[i] & 1)
            return cout << "NO", 0;
    cout << "YES";
    return 0;
}

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

int main(){
    int A,B,C,K;
    cin>>A>>B>>C;
    cin>>K;
    int n=0;
    while(B<=A){
        B=B*2;
        n++;
        if(n>K){
            cout<<"No"<<endl;
            return 0;
        }
    }
    while(C<=B){
        C=C*2;
        n++;
        if(n>K){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 2e3 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

char c[N][N];
int l[N][N], r[N][N], u[N][N], d[N][N];
 
signed main() {
    IOS;
    #ifdef LOCAL
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++)
            cin >> c[i][j];   
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(c[i][j] == '#')  continue;
            l[i][j] = 1 + l[i][j-1];
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = m; j >= 1; j--){
            if(c[i][j] == '#')  continue;
            r[i][j] = 1 + r[i][j+1];
        }
    }
    for(int j = 1; j <= m; j++){
        for(int i = 1; i <= n; i++){
            if(c[i][j] == '#')  continue;
            u[i][j] = 1 + u[i-1][j];
        }
    }
    for(int j = 1; j <= m; j++){
        for(int i = n; i >= 1; i--){
            if(c[i][j] == '#')  continue;
            d[i][j] = 1 + d[i+1][j];
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(c[i][j] == '#')  continue;
            ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 66944
n = gets.to_i
s = gets.chomp

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

total = r_count * g_count * b_count

gap_max = (n - 1) / 2
(1..gap_max).each do |gap|
  first_max = n - gap*2 - 1
  (0..first_max).each do |first|
    a = s[first]
    b = s[first + gap]
    c = s[first + gap*2]
    if (a != b) && (b != c) && (c != a)
      total -=1
    end
  end
end

puts total

Measured memory_bytes: 14380
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vi H(N);
	REP(i, N) {
		cin >> H[i];
	}
	vi dp(N,1e9+100);
	dp[0] = 0;
	REP(i, N) {
		if(i + 1 < N)dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]));
		if(i + 2 < N)dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]));
	}
	cout << dp[N - 1] << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N,K;cin >> N >> K;
    vector<LL> h(N+100);
    rep(i,N)cin >> h[i];
    vector<LL> dp(N+100);
    rep(i,N+100)dp[i] = 1 << 30;
    dp[0] = 0;
    rep(i,N){
        for(int j = 1;j <= K;j++){
            chmin(dp[i+j],dp[i] + abs(h[i] - h[i+j]));
        }
    }

    cout << dp[N-1] << endl;
}



Measured memory_bytes: 1792
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    h = list(map(int, input().split()))

    dp = [0] * N
    dp[1] = abs(h[1] - h[0])
    for i in range(2, N):
        h2 = h[i] - h[i - 2]
        if h2 < 0:
            a = dp[i - 2] - h2
        else:
            a = dp[i - 2] + h2
        h1 = h[i] - h[i - 1]
        if h1 < 0:
            b = dp[i - 1] - h1
        else:
            b = dp[i - 1] + h1
        if a < b:
            dp[i] = a
        else:
            dp[i] = b

    ans = dp[-1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N, M;
    cin >> N >> M;
    int x, y;
    set<int> S;
    S.insert(1);
    vector<int> cnt(N+1, 1);
    for (int i = 0; i < M; i++) {
        cin >> x >> y;
        cnt[x]--;
        cnt[y]++;
        if(S.count(x)){
            S.insert(y);
            if(cnt[x] == 0){
                S.erase(x);
            }
        }
    }
    int ans = S.size();
    printf("%d\n", ans);

}

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


using namespace std;

bool f[3333][3333];

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  memset(f, false, sizeof(f));
  f[0][0] = true;
  for(int j = 0; j <= F; j++) {
    for(int i = 0; i <= F - j; i++) {
      if (i * 100 > j * E) {
        break;
      }
      if (j >= 100 * A && f[i][j - 100 * A]) {
        f[i][j] = true;
      }
      if (j >= 100 * B && f[i][j - 100 * B]) {
        f[i][j] = true;
      }
      if (i >= C && f[i - C][j]) {
        f[i][j] = true;
      }
      if (i >= D && f[i - D][j]) {
        f[i][j] = true;
      }
    }
  }
  double res = -1;
  int res1 = 0, res2 = 0;
  for(int j = 1; j <= F; j++) {
    for(int i = 0; i <= F - j; i++) {
      if (f[i][j]) {
        if (res < 100.0 * i / (i + j)) {
          res = 100.0 * i / (i + j);
          res1 = i; res2 = i + j;
        }
      }
    }
  }
  cout << res2 << " " << res1 << endl;
  return 0;
}


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

const ll MOD = 1000000007;
 
map< pair<ll,ll> , int > m;
ll p2[202020];

ll GCD(ll a, ll b) {
  if ( a%b==0 ) return b;
  return GCD(b, a%b);
}

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

int main(){
  p2[0] = 1;
  REP(i,202020) p2[i+1] = (p2[i] * 2) % MOD;
  
  int N;
  cin >> N;
  ll ans = 1;
  int z = 0;
  REP(i,N) {
    ll a,b;
    cin >> a >> b;
    if (a==0 && b==0) {
      z++;
    } else if (a==0) {
      m[{0,-1}]++;
    } else if (b==0) {
      m[{1,0}]++;
    } else {
      ll gcd = GCD(abs(a),abs(b));
      a /= gcd;
      b /= gcd;
      if (a<0) {
        a = -a;
        b = -b;
      }
      m[{a,b}]++;
    }
  }
  for ( auto m0 : m ) {
//    cout << m0.first.first << " " << m0.first.second << " " << m0.second << " " << ans << endl;
    ll a0 = m0.first.first;
    ll b0 = m0.first.second;
    ll a1,b1, t = 1;
    if ( m[{a0,b0}] != 0 ) {
      if ( b0<0 ) {
        a1 = -b0;
        b1 = a0;
      } else {
        a1 = b0;
        b1 = -a0;
      }
//      t = (modpow(2, m[{a0,b0}], MOD) + modpow(2, m[{a1,b1}], MOD) - 1) % MOD;
      t = (p2[m[{a0,b0}] ] + p2[m[{a1,b1}]]- 1) % MOD;
      m[{a1,b1}] = 0;
    }
    m[{a0,b0}] = 0;
    ans = (ans * t)% MOD;
  }
  cout << ((ans+z+MOD-1)%MOD) << endl;
}



Measured memory_bytes: 30092
function getCell(w, h, input, W, H) {
    return input[Math.max(0, Math.min(h, H - 1))][Math.max(0, Math.min(W - 1, w))];
}

function insert(w, h, input, W, H, value) {
    input[Math.max(0, Math.min(h, H - 1))][Math.max(0, Math.min(W - 1, w))] = value;
}

function checkValid(w, h, W, H) {
    return h == Math.max(0, Math.min(h, H - 1)) && w == Math.max(0, Math.min(W - 1, w));
}

function Main(input) {
    const H = parseInt(input.shift());
    const W = parseInt(input.shift());

    isBlack = false;
    var count = 0;

    var currentMap = [];
    var targetMap = [];
    input.forEach(element => {
        currentMap.push(element.split(""));
    });

    for (var h = 0; h < H; h++) {
        for (var w = 0; w < W; w++) {
            var cell = getCell(w, h, currentMap, W, H);
            if (cell == "#") {
                if (checkValid(w - 1, h, W, H) && getCell(w - 1, h, currentMap, W, H) == ".") targetMap.push([w - 1, h]);
                if (checkValid(w + 1, h, W, H) && getCell(w + 1, h, currentMap, W, H) == ".") targetMap.push([w + 1, h]);
                if (checkValid(w, h + 1, W, H) && getCell(w, h + 1, currentMap, W, H) == ".") targetMap.push([w, h + 1]);
                if (checkValid(w, h - 1, W, H) && getCell(w, h - 1, currentMap, W, H) == ".") targetMap.push([w, h - 1]);
            }
        }
    }
    
    while (targetMap.length > 0) {
        var nextTarget = [];
        var lightTarget = [];
        targetMap.forEach(element => {
            if(getCell(element[0], element[1], currentMap, W, H) == ".") {
                lightTarget.push(element);
            }
            insert(element[0], element[1], currentMap, W, H, "#");
        });
        targetMap = lightTarget;
        targetMap.forEach(element => {
            var w = element[0];
            var h = element[1];
            if (checkValid(w - 1, h, W, H) && getCell(w - 1, h, currentMap, W, H) == ".") nextTarget.push([w - 1, h]);
            if (checkValid(w + 1, h, W, H) && getCell(w + 1, h, currentMap, W, H) == ".") nextTarget.push([w + 1, h]);
            if (checkValid(w, h - 1, W, H) && getCell(w, h - 1, currentMap, W, H) == ".") nextTarget.push([w, h - 1]);
            if (checkValid(w, h + 1, W, H) && getCell(w, h + 1, currentMap, W, H) == ".") nextTarget.push([w, h + 1]);
        });
        count++;
        targetMap = nextTarget;
    }

    console.log(count);
}

// 改行・空白で分割
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 219696
#include<bits/stdc++.h>
#define ll long long
using namespace std;
//double dp[3000][3000];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*for(int i = 0 ; i<3000 ; i++){
        for(int j = 0  ; j<3000 ; j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;*/

    //dp[1][0] = 1-p[i];
    //dp[1][1] = p[i];
    int n;
    cin>>n;
    double dp[n+1][n+1];
    for(int i = 0 ; i<=n ; i++){
        for(int j = 0  ; j<=n ; j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    double p[n+1];
    //cout<<"ahem"<<endl;
    for(int i = 1 ;i<=n ; i++){
        double val = 0.0;
        cin>>val;
        p[i] = val;
    }
    //cout<<"ahem"<<endl;
    /*for(int i = 1 ; i<=n ; i++){
        dp[i][0] = dp[i-1][0]*(1.0-p[i]);
    }*/
    for(int i = 1 ; i<=n ; i++){
        for(int j = 0 ; j<=i ; j++){
            if(j == 0) dp[i][j] = dp[i - 1][j] * (1.0 - p[i]);
            else dp[i][j] = dp[i-1][j]*(1-p[i]) + dp[i-1][j-1]*p[i];
        }
    }
    /*for(int i = 0 ; i<=n ; i++){
        for(int j = 0; j <=n ; j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    double ans = 0.0;
    for(int i = n/2+1 ; i<=n ; i++){
        ans = ans+dp[n][i];
    }
    printf("%0.10f",ans);
    //cout<<ans;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define LL long long
using namespace std;

int main()
{
    LL n, k;
    cin>>n>>k;

    if (k%2) {
        LL x = n/k;
        cout<<x*x*x<<endl;
    }
    else {
        LL x = n/(k/2);
        LL a = x/2;
        LL b = x-x/2;
        cout<<a*a*a+b*b*b<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    string N;
    cin >> N;
    long long total = 0;

    for(int i = 0; i < N.size(); i++){
        total += N.at(i) - '0';
    }

    if(total % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        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 print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
typedef pair<int, int> P;
int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n - 1));
    REP(i, n) {
        REP(j, n - 1) {
            cin >> a[i][j];
            a[i][j]--;
        }
        reverse(a[i].begin(), a[i].end());
        //末尾を見れば次の人がわかる
    }
    vector<P> q;
    auto check = [&](int i) {
        //選手iが試合をできるか
        //できるならば追加する
        if(a[i].size() == 0)
            return;
        //対戦相手
        int j = a[i].back();
        if(a[j].back() == i) {
            P p(i, j);
            if(p.second < p.first) {
                swap(p.first, p.second);
            }
            q.push_back(p);
        }
    };
    REP(i, n) { check(i); }
    int day = 0;
    while(q.size() > 0) {
        day++;
        sort(q.begin(), q.end());
        q.erase(unique(q.begin(), q.end()), q.end());
        vector<P> prevQ;
        swap(prevQ, q);
        // qが空になる
        for(P p : prevQ) {
            int i = p.first;
            int j = p.second;
            a[i].pop_back();
            a[j].pop_back();
        }
        for(P p : prevQ) {
            int i = p.first;
            int j = p.second;
            check(i);
            check(j);
        }
    }
    REP(i, n) {
        if(a[i].size() != 0) {
            puts("-1");
            return 0;
        }
    }
    cout << day << endl;
    return 0;
}

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

using namespace std;
vector <long long> prime;
bitset <100009> bs;

void sieve ()
{
	bs.set ();

	for (long long i = 2; i < 100007; i++)
	{
		if (bs[i])
		{
			prime.push_back(i);
			for (long long j = i * i; j < 100007; j += i)
			{
				bs[j] = 0;
			}
		}
	}
}
int main(){

    sieve();
    long long n;
    cin>>n;
    int idx = lower_bound(prime.begin(),prime.end(),n)-prime.begin();
    cout<<prime[idx]<<"\n";
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

bool check(string s){
    int N=s.size();
    REP(i,N/2){
        if(s[i]!=s[N/2+i]) return false;
    }
    return true;
}

signed main()
{
    string s; cin>>s;
    int N=s.size();

    int ans;
    for(int i=2;i<=N-1;i+=2){
        if(check(s.substr(0,i))) ans=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,k;
  	ci(n>>k);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  ll ans=INF;
  FOR(i,0,n-k+1){
    if(A[i]<0&&A[i+k-1]<=0){
      chmin(ans,-A[i]);
    }
    else if(A[i]>=0&&A[i+k-1]>0){
      chmin(ans,A[i+k-1]);
    }
    else{
      ll a=rM(-2*A[i]+A[i+k-1],-A[i]+2*A[i+k-1]);
      chmin(ans,a);
    }
  }
  co(ans)
}

Measured memory_bytes: 1024
#include<iostream>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;


int main () {
  int count[26] = {0};
  int i;
  char ch;

  while (cin >> ch) {
    ch = tolower(ch);
    count[ch - 'a']++;
  }

  rep(i,26) {
    cout << (char)(i+'a') << " : " << count[i];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)



signed main(){
  int n;
  cin>>n;
  int cnt=0;
  lp(i,n){
    int a;
    cin>>a;
    if(a%2==0)cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}




Measured memory_bytes: 3092
n = int(input())
s = str(input())

line = [0]*(n+1)

for i in range(n):
    if s[i] == 'W':
        line[0] += 1
        line[i+1] -= 1
    if s[i] == 'E':
        line[i] += 1
        line[n] -= 1

# print(l)

for i in range(n-1):
    line[i+1] += line[i]

# print(line)
print(len(s)-max(line))

Measured memory_bytes: 15264
/*
 * a.cc:
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if (a<b && b<c) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;

}



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


int N, Q;
string S;
vector<set<int>> w(26);


void input() {
    cin >> N >> S >> Q;
}


void query1() {
    int i;
    char c;
    cin >> i >> c;
    i--;
    char x = S[i];
    S[i] = c;
    w[x - 'a'].erase(i);
    w[c - 'a'].insert(i);
}


void query2() {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    int ans = 0;
    rep(i, 26) {
        if (*w[i].lower_bound(l) <= r) ans++;
    }
    cout << ans << endl;
}


int main() {
    input();
    rep(i, 26) w[i].insert(N);
    rep(i, N) w[S[i] - 'a'].insert(i);
    rep(i, Q) {
        int type;
        cin >> type;
        if (type == 1) {
            query1();
        } else {
            query2();
        }
    }
}


Measured memory_bytes: 24196
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
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 dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
Pi xl[100100];
int ans;
int main(){
	cin>>n;
	ans=n;
	REP(i,n){
		int x,l;
		cin>>x>>l;
		xl[i]=Pi(x,l);
	}
	sort(xl,xl+n);
	int t=0;
	for(int i=1;i<n;i++){
		if(xl[t].first+xl[t].second>xl[i].first-xl[i].second){
			ans--;
			if(xl[t].first+xl[t].second>xl[i].first+xl[i].second){
				t=i;
			}
		}else{
			t=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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 dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};

const int inf=100000000;

llong pownew(llong m, llong n) {
        if (n == 0) { return 1; }
        if (n % 2 == 0) { return pow(m*m, n/2); }
        return pow(m, n-1) * m;
    }

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    cout<<(n-2)*180<<endl;




    return  0;
}


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// 最小値yを固定して最大値を最小化する
// 最小値をa[i]にすると決めると、y未満の数を含む区間は選べない
// そういう区間を消すといくつか列が残る
// ある長さmの列からはmax(0,m-k+1)個まで好きに取れる
// これらの候補がq個以上あればq番目に小さいものがxになる

int n, k, q, a[2020], res = inf;

int main() {
	cin >> n >> k >> q;
	rep(i,n) cin >> a[i];
	rep(i,n) {
		int y = a[i];
		vector<int> mn;
		rep(l,n) if (y<=a[l]) {
			int r = l;
			vector<int> t;
			while (r<n && y<=a[r]) t.push_back(a[r++]);
			sort(all(t));
			rep(j,(int)t.size()-k+1) mn.push_back(t[j]);
			l = r-1;
		}
		sort(all(mn));
		if (mn.size()>=q) chmin(res, mn[q-1]-y);
	}
	cout << res;
}

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

int	main()
{
    int M;
    cin >> M;
    vector<int64_t> d_vec(M), c_vec(M);
    for (int i = 0; i < M; ++i)
        cin >> d_vec.at(i) >> c_vec.at(i);
    int64_t sum_digit = 0;
    int64_t num_digit = 0;
    for (int i = 0; i < M; ++i) {
        sum_digit += d_vec.at(i) * c_vec.at(i);
        num_digit += c_vec.at(i);
    }
    cout << num_digit - 1 + (sum_digit - 1) / 9 << endl;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin>>s;
  bool j=true;
  rep(i,s.size()){
    if(i%2==1){
      if(s.at(i)=='R') j=false;
    }else if(s.at(i)=='L') j=false;
  }
  if(j) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	int n, coun = 0;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++){
		cin >> p[i];
		if (p[i] != i+1){
			coun++;
		}
	}
	if (coun <= 2) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}



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

signed main() {

  std::ios_base::sync_with_stdio(false);

  int n;
  std::cin >> n;

  std::map<std::string, int> cnt;
  
  for(int i = 0; i < n; ++i) {
    std::string s; 
    std::cin >> s;
    std::sort(begin(s), end(s));
    cnt[s]++;
  }

  long long ans = 0;
  for(const auto& pair : cnt) {
    ans += 1LL * pair.second * (pair.second - 1) / 2;
  }

  std::cout << ans << std::endl;

  

  return 0;
}

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

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

using namespace std;
using lint=long long;

int main(){
	lint s; scanf("%lld",&s);

	lint x1=min(s,lint(1e9));
	lint y2=(s+x1-1)/x1;
	lint x2=1;
	lint y1=x1*y2-s;

	printf("%lld %lld %lld %lld 0 0\n",x1,y1,x2,y2);

	return 0;
}


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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  int mx = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'I') {
      cnt++;
    } else {
      cnt--;
    }
    mx = max(mx, cnt);
  }
  cout << mx << endl;
  return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int X,Y,now,cnt;
bool memox[16001], memoy[16001];
string s;
vector<int> x,y;

void kr(vector<int>& v, bool memo[16001], bool f) {
    memo[8000] = true;
    for(auto i : v) {
        bool tmp[16001]={};
        rep(j,16000) {
            if (memo[j]) {
                if (f && j-i >= 0) tmp[j-i] = true;
                if (j+i <= 16000) tmp[j+i] = true;
            }
        }
        rep(j,16001) memo[j] = tmp[j];
        f = true;
    }
}

signed main() {
    cin >> s >> X >> Y;
    for(auto i : s) {
        if (i == 'F') cnt++;
        else {
            if (now%2) y.pb(cnt);
            else x.pb(cnt);
            cnt = 0;
            now++;
        }
    }
    if (cnt) {
        if (now%2) y.pb(cnt);
        else x.pb(cnt);
    }
    kr(x, memox, false);
    kr(y, memoy, true);
    if (memox[8000+X] && memoy[8000+Y]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
from collections import defaultdict

def bfs(s):
  q = [s]
  visited[s] = True
  c = 0
  while q != []:
    p = q[0]
    c += 1
    del q[0]
    for node in adj[p]:
      if not visited[node]:
        visited[node] = True
        q.append(node)
  return c

n,m = map(int,input().split())
adj = defaultdict(list)
visited = [False]*(n+1)
ans = 0
for _ in range(m):
  a,b = map(int,input().split())
  adj[a].append(b)
  adj[b].append(a)
for i in range(1,n+1):
  if not visited[i]:
    ans = max(ans,bfs(i))
print(ans)

Measured memory_bytes: 55608
#include<stdio.h>
int n,t,e,r,x;
int main() {
	scanf("%d%d%d",&n,&t,&e);r=-1;
	for(int i=0;i<n;i++) {
		scanf("%d",&x);
		if(t-e<=(t+e)/x*x)r=i+1;
	}
	printf("%d\n",r);
}

Measured memory_bytes: 2724
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

const LL MOD = 1000000007;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    VI vi = VI(5, 0);
    int k;
    cin >> vi[0] >> vi[1] >> vi[2] >> vi[3] >> vi[4] >> k;
    for (int i = 0; i < 4; ++i)
    {
        for (int j = i + 1; j < 5; ++j)
        {
            if (vi[j]-vi[i] > k)
            {
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    
    return 0;
}



Measured memory_bytes: 256
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]

sort_AB = sorted(AB, key= lambda x: x[1])
ans = 'Yes'
tmp = 0

for i in range(N):
    tmp += sort_AB[i][0]
    if tmp > sort_AB[i][1]:
        ans = 'No'
        break
        
print(ans)

Measured memory_bytes: 48496
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1) 

const ll INF = 10010001010;
const int inf = 2000000000;


typedef tuple<string, int, int> TUP;

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

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    ll ans = 0;
    ll y = min(A,min(B,C));
    ll x = max(A,max(B,C));
    ll z = A + B + C - y - x;
    if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0)
    {
        ans = 0;
    }
    else{
        ll ookii = x - x / 2;
        ll tiisai = x - ookii;
        ans = abs(ookii - tiisai) * y * z;
    }
    cout << ans << endl;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int n = 0; int x = 0;
  cin >> n >> x;
  while(n != 0 || x != 0) {
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
      for(int k = i; k <= n; ++k) {
        if(i == k) continue;
        if(x - i - k > 0 && x - i - k <= n && x - i - k != i && x - i - k != k && i < x - i - k && k < x - i - k) {
          ans++;
        }
      }
    }
    cout << ans << endl;
    cin >> n >> x;
  }
}


Measured memory_bytes: 3068
#include <cstring>
#include <cstdio>
#include <string>

using namespace std;

int main()
{
    char s0[4];
    if (scanf("%s", s0) < 1) return 0;

    char s1[4];
    if (scanf("%s", s1) < 1) return 0;

    char s2[4];
    if (scanf("%s", s2) < 1) return 0;

    printf("%c%c%c\n", s0[0], s1[1], s2[2]);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
//    fl();
	int n,m;
	scanf("%d%d",&n,&m);
	puts(n==m?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
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; }
using namespace std;

int V,E;
int dist2[110][110];//dist2[i][i]=0, and if there aren't any edges between i and j, then dist2[i][j]=INF;
void warshall_floyd(){
    rep(k,V){
        rep(i,V){
            rep(j,V){
                dist2[i][j]=min(dist2[i][j],dist2[i][k]+dist2[k][j]);
            }
        }
    }
}

signed main(){
    cin>>V>>E;
    map<P,int> edge;
    rep(i,V){
        rep(j,V){
            if(i==j)dist2[i][j]=0;
            else dist2[i][j]=INF;
        }
    }
    rep(i,E){
        int a,b,c; cin>>a>>b>>c;
        a--; b--;
        edge[P(a,b)]=c;
        dist2[a][b]=c;
        dist2[b][a]=c;
    }
    warshall_floyd();
    int ans=0;
    for(auto x: edge){
        int s=x.F.F,t=x.F.S,u=x.S;
        bool b=false;
        rep(i,V){
            if(dist2[i][s]+u==dist2[i][t]){
                b=true;
                break;
            }
        }
        if(!b)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
a,b,c,d = list(map(int, input().split()))
if(a <= c and c <= b and b <= d):
  print(b - c)
elif(c <= a and a <= b and b <= d):
  print(b - a)
elif(c <= a and a <= d and d <= b):
  print(d - a)
elif(a <= c and c <= d and d <= b):
  print(d - c) 
else:
  print(0)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
	int data[10],i,k,work;
	for(i=0;i<3;i++){
		scanf("%d",&data[i]);
	}
	for(i=0;i<3;i++){
		for(k=i+1;k<3;k++){
			if(data[i]>data[k]){
				work=data[i];data[i]=data[k];data[k]=work;
			}
		}
	}
	for(i=0;i<3;i++){
		if(i>0)printf(" ");
		printf("%d",data[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2592
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl "\n"

using namespace std;

const int N = int(10e5 + 5);

int main() {

	FIO
	int n, k; cin >> n >> k;
	int a[N];
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = k+1; i <= n; i++) {
		if (a[i-k] < a[i])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 4444
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

bool solve(int X, int Y, vector<int>& x, vector<int>& y) {
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  for (int Z = X + 1; Z <= Y; ++Z) {
    // cout << x.back() << "<" << Z << "<=" << y.front() << endl;
    if (X < Z && Z <= Y && x.back() < Z && y.front() >= Z) return true;
  }
  return false;
}

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  REP(i, N) cin >> x[i];
  REP(i, M) cin >> y[i];
  if (solve(X, Y, x, y)) cout << "No War" << endl;
  else cout << "War" << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#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 < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N;
    cin >> N;
    vector<int> b(N), res;
    rep(i, N) cin >> b[i], --b[i];

    

    rep(i, N){
        int p = -1;
        for(int j = (int)b.size()-1; j >= 0; j--){
            if(b[j] == j){
                p = j;
                break;
            }
        }
        if(p == -1){
            cout << -1 << endl;
            return 0;
        }

        res.push_back(p+1);
        b.erase(b.begin() + p);
    }

    reverse(res.begin(), res.end());
    for(auto v : res) cout << v << endl;

    return 0;
}

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

using ll = long long;
using p = pair<string, int>;

int main()
{
    int n, max_cnt = 0;
    cin >> n;
    
    unordered_map<string, int> m;
    set<string> set;

    string tmp;
    for(int i = 0; i < n; ++i)
    {
        cin >> tmp;
        m[tmp]++;
        max_cnt = max(m[tmp], max_cnt);
    }

    for(auto i: m)
    {
        if(i.second == max_cnt)
            set.insert(i.first);
    }

    for(auto i: set) cout << i << "\n";
    return 0;
}

Measured memory_bytes: 33352
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <stack>
using namespace std;
int main(){
  string str;
  stack<int> st;
  getline(cin, str);
  stringstream ss(str);
  while(ss >> str){
    if(isdigit(str[0])){
      int x = atoi(str.c_str());
      st.push(x);
    }
    else{
      int p2 = st.top(); st.pop();
      int p1 = st.top(); st.pop();
      switch(str[0]){
      case '+':
	st.push(p1+p2); break;
      case '-':
	st.push(p1-p2); break;
      case '*':
	st.push(p1*p2); break;
      }
    }
  }
  cout << st.top() << endl;

  return 0;
}

Measured memory_bytes: 1212