akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template <typename T>
struct edge {
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x) {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

template <typename T>
using Edges = vector<edge<T>>;
template <typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T>
using Matrix = vector<vector<T>>;

template <typename T>
vector<T> bellman_ford(Edges<T> &edges, int V, int s) {
    const auto INF = numeric_limits<T>::max();
    vector<T> dist(V, INF);
    dist[s] = 0;
    for (int i = 0; i < V - 1; i++) {
        for (auto &e : edges) {
            if (dist[e.src] == INF) continue;
            dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
        }
    }
    for (auto &e : edges) {
        if (dist[e.src] == INF) continue;
        if (dist[e.src] + e.cost < dist[e.to]) return vector<T>();
    }
    return dist;
}

int main() {
    const int64_t INF = numeric_limits<int64_t>::max();
    int V, E, r;
    cin >> V >> E >> r;
    Edges<int64_t> G;
    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        G.emplace_back(s, t, d);
    }
    auto dist = bellman_ford(G, V, r);
    if (dist.empty()) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    for (int i = 0; i < V; i++) {
        if (dist[i] == INF)
            cout << "INF" << endl;
        else
            cout << dist[i] << endl;
    }
}


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

using namespace std;

int n, q;
vector<int> A(n);
vector<bool> isE(2001);

int main()
{
	cin>>n;
	int num;
	
	for( int i=0; i<n; i++ ) {
		cin>>num;
		A.push_back( num );
		for( int j=2000-num; 0<j; j-- ) {
			if( isE.at( j ) ) {
				isE.at( j+num ) = true;
			}
		}
		isE.at( num ) = true;
	}
	cin>>q;
	for( int i=0; i<q; i++ ) {
		cin>>num;
		if( isE.at( num ) ) {
			cout<<"yes"<<'\n';			
		} else {
			cout<<"no"<<'\n';
		}
	}
    return 0;
}	

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long N;
  cin >> N;
  long count1=0;
  long count2=0;
  while(N>=500)
  {
  	N=N-500;
    count1++;
  }
  while(N>=5)
  {
  	N=N-5;
    count2++;
  } 
  cout << 1000*count1+5*count2 << endl;
}


Measured memory_bytes: 256
fun main() {
    var (a, b, h, m) = readLine()!!.split(" ").map(String::toInt)

    val ta = (360 * (h / 12.0) + 30.0 * (m / 60.0)) % 360
    val ma = (360 * (m / 60.0)) % 360

    var angle = Math.abs(ta - ma)
    angle = if (angle > 180) {
        360 - angle
    } else {
        angle
    }

    println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(angle))))
}





Measured memory_bytes: 36592
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pi              pair<int,int>
#define vi              vector<int>
#define mi              map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define MOD             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1N
#define loop(i,a,b)     for(int i=a;i<b;i++)

void FIO(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main(){
    FIO();
    int h1,m1,h2,m2,k; cin >> h1>>m1>>h2>>m2>>k;
    int totalH = (h2 - h1 ) * 60;
    int totalM = (m2-m1);
    int total = totalH + totalM;
    if(k > total) cout << 0;
    else cout << total - k;

}



















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = acos(-1.0);

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

int main() {
    int A, B; cin >> A >> B;

    int ans = 0;
    
    if (A <= 5) {
        ans = 0;
    } else if (6 <= A && A <= 12) {
        ans = B / 2;
    } else {
        ans = B;
    }

    cout << ans << endl;
    return 0;
}


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

int d[110][110][1<<4];

int main(){
  int n,m,e,s,t,r;
  cin >> n >> m >> e >> s >> t >> r;
  vector<vi> g(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<vi> ev(e,vi(3));
  int sbit = 0;
  rep(i,e){
    rep(j,3)cin >> ev[i][j];
    if(ev[i][2] == s)sbit |= 1<<i;
  }

  memset(d,-1,sizeof(d));
  d[s][0][sbit] = 0;
  queue<int> q;
  q.push(s*10000 + sbit);

  while(q.size()){
    int p = q.front(); q.pop();
    int v = p/10000, x = p/100%100, bit = p%100;
    //cout << v << " " << x << " " << bit << " " << d[v][x][bit] << endl;

    if(v==t){
      cout << d[v][x][bit] << endl;
      return 0;
    }

    //ocarina
    if(d[s][0][bit]<0){
      d[s][0][bit] = d[v][x][bit]+1;
      q.push(s*10000 + bit);
    }

    if(x>=r)continue;
    //normal road
    for(int u : g[v]){
      int nbit = bit;
      rep(i,e){
	if(u == ev[i][2])nbit |= 1<<i;
      }
      if(d[u][x+1][nbit]<0){
	d[u][x+1][nbit] = d[v][x][bit] + 1;
	q.push(u*10000 + (x+1)*100 + nbit);
      }
    }

    //event road
    rep(i,e){
      if( (bit>>i)&1 ){
	if(v==ev[i][0]){
	  int u = ev[i][1], nbit = bit;
	  rep(i,e){
	    if(u == ev[i][2])nbit |= 1<<i;
	  }
	  if(d[u][x+1][nbit]<0){
	    d[u][x+1][nbit] = d[v][x][bit] + 1;
	    q.push(u*10000 + (x+1)*100 + nbit);
	  }
	}

	if(v==ev[i][1]){
	  int u = ev[i][0], nbit = bit;
	  rep(i,e){
	    if(u == ev[i][2])nbit |= 1<<i;
	  }
	  if(d[u][x+1][nbit]<0){
	    d[u][x+1][nbit] = d[v][x][bit] + 1;
	    q.push(u*10000 + (x+1)*100 + nbit);
	  }
	}

      }
    }
  }
  cout << -1 << endl;
}

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

using namespace std;

signed main() {
  int n; cin >> n;
  string x,y;
  while(n--){
    cin >> x >> y;
    vector<vector<int> > dp(x.size()+1,vector<int>(y.size()+1));
    for(int i=0;i<x.size();++i){
      for(int j=0;j<y.size();++j){
	if(x[i]==y[j]) dp[i+1][j+1]=dp[i][j]+1;
	else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
      }
    }
    cout << dp[x.size()][y.size()] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 6860
import java.util.*;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    List<Integer> list = new ArrayList<Integer>();
    int num = sc.nextInt();
    
    while(sc.hasNext()){
      list.add(sc.nextInt());
    }
    Collections.sort(list,  Collections.reverseOrder());
    //System.out.println(list);
      
    int alisNum = 0;
    int bobNum = 0;
    for(int i = 0; i < num; i++){
    	if(i % 2 == 0){
        	alisNum += list.get(i);
          	//System.out.println(alisNum);
        } else {
          	bobNum += list.get(i);
            //System.out.println(bobNum);
        }  
    }  
    System.out.println(alisNum-bobNum);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N,K;
  cin >> N >> K;
  ll H[N];
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  sort(H,H+N);
  reverse(H,H+N);
  for (int i = 0; i < min(K,N); i++) {
    H[i] = 0;
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += H[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}

ll N;
ll K;
std::vector<long long> A;

bool check(ll mid){
    ll cnt=0;
    for (long long i = 0; i < N; i++) {
        if(A[i]<=mid) continue;
        cnt+=A[i]/mid;
    }
    return cnt<=K;
}

int main(){
    // long long N;
    scanf("%lld",&N);
    // long long K;
    scanf("%lld",&K);
    // std::vector<long long> A(N);
    A.resize(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }

    long long ng=0, ok=INF;
    while (abs(ok - ng) > 1) {
      long long mid = (ok + ng) / 2;
      if (check(mid)) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 4744
import sys
sys.setrecursionlimit(100000)

def solve(x,a,ans=0):
  if x == 0:
    return ans
  else:
    return solve(x-1,a[1:],ans+1/a[0])
  
N = int(input())
a = list(map(int,input().split()))

print(1/solve(N,a))

Measured memory_bytes: 3060
O = input()
E = input()

L = []
for i in range(len(O)):
  L.append(O[i])
  L.append("")

for j in range(len(E)):
  L[2*j+1] = E[j]

l = ""
for i in range(len(L)):
  l = l + L[i]

print(l)

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


int main(){
  string S;
  cin >> S;
  sort(S.begin(), S.end());
  S.erase(unique(S.begin(), S.end()), S.end());
  if(S.size()==26){
    cout << "None" << endl;
    return 0;
  }
  char t = 'a';
  for(auto& s : S){
    if(s!=t){
      cout << t << endl;
      return 0;
    }
    t++;
  }
  cout << 'z' << endl;
  return 0;
}

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

int main(void){
    int n,r;cin>>n>>r;
    if(n<10){
        cout<<r+100*(10-n)<<endl;
    }else{
        cout<<r<<endl;
    }
    
    
    
    return 0;
}


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

int main() {
    int n; cin >> n;
    int prevmin = 100000000;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int t; cin >> t;
        if (t < prevmin) {
            ans++;
            prevmin = t;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

k=int(input())

s=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]



print(s[k-1])


Measured memory_bytes: 2940
def solve(X):
    cnt = X.count('1')

    memo = [0]*(cnt+2)

    for v in range(1,cnt+2):
        memo[v] = memo[v%(bin(v).count('1'))]+1

    res = [None]*len(X)
    if cnt > 1:
        m = int(X,2)%(cnt-1)

        r = 1
        for i,c in enumerate(reversed(X)):
            if c == '1':
                res[i] = memo[(m-r)%(cnt-1)]+1
            r *= 2
            r %= cnt-1
    else:
        for i,c in enumerate(reversed(X)):
            if c == '1':
                res[i] = 0

    m = int(X,2)%(cnt+1)

    r = 1
    for i,c in enumerate(reversed(X)):
        if c == '0':
            res[i] = memo[(m+r)%(cnt+1)]+1
        r *= 2
        r %= cnt+1

    return '\n'.join(map(str,reversed(res)))



if __name__ == '__main__':
    N = int(input())
    X = input()
    print(solve(X))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    string s,t;
    int ans = 0;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i])ans++;
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi>
#define pb push_back
#define vs vector<string>
#define all(x) x.begin(),x.end()
#define mii map<int,int>
const int inf=0x3f3f3f3f3f3f3f3f;
void print(vi &v){
    for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
    cout<<endl;
}
int power(int a,int b){
    int res = 1;
    while(b!=0){
        if(b&1){
            res *= a; 
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t = 1;
    while(t--){
        int sum = 0,n,i;
        cin>>n;
        for(i=1;i<=n;i++){
        	if(i%3 && i%5)sum+=i;
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    struct P
    {
        public int index;
        public List<int> ad;
        public P(int index)
        {
            this.index = index;
            ad = new List<int>();
        }
    }
    static void Main(string[] args)
    {
        var nm = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ab = new int[nm[1]][];
        for (var i = 0; i < nm[1]; i++)
            ab[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var res = 0;
        for (var i = 0; i < nm[1]; i++)
        {
            var ps = new P[nm[0]];
            for (var j = 0; j < nm[0]; j++)
                ps[j] = new P(j);
            for(var j = 0; j < nm[1]; j++)
            {
                if (i == j) continue;
                ps[ab[j][0] - 1].ad.Add(ab[j][1] - 1);
                ps[ab[j][1] - 1].ad.Add(ab[j][0] - 1);
            }
            var set = new HashSet<int>();
            dfs(set, ps, 0);
            if (set.Count != nm[0]) res++;
        }
        WriteLine(res);
    }
    private static void dfs(HashSet<int> set,P[] ps,int index)
    {
        set.Add(index);
        foreach (var ad in ps[index].ad)
            if (!set.Contains(ad))
                dfs(set, ps, ad);
        
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 13524
#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(){
    long long x;
    cin >> x;
    long long a, b;
    a = x / 500;
    x -= (a * 500);
    b = x / 5;
    cout << a * 1000 + b * 5 << endl;
    return 0;
}



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

int main(){
    long long n;
    cin >> n;

    char s[n];
    for(long long i = 0; i< n; i++) cin >> s[i];

    for(long long i = 0; i < n; i++){
        if(s[i] == 'Y'){
            printf("Four\n");
            return 0;
        }
    }
    printf("Three\n");
    return 0;
}

Measured memory_bytes: 3648
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (h, w) = listOfInt()

    var line = ""
    repeat(w+2){line += "#"}
    println(line)

    repeat(h){
        println("#" + next() + "#")
    }

    println(line)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37868
def insertion_sort(array):
    for i in range(len(array)):
        v = array[i]
        j = i - 1

        while(j>=0 and array[j] > v):
            array[j+1] = array[j]
            j = j - 1

        array[j+1] = v

        print(' '.join(map(str, array)))

    return array

if __name__ == '__main__':
    element_number = int(input())
    input_array = list(map(int, input().split()))

    insertion_sort(input_array)

Measured memory_bytes: 7640
n=int(input())
ab=[list(map(int, input().split())) for _ in range(n)] 
cd=[list(map(int, input().split())) for _ in range(n)] 

#ab = sorted(ab, key=lambda x:x[1]*(-1))
ab.sort(key=lambda x: x[0],reverse=True)
ab.sort(key=lambda x: x[1],reverse=True)
cd=sorted(cd)

cnt=0
for i in range(n):#ab
    for j in range(len(cd)):#cd
        if ab[i][0]<cd[j][0] and ab[i][1]<cd[j][1]:
            cnt+=1
            cd.pop(j)
            break
print(cnt)

Measured memory_bytes: 38896
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

ll n;
ll ans(ll a){
    return (a+n-2)/n;
}

ll pro(ll a){
    ll res = 0;
    while(a!=1){
        a = ans(a);
        res++;
    }
    return res;
}

int main(){
    ll q;
    cin >> n >> q;
    
    vector<ll> v(q);
    vector<ll> w(q);
    REP(i,q){
        cin >> v[i] >> w[i];
    }
    REP(i,q){
        if(n==1){
            put(min(v[i],w[i]));
        }else{
            ll h1 = pro(v[i]);
            ll h2 = pro(w[i]);
            REP(j,h1-h2){
                v[i] = ans(v[i]);
            }
            REP(j,h2-h1){
                w[i] = ans(w[i]);
            }
            while(v[i]!=w[i]){
                v[i] = ans(v[i]);
                w[i] = ans(w[i]);
            }
            put(v[i]);
        }
    }
    return 0;
}


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

bool table[100][100] = {};

int main() {
	int w,h,n;
	cin >> w >> h >> n;
	for(int l = 0; l < n; l++) {
		int x,y,a;
		cin >> x >> y >> a;
		int xf=0,xc=w,yf=0,yc=h;
		if(a==1) {
			xf = 0;
			xc = x;
		}
		if(a==2) {
			xf = x;
			xc = w;
		}
		if(a==3) {
			yf = 0;
			yc = y;
		}
		if(a==4) {
			yf = y;
			yc = h;
		}
		for(int i = xf; i < xc; i++) {
			for(int j = yf; j < yc; j++) {
				table[i][j] = true;
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < w; i++) {
		for(int j = 0; j < h; j++) {
			ans += (table[i][j])?1:0;
		}
	}
	cout << (w*h-ans) << 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;
using ll = long long;
using v  = vector<int>;
using vv = vector<v>;

int main(){
    int n;
    cin >> n;
    
    queue<ll> q;
    
    vector<int> a={3,5,7};
    
    q.push(3);
    q.push(5);
    q.push(7);
    
    int ans = 0;
    
    while(q.front()<=n){
        
        v c(3,0);
        ll k = q.front();
        while(k){
            if(k%10==3)c[0]++;
            if(k%10==5)c[1]++;
            if(k%10==7)c[2]++;
            k /=10;
        }
        if(c[0]&&c[1]&&c[2])
            ans++;
        for(auto b : a){
            q.push(q.front()*10+b);
        }
        q.pop();
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int recur(int x,int y,int a,int b)
{

    return (abs(x-a)+abs(b-y));
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int x=0,y=0,n,f=0,last_t=0;
    cin>>n;
    while(n--)
    {
        int t,a,b;
        cin>>t>>a>>b;
        int req=recur(x,y,a,b);
            int cur_t=t-last_t;
        if(req>cur_t){
            f=1;

        }
        else{
            int rem=cur_t-req;
            if(rem%2)
                f=1;

        }
        x=a;
        y=b;
        last_t=t;

    }
    if(!f)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,n,sum=0;
    cin>>h>>n;
    int arr[n];
    int i;
    for(i=0;i<n;i++)
    {cin>>arr[i];
    sum+=arr[i];
    }
    if(sum>=h)
    cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    
}

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

const int N = 100 * 1000 + 5;
int root = -1;

vector <int> adj[N];
int par[N];
int dp0[N];
int dp1[N];

void dfs(int v) {
	if (adj[v].size() == 1) {
		dp0[v] = 1;
		return ;
	}
	int maxi = 0;
	bool b = false;
	if (adj[v].size() == 2 && v != root) {
		for (auto u : adj[v]) {
			if (u != par[v]) {
				par[u] = v;
				dfs(u);
				dp1[v] = dp1[u];
				dp0[v] = dp0[u];
			}
		}
		return;
	}
	for (auto u : adj[v]) {
		if (u != par[v]) {
		//	cout << 73 << " " << v << " " << u << endl; 
			par[u] = v;
			dfs(u);
		//	dp0[v] += dp0[u];
			dp0[v] += max(dp1[u], 1);
			if (dp1[u] == 0) {
				b = true;
			}
		//	maxi = max(maxi, dp0[u] - dp1[u]);
		}
	}
	dp1[v] = dp0[v];
	if (b) {
		dp1[v]--;
	}
}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	if (n <= 2) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		if (adj[i].size() > 2) {
			root = i;
		}
	}
	if (root == -1) {
		cout << 1;
		return 0;
	}
//	root = 2;
//	cout << "94 " << root << endl;
	par[root] = -1;
	dfs(root);
//	for (int i = 0 ; i < n; i++) {
//		cout << i << " " << dp0[i] << " " << dp1[i] << endl;
//	}
	cout << dp1[root] << endl;
	return 0;
}

Measured memory_bytes: 10368
x[1<<17];i;m=1<<30;main(a,b){for(;~scanf("%d",x+i);)i++>x[1]?a=x[i-x[1]],b=x[i-1],m=fmin(m,b-a+fmin(abs(a),abs(b))):0;printf("%d",m);}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        long n = scanner.nextLong();
        final StringBuilder builder = new StringBuilder();
        while (n > 0) {
            n--;
            final long mod = n % 26;
            builder.append((char) ('a' + mod));
            n /= 26;
        }
        System.out.println(builder.reverse());
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 32864
H[4][501][501],n,m,a,b,c,i;main(h){for(;scanf("%d%d",&n,&h)*n;printf("%d\n",n*n*n-m))for(memset(H,m=0,4e6);h--;)for(scanf("%s%d%d",&c,&a,&b),c%=3,c>1?i=a,a=b,b=i:0,i=!H[c][a][b]++*n;i;i--)m+=!H[(c+2)%3][b][i]&!H[-~c%3][i][a];}

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

int main() {
  int K,N;
  cin >> K >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  int64_t max = 0;
  int max_id = 0;
  for(int i=0; i<N; i++){
    int64_t tmp;
    if(i != N-1){
      tmp = A.at(i+1)-A.at(i);
    }
    else{
      tmp = A.at(0)+K-A.at(i);
    }
    
    if(tmp>max){
      max=tmp;
      max_id = i;
    }
  }
  
  cout << K-max << endl;
    
  
}


// int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));
 
  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
   // }
  //}


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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

signed main() {
  int n;
  cin >> n;
  vi x(n), y(n);
  rep (i, n) {
    cin >> x[i] >> y[i];
  }

  vi idx(n);
  rep (i, n) idx[i] = i;

  double sum = 0;
  do {
    double ans = 0;
    rep (j, n - 1) {
      int i = idx[j];
      int i2 = idx[j + 1];
      double dist = sqrt((x[i] - x[i2]) * (x[i] - x[i2]) + (y[i] - y[i2]) * (y[i] - y[i2]));
      ans += dist;
    }
    sum += ans;
  } while (next_permutation(all(idx)));

  rep1 (i, n) {
    sum /= i;
  }
  Sp(sum);
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

if len(set(l)) == 1:
    print(len(l)//2)
    exit()

even = [l[_] for _ in range(n) if _%2 ==1]
odd = [l[_] for _ in range(n) if _%2 ==0]

from collections import Counter

odd_cnt = Counter(odd)
even_cnt = Counter(even)

if odd_cnt.most_common()[0][0] != even_cnt.most_common()[0][0]:
    print(len(odd) - odd_cnt.most_common()[0][1] + len(even) - even_cnt.most_common()[0][1])
else:
    if odd_cnt.most_common()[1][1] >= even_cnt.most_common()[1][1]:
        print(len(odd) - odd_cnt.most_common()[1][1] + len(even) - even_cnt.most_common()[0][1])
    else:
        print(len(odd) - odd_cnt.most_common()[0][1] + len(even) - even_cnt.most_common()[1][1])

Measured memory_bytes: 20444
# coding:UTF-8
import sys
from math import factorial

def comb(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)

def perm(n, r):
    return factorial(n) // factorial(r)

def resultSur97(x):
    return x % (10**9 + 7)

if __name__ == '__main__':
    # ------ 入力 ------#
    # 1行入力
    s = int(input())    # 数字
    # a = input()     # 文字列
    # aList = list(map(int, input().split()))     # スペース区切り連続数字
    # aList = input().split()     # スペース区切り連続文字列
    # aList = [int(c) for c in input()]   # 数字→単数字リスト変換

    # 定数行入力
    x = 5
    # aList = [int(input()) for _ in range(x)] # 数字
    # aList = [input() for _ in range(x)] # 文字
    # aList = [list(map(int, input().split())) for _ in range(x)]     # スペース区切り連続数字(行列)
    # aList = [input().split() for _ in range(x)]     # スペース区切り連続文字
    # aList = [[int(c) for c in input()] for _ in range(x)]   # 数字→単数字リスト変換(行列)

    # スペース区切り連続 数字、文字列複合
    # aList = []
    # for _ in range(x):
    #     aa, bb = input().split()
    #     a.append((int(aa), bb))

    # ------ 処理 ------#
    a = [1,0,0]
    for i in range(3,s+1):
        sum = 0
        for j in range(i-2):
            sum += a[j]
        a.append(sum)

    out = resultSur97(a[s])
    if s >= 3:
        print(out)
    else:
        print(0)

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

int main()
{
	string s,t;
	int vis[30] = {0};
	cin >> s >> t;
	for(int i = 0;i < s.size();i++) vis[s[i] - 'a']++;
	
	long long ans = 0,k = 0;
	for(int i = 0;i < t.size();i++){
		if(!vis[t[i] - 'a']) {cout << -1 << endl;return 0;}
		
		k = s.find(t[i],k);
		if(k == s.npos){
			k = 0;
			ans++;
			i--;
		}
		else if(k == s.size() - 1){
			ans++;
			k = 0;
		}
		else{
			k++;
		}
	}
	cout << ans * s.size() + k << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll h, w;  // h行w列のマス目
    cin >> h >> w;

    vl x(h*w), y(h*w);  // うなぎのi番目の座標が(x[i], y[i])
    rep(i, h) {
        rep(j, w) {
            x[i*w + j] = i;
        }
    }

    rep(i, h*w) {
        ll m = i%(2*w);
        if(m < w) {
            y[i] = m;
        }
        else {
            y[i] = (2*w - 1) - m;
        }
    }   

    ll n;
    cin >> n;

    ll k = 0;
    vvl matrix(h, vl(w));
    rep(i, n) {
        ll a;
        cin >> a;
        exrep(j, k, k+a-1) {
            matrix[x[j]][y[j]] = i+1;
        }
        k += a;
    }
    
    rep(i, h) {
        rep(j, w) {
            cout << matrix[i][j] << " ";
        }
        cout << "\n";
    }

    re0;
}

Measured memory_bytes: 512
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int f[N],n;
void solve(){
  cin>>n;
  rep(i,1,200)
    rep(j,1,200)
      rep(k,1,200){
        f[i*i+j*j+k*k+i*j+j*k+k*i]++;
      }
  rep(i,1,n)cout<<f[i]<<"\n";
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 5396
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
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;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

vector<ll> enum_div(ll n){
    vector<ll> ret;
    for(ll i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

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

ll n;
ll x=1,y=1;
cin >> n;
auto a = enum_div(n);
a.push_back(n);
Sort(a);
auto siz = a.size();
if(siz % 2 == 0){
    x=a[siz/2];
    y=a[siz/2 - 1];
}else{
    x=a[siz/2];
    y=x;
}
cout << (x+y-2) << endl;
//cout << x << " " << y << endl;
//for(auto e:a) cout << e << endl;

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int A, B, C, D;

int main() {
	cin >> A >> B >> C >> D;

	while (true) {
		// 高橋君
		C -= B;
		if (C <= 0) { cout << "Yes" << endl; return 0; }
		// 青木君
		A -= D;
		if (A <= 0) { cout << "No" << endl; return 0; }
	}
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 2147483647;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);
const ll LLMAX = 9223372036854775805;


int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for(int i=1;i<=n;i++){
        ll y = n / i;
        ans += y*(y+1)*i/2;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3500
N = int(input())
ans = 0
xy = [[] for _ in range(N)]
for i in range(N):
  A = int(input())
  for j in range(A):
    x, y = map(int, input().split())
    xy[i].append([x-1, y])
for i in range(1<<N):
  flag = 1
  count = list()
  for j in range(N):
    if i>>j & 1:
      count.append(j)
  for k in count:
    for x, y in xy[k]:
      if(y == 1):
        if x not in count:
          flag = 0
      else:
        if x in count:
          flag = 0
  
  if(flag == 1):
    ans = max(ans, len(count))
print(ans)

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

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int mx = a[0];
    ll sum = 0;
    for(int i = 1; i < n; i++){
        sum += max(0, mx - a[i]);
        mx = max(mx, a[i]);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4040
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.TreeMap;
import java.util.*;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = Integer.parseInt(fs.next() + fs.next());
        if (n % (int) Math.sqrt(n) == 0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }

}


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

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

  N %= 10;
 if(N==2||N==4||N==5||N==7||N==9) cout << "hon" << endl;
 else if(N==0||N==1||N==6||N==8) cout << "pon" << endl;
 else cout << "bon" << endl;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 998244353;
int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<pair<string, int>> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i].first >> a[i].second;
    }
    string X;
    int ans = 0;
    bool flag = false;
    cin >> X;
    for (int i = 0; i < N; i++) {
        if (flag) ans += a[i].second;
        if (a[i].first == X) flag = true;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 998244353;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 300, MAX = 90000;
int N;
ll a[MAX_N+1];
ll dp[MAX_N+1][MAX+1];
ll dp2[MAX_N+1][MAX+1];

//x^nをmodのもとで計算する
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow((x*x) % mod, n/2, mod);
  if (n & 1) res = (res*x) % mod;
  return res;
}

//整数a,bに対し、ax + by = gcd(a,b) を満たす整数x,y,gcd(a,b) を計算する
ll extgcd(ll a, ll b, ll& x, ll& y) {
  ll d = a;
  if (b != 0) {
    d = extgcd(b, a%b, y, x);
    y -= (a/b) * x;
  } else {
    x = 1; y = 0;
  }
  return d;
}

//ax ≡ gcd(a,m) (mod m) を満たすxを計算する。
ll mod_inverse(ll a, ll m) {
  ll x, y;
  extgcd(a, m, x, y);
  return (m + x%m) % m;
}


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

  cin >> N;
  rep(i, 1, N) cin >> a[i];

  dp[0][0] = 1;
  dp2[0][0] = 1;
  for (int i = 1; i <= N; ++i) {
      for (int j = 0; j <= MAX; ++j) {
          dp[i][j] = mod(dp[i-1][j]*2, MOD);
          dp2[i][j] = dp2[i-1][j];
          if (a[i] <= j) {
              (dp[i][j] += dp[i-1][j-a[i]]) %= MOD;
              (dp2[i][j] += dp2[i-1][j-a[i]]) %= MOD;
          }
      }
  }


  ll sum = 0;
  for (int i = 1; i <= N; ++i) {
      sum += a[i];
  }
  ll K = (sum+1)/2;

  ll tmp = 0;
  for (int j = K; j <= MAX; ++j) {
      (tmp += dp[N][j]) %= MOD;
  }
  tmp = mod(tmp*3, MOD);
  if (sum%2 == 0) {
      tmp = mod(tmp-dp2[N][K]*3, MOD);
  }


  ll ans = mod_pow(3, N, MOD);
  cout << mod(ans-tmp, MOD) << endl;

  return 0;
}


Measured memory_bytes: 422784