akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)

typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;



int main() {
  string s;
  cin >> s;
  ll n= s.size();
  string s1 = s.substr(0,(n-1)/2);
  string s2 = s.substr((n+3)/2-1);
  bool flag = true;
  string p,p1,p2;
  p = s;
  p1 = s1;
  p2 = s2;
  reverse(s.begin(),s.end());
  reverse(s1.begin(),s1.end());
  reverse(s2.begin(),s2.end());
  
  if(s==p&&s1==p1&&s2==p2){
    cout << "Yes" << endl;
  }else{
    cout << "No"<< endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
}

typedef long long ll;
const ll MOD = 1e9 + 7;
const int N = 1e4 + 1, M = 1e3+1, OO = 0x3f3f3f3f;
int memo[M][N],d[M],c[M],n,h;
int solve(int idx=0,int rem=h)
{
  if(rem<=0) return 0;
  if(idx==n && rem>0) return OO;

  int &ret = memo[idx][rem];
  if(~ret) return ret;

  ret = 0;
  int a=0,b=0;
  
  a += solve(idx,rem-d[idx])+c[idx];
  b += solve(idx+1,rem);
  ret += min(a,b);
  
  return ret;
}
int main()
{
  memset(memo,-1,sizeof memo);
  scanf("%d%d",&h,&n);
  for(int i=0;i<n;++i) scanf("%d %d",d+i,c+i); 
  printf("%d\n",solve());
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0;
}

Measured memory_bytes: 39936
N = int(input())

lst = []
for _ in range(N):
    tmp = list(input())
    tmp.sort()
    lst.append(tmp)
lst.sort()
tmp = lst[0]
count = 1
ans = 0
for i in range(1, N):
    if tmp == lst[i]:
        count += 1
    else:
        ans = ans + (count * (count - 1))//2
        count = 1
        tmp = lst[i]
ans = ans + (count * (count - 1))//2
print (ans)

Measured memory_bytes: 24652
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << n); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "yes" << endl; else cout << "no" << endl; }

void YesNo(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll INF = 10000000;
//ll mod = 1000000007;//10^9+7
int dx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int dy[8] = {0, -1, 1, 0, -1, 1, -1, 1};
using Graph = vector<vector<int>>;//隣接リスト:G[i]にはiと隣接する頂点が入るよ。
using P = pair<int, int>;//BFSで利用。queueに入れる。
using PP = pair<int, P>; //dijkstraで利用,priority_queueに入れる。
using p_queue = priority_queue<int, vector<int>, greater<int>()>;
//struct edge{int to, cost};






//番号ズレ注意！！
int main() {
    int N;
    cin >> N;
    P R[N], B[N];
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        R[i] = make_pair(b, a);
    }
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        B[i] = make_pair(a, b);
    }
    sort(R, R + N);
    reverse(R, R + N);
    sort(B, B + N);
    vector<bool> used_R(N, false);
    int ans = 0;
    REP(i, N) {
        REP(j, N) {
            if (B[i].first > R[j].second && B[i].second > R[j].first && !used_R[j]) {
                ans++;
                used_R[j] = true;
//                cout<<"pair: B("<<B[i].first<<","<<B[i].second<<")&R("<<R[j].second<<","<<R[j].first<<")"<<endl;
                break;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll l(n), r(n);
    REP(i, n) cin >> l[i] >> r[i];

    set< P<ll, P<ll, ll> > > sl, sr;
    REP(i, n) sl.insert(make_pair(l[i], make_pair(-r[i], i))), sr.insert(make_pair(r[i], make_pair(-l[i], i)));
    
    ll tmp1 = 0, pos = 0;
    REP(i, n) {
        if (i % 2 == 0) {  // to right
            P<ll, P<ll, ll> > tmp = *(--sl.end());
            sl.erase(--sl.end());
            sr.erase(make_pair(-tmp.second.first, make_pair(-tmp.first, tmp.second.second)));
            if (pos < tmp.first) {
                tmp1 += tmp.first - pos;
                pos = tmp.first;
            }
        } else { // to left
            P<ll, P<ll, ll> > tmp = *(sr.begin());
            sr.erase(sr.begin());
            sl.erase(make_pair(-tmp.second.first, make_pair(-tmp.first, tmp.second.second)));
            if (pos > tmp.first) {
                tmp1 += pos - tmp.first;
                pos = tmp.first;
            }
        }
    }
    ll ans = tmp1 + abs(pos);
    
    sl.clear(), sr.clear();
    REP(i, n) sl.insert(make_pair(l[i], make_pair(-r[i], i))), sr.insert(make_pair(r[i], make_pair(-l[i], i)));
    ll tmp2 = 0;
    pos = 0;
    REP(i, n) {
        if (i % 2 == 1) {  // to right
            P<ll, P<ll, ll> > tmp = *(--sl.end());
            sl.erase(--sl.end());
            sr.erase(make_pair(-tmp.second.first, make_pair(-tmp.first, tmp.second.second)));
            if (pos < tmp.first) {
                tmp2 += tmp.first - pos;
                pos = tmp.first;
            }
        } else { // to left
            P<ll, P<ll, ll> > tmp = *(sr.begin());
            sr.erase(sr.begin());
            sl.erase(make_pair(-tmp.second.first, make_pair(-tmp.first, tmp.second.second)));
            if (pos > tmp.first) {
                tmp2 += pos - tmp.first;
                pos = tmp.first;
            }
        }
    }
    
    cout << max(ans, tmp2 + abs(pos)) << '\n';
    return 0;
}


Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a[3],k;
  rep(i,3) R a[i];
  R k;
  ll ans=0;
  ll x=min(k,a[0]);
  ans+=x;
  k-=x;
  x=min(k,a[1]);  
  k-=x;
  x=min(k,a[2]);  
  ans-=x;
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

#define MOD 1000000007
#define MAX 200010

long long int f[MAX] = {};
long long int rf[MAX] = {};

long long int pw(long long int x, long long int y) {
    long long ret = 1LL;

    for(long long int mask = 0; mask < 50; ++mask) {
        if(y >> mask & 1)
            ret = ret * x % MOD;
        x = x * x % MOD;
    }
    return ret % MOD;
}

long long int getComb(int n, int k) {
    if(k > n)
        return 0;
    long long int ret = f[n];
    ret = ret * rf[k] % MOD;
    ret = ret * rf[n - k] % MOD;
    return ret;
}

long long int initComb(int n) {
    rf[0] = f[0] = 1;
    for(int i = 1; i < n + 1; i++) {
        f[i] = f[i - 1] * i % MOD;
        rf[i] = pw(f[i], MOD - 2);
    }
    return 1;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n, k;
    cin>>n>>k;
    vll a(n);
    rep(i, n) {
        cin>>a[i];
        a[i] += 1e9;
    }
    sort(all(a));

    const ll mod = 1e9 + 7;

    initComb(n);

    ll hi = 0, lo = 0, x = 0;
    rep(i, n - k + 1) {
        ll h = a[n - 1 - i] * getComb(n - i - 1, n - k - i);
        ll l = a[i] * getComb(n - i - 1, n - k - i);
        ll xx = 2e9;
        xx *= getComb(n - i - 1, n - k - i);
        x += xx;
        x %= mod;
        // cout << a[i] << " : " << l << " , " << a[n - 1 - i] << " : " << h << endl;
        hi += h % mod;
        lo += l % mod;
        hi %= mod;
        lo %= mod;
    }

    x = 0;
    ll ans = (mod + hi - lo) % mod;
    ans = (mod + ans - x) % mod;
    cout << ans << endl;
    // cout << (hi - lo) % mod << endl;

    return 0;
}


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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    rep(i, 100000) {
        if (i * 8 / 100 == A && i * 10 / 100 == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <numeric>
#include <map>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;

int main()
{
    int l,r,d;
    cin >> l >> r >> d;
    int cnt = 0;
    for (int i = l; i <= r; i++)
    {
        if (i%d == 0)
        {
            cnt++;
        }
        
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3624
s = input()
t = input()

s = sorted(s)
t = sorted(t, reverse=True)

li = []
li.append(t)
li.append(s)
li = sorted(li)

if s == t:
    print('No')
    exit()

if li[0] == s:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import java.util.*;

class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.length() == 1) {
            System.out.println(s);
        } else {
            String out = "";
            int index = -1;
            for(int i = 0; i < s.length(); i++) {
                if(s.charAt(i) != '9') {
                    index = i;
                    break;
                }
            }
            if(index == -1) {
                out = s;
            } else if(index == 0) {
                int b = 0;
                for(int i = 0; i < s.length(); i++) {
                    if(s.charAt(i) != '9') b++;
                }
                if(b == 1) {
                    out = s;
                } else {
                    out += String.valueOf((char)(s.charAt(index) - 1));
                    for(int i = index + 1; i < s.length(); i++) {
                        out += "9";
                    }
                }

                
            } else {
                out = s.substring(0,index-1);
                out += String.valueOf((char)(s.charAt(index-1) - 1));
                for(int i = index; i < s.length(); i++) {
                    out += "9";
                }
            }
            int ans = 0;
            for(int i = 0; i < s.length(); i++) {
                ans += out.charAt(i) - '0';
            }
            System.out.println(ans);
        }

    }
}



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

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

    for (int i = 1; i <= 3; i++) {
        if (i == A || i == B) continue;
        cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

func calcMax(n int) (sum int) {
	return n * (n - 1) / 2
	// for i := 1; i < n+1; i++ {
	// 	d := i + 1
	// 	if d > n {
	// 		d -= n
	// 	}
	// 	sum += i % d
	// }
	// return
}

func main() {
	n := nextInt()
	fmt.Println(calcMax(n))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define maxn 1001000
char s[2020];

int main(){
	int n;
	scanf("%d",&n);
	int num = 0;
	for(int i = 1;i <= n;i++) {
		int x,y;
		scanf("%d%d",&x,&y);
		if(x==y) {
			num++;
			if(num>=3) {
				printf("Yes\n");
				return 0;
			}
		} else {
			num = 0;
		}
	}
				printf("No\n");
				return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <vector>
using namespace std;
const long long N = 1e5+507;
long long n,m,h[N],ok,good,i,x,y,j;
vector <long long> a[N];
int main()
{
    cin>>n>>m;
    for (i=1;i<=n;++i)
         cin>>h[i];
    for (i=1;i<=m;++i)
    {
        cin>>x>>y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    for (i=1;i<=n;++i)
    {
        if (a[i].size()==0) good++;
        else
        {
            ok=0;
            for (j=0;j<a[i].size();++j)
            {
                if (h[a[i][j]]>=h[i])
                {
                    ok=1;
                    break;
                }
            }
            if (!ok) good++;
        }
    }
    cout<<good<<"\n";
}


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

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(int *a, int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	int a,b,c,n,i,j,k,count,x=1,y=1,z=1,temp;

scanf("%d",&n);
  
  	for(i=1;i<=n;i++){
      count=0;
      x=1;
      y=1;
      z=1;
      //(x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x)<=2*i
  for(x=1;x*x<=2*i;x++){
    for(y=1;y<=x;y++){
      for(z=1;z<=y;z++){
        //printf("(x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x)=%d, 2*i=%d\n",(x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x),2*i);
        if((x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x)==2*i){
          if(z==y){
          if(y==x){
          count++;
          }
          else{
          count+=3;
          }
          }
            
            else if(y==x){
            count+=3;
            }
          
          else{
          
          count+=6;
          }
        }
    }
        
  }
  
  }
      
    printf("%d\n",count);
      
    }
  
return 0;
}


Measured memory_bytes: 1648
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=305;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,m,L,q,f[N][N];
ll mp[N][N];
int main()
{
	n=read(); m=read(); L=read();
	clr(mp, 7);
	for(int i=1; i<=n; i++) mp[i][i]=0;
	for(int i=1; i<=m; i++){
		int u=read(),v=read(),w=read();
		mp[u][v]=mp[v][u]=w;
	}
	
	for(int k=1; k<=n; k++)
		for(int i=1; i<=n; i++)
			for(int j=1; j<=n; j++)
				mp[i][j]=min(mp[i][j], mp[i][k]+mp[k][j]);

	clr(f, 7);
	for(int i=1; i<=n; i++){
		f[i][i]=0;
		for(int j=1; j<=n; j++){
			if(i!=j && mp[i][j]<=L) f[i][j]=1;
		}
	}
	
	for(int k=1; k<=n; k++)
		for(int i=1; i<=n; i++)
			for(int j=1; j<=n; j++)
				f[i][j]=min(f[i][j], f[i][k]+f[k][j]);
	
	q=read();
	for(int i=1; i<=q; i++){
		int u=read(),v=read();
		if(f[u][v]<=n) printf("%d\n",f[u][v]-1);
		else puts("-1");
	}
	return 0;
}

Measured memory_bytes: 1664
#include"bits/stdc++.h"
using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	int ans = 0;
	for (int i = 0; i < N; i++) {
		while (1) {
			if (a[i] % 2 == 0) {
				ans++;
				a[i] /= 2;
			}
			else break;
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>s1;
  a=count(s1.begin(),s1.end(),'7');
  if(a>0)
  {
  cout<<"Yes"<<endl;
  }
  else
  {
  cout<<"No"<<endl;}
}

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



int main(){
	ll n,r,l,maxtime=0,ansid=0,nowtime=0,nexttime;
	ll player[100000][2]={};//0 今まで表示された時間　１　今のスコア
	map<ll,set<ll>,greater<ll>> score;//得点　id
	cin>>n>>r>>l;
	for(ll i=0; i<n; i++){
		score[0].insert(i);
	}
	//cout<<score.rend<<endl;//era-
	for(ll i=0;i<r; i++){
		ll d,x;
		cin>>d>>nexttime>>x;
		d--;
		ll topid=0;		//わからん   //今一番高いやつのidを保存
		for(auto & t : score){
			//for(ll o : t.second){
			//	cout<<"www"<<o<<endl;
			//}
			for(ll o : t.second){
				//cout<<"score"<<o<<endl;
				topid=o;
				break;
			}
			break;
		}
		//cout<<topid<<endl;
		player[topid][0]+= (nexttime-nowtime);//表示時間を追加
		
		
		if(player[topid][0] > maxtime){//一番長く表示された時間を更新
			ansid=topid;
			maxtime=player[topid][0];
		}else if(player[topid][0] == maxtime && topid < ansid){
			ansid=topid;
		}
		
		
		//topが変わったかどうかを記録する
		score[player[d][1]].erase(d);//前の記録を消す
		//if(score[player[d][1]].size() == 0)//消した記録が
		//	score.erase(player[d][1]);
		//
		player[d][1]+=x;//記録を更新
		score[player[d][1]].insert(d);//新しくできたデータを保存
		
		nowtime=nexttime;//時間を更新
		//cout<<"########"<<endl;
		//for(ll u=0; u<n; u++){
		//	cout<<u<<" "<<player[u][0]<<" "<<player[u][1]<<endl;
		//}
		//cout<<"########"<<endl;
	}
	
	
	
	
	ll topid=2;   //わからん   //今一番高いやつのidを保存
	//cout<<"WWWW"<<endl;
	bool c=true;
	for(auto & t : score){
		//cout<<"scor"<<endl;
		//for(ll o : t.second){
		//	cout<<"score"<<o<<endl;
		//}
		for(ll o : t.second){
			if(c){
				topid=o;
				//cout<<"1break"<<endl;
				c=false;
			}else{
				break;
			}
		}
		if(!c){
			break;
		}
		//cout<<"break"<<endl;
	}
	//cout<<topid<<endl;
	player[topid][0]+=l-nowtime;//表示時間を追加
		
		
	if(player[topid][0] > maxtime){//一番長く表示された時間を更新
		ansid=topid;
		maxtime=player[topid][0];
	}else if(player[topid][0] == maxtime && topid < ansid){
		ansid=topid;
	}
	//for(ll i=0; i<n; i++){
	//	cout<<player[i][0]<<" "<<player[i][1]<<endl;
	//}
	cout<<ansid+1<<endl;
}


Measured memory_bytes: 70292
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		String[] a = new String[n];
		String[] b = new String[m];
		for (int i = 0; i < n; i++) {
			a[i] = sc.next();
		}
		for (int i = 0; i < m; i++) {
			b[i] = sc.next();
		}
		boolean pos = false;
		out: for (int i = 0; i <= n - m; i++) {
			for (int j = 0; j <= n - m; j++) {
				boolean bre = false;
				for (int k = 0; k < m; k++) {
					if (!b[k].equals(a[i + k].substring(j, j + m))) {
						bre = true;
						break;
					}
				}
				if (!bre) {
					pos = true;
					break out;
				}
			}
		}
		if (pos) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
N = 50050
a = [True] *  N
i = 3
while i * i < N:
    for j in range(3 * i, N, 2 * i): a[j] = False
    i += 2
  
while True:
    try:
        n = int(input())
    except:
        break
 
    n0 = n + 2 if (n & 1) else n + 1
    for max in range(n0, N, 2):
        if a[max]: break
    n0 = n - 2 if (n & 1) else n - 1
    for min in range(n0, 2, -2):
        if a[min]: break
    else:
        min = 2
 
    print(min, max)


Measured memory_bytes: 5984
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>
#include <unordered_map>
#include <iomanip>


using namespace std;
#define ASCII 97


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

	int count = 0;
	while (true) {
		if (1 + count * (A-1) >= B) {
			break;
		}
		count++;
	}
	cout << count << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string S;
	bool di[4];
	for(int i = 0; i < 4; i++) di[i] = false;
	cin >> S;
	for(int i = 0; i < S.length(); i++){
		if(S[i] == 'N') di[0] = true;
		else if(S[i] == 'W') di[1] = true;
		else if(S[i] == 'S') di[2] = true;
		else if(S[i] == 'E') di[3] = true;
	}
	if(di[0]^di[2] || di[1]^di[3]) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    ll n;
    cin >> n;
    vector<ll> H(n);
    rep(i,n) cin >> H[i];
    ll memo=H[0];
    ll cnt=0;
    ll ans=0;
    for(int i=1;i<n;i++){
        if(memo>=H[i])
            cnt++;
        else{
            if(ans<cnt)
                ans=cnt;
            cnt=0;
        }
        memo=H[i];
    }
    if(ans<cnt)
        ans=cnt;
    cout << ans << endl;
    return 0;
}

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

#define NMAX 100005
using namespace std;

long long dp[NMAX], v[NMAX];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n, k;
    cin >> n >> k;

    for(int i = 1; i <= n; ++i)
        cin >> v[i];

    dp[2] = abs(v[1] - v[2]);
    for(int i = 3; i <= n; ++i){
        long long minn = (1e10);
        for(int j = max(i - k, 1); j < i; ++j)
            minn = min(minn, dp[j] + abs(v[i] - v[j]));
        dp[i] = minn;
    }
    cout << dp[n] << '\n';
    return 0;
}


Measured memory_bytes: 1792
n,m=[int(i) for i in input().split()]
top=n
under=1

for i in range(m):
    low,high =[int(i) for i in input().split()]
    if(under<low):
        under=low
    if(top>high):
        top=high

if(top<under):
    print(0)
else:
    print(top-under+1)

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (d == 1)
        puts("1");
    else
        puts("0");
}

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


Measured memory_bytes: 256
gets
arr = gets.split.map(&:to_i)

@count = 0

def merge_sort(arr)
  return arr if arr.size <= 1

  mid = arr.size / 2
  left = arr[0..(mid - 1)]
  right = arr[mid..(arr.size - 1)]

  merge(merge_sort(left), merge_sort(right))
end

def merge(left, right)
  result = []
  until left.empty? || right.empty?
    if left[0] < right[0]
      result << left.shift
    else
      # 右の要素が左の残りの要素より小さい場合、
      # 左の要素の残りの数だけ反転して、ソート済みの配列に並ぶ
      @count += left.size
      result << right.shift
    end
  end

  result << left.shift until left.empty?
  result << right.shift until right.empty?
  result
end

merge_sort(arr)
puts @count


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

int ans = 0;
vector<vector<int> > g;
int n, m;
vector<bool> v;

void dfs(int curr, int ver){
    if(ver == n){
        ans++;
        return;
    }
    v[curr] = true;
    for(int i=0 ; i<g[curr].size() ; i++){
        if(v[g[curr][i]] == true){
            continue;
        }
        dfs(g[curr][i], ver+1);
    }
    v[curr] = false;
}

int main(){
    cin >> n >> m;
    g.resize(n+1);
    for(int i=0 ; i< m ;i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    v.resize(n+1, 0);
    dfs(1, 1);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,j;
	int x[3][3];
	int sum[6];
	for(i=0;i<3;i++)
	{
		scanf("%d%d%d",&x[i][0],&x[i][1],&x[i][2]);
	}
	sum[0]=x[0][0]+x[1][1]+x[2][2];
	sum[1]=x[1][0]+x[2][1]+x[0][2];
	sum[2]=x[2][0]+x[0][1]+x[1][2];
	sum[3]=x[0][2]+x[1][1]+x[2][0];
	sum[4]=x[1][2]+x[2][1]+x[0][0];
	sum[5]=x[2][2]+x[0][1]+x[1][0];
	if(sum[0]==sum[1]&&sum[1]==sum[2]&&sum[2]==sum[3]&&sum[3]==sum[4]&&sum[4]==sum[5]) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.uni;
import std.range;
import std.algorithm;

void main()
{
    readln;
    auto a = readln.strip.split(' ').map!(to!int).array;
    foreach (i, v; a)
    {
        if (!a[0..i + 1].isSorted)
        {
            a[0..i + 1].sort;
        }
        a.map!(x => x.to!string).join(" ").writeln;
    }
}



Measured memory_bytes: 2636
n, m, l = map(int, input().split())

A = []
B = []
C = [[] for i in range(n)]

for i in range(n):
    tmp_row = list(map(int, input().split()))
    A.append(tmp_row)

for i in range(m):
    tmp_row = list(map(int, input().split()))
    B.append(tmp_row)

for i in range(n):
    line = ""
    for j in range(l):
        ab = sum([A[i][k] * B[k][j] for k in range(m)])
        line += " {0}".format(ab)
    print(line[1:])

Measured memory_bytes: 8476
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int K,S;
    int ans=0;
    
    cin >> K >> S;

    for (int x=0;x<=K;x++){
        for(int y=0;y<=K;y++){
           int z=S-x-y;
           if(z>=0&& z<=K){
               ans++;

        
           }
        }
    }
    cout << ans <<endl;
}

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

using namespace std;

class Input
{
    public:
        int num1st,num2nd;
        Input(int input1, int input2);
};

Input::Input(int input1, int input2)
{
    if(input1 <= input2)
    {
        num1st = input1;
        num2nd = input2;
    }
    else
    {
        num1st= input2;
        num2nd = input1;
    }
}

int main(int argc, char* argv[])
{
    int input1, input2;
    vector<Input> values;
    while(1)
    {
        cin >> input1 >> input2;
        if(input1 == 0 and input2 == 0) break;
        values.push_back(Input(input1,input2));
    }
    for(auto output: values)
    {
        cout << output.num1st << " " << output.num2nd << endl;
    }
}

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



int main(){
  ll n;
  cin >> n;
  vector<ll>a(n),sum(n);
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a.begin(),a.end());
  
  for(int i=0; i<n; i++){
    if(i==0) sum[i]=a[i];
    else sum[i]=sum[i-1]+a[i];
  }
  
  reverse(sum.begin(),sum.end());
  reverse(a.begin(),a.end());
  
  ll count=1;
  for(int i=0; i<n-1; i++){
    if(a[i]>sum[i+1]*2) break;
    count++;
  }
  
  cout << count << endl;
  
  
  
  
  
}
       
        
      
  
    

Measured memory_bytes: 4772
//PLUS ULTRA

#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define mp make_pair
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define nfor(i,st,n) for(int i = st; i >= n ; i--)

typedef long double ld;
typedef pair <int , int> pii;

const int N = 1e5 + 10 , mod =  1000000007;



int main(){
   // SPEED;

    int l; cin >> l;
    double ans =(double) l /3.0;

    ans = pow(ans , 3);

    printf("%0.11f\n",ans );





    
    return 0;
}
      
       


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

#define x first
#define y second

const int INF = 1e9;

array <int, 4> dx = {-1, 1, 0, 0};
array <int, 4> dy = {0, 0, -1, 1};

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, m;
    cin >> n >> m;
    auto on_grid = [&](int x, int y) {
        return 0 <= x && x < n && 0 <= y && y < m;
    };
    pii st, fn;
    cin >> st.x >> st.y >> fn.x >> fn.y;
    st.x--, st.y--, fn.x--, fn.y--;
    vector <string> a(n);
    cin >> a;
    vector <vector <int>> dst(n, vector <int> (m, INF));
    dst[st.x][st.y] = 0;
    array <deque <pii>, 2> q;
    q[0].pb(st);
    while (!q[0].empty()) {
        cerr << "kek\n";
        while (!q[0].empty()) {
            auto [x, y] = q[0].front();
            q[0].pop_front();
            forn (i, 0, 4) {
                int nx = x + dx[i], ny = y + dy[i];
                if (on_grid(nx, ny) &&
                    a[nx][ny] == '.' &&
                    dst[x][y] < dst[nx][ny]) {
                    dst[nx][ny] = dst[x][y];
                    q[0].eb(nx, ny);
                }
            }
            forn (nx, x - 2, x + 3) {
                forn (ny, y - 2, y + 3) {
                    if (on_grid(nx, ny) &&
                        a[nx][ny] == '.' &&
                        dst[x][y] + 1 < dst[nx][ny]) {
                        dst[nx][ny] = dst[x][y] + 1;
                        q[1].eb(nx, ny);
                    }
                }
            }
        }
        swap(q[0], q[1]);
    }
    cout << (dst[fn.x][fn.y] == INF ? -1 : dst[fn.x][fn.y]);
    return 0;
}

Measured memory_bytes: 8716
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;
use std::f64::consts;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let R: f64 = sc.get();
    println!("{}", 2. * R * consts::PI);
}


Measured memory_bytes: 2188
r=lambda x:x if u[x]<0else r(u[x])
n,m,*t=map(int,open(0).read().split())
u=[-1]*-~n
for x,y in zip(t[::3],t[1::3]):
 x,y=sorted((r(x),r(y)))
 if x!=y:u[x]+=u[y];u[y]=x
print(sum(i<0for i in u)-1)

Measured memory_bytes: 144380
#include <stdio.h>
 
int parent(int);
int left(int);
int right(int);
 
main(void){

  int a,i,A[260];

    scanf("%d",&a);

    for(i=1;i<=a;i++) {

        scanf("%d",&A[i]);

    }
  
    for(i=1;i<=a;i++) {

        printf("node %d: key = %d, ",i,A[i]);

        if(parent(i)!=0){

      printf("parent key = %d, ",A[parent(i)]);

    }
        if(left(i)<=a){

      printf("left key = %d, ",A[left(i)]);

    }
        if(right(i)<=a){

      printf("right key = %d, ",A[right(i)]);

    }

        printf("\n");

    }

    return 0;

}

  
int parent(int i)
{
  return i/2;
}
int left(int i)
{
  return 2*i;
}
int right(int i)
{
  return 2*i+1;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
int cnt[200010];
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		if (0 <= i - a + 1)ans += cnt[i - a + 1];
		cnt[min(n, i + a + 1)]++;
	}
	cout << ans << endl;
}

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

const long long INF = 100000000;

int main() {
  long long n;
  cin >> n;
  vector<long long> flog(n);
  vector<long long> dp(n);
  for(long long i = 0; i < n; ++i) {
    cin >> flog[i];
    dp[i] = INF;
  }
  auto a = [](long long a, long long b){
    if(a<b) return a;
    else return b;
  };

  dp[0] = 0;
  for(long long i = 1; i < n; ++i) {
    if(i>1){
      dp[i] = a(dp[i - 1] + abs(flog[i - 1] - flog[i]),dp[i - 2] + abs(flog[i - 2] - flog[i]));
    }else{
      dp[i] = a(dp[i],dp[i - 1] + abs(flog[i - 1] - flog[i]));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int nax=1e4;

void solve(){
    ll x;
    cin>>x;
    ll s=100;
    for(ll i=1;true;i++){
        s+=s/100;
        if(s >= x){
            cout<<i<<'\n';
            return ;
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tc;
 //   cin>>tc;
    tc=1;
    while(tc--){
        solve();
    }
return 0;
}


Measured memory_bytes: 3584
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int A, B, C;
    cin >> A >> B >> C;

    int a = 0;
    REP(i, B) {
        a += A;

        if (a % B == C) {
            cout << "YES";
            return;
        }
    }

    cout << "NO";
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int A[3]={0};
  rep(i,3) cin>>A[i];
  sort(A,A+3);
  cout<<A[2]-A[0]<<endl;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
l = [['#']*(w+2)]
for i in range(h):
    l.append(['#']+list(input())+['#'])
l.append(['#']*(w+2))

mod = 10**9+7
dp = [[0]*(w+2) for _ in range(h+2)]

for i in range(1,h+1):
    for j in range(1,w+1):
        if i==1 and j==1:
            dp[1][1] = 1
            continue
        if l[i][j] == '.':
            dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod
print(dp[h][w])

Measured memory_bytes: 112488
n=int(input())
l=list(map(int,input().split()))
if(n<=2):
    print(1)
    quit()
h=0
ans=1
for i in range(n-1):
    if((l[i+1]-l[i])*h<0):
        ans+=1
        h=0
        continue
    if(l[i+1]-l[i]<0):
        h=-1
    elif(l[i+1]-l[i]>0):
        h=1
print(ans)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    rep(i, 365) {
        cout << 26-(i+3)%26 << endl;
    }
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<math.h>

#define SIZE 10	//??????????????§?????????

int Main();
void SetChar(char *c, int size);
int ConvertMCXItoI(char *str);
int ConvertItoMCXI(char *str, int value);

int main(int argc, char *argv[]){
	int n = 0, i = 0;
	if( scanf("%d", &n) != 1 ){ return -1; }
	for( i = 0; i < n; i++ ){ Main(); }
	return 0;
}

int Main(){
	char ans[SIZE], str1[SIZE], str2[SIZE];	//???, ?????????1, ?????????2???
	SetChar(ans, SIZE);
	SetChar(str1, SIZE);
	SetChar(str2, SIZE);
	if( scanf("%s %s", str1, str2) != 2 ){ return -1; }
	ConvertItoMCXI(ans, ConvertMCXItoI(str1) + ConvertMCXItoI(str2));
	printf("%s\n", ans);
	return 0;
}

void SetChar(char *c, int size){
	int i = 0;
	for( i = 0; i < size; i++ ){
		c[i] = '\0';
	}
	return;
}

int ConvertMCXItoI(char str[SIZE]){
	int i = 0;
	int ans = 0;	//?????????????????????
	int coef = 1;	//?????°???
	for( i = 0; i < SIZE || str[i] != '\0'; i++ ){
		if( '2' <= str[i] && str[i] <= '9' ){
			coef = str[i] - '0';
		}else if( str[i] == 'm' ){
			ans += coef * 1000;
			coef = 1;
		}else if( str[i] == 'c' ){
			ans += coef * 100;
			coef = 1;
		}else if( str[i] == 'x' ){
			ans += coef * 10;
			coef = 1;
		}else if( str[i] == 'i' ){
			ans += coef;
		}
	}
	return ans;
}

int ConvertItoMCXI(char *str, int value){
	int coef = 0;	//?????°???
	int count = 0;	//???????????????????????????
	char mcxi[4] = {'i', 'x', 'c', 'm'};	//??????mxci?????????????????????????????????????????????
	int i = 0;
	//?????????????????????????????????????±??????????MCXI????????????????????°????±??????????
	for( i = 3; i >= 0; i-- ){
		coef = value / (int)pow(10, i);
		if( coef == 0 ){
			continue;
		}else if( coef == 1 ){
			str[count++] = mcxi[i];
		}else if( 2 <= coef && coef <= 9 ){
			str[count++] = coef + '0';
			str[count++] = mcxi[i];
		}
		value -= coef * (int)pow(10, i);
	}
	return 0;
}

Measured memory_bytes: 624
#include <stdio.h>
#include <algorithm>

using namespace std;

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

	int i;
	int t[3];
	for(i=0;i<n;i++){
		scanf("%d%d%d", t, t+1, t+2);
		sort(t, t+3);
		printf("%s\n", (t[0]*t[0] + t[1]*t[1] == t[2]*t[2])? "YES":"NO");
	}
		
}

Measured memory_bytes: 0
import bisect

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
C.sort()

ans = 0

for b in B:
    a_max = bisect.bisect_left(A, b)
    c_min = bisect.bisect_right(C ,b)
    ans += a_max * (n - c_min)
print(ans)

Measured memory_bytes: 29364
import java.util.Scanner;
import java.lang.*;
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		int[] heights = new int[n];
		for(int i = 0; i < n; i++) {
			heights[i] = sc.nextInt();
		}
		
		int[] dp = new int[n]; //min number of cost before reaching i
		
		dp[0] = 0;
		dp[1] = Math.abs(heights[0] - heights[1]);
		for(int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i-1] + Math.abs(heights[i-1] - heights[i]), dp[i-2] + Math.abs(heights[i-2] - heights[i])); //from i-1 or i-2
		}
		System.out.println(dp[n-1]);
	}
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
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<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{  
  gearup;
  ll n; cin >> n;
  vl x(n),l(n);
  rep(i,n)cin>>x[i]>>l[i];
  vector<pair<ll,ll> > p;
  rep(i,n){
    ll left = x[i]-l[i];
    ll right = x[i]+l[i];
    p.emplace_back(right,left);
  }
  sort(all(p));
  ll res = 1;
  ll end = p[0].first;
  rep1(i,n){
    if(p[i].second >= end){
      end = p[i].first;
      res++;
    }
  }
  out(res);
}


Measured memory_bytes: 4980