akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#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 rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#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");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
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>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const 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>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n,k;
    cin>>n>>k;
    vp p(n);
    cin>>p;
    ll mi=LINF;
    REP(l,n){
        REP(r,n){
            if(p[l].F>p[r].F)continue;
            REP(u,n){
                REP(d,n){
                    if(p[u].S<p[d].S)continue;
                    int c=0;
                    REP(i,n){
                        if(p[l].F<=p[i].F && p[i].F<=p[r].F &&
                            p[d].S<=p[i].S && p[i].S<=p[u].S)
                            ++c;
                    }
                    if(c>=k)chmin(mi, (ll)(p[r].F-p[l].F) * (ll)(p[u].S-p[d].S));
                }
            }
        }
    }
    print(mi);
}


Measured memory_bytes: 256
#include <iostream>

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<set>
#define LL long long
#define INF 1000000009
#define mod 1000000007
#define maxn 10000009
#include <set>
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
    int n;
    char s1[100],s2[100];
    scanf("%d",&n);
    scanf("%s",&s1);
    scanf("%s",&s2);
    LL ans=1;
    int a,b;
    if(s1[0]==s2[0])
    {
        ans=3;
        a=1;
        b=1;
    }
    else
    {
        ans=6;
        a=2;
        b=2;
    }
    for(int i=a;i<n;i++)
    {
        if(s1[i]==s2[i])
        {
            if(b==1)
            {
                ans*=2;
                ans%=mod;
            }
            b=1;
        }
        else
        {
            if(b==1)
            {
                ans*=2;
                ans%=mod;
            }
            else
            {
               ans*=3;
               ans%=mod;

            }
            b=2;
            i++;
        }
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c[7],d;
	for(d=0; d<7; d++){
	scanf("%d %d",&a,&b);
	c[d]=a-b;
	}
	for(d=0; d<7; d++){
	printf("%d\n",c[d]);
	}
	
	return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <sstream>
typedef long long ll;
using namespace std;

int sum(int n) {
    int s = 0;
    while(n != 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    int ans = sum(n);
    if (ans == 1) {
        std::cout << 10 << std::endl;
        return 0;
    }
    std::cout << ans << std::endl;
    return 0;
}

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

main(){
	int n,k,maxi =0;
	cin >> n >> k;
	vector<int> v;
	vector<int> vet(n);
	for(int i = 0;i<n;i++) cin >> vet[i];
	
	for(int l =0;l<=n;l++)
		for(int r = 0;r<=n;r++){
				v.clear();
				if(r + l > k or r + l >n)
					continue;
				int d = k-(l+r);
				
				for(int i=0;i<l;i++)
					v.push_back(vet[i]);
			
				for(int i = n-1;i>n-r-1;i--)
					v.push_back(vet[i]);	
			
				sort(v.begin(),v.end(),greater<int>());
				
				for(int i =0;i<d and v.size() and v.back() < 0;i++)
					v.pop_back();
			
				maxi = max(maxi, accumulate(v.begin(),v.end(),0LL));
			}
	cout<<maxi<<endl;	
}

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

int main() {
    int a, b; cin >> a >> b;

    int minus = 0;
    bool is_zero = false;
    for (int i = a; i <= b; i++) {
        if (i < 0)
            minus++;
        else if (i == 0)
            is_zero = true;
    }

    if (is_zero)
        puts("Zero");
    else if (minus % 2 == 0)
        puts("Positive");
    else
        puts("Negative");
    return 0;
}

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

int main(void)
{
	int n, k, p;
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		scanf("%d %d", &k, &p);
		
		if (k % p != 0){
			printf("%d\n", k % p);
		}
		else {
			printf("%d\n", p);
		}
	}
	
	return (0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = ll(1e9 + 7);
ll dp[70][2][2];
int a[70];

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

	ll N;
	cin >> N;

	for(int i = 0; i < 64; i++) {
		a[i] = N >> i & 1;
	}

	dp[0][0][0] = 1;
	for(int i = 0; i < 64; i++) {
		for(int j = 0; j < 2; j++) {
			for(int k = 0; k < 2; k++) {
				if(dp[i][j][k] == 0) continue;
				int u[4] = { 0, 0, 1 }, v[4] = { 0, 1, 1 };
				for(int l = 0; l < 3; l++) {
					int sum = j + u[l] + v[l];
					int nj = sum / 2;
					int nk = (sum % 2) > a[i] || k && (sum % 2) >= a[i];
					dp[i + 1][nj][nk] += dp[i][j][k];
					dp[i + 1][nj][nk] %= MOD;
				}
			}
		}
	}

	cout << dp[64][0][0] << endl;
}

Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

const long long MAX = 1001000;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    int n,k;
    cin>>n>>k;

    COMinit();
    for(int i=1; i<=k; i++){
        ll com1=COM(n-k+1,i);
        com1%=MOD;
        ll com2=COM(k-1,i-1);
        com2%=MOD;
        ll ans = com1*com2;
        ans%=MOD;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 27056
package main

import "fmt"

var bin [9]bool

func main() {
	var bingo [9]int
	var n int
	b := make(map[int]bool)
	fmt.Scanf("%d %d %d\n %d %d %d\n %d %d %d \n%d", &bingo[0], &bingo[1], &bingo[2], &bingo[3], &bingo[4], &bingo[5], &bingo[6], &bingo[7], &bingo[8], &n)
	//fmt.Println(bingo)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scanf("%d", &tmp)
		b[tmp] = true
	}
	for i, j := range bingo {
		if b[j] {
			bin[i] = true
		}
	}
	//fmt.Println(b)
	if h(1, 2, 3) || h(4, 5, 6) || h(7, 8, 9) || h(1, 4, 7) || h(2, 5, 8) || h(3, 6, 9) || h(1, 5, 9) || h(3, 5, 7) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}
func h(a, b, c int) bool {
	if bin[a-1] && bin[b-1] && bin[c-1] {
		return true
	}
	return false
}


Measured memory_bytes: 1836
# -*- coding: utf-8 -*-
import numpy as np

N = int(input())
A = [input() for _ in range(N)]

def count(a):
  if '.' in a:
    c = a.split('.')
    n = int(c[0]+c[1])
    count2 = 9 - len(c[1])
    count5 = 9 - len(c[1])
  else:
    n = int(a)
    count2 = 9
    count5 = 9
  while n%2 == 0 and count2<18:
    n //= 2
    count2 += 1
  while n%5 == 0 and count5<18:
    n //= 5
    count5 += 1
  return count2,count5

Z = np.zeros((19,19), dtype=np.int64)
answer = 0
for a in A:
  c2,c5 = count(a)
  answer += Z[18-c2,18-c5]
  Z[:c2+1,:c5+1] += 1

print(answer)

Measured memory_bytes: 41136
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct UnionFind{
  Int num;
  vector<Int> r,p;
  UnionFind(){}
  UnionFind(Int n):num(n),r(n,1),p(n,0){iota(p.begin(),p.end(),0);}
  Int find(Int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(Int x,Int y){
    return find(x)==find(y);
  }
  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
    num--;
  }
  Int size(Int x){
    return r[find(x)];
  }
  Int count() const{
    return num;
  }
};


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector< vector<Int> > G(n,vector<Int>(n));

  const Int INF = 1e9;
  char c;
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      cin>>c,G[i][j]=(c=='1'?1:INF);

  for(Int i=0;i<n;i++) G[i][i]=0;

  UnionFind uf(n*2);
  auto unite=
    [&](Int x,Int y){
      uf.unite(x,n+y);
      uf.unite(y,n+x);
    };

  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      if(G[i][j]==1) unite(i,j);

  for(Int i=0;i<n;i++)
    if(uf.same(i,n+i)) drop(-1);

  for(Int k=0;k<n;k++)
    for(Int i=0;i<n;i++)
      for(Int j=0;j<n;j++)
        chmin(G[i][j],G[i][k]+G[k][j]);

  Int ans=0;
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      chmax(ans,G[i][j]+1);

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


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

struct ca
{
  int idx,st,et,aidx;
};

int prime[1000001]={};

int power(int x, unsigned int y, int p)  
{  
    int res = 1;     
  
    x = x % p; 
   
    if (x == 0) return 0; 
  
    while (y > 0)  
    {  
         
        if (y & 1)  
            res = (res*x) % p;  
  
        
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}  

void pr()
{
  prime[1]=0;

 for(int i=2;i*i<1000001;i++)
  if(prime[i]==0)
  for(int j=i*i;j<1000001;j+=i)
  prime[j]=1;

}

int countSetBits( int n) 
{ 
     int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 
  
bool cmp1(ca c1,ca c2)
{
  if(c1.st<c2.st)
   return true;

  if(c1.st==c2.st && c1.idx<c2.idx)
   return true;

  return false;
}

bool cmp2(ca c1,ca c2)
{
  
  if(c1.idx<c2.idx)
  return true;
  return false;
}








int main()
{

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
   //pr();
  int t;
   //cin>>t;
   t=1;
  int id=1;

  while(t--)
{
   int n;
    cin>>n;

    if(n%10 ==7)
  {
    cout<<"Yes";
    continue;
  }

  n/=10;
    if(n%10 ==7)
  {
    cout<<"Yes";
    continue;
  }
   

   n/=10;
    if(n%10 ==7)
  {
    cout<<"Yes";
    continue;
  }

  cout<<"No";

   vector<int> arr;

}



return 0;
}


Measured memory_bytes: 3596
kata = [] #空リスト作成
try: #ここから下でエラーを拾う
    while True: #無限ループ
        a,b = input().split(",") #標準入力
        kata.append(b) #型の方をリストに格納する
except EOFError: #EOFErrorを拾う
    print(kata.count("A")) #A型の人数を出力
    print(kata.count("B")) #B型の人数を出力
    print(kata.count("AB")) #AB型の人数を出力
    print(kata.count("O")) #O型の人数を出力


Measured memory_bytes: 5560
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

bool compair(pair<long long, long long> a, pair<long long, long long> b){
    return a.second > b.second;
}

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

    vector<long long> a(n);

    for(long long i = 0; i < n; i++){
        cin >> a[i];
    }

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

    vector<pair<long long, long long> > bc(m);

    for(long long i = 0; i < m; i++){
        cin >> bc[i].first >> bc[i].second;
    }

    sort(bc.begin(), bc.end(), compair);

    long long sum = 0;

    vector<long long> b(n, 0);

    long long b_index = 0;
    for(long long i = 0; i < m; i++){
        if(b_index >= n){
            break;
        }
        for(long long j = 0; j < bc[i].first; j++){
            if(b_index >= n){
                break;
            }
            b[b_index] = bc[i].second;
            b_index++;
        }
    }

    for(long long i = 0; i < n; i++){
        sum += max(a[i], b[i]);
    }

    cout << sum << endl;
    return 0;

}

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

const int inf = 1001001001;

int main() {
  int n, m;

  while (cin >> n >> m, n) {
    int a = inf, b = inf;
    int sum1 = 0, sum2 = 0;

    vector<int> s1, s2;

    for (int i = 0; i < n; ++i){
      int x;
      cin >> x;
      s1.push_back(x);

      sum1 += x;
    }
    for (int i = 0; i < m; ++i){
      int x;
      cin >> x;
      s2.push_back(x);

      sum2 += x;
    }

    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (sum1 - s1[i] + s2[j] == sum2 - s2[j] + s1[i]) {
          if (a + b > s1[i] + s2[j]) {
            a = s1[i];
            b = s2[j];
          }
        }
      }
    }

    if (a == inf && b == inf) cout << -1 << endl;
    else cout << a << " " << b << endl;
  }
}

Measured memory_bytes: 3004
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n = int(input())
x = list(map(int, input().split()))

mix_x = min(x)
max_x = max(x)

ans = 10000000000000
for i in range(mix_x, max_x+1):
    power = 0
    for j in range(n):
        power += (x[j] - i)**2
    ans = min(ans, power)
print(ans)





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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  cin.tie(0);
  int X;
  cin >> X;
  int div = X / 100, mod = X % 100;
  if (mod > 5 * div) {
    print(0);
  } else {
    print(1);
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
int t,n,d,l,r,md;
int main()
{
	int h,w;
	cin>>h>>w>>n;
	if(h>w)swap(h,w);
	cout<<(n+w-1)/w;
	return 0;
}

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

int main() {
	string s[4] = {"AC", "WA", "TLE", "RE"};
	int n;
	cin >> n;
	vector<int> cnt(4,0);
	rep(i,n) {
		string str;
		cin >> str;
		rep(j,4) if (s[j]==str) cnt[j]++;
	}

	rep(i,4) {
		printf("%s x %d\n", s[i].c_str(), cnt[i]);
	}

	return 0;
}


Measured memory_bytes: 3736
# 解説を見て書いたコード
N = int(input())
data = list(map(int, input().split()))
count = 0

def ary_abs(data):
    for i in range(len(data)):
        data[i] = abs(data[i])


for i in data:
    if i <= 0:
        count += 1

if count % 2 == 0:
    # 負が 偶数 個のとき
    # 全てを正にした和
    ary_abs(data)
    print(sum(data))
else:
    # 負が 奇数 個のとき
    # どれか一つを負(最小のもの)
    ary_abs(data)
    print(sum(data) - min(data) * 2)


Measured memory_bytes: 14412
n = int(input())
s = [input() for _ in range(n)]
from collections import Counter
cnt = Counter(s)
for i in ['AC','WA','TLE','RE']:
    if i in cnt.keys():
        print('{}'.format(i)+' '+'x' + ' ' + '{}'.format(cnt[i]))
    else:
        print('{}'.format(i)+' '+'x' + ' ' + '0')

Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define _GLIBCXX_DEBUG

int main(){
  
  int a, b, c;
  cin >> a >> b >> c;

  vector<int> vb = {a, b, c};
  sort(ALL(vb));
  vector<int> ans = {5, 7, 5};
  do{
    if (vb == ans){
      cout << "YES" << endl;
      return 0;
    }
  }
  while(next_permutation(ALL(vb)));
  cout << "NO" << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        for (int i = 0; i <= x; i++) {
            if (i * 2 + (x - i) * 4 == y) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 35812
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] HW = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long[,] result = new long[HW[0], HW[1]];
            for (int j = 0; j < HW[0]; j++)
            {
                string s = Console.ReadLine();
                for (int z = 0; z < HW[1]; z++)
                {
                    //爆弾がいたら周り8マスに+1
                    if (s.Substring(z, 1) == "#")
                    {
                        result[j, z] = 99;
                        for (int x = j - 1; x <= j + 1; x++)
                        {
                            if (x < 0 || HW[0] == x)
                            {
                                continue;
                            }
                            for(int y = z - 1; y <= z + 1; y++)
                            {
                                if(y < 0 || HW[1] == y)
                                {
                                    continue;
                                }
                                result[x, y]++;
                            }
                        }
                    }
                }
            }
            for(int d = 0; d < HW[0]; d++)
            {
                string ans = "";
                for(int g = 0; g < HW[1]; g++)
                {
                    if(99 <= result[d,g])
                    {
                        ans += "#";
                    }
                    else
                    {
                        ans += result[d, g].ToString();
                    }
                }
                Console.WriteLine(ans);
            }
           
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(ans);


Measured memory_bytes: 28540
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000000;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

Graph G;
vector<ll>ans;

void dfs(int k, int parent = -1) {
	for (auto p : G[k]) {
		if (p == parent)continue;
		ans[p] += ans[k];
		dfs(p, k);
	}
}
int main() {
	init();

	int N, Q; cin >> N >> Q;
	G.resize(N);
	ans.resize(N);
	fill(all(ans), 0);
	rep(i, N - 1) {
		int a, b; cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i, Q) {
		int a, b; cin >> a >> b;
		ans[a - 1] += b;
	}
	dfs(0);

	rep(i, N)cout << ans[i] << (i == N - 1 ? "\n" : " ");

	return 0;
}

Measured memory_bytes: 24320
#include <string>
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int s = 0, c = n;
	while (c > 0) {
		s += c % 10;
		c /= 10;
	}
	cout << (n % s == 0 ? "Yes\n" : "No\n");
	return 0;
}

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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 2e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e17;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

map <int, int> mp;

signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int n;   
   cin >> n;
   int k = sqrt(n);
   int x, y, x1, y1;
   int l = 0, r = 1e9 + 1;
   while (r - l != 1) {
      int m = (r + l) / 2;
      if (m * m <= n) l = m;
      else r = m;
   }
   k = l;
   if (k * k != n) k++;
      x = k, y1 = k;
   int delta = x * y1 - n;
   cout << 0 << ' ' << 0 <<  ' ' << x << ' ' << delta << ' ' << 1 << " " << y1;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,m,i,j,p,c,max,min,sum;
    int a[100000];
    scanf("%d %d",&n,&m);
    max=0;min=0;
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        max += a[i];
        if(min<a[i]){
            min=a[i];
        }
    }
    while(min<max){
        c=1;sum=a[0];
        p = (min+max)/2;
        for(j=1;j<n&&c<=m;j++){
            i = sum+a[j]-p;
            if(i>0){
                c++;
                sum = a[j];
            }else{
                sum += a[j];
            }
        }
        if(c>m){
            min=p+1;
        }else{
            max=p;
        }
    }
    printf("%d\n",max);
    return 0;
}



Measured memory_bytes: 2232
#include <iostream>
#include <cmath>

using namespace std;

const long long int MOD=1e9+7;

int main() {
    long long int N, M;
    cin >> N >> M;
    long long int ans=1;
    if(abs(N-M)>1) {
        ans = 0;
    } else {
        for(int n=1; n<=N; n++) {
            ans *= n;
            ans %= MOD;
        }
        for(int m=1; m<=M; m++) {
            ans *= m;
            ans %= MOD;
        }
        if(abs(N-M)==0) {
            ans *= 2;
            ans %= MOD;
        }
    }

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int W,H,x,y,r;
  cin>>W>>H>>x>>y>>r;

  if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
       cout<<"Yes"<<endl;
  }
  else{
       cout<<"No"<<endl;
   }

}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
} 
int main() {
    string s,t;cin>>s>>t;
    int s_sz=SIZE(s);
    int t_sz=SIZE(t);
    if(s_sz<t_sz){
        cout<<"UNRESTORABLE"<<endl;
    }else{
        bool o=0;
        int an=0;
        rep(i,s_sz-t_sz+1){
            bool k=1;
            rep(j,t_sz){
                if(s[s_sz-t_sz-i+j]!='?'&&s[s_sz-t_sz-i+j]!=t[j]){
                    k=0;break;
                }
            }
            if(k){
                    o=1;
                    an=i;
                    break;
                }
        }
        
        if(o){
            rep(i,s_sz){
                if(s_sz-t_sz-an<=i&&i<=s_sz-1-an){
                    cout<<t[i-(s_sz-t_sz-an)];
                }else if(s[i]=='?'){
                    cout<<"a";
                }else{
                    cout<<s[i];
                }
            }
        }else{
            cout<<"UNRESTORABLE"<<endl;
        }
    }
}

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

namespace testing
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int counter = 0;
            for (int i = 0; i < N - 2; i++)
            {
                int[] vs = new int[] { a[i], a[i + 1], a[i + 2] };
                Array.Sort(vs);
                if (vs[1] == a[i + 1])
                {
                    counter++;
                }
            }
            Console.WriteLine(counter);
        }
    }
}


Measured memory_bytes: 28268
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <set>
#include <stack>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
string convertInt(int number)
{
    if (number == 0)
        return "0";
    string temp = "";
    string returnvalue = "";
    while (number > 0)
    {
        temp += number % 10 + 48;
        number /= 10;
    }
    for (int i = 0; i < temp.length(); i++)
        returnvalue += temp[temp.length() - i - 1];
    return returnvalue;
}
const int eps = 1e-7;


    vector<int>v(1e7);
    int main() {

        fast
            int n, t = 1,t1=0;
        cin >> n;
        vector<int>v(n);
        for (int i = 0; i < n; i++) {
            cin >> v[i];
            if (v[i] % 2 == 0) {
                if (v[i] % 3 != 0 && v[i] % 5 != 0&&t1==0) {
                    cout << "DENIED" << endl; t = 0; t1 = 1;
                }
            }
        }
        if (t == 1)cout <<"APPROVED"  << endl;
    }


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  vector<LL> a(n),r(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(all(a));
  r[0]=a[0];
  for(int i=1;i<n;i++){
    r[i]=r[i-1]+a[i];
  }
  vector<bool> dp(n,false);
  dp[n-1]=true;
  int ans=1;
  for(int i=n-2;i>=0;i--){
    int idx=distance(a.begin(),upper_bound(all(a),2*r[i]))-1;
    if(dp[idx]){
      dp[i]=true;
      ans++;
    }else{
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
  ll ans = 0, n;
  cin >> n;

  REP(a,1,n){
    ans+= (n-1)/a;
  }
  cout << ans << endl;

  //--debug : end_stoper
  //string end_stoper; cin >> end_stoper;

  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));


int main(){	
	vector<long long> A(3-1+1);
	for(int i = 0 ; i <= 3-1 ; i++){
		scanf("%lld",&A[i]);
	}
	if (A[0]+A[1]+A[2] >= 22) cout << "bust" << endl; else  cout << "win" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int n; cin >> n;
    string c; cin >> c;
    int rCount = 0, wCount = 0;
    rep(i, n) if(c[i] == 'R') ++rCount;
    wCount = n - rCount;
    int l = 0, r = n - 1;
    int ans = 0;
    while(1) {
        bool flg = true;
        if(c[l] == 'R') ++l, flg = false;
        if(c[r] == 'W') --r, flg = false;
        if(flg) {
            if(l < r) {
                ++l;
                --r;
                ++ans;
            } else {
                break;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3748
#include<stdio.h>

int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	int a[n][m],b[m];
	int c[n];

	for(int i = 0;i < n;i++) {
		for(int j = 0;j < m;j++) {
			scanf("%d",&a[i][j]);
		}
	}
	for(int i = 0;i < m;i++) {
		scanf("%d",b + i);
	}
	for(int i = 0;i < n;i++) {
		c[i] = 0;
		for(int j = 0;j < m;j++) {
			c[i] += a[i][j] * b[j];
		}
	}

	for(int i = 0;i < n;i++) {
		printf("%d\n",c[i]);
	}
}



Measured memory_bytes: 2724
n = int(input())

zmax = -10**10
zmin = 10**10
wmax = -10**10
wmin = 10**10

for i in range(n):
    x, y = map(int, input().split())
    zref = x + y
    wref = x - y
    zmax = max(zmax, zref)
    zmin = min(zmin, zref)
    wmax = max(wmax, wref)
    wmin = min(wmin, wref)

ans = max(zmax - zmin, wmax - wmin)
print(ans)

Measured memory_bytes: 9212
from collections import deque

N = int(input())
es = [[] for _ in range(N)]
# 0-indexed

for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    es[u].append((v, w))
    es[v].append((u, w))

visited = [-1] * N
visited[0] = 0

dq = deque()
dq.append(0)
while dq:
    v = dq.popleft()
    for nv, cost in es[v]:
        if visited[nv] != -1: continue
        visited[nv] = (visited[v] + cost) % 2
        dq.append(nv)
print(*visited, sep='\n')

# UnionFindしたのは無意味だった
# どこから探索を始めても問題ない


Measured memory_bytes: 40696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int N;
string S;
int R_sum[4010], G_sum[4010], B_sum[4010];

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

    memset(R_sum, 0, sizeof(R_sum));
    memset(G_sum, 0, sizeof(G_sum));
    memset(B_sum, 0, sizeof(B_sum));

    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') {
            R_sum[i+1] = R_sum[i] + 1;
            G_sum[i+1] = G_sum[i];
            B_sum[i+1] = B_sum[i];
        }
        else if (S[i] == 'G') {
            R_sum[i+1] = R_sum[i];
            G_sum[i+1] = G_sum[i] + 1;
            B_sum[i+1] = B_sum[i];
        }
        else {
            R_sum[i+1] = R_sum[i];
            G_sum[i+1] = G_sum[i];
            B_sum[i+1] = B_sum[i] + 1;
        }
    }

    ll ans = 0;
    for (int i = 0; i < N-2; i++) {
        for (int j = i+1; j < N-1; j++) {
            if (S[i] != S[j]) {
                if ((S[i] == 'G' && S[j] == 'B')|| (S[j] == 'G' && S[i] == 'B')) {
                    ans += R_sum[N] - R_sum[j+1];
                    if (S[2*j - i] == 'R') ans--;
                }
                else if ((S[i] == 'R' && S[j] == 'B') || (S[j] == 'R' && S[i] == 'B')) {
                    ans += G_sum[N] - G_sum[j+1];
                    if (S[2*j - i] == 'G') ans--;
                }
                else {
                    ans += B_sum[N] - B_sum[j+1];
                    if (S[2*j - i] == 'B') ans--;
                }
            }
        }
    }

    cout << ans << endl;

    
    return 0;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    string s;
    cin >> s;
    string t;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == t[i])
            ans++;
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

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


long long div(long long A,long long B,long long C) {
  long long N = (B - A + 1)/C;
  long long M = (B -A + 1)%C;
  long long L = (A+C*N-1)%C;
  if ((L+M) >= C) {
    return N+1;
  }
  else {
    return N;
  }
}

long long min_baisu(long long a,long long b) {
  long long A = max(a,b);
  long long B = min(a,b);
  long long x = A*B;
  long long r = A%B;
  while (A%B != 0) {
    A = B;
    B = r;
    r = A%B;
  }
  //最終的なBが、最大公約数
  return x/B;
}

  

    
  





int main() {
  long long A,B,C,D;
  cin >> A >> B >> C >> D;
  long long c = div(A,B,C);
  long long d = div(A,B,D);
  long long cd = div(A,B,min_baisu(C,D));
  cout << B-A+1 - (c+d-cd) << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
 
int main() {
  int N;
  cin >> N;
  vb A(1000000000);
  REP(i, N) {
    int a;
    cin >> a;
    if(A.at(a)) {
      cout << "NO" << endl;
      return 0;
    }
    A.at(a) = true;
  }
  cout << "YES" << endl;
}

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

int main(void){
  int a, b, c, d;
  double e;
  cin >> a >> b;
  c = a / b;
  d =  a % b;
  e = (double)a / b;
  cout << c << " "<< d << " " << fixed << setprecision(8) << e << endl;
  return 0;
}



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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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 rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
typedef pair<dou,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた

//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！
bool IsPrime(ll num)//素数
{
    if (num < 2ll) return false;
    else if (num == 2ll) return true;
    else if (num % 2ll == 0ll) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3ll; i <= sqrtNum; i += 2ll)
    {
        if (num % i == 0ll)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}



int main(){
    std::vector<int> b(100001,0);
    rep(i,100000){
        if(IsPrime(i)&&IsPrime((i+1)/2)){
            b[i]=1;
        }
    }
    std::vector<int>c(100002,0) ;
    rrep(i,1,100001)c[i]=c[i-1]+b[i];
    query{
        int l,r;
        std::cin >> l>>r;
        std::cout << c[r]-c[l-1] << std::endl;
    }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
    using namespace std;
    #define endl "\n"
    #define pb push_back
    
    queue<int>q;
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        int n,x,t,ans=0;
        cin>>n>>x>>t;
        while(n>0){
            n-=x;
            ans+=t;
        }
    cout<<ans<<endl;
    }

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int H, W, i, j, dp[1001][1001];
	char maze[1001][1001];
	cin >> H >> W;
	for(i = 0; i < H; i++)
	{
		for(j = 0; j < W; j++)
			cin >> maze[i][j];
	}
	dp[0][0] = 1;
	for(i = 1; i < H; i++)
	{
		dp[i][0] = 1;
		if(maze[i][0] == '#' || dp[i - 1][0] == 0)
				dp[i][0] = 0;
	}
	for(i = 1; i < W; i++)
	{
		dp[0][i] = 1;
		if(maze[0][i] == '#' || dp[0][i - 1] == 0)
				dp[0][i] = 0;
	}
	for(i = 1; i < H; i++)
	{
		for(j = 1; j < W; j++)
		{
			if(maze[i][j] == '#')
				dp[i][j] = 0;
			else
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % (1000000007);
		}
	}
	cout << dp[H - 1][W - 1];
	return 0;
}

Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int ans = 0;
        while(true){
            int num = (int)Math.pow(K, ans);
            if(num > N){
                break;
            }
            ans += 1;
        }
        System.out.println(ans);
    }
}

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

int main()
{
    int i,n,a[200005];;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
        
    }
    bool flag=false;
    for(i=0;i<n;i++){
        if(i==0)
            a[i]--;
        
        else if(a[i]>a[i-1])
            a[i]--;
        else if(a[i]==a[i-1])
                continue;
        else{
            flag=true;
            
            
        }
    }
    if(flag)
        cout<<"No";
    else
        cout<<"Yes";
    
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

const int MOD = 1000000007;

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

    int n;
    cin >> n;

    int A[n];
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    sort(A, A+n);

    vector <int> vec(n);
    if (n % 2 == 0) {
        int s = 1;
        for (int i = 0; i < n; i += 2) {
            vec[i] = s;
            vec[i+1] = s;
            s += 2;
        }
    } else {
        int s = 2;
        vec[0] = 0;
        for (int i = 1; i < n; i += 2) {
            vec[i] = s;
            vec[i+1] = s;
            s += 2;
        }
    }

    for (int i = 0; i < n; i++) {
        if (A[i] != vec[i]) {
            cout << 0 << "\n";
            return 0;
        }
    }

    int ans = 1;
    for (int i = 0; i < n / 2; i++) {
        ans = ans * 2 % MOD;
    }

    cout << ans << "\n";
    return 0;
}

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

typedef pair<int, int> pi; 

int main(){

ios_base::sync_with_stdio(false);

long long n,i,ans=0;

cin>>n;

long long a[n],b[n+1],c[n+1];

for(i=0;i<n;i++)
	cin>>a[i];

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

for(i=1;i<=n-1;i++)
	cin>>c[i];

for(i=0;i<n;i++){
	
ans+=b[a[i]];

if(i!=0){
if(a[i]==a[i-1]+1)
ans+=c[a[i-1]];}}

cout<<ans<<endl;

return 0;}


Measured memory_bytes: 256
import copy

n = int(input())
A = []

for i in range(n):
    a = [int(x) for x in input().split()]
    a.append(a[0]+a[1])
    A.append(a)

A.sort(key=lambda x: x[2])
#print(A)

count = 0
max_l = -10000000000
for i in A:
    if i[0]-i[1] >= max_l:
        count += 1
        max_l = i[2]

print(count)


Measured memory_bytes: 66072
import java.io.*;
import java.util.Arrays;

public class Main{
	public static void main(String[] argv) throws NumberFormatException, IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int lineNum = Integer.parseInt(br.readLine());
		for(int i=0; i<lineNum; i++){
			String[] line = br.readLine().split(" ");
			int[] lineInt = {Integer.parseInt(line[0]), Integer.parseInt(line[1]), Integer.parseInt(line[2])};
			Arrays.sort(lineInt);
			String out;
			if((lineInt[2] * lineInt[2]) == (lineInt[0] * lineInt[0] + lineInt[1] * lineInt[1])){
				out = "YES";
			}else{
				out = "NO";
			}
			System.out.print(out+"\n");
		}
	}
}

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

int cnt = 0;

void bubbleSort(vector<int> &V, int N)
{
    bool flag = true;
    while (flag)
    {
        flag = false;
        for (int i = N - 1; i > 0; i--)
        {
            if (V[i] < V[i - 1])
            {
                int tmp = V[i];
                V[i] = V[i - 1];
                V[i - 1] = tmp;
                flag = true;
                cnt++;
            }
        }
    }
}

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }

    bubbleSort(A, n);

    for (int i = 0; i < n; i++)
    {
        cout << A[i];
        if (i != n - 1)
        {
            cout << " ";
        }
    }
    cout << endl;
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3104
using System;

namespace AOJ
{
    class ModeValue
    {
        public static void Main()
        {
            int[] counter = new int[101];
            for (int i = 1; i <= 100; i++) { counter[i] = 0; }
            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }
                counter[int.Parse(input)]++;
            }

            int max = 0;
            for (int i = 1; i <= 100; i++)
            {
                max = Math.Max(max, counter[i]);
            }

            for (int i = 1; i <= 100; i++)
            {
                if (counter[i] == max) { Console.WriteLine(i); }
            }
        }
    }
}

Measured memory_bytes: 5604