akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
//#define endl "\n"
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}




int main() {
	int n, d,ans;
	cin >> n >> d;
	n % (d * 2 + 1) == 0 ? cout << n / (d * 2 + 1) << endl : cout << n / (d * 2 + 1) + 1 << endl;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var abc = Sarray();
            var a = abc[0];
            var b = abc[1];
            var c = abc[2];
            var d = c - (a + b);
            if (0 < d && 4 * a * b < d * d)
                WriteLine("Yes");
            else
                WriteLine("No");
            //Out.Flush();
        }
    }
}

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

bool isPalindrome(string s)
{
  string t(s.rbegin(), s.rend());
  return s == t;
}

int main()
{
  string S;
  cin >> S;
  
  int N = S.length();
  if(isPalindrome(S) && isPalindrome(S.substr(0, (N-1)/2)) && isPalindrome(S.substr((N+1)/2)))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
 #define int long long 
 
 
 signed main(){
     int n;cin>>n;
     int a[n];
     int flag=9999999;
     for(int i=0;i<n;i++){
         cin>>a[i];
     }int ans=0;
     for(int i=0;i<n;i++){
         if(a[i]<flag){
             flag=a[i];
             ans++;
         }
         
     }
     cout<<ans<<endl;
     
     
     
     
 }

Measured memory_bytes: 1792
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(itr,data) for(__typeof((data).begin()) itr=(data).begin();itr!=(data).end();++itr)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

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

using namespace std;

typedef pair<int ,int > P;

int n,p;

bool check(int *a) {
    int cnt=0;
    rep(i,n) if(a[i]!=0) cnt++;
    return cnt==1;
}

void solve() {
    int ary[100]={};
    int wan=p;

    int index = 0;
    while(wan!=0 || !check(ary)) {
        if(wan==0) {
            wan = ary[index];
            ary[index] = 0;
        }
        else {
            wan--;
            ary[index]++;
        }
        index++;
        index%=n;
    }
    index=index+n-1;
    index%=n;
    cout<<index<<endl;


}

int main() {
    while(cin>>n>>p){
        if(!(n+p)) return 0;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main (int argc, char* argv[])
{
  int i, j, k;
  double a[2][3], dat;

  while (scanf("%lf %lf %lf %lf %lf %lf", &a[0][0], &a[0][1], &a[0][2], &a[1][0], &a[1][1], &a[1][2]) != EOF) {
    for (k=0; k<2; k++) {
      for (j=k+1; j<=2; j++) {
	a[k][j] /= a[k][k];
      }
      for (i=0; i<2; i++) {
	if (i != k) {
	  for (j=k+1; j<=2; j++) {
	    a[i][j] -= a[i][k] * a[k][j];
	  }
	}
      }
    }
    for (i=0; i<2; i++) {
      dat = 1000 * a[i][2] - (int)(1000 * a[i][2]);
      if (0.5 <= dat) {
	a[i][2] += 0.001;
      }
    }
    printf("%.3f %.3f\n", a[0][2], a[1][2]);
  }
  return 0;
}

Measured memory_bytes: 0
def ABC_44_B():
    w = input()
    k=0
    s=0

    for i in range(len(w)):
        if w.count(w[i])%2 == 0:
            s+=0
        else:
            s+=1
       
    if s == 0:
        print('Yes')
    else:
        print('No')
    


if __name__ == '__main__':

    ABC_44_B()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
#define mod 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    bool f=true;
    for(ll i=0;i<s.size();i++)
    {
        if(i%2==0)
        {
            if(s[i]=='L')
                f=false;
        }
        else
        {
            if(s[i]=='R')
                f=false;
        }
    }
    if(f)
    {
        cout<<"Yes\n";
    }
    else
        cout<<"No\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    char ss = s[k - 1];
    if (ss == 'A')
        s[k - 1] = 'a';
    else if (ss == 'B')
        s[k - 1] = 'b';
    else if (ss == 'C')
        s[k - 1] = 'c';
    cout << s << endl;
    return 0;
}

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

using namespace std;


int main()
{
	ll n;
	cin>>n;
	set<string> ss;
	while(n--)
	{
		string s;
		cin>>s;
		ss.insert(s);
	}
	cout<<ss.size()<<endl;
}

Measured memory_bytes: 19096
#include <iostream>
#include <stdio.h>
#include <memory.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long ll;
const int oo=1000000000;
vector<int> v;
int main(){
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//#endif	
	int n,sum=0;
	bool d=1;
	cin>>n;
	v.resize(n);
	for(int i=0,x;i<n;i++){
		scanf("%d",&x);
		v.push_back(x);
		sum+=x;
		if(x%10!=0)d=0;
	}
	if(d)
		sum=0;
	else {
		sort(v.begin(),v.end());
		for(int i=0; i<v.size()&& sum%10==0 ;i++){
			if(v[i]%10!=0){
				sum-=v[i];
			}
		}
	}
	printf("%d",sum);
	return 0;
}	


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n+1),sum(n+1,0),b;
    FOR(i,1,n+1){
      cin>>a[i];
      sum[i]=sum[i-1]+a[i];
    }
    FOR(i,1,n+1)FOR(j,i,n+1){
      b.push_back(sum[j]-sum[i-1]);
    }
    ll ans=0;
    ll m=len(b);
    bool flag=false;
    vector<bool> ch(m,false);
    for(ll i=50;i>=0;i--){
      ll cnt=0;
      ll now=(1LL<<i);
      rep(j,m){
        if(flag){
          if(ch[j]&&(b[j]&now)) cnt++;
        }else{
          if((b[j]&now)) cnt++;
        }
      }
      if(cnt>=k){
        if(flag){
          rep(j,m){
            if(ch[j]&&!(b[j]&now)) ch[j]=false;
          }
        }else{
          rep(j,m) if(b[j]&now) ch[j]=true;
          flag=true;
        }
        ans+=now;
        //cout<<i<<' '<<now<<' '<<cnt<<' '<<ans<<endl;
      }
      //cout<<i<<' '<<(1<<i)<<' '<<cnt<<' '<<ans<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6384
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    Map<StringCount, AtomicLong> count = new HashMap<>();
    for (int i = 0; i < n; i++) {
      StringCount string = toMap(sc.next());
      count.computeIfAbsent(string, k -> new AtomicLong()).incrementAndGet();
    }
    pw.println(
      count.entrySet().stream().mapToLong(e -> e.getValue().get()).filter(i -> i > 1).map(
        i -> i * (i - 1) / 2
      ).sum());
  }

  static StringCount toMap(String s) {
    int[] ans = new int[26];
    Map<Character, AtomicInteger> map = new HashMap<>();
    for (int i = 0; i < s.length(); i++) {
      char c = s.charAt(i);
      int index = c - 97;
      ans[index] = ans[index] + 1;
    }
    return new StringCount(ans);
  }

  static class StringCount {

    int[] ans;

    StringCount(int[] ans) {
      this.ans = ans;
    }

    @Override
    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (o == null || getClass() != o.getClass()) {
        return false;
      }
      StringCount that = (StringCount) o;
      return Arrays.equals(ans, that.ans);
    }

    @Override
    public int hashCode() {
      return Arrays.hashCode(ans);
    }
  }
}


Measured memory_bytes: 69236
program MSOLUTIONSA
    implicit none
    integer(8)::X,A(8)=(/599,799,999,1199,1399,1599,1799,1999/),i

    read*,X
    
    do i=1,8
        if(X<=A(i))exit
    end do
    print'(i0)',9-i
end program MSOLUTIONSA

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

int main(){
    string ans = "No";
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a + b == c || a + c == b || b + c == a) {
        ans = "Yes";
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
    	Scanner scanner = new Scanner(System.in);
    	long n = scanner.nextLong(), a = scanner.nextLong(), b = scanner.nextLong();
    	if (n % (a+b) == 0) {
    		System.out.println(n/(a+b) * a);
    	}else {
    		long z = n / (a+b);
    		z = Math.max(0, z);
    		n -= z * (a+b);
    		long res = 0;
    		if (n > a) {
    			res = z * a + a;
    		}else {
    			res = z * a + n;
    		}
    		System.out.println(res);
    	}
    	}
    }


Measured memory_bytes: 23764
#include <stdio.h>
#include <string.h>

int main(){

  char str[21];
  int i,n;

  scanf("%s",&str);
  n=strlen(str);
  for(i=n-1;i>=0;i--){
    printf("%c",str[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 524
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
    long double a,b,c;
    cin >> a >> b >> c;
    string ans = "No";
    if( 4*a*b < (c-a-b)*(c-a-b) && c-a-b >0){
        ans = "Yes";
    }
    
    cout << ans << endl; 
    return 0;
}
    



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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define test(t) int t;cin>>t;while(t--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
const int MOD = 1e9+7,MAX = 1e5+5;
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
ll modInv(ll a)
{
	return powN(a,MOD-2);
}


int main()
{
	int x,y;
	cin>>x>>y;
	long long int sum=0;
	if(x<=3) sum+=(4-x)*100000;
	if(y<=3) sum+=(4-y)*100000;
	if(x==1&&y==1) sum+=400000;
	cout<<sum<<endl;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    //ある整数をnで割ると余りは0〜n-1のn通り
    bool ans = false;
    rep(i, b){
        if ((a * (i+1)) % b == c) ans = true;
    }
    if (ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    int maxH = 0;
    int ans = 0;
    for (int i=0; i < N; ++i) {
        int H;
        cin >> H;
        if (H >= maxH) {
            ++ans;
        }
        if (H > maxH) maxH = H; 
    }
    
    cout << ans << endl;
    
    return 0;
}


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


string rev(string s){
  string t=s;
  for(int i=0;i<s.size();i++){
    t[i]=s[s.size()-1-i];
  }
  return t;
}

int main(){
  int n;
  cin>>n;
  for(int x=0;x<n;x++){
    string s;
    cin>>s;
    set<string> st;
    for(int i=1;i<s.size();i++){
      string a,b;
      for(int j=0;j<i;j++)a.push_back(s[j]);
      for(int j=i;j<s.size();j++)b.push_back(s[j]);
      string ra=rev(a);
      string rb=rev(b);
      st.insert(a+b);
      st.insert(ra+b);
      st.insert(a+rb);
      st.insert(ra+rb);
      st.insert(b+a);
      st.insert(b+ra);
      st.insert(rb+a);
      st.insert(rb+ra);
    }
    cout<<st.size()<<endl;
  }
  return 0;
}

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

 
int main() {
  int h,w;
  cin >> h >> w;
  
  char S[h+2][w+2];
  rep(i,h+2){
    rep(j,w+2){
      S[i][j] = '0';
    }
  }
  
  char nyu[h][w];
  rep(i,h){
    rep(j,w){
      cin >> nyu[i][j];
    }
  }
  
  rep(i,h){
    rep(j,w){
    S[i+1][j+1] = nyu[i][j];
    }
  }
  
  
  
  
    
    
  rep(i,h+2){
	rep(j,w+2){
      	
      	int n = 0;
      	if(S[i][j] == '#'){
          continue;
        }
      	if(S[i-1][j-1] == '#'){
          n++;
        }
        if(S[i][j-1] == '#'){
          n++;
        }
        if(S[i+1][j-1] == '#'){
          n++;
        }
        if(S[i-1][j] == '#'){
          n++;
        }
        if(S[i][j+1] == '#'){
          n++;
        }
        if(S[i+1][j] == '#'){
          n++;
        }
        if(S[i+1][j+1] == '#'){
          n++;
        }
        if(S[i-1][j+1] == '#'){
          n++;
        }
        S[i][j] = n + '0';
     }
  }
  
  rep(i,h+2){
	rep(j,w+2){
      if(i != 0 && i != h+1 && j != 0 && j != w+1){ 
        cout << S[i][j];
      }
    }
    if(i != 0 && i != h+1 )
  	cout << endl;
  }
  
  
  
  
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
 
const int N = 2e5 + 5;
const int mod = 1e7 + 7;
const int INF = 1e15;
const int LG = 21;

int arr[N];
int n, m, k;
vector<string> v1, v2;
int cnt[N];

void solve()
{
	string input;
	cin >> input;
	if(input[2] == input[3] and input[4] == input[5])
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}

 
int32_t main()
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll h, w, n;
    cin >> h >> w >> n;
    
    if(w < h) {
        cout << (n+h-1)/h << endl;
    } else {
        cout << (n+w-1)/w << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
constexpr const int INF=1<<30,MOD=1000000007;constexpr const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define cerr cer_
#endif
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}template<class T>istream&operator>(istream&i,T&t){return i>>t;}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<t<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}template<class...T>void dprint(T&&...t){_print(cerr,t...);}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<p.F<' '<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>p.F>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>queue<T>&operator<<(queue<T>&q,const T&t){q.push(t);return q;}template<class T>queue<T>&operator<<(T&t,queue<T>&q){t=q.front();q.pop();return q;}
template<class T>deque<T>&operator>>(const T&t,deque<T>&q){q.push_front(t);return q;}template<class T>deque<T>&operator<<(T&t,deque<T>&q){t=q.front();q.pop_front();return q;}
template<class T>deque<T>&operator<<(deque<T>&q,const T&t){q.push_back(t);return q;}template<class T>deque<T>&operator>>(deque<T>&q,T&t){t=q.back(t);q.pop_back();return q;}
template<class T>stack<T>&operator<<(stack<T>&s,const T&t){s.push(t);return s;}template<class T>stack<T>&operator>>(stack<T>&s,T&t){t=s.top();s.pop();return s;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>n;
    vector<pair<pair<string,int>,int>> a(n);
    REP(i,n){
        string s;int b;
        cin>s>b;
        a[i]={{s,100-b},i+1};
    }
    sort(all(a));
    REP(i,n){
        cout<a[i].S<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    int res=0;
    rep(i,0,n){
        int a; cin >> a;
        if(a >= k)res++;
    }
    cout << res << endl;
}

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

typedef long long int ll;
ll a[100005];

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int flag=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]!=a[i-1])
        {
            flag=1;
        }
    }
    if(!flag)
    {
        cout<<a[n-1]<<' '<<a[n-2]<<endl;
    }
    else
    {
        double ans=a[n-1]*1.0/2;
        int t=upper_bound(a,a+n,(int)ans)-a;
        int flag=t;
        while(a[t]>ans)
            t--;
        if(flag==n-1)
            flag--;
        if(abs(a[t]-ans)>abs(a[flag]-ans))
        {
            cout<<a[n-1]<<' '<<a[flag]<<endl;
        }
        else
        {
            cout<<a[n-1]<<' '<<a[t]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

template<typename T>
T gcd(T a, T b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int main() {
    /*
    int table[20] = {2, 3, 5 ,7, 11, 13, 17, 19, 23};
    int tmp = 1;
    rep(i, 9) tmp *= table[i];
    cout << tmp << endl;
     */
    int n;
    cin >> n;
    int a[n + 1];
    a[0] = 0;
    rrep(i, 1, n + 1) cin >> a[i];
    int g[n + 1];
    g[0] = 0;
    g[1] = a[1];
    rrep(i, 2, n + 1) g[i] = gcd(a[i], g[i - 1]);
    //rep(i, n + 1) cout << g[i] << " "; cout << endl;
    set<int> s[n + 1];
    s[2].insert(a[1]);
    s[2].insert(a[2]);
    rrep(i, 3, n + 1) {
        s[i].insert(g[i - 1]);
        for (auto it = s[i - 1].begin(); it != s[i - 1].end(); ++it) {
            s[i].insert(gcd(*it, a[i]));
        }
    }
    /*
    rep(i, n + 1) {
        for (auto it = s[i].begin(); it != s[i].end(); ++it) {
            cout << *it << " ";
        }
        cout << endl;
    }
     */
    int ans = 0;
    for (auto it = s[n].begin(); it != s[n].end(); ++it) {
        chmax(ans, *it);
    }
    cout << ans << endl;
}


Measured memory_bytes: 14208
// Between a ans b ...
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long INT;

int main(){
    INT a,b,x;
    cin>>a>>b>>x;
    INT A=a%x,B=b%x;
    a/=x; b/=x;
    if(A) a++;
    cout<<max((INT)0,b-a+1);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<vector>
#include<cstring>
#include<set>
#include<queue>
#include<map>
#include<climits>
#include<cmath>
#include<iomanip>

#define F first
#define S second
#define vi vector
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000007
#define pb push_back
#define ll long long int
#define db double
#define all(v) v.begin(),v.end()
using namespace std;



ll expo(ll n){
    ll t;
    if(n==0)return 1;
    else if(n==1) return 2;
    t=expo(n/2);
    if(n%2){
        return t*t*2;
    }
    else return t*t;
}

//ffrom geek for geek
ll exponentMod(ll A, ll B, ll C)  
{  
    if (A == 0)  
        return 0;  
    if (B == 0)  
        return 1;  
    ll y;  
    if (B % 2 == 0) {  
        y = exponentMod(A, B / 2, C);  
        y = (y * y) % C;  
    }  
    else {  
        y = A % C;  
        y = (y * exponentMod(A, B - 1, C) % C) % C;  
    }  
  
    return (ll)((y + C) % C);  
}

/*
vi<ll> v;
 
ll dsufind(ll x){
    if(v[x]<0){
        return x;
    }
    v[x]=dsufind(v[x]);
    return v[x];
}
 
 
 
void dsujoin(ll x,ll y){
    x=dsufind(x);
    y=dsufind(y);
    
    if(x==y)
    return;
    if(v[x]>v[y])swap(x,y);
    v[y]+=v[x];
    v[x]=y;
}
 */

 



int main(){
   ll n;
   cin>>n;
   ll arr[n+1];
   FORE(i,1,n){
       cin>>arr[i];}
       arr[0]=INT_MAX;
    ll dp[n+1];
    dp[0]=INT_MAX;
    dp[1]=0;
    FORE(i,2,n){
        dp[i]=min((dp[i-2]+abs(arr[i]-arr[i-2])),(dp[i-1]+abs(arr[i]-arr[i-1])));
      //  cout<<dp[i]<<" "<<i<<"\n";
    }

    cout<<dp[n]<<"\n";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
# define ppi pair<ll,ll>
ll n,arr[3005],cnt[3005]={0};
vector<vector<vector<ppi>>>dp(3005,vector<vector<ppi>>(3005,vector<ppi>(2)));
ppi func(ll chan,ll i,ll j)
{
    if(i>j)
        return {0,0};
    ppi u=dp[i][j][chan];
    if(u.first!=-1 and u.second!=-1)
        return dp[i][j][chan];
    ppi x=func(1-chan,i+1,j);
    ppi y=func(1-chan,i,j-1);
    if(chan)
    {    
        if(arr[i]+x.first-x.second>=arr[j]+y.first-y.second)
            dp[i][j][chan]={x.first+arr[i],x.second};
        else
            dp[i][j][chan]={y.first+arr[j],y.second};
    }
    else
    {
        if(x.first-x.second-arr[i]<=y.first-y.second-arr[j])
            dp[i][j][chan]={x.first,x.second+arr[i]};
        else
            dp[i][j][chan]={y.first,y.second+arr[j]};
    }
    return dp[i][j][chan];
}
int main()
{
// #ifndef ONLINE_JUDGE
//        freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
        cin>>n;
        for(ll i=0;i<3005;i++)
        {
            for(ll j=0;j<3005;j++)
            {
                for(ll k=0;k<2;k++)
                    dp[i][j][k]={-1,-1};
            }
        }
        for(ll i=1;i<=n;i++)
        {
            cin>>arr[i];
            cnt[i]=cnt[i-1]+arr[i];
        }
        ppi d=func(1,1,n);
        cout<<d.first-d.second;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t> bool ckmin(t& a, const t& b) { return a > b ? a = b, true : false; }
template <class t> bool ckmax(t& a, const t& b) { return a < b ? a = b, true : false; }

#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
  if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T> struct IsC {
  template <class C> static char test(typename C::const_iterator*);
  template <class C> static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <> struct IsC<string> { static const bool value = false; };
template <class C> typename enable_if<IsC<C>::value, ostream&>::type operator<<( ostream& o, const C& c) {
  o << '{';
  for (auto it = c.begin(); it != c.end();)
    o << *it << (++it != c.end() ? ", " : "}");
  return o;
}
template <class a, class b> ostream& operator<<(ostream& o, const pair<a, b>& p) {
  return o << '(' << p.fi << ", " << p.se << ')';
}

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

    int k, a, b;
    cin >> k >> a >> b;
    int lowest = a/k * k;
    if(lowest != a && lowest + k > b)
        cout << "NG";
    else
        cout << "OK";
}




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

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<int> v(n);
    for (size_t i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        v[l-1]++;
        v[r]--;
    }

    int ans = 0, num = 0;
    for (size_t i = 0; i < n; i++) {
        num += v[i];
        if (num == m) ans++;
    }

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


Measured memory_bytes: 3780
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>
#include <iomanip>

#define BIG 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;

int main(){
    int n,l;
    cin >> n >> l;
    long o = (l + l + n - 1) * n / 2;
    if((l <= 0 && l + n - 1 >= 0))cout << o << endl;
    else if(l > 0)cout << o - l << endl;
    else if(l < 0)cout << o - (l + n - 1) << endl;
}




Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
char s[200010];

ll bigMod(ll a, ll b, ll mod)
{
	if(b==0) return 1;
	ll x=bigMod(a, b/2, mod);
	x=(x*x)%mod;
	if(b%2==0) return x;
	else return (x*a)%mod;
}

int main()
{
	ll n, m, i, j, cnt=0, f0, f1, f2;

	scanf("%lld %s", &n, s);

	//for(i=0; i<n/2; i++) swap(s[i], s[n-i-1]);

	for(i=0; i<n; i++)
	{
		if(s[i]=='1') cnt++;
	}

	f1=cnt, f2=cnt+1, f0=cnt-1;
	ll res0=0, res1=0, res2=0;
	for(i=0; i<n; i++)
	{
		if(s[i]=='0') continue;
		if(f0>0) 
			{
			res0+=bigMod(2LL, n-i-1, f0);
			res0%=f0;
			}
		//cout<<bigMod(2LL, n-i-1, f2)<<endl;
		res2+=bigMod(2LL, n-i-1, f2);
		res2%=f2;
	}


	for(i=0; i<n; i++)
	{
		if(f0==0 && s[i]=='1')
		{
			printf("0\n");
			continue;
		}
		ll ans, fin=1;
		if(s[i]=='0')
		{
			ans=res2;
			ans+=bigMod(2LL, n-i-1, f2);
			ans%=f2;
		}
		else 
		{
			ans=res0;
			ans-=bigMod(2LL, n-i-1, f0);
			ans+=f0;
			ans%=f0;
		}

		//cout<<res2<<" ";

		while(ans)
		{
			ll bc=0;
			ll x=ans;
			while(x) 
			{
				bc+=x%2;
				x/=2;
			}
			ans=ans%bc;
			fin++;
		}

		printf("%lld\n", fin);


	}






	return 0;
}

Measured memory_bytes: 3948
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    map<char,int> D;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        D[s[0]]++;
    }
    char c[5]={'M','A','R','C','H'};
    int res=0;
    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++){
                res+=D[c[i]]*D[c[j]]*D[c[k]];
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=(1<<16)+5,Mod=1e9+7;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,m,S,Lg[MAXN],Fac[MAXN],iFac[MAXN],a[MAXN],F[20][MAXN],cnt[MAXN];
inline int C(int n,int m){if(n<0||m<0||n<m)return 0;return 1ll*Fac[n]*iFac[m]%Mod*iFac[n-m]%Mod;}
inline int Fp(int x,int k){int ans=1;for(;k;k>>=1,x=1ll*x*x%Mod)if(k&1)ans=1ll*ans*x%Mod;return ans;}
inline void pre(){
	int n=16,S=1<<16;
	Rep(i,0,n)Lg[1<<i]=i;
	Fac[0]=1;Rep(i,1,S)Fac[i]=1ll*Fac[i-1]*i%Mod;
	iFac[S]=Fp(Fac[S],Mod-2);Red(i,S,1)iFac[i-1]=1ll*iFac[i]*i%Mod;
	Rep(i,0,S)cnt[i]=cnt[i>>1]+(i&1);
}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),m=read(),S=(1<<n)-1,pre();
	Rep(i,1,m)a[i]=read();F[m+1][0]=1;
	Red(i,m,1){
		Rep(s,0,S)F[i][s]=F[i+1][s];
		Rep(s,0,S)if(F[i+1][s])for(int t=s^S;t;t^=t&-t){
			int nxt=s^(t&-t);
			F[i][nxt]=(F[i][nxt]-1ll*C((1<<n)-a[i]-s,(t&-t)-1)*F[i+1][s])%Mod;
		}
	}
	ll ans=0;
	Rep(i,0,S){
		int tmp=1ll*F[1][i]*Fac[S^i]%Mod;
		for(int j=0;j<n;j++)if(!(i>>j&1))tmp=1ll*tmp*iFac[1<<j]%Mod;
		ans+=tmp;
	}ans%=Mod;Rep(i,0,n-1)ans=ans*Fac[1<<i]%Mod;cout<<((ans<<n)%Mod+Mod)%Mod<<"\n";
	return 0;
}




Measured memory_bytes: 8544
#include<cstdio>
#include<cstring>
#include<algorithm>
const int MAXN=200010;
const long long MOD=1e9+7;

struct node{
	int x,y;
	node(int x=0,int y=0):x(x),y(y){}
	inline bool operator<(const node &rhs)const{
		return x<rhs.x||x==rhs.x&&y<rhs.y;
	}
}p[MAXN];
int h,w,n;
long long f[MAXN];
long long inv[MAXN],fac[MAXN],inc[MAXN];

inline long long c(int x,int y) {
	return fac[x]*inc[y]%MOD*inc[x-y]%MOD;
}

int main(){
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;i++){
		int x,y;scanf("%d%d",&x,&y);
		p[i]=node(x,y);
	}
	std::sort(p+1,p+n+1);

	inv[0]=inv[1]=1ll;
	for(int i=2;i<=h+w;i++){
		inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
	}
	fac[0]=inc[0]=1ll;
	for(int i=1;i<=h+w;i++){
		fac[i]=fac[i-1]*i%MOD;
		inc[i]=inc[i-1]*inv[i]%MOD;
	}
	f[0]=1;p[0]=node(1,1);
	p[++n]=node(h,w);
	for(int i=0;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			if(p[i].y>p[j].y)
				continue;
			f[j]=(f[j]-f[i]*c(p[j].x-p[i].x+p[j].y-p[i].y,p[j].x-p[i].x)%MOD+MOD)%MOD;
		}
	printf("%lld\n",(MOD-f[n])%MOD);
	return 0;
}

Measured memory_bytes: 7808
n = int(input())
l_a = list(map(int, input().split()))
many = [0]*101000
for i in range(0, len(l_a)) :
    many[l_a[i]-1]+=1
bef = sum(l_a)
q = int(input())
ans = []
for _ in range(q) :
    b, c = map(int, input().split())
    bef += (c - b)*many[b - 1]
    ans.append(bef)
    many[c - 1] += many[b - 1]
    many[b - 1] = 0
 
for value in ans :
    print(value)

Measured memory_bytes: 20900
import sys
sys.setrecursionlimit(10**8)

N,M = map(int,input().split())
G = [[] for i in range(N)]
for _ in range(M):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    G[x].append(y)

dp = [-1]*(N+5)
def rec(v):
    if dp[v] != -1:
        return dp[v]

    res = 0
    for nv in G[v]:
        if rec(nv) + 1 >= res:
            res = rec(nv) + 1
    dp[v] = res
    return res
ans = 0
for v in range(N):
    ans = max(ans, rec(v))
print(ans)

Measured memory_bytes: 153036
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
int main(){
int x,y;
int max=0;
scanf("%d %d",&x,&y);
max=x+y;
if(max<=x-y)max=x-y;
if(max<=x*y)max=x*y;
printf("%d",max);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
string s;
int main()
{
	cin >> s;
	if (s.length()>=4&&s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') cout << "Yes" << endl; else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll H,W,A,B;
    cin >> H >> W >> A >> B;
    rep(i,B){
        rep(j,A){
            cout << "1";
        }
        rep(j,W-A){
            cout << "0";
        }
        cout << endl;
    }
    rep(i,H-B){
        rep(j,A){
            cout << "0";
        }
        rep(j,W-A){
            cout << "1";
        }
        cout << endl;
    }
    /*
    ll n = -1, m = -1;
    bool flag = false;
    rep(i,H+1){
        rep(j,W+1){
            if(i*A +(H-i)*(W-A) == j*B + (W-j)*(H-B)){
                n = i;
                m = j;
                flag = true;
                break;
            }
        }
        if(flag)break;
    }
    if(!flag){
        cout << "No"<<endl;
        return 0;
    }
    rep(i,n){
        rep(j,i){
            cout << '1';
        }
        rep(j,A){
            cout << '0';
        }
        rep(j,W-A-i){
            cout << '1';
        }
        cout << endl;
    }
    rep(i,H-n){
        rep(j,i){
            cout << '0';
        }
        rep(j,A){
            cout << '1';
        }
        rep(j,W-A-i){
            cout << '0';
        }
        cout << endl;
    }
    */
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int sol = 0;
        int N = sc.nextInt();

        int[] A = new int[N];
        int[] C = new int[N - 1];

        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        for (int i = 0; i < N; i++) {
            sol += sc.nextInt();
        }

        for (int i = 0; i < N - 1; i++) {
            C[i] = sc.nextInt();
        }

        for (int i = 0; i < N - 1; i++) {
            if (A[i] + 1 == A[i + 1]) {
                sol += C[A[i] - 1];
            }
        }

        System.out.println(sol);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
vector<vector<int>> getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}
const int nmax = 8;
int dfs(int v, int N, const AdjList adj, bool visited[nmax]);
int main(){
	int N,M;
	cin >> N >> M;
	AdjList adj = getadj(N,M);
	int a[N];

	bool visited[nmax];
	rep(i,N)
		visited[i] = false;

	visited[0] = true;
	cout << dfs(0,N,adj,visited) << endl;
	return 0;
}

int dfs(int v, int N, const AdjList adj, bool visited[nmax]){
// cout << "Now I'm at "<< v << endl;
// rep(i,nmax)
// 	cout << visited[i] << "  ";
// cout << endl;
	// If all nodes have already visited , return 1.
	bool all_visited = true;
	rep(i,N)
		if(visited[i] == false){
// cout << i << " has not yet visited." << endl;
			all_visited = false;
		}
	if(all_visited) return 1;

	int ret = 0;

	int n = adj[v].size();
	rep(i,n){
		int u = adj[v][i];
		if(visited[u]) continue;
// cout << "I'll visit " << u << endl;
		visited[u] = true;
		ret += dfs(u,N,adj,visited);
		visited[u] = false;
	}
	return ret;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef pair<ll,ll> pll;
     
    const ll mod = 1e9 + 7;
    const ld PI = 3.1415926535897932384626;
    const ld eps = 1e-9;                            
     
    #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define sidha(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
    #define ulta(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);--i)
    #define stl(container,itr) \
        for(auto itr = container.begin(); itr != container.end(); itr++)
    #define sab(v) v.begin(), v.end()
    #define rall(v) v.rbegin(), v.rend()            
    #define test ll t;cin>>t;while(t--)
    #define sz(v) ((int)(v).size())
    #define pb push_back
    #define mp make_pair
    #define fi first
    #define se second
    #define LOG2(X) (63ll - __builtin_clzll(X))
    #define endl '\n'
    #define modinv(x) power(x, mod-2)
    #define MAX 100005
     
    ll power(ll x, ll y) { 
        ll ans=1;
        x=x%mod;
        while(y>0) { 
            if (y&1) 
                ans=(ans*x)%mod; 
            y=y>>1;
            x=(x*x)%mod; 
        } 
        return ans; 
    }

    int main()
    {
        boost;
        ll n,ans=0,temp;
        string s;
        cin>>n>>s;
        ll arrr[n],arrw[n],r=0,w=0;
        sidha(i,0,n){
            if(s[i]=='R')   r++;
            else    w++;
            arrr[i]=r;
            arrw[i]=w;
        }
        ans=min(n-r,n-w);
        sidha(i,0,n){
            temp=arrw[i]+r-arrr[i];
            ans=min(ans,temp);
            if(arrw[i]){
                ll minn=min(arrw[i],r-arrr[i]);
                temp=arrw[i]+(r-arrr[i]-minn);
                ans=min(ans,temp);
            }
        }
        cout<<ans;
        return 0;
    }
    

Measured memory_bytes: 6860
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
    string s;
	int j, count = 0;
	cin >> s;
	int n = s.size();
	if(n % 2 ==1) {
		cout << "No" << "\n";
		return 0;
	}
	for(int i = 0; i < n - 1; i = i + 2){
		
		string subs = s.substr(i, 2);
		if(subs == "hi"){
			count++;
		}
		
		
	}
	cout << (n / 2 == count ? "Yes" : "No") << "\n";
	return 0;
}



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





int main() {

   string S;
   cin >> S;

   string ans = "Good";

   for(int i = 0;i < 3;i++) {
       if(S.at(i) == S.at(i + 1)) {
           ans = "Bad";
       }
   }

   cout << ans << endl;
}


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

namespace CSharpSample01
{


	class Program
	{
		static void Main(string[] args)
		{
			// スペース区切りの整数の入力
			var inputNum = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

			long N = inputNum[0];
			long A = inputNum[1];
			long B = inputNum[2];

			// ペア数
			long num = N / (A + B);

			long amari = N % (A + B);

			long answer = num * A;

			if (amari >= A)
			{
				answer += A;
			}
			else
			{
				answer += amari;
			}

			Console.WriteLine(answer);

		}
	}
}

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

int main(){
    int n,m,maxl=0,minr=1000000;
    cin >> n >> m;
    vector<int> l(m),r(m);
    for(int i=0;i<m;i++){
        cin >> l.at(i) >> r.at(i);
        if(l.at(i)>maxl)maxl=l.at(i);
        if(r.at(i)<minr)minr=r.at(i);
    }
    if(minr-maxl+1>0)cout << minr-maxl+1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 4024
# include <iostream>
using namespace std;
int n;
void work (void)
{
	int p,q;
	p=n%10;
	q=n/10;
	if (p==9||q==9)
	cout<<"Yes";
else cout<<"No";
}
int main (void)
{
	cin>>n;
	work ();
	return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int a[1120];
int er(int n){
  int i,j;
  a[0]=a[1]=0;
  for(i=2;i<n;++i)
    a[i]=i;
  for(i=2;i*i<n;++i){
    if(!a[i])
      continue;
    for(j=i*i;j<n;j+=i)
      a[j]=0;
  }
  j=2;
  for(i=0;j<n;++i){
    a[i]=a[j];
    for(j++;j<n&&a[j]==0;++j);
  }
  return i;
}
int b[15][1121][188];
int fi(int p,int q,int r){
  int i;
  if(b[p][q][r]>=0)
    return b[p][q][r];
  int sm=0;
  for(i=r;a[i]*p<=q;++i)
    sm+=fi(p-1,q-a[i],i+1);
  return b[p][q][r]=sm;
}
int main(){
  a[er(1120)]=1121;
  memset(b,-1,sizeof(b));
  memset(b,0,1121*188*sizeof(int));
  fill(b[0][0],b[0][0]+188,1);
  int n,k;
  while(cin>>n>>k,n||k)
    cout<<fi(k,n,0)<<endl;
  return 0;
}

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

using namespace std;

int D;

long long int G;

int p[12];
long long int c[12];

long long int dp[11][10005];

int main(void) {

	cin >> D >> G;

	int tmp1;
	long long int tmp2;

	for (int i = 1; i <= D; i++) {
		cin >> tmp1; p[i] = tmp1;
		cin >> tmp2; c[i] = tmp2;
	}

	dp[0][0] = 0; long long int val;

	for (int i = 1; i <= D; i++) {
		for (int m = 0; m <= 1000; m++) {
			for (int q = 0; q <= p[i]; q++) {
				if (q == p[i]) { val = 100 * i*q + c[i]; }
				else { val = 100 * i*q; }
				dp[i][m + q] = max(dp[i][m + q], dp[i-1][m]+val);
			}
		} //m-loop
	}

	int ans = 1005;

	for (int m = 0; m <= 1000; m++) {
		if (dp[D][m] >= G) { ans = min(ans, m); }
	}

	/*for (int m = 0; m <= 15; m++) {
		cout << "dp[D][" << m << "]= " << dp[D][m] << endl;
	}*/

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 384