akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
signed main(){

	int N;
	cin>>N;
	map<string, int> pam;
	for(int i=0;i<N;i++){
		string s;
		cin>>s;
		pam[s]++;
	}
	int maxi=0;
	for(auto p:pam)
		maxi=max(maxi, p.second);
	for(auto p:pam)
		if(p.second==maxi)
			cout<<p.first<<endl;

	return 0;
}

Measured memory_bytes: 25216
N, Q = map(int, input().split())
S = input()

t = [0] * (N + 1)

for i in range(N):
    t[i + 1] = t[i] + (1 if S[i:i + 2] == "AC" else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])

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

int main() {
  ll a, b;
  long long v, w, t;
  string ans = "NO";
  cin >> a >> v >> b >> w >> t;
  for(ll i = 1; i <= t ;i++) {
    if(a <= b) {
      if((a + i * v) >= (b + i * w)) {
        ans = "YES";
        break;
      }
    } else {
      if((a - i * v) <= (b - i * w)) {
        ans = "YES";
        break;
      }

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

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed;
// cout << setprecision(10) << val;
#define FW "First"
#define SW "Second"

string s, ans;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> s;
  int n = s.size();
  bool flag = s[0] == s[n-1];
  if (n % 2) {
    if (flag) { ans = SW; }
    else ans = FW;
  } else {
    if (flag) { ans = FW; }
    else ans = SW;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 512
import sys
from collections import deque

input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    h, w, k = map(int, input().strip().split())
    x1, y1, x2, y2 = map(int, input().strip().split())
    x1 -= 1
    y1 -= 1
    x2 -= 1
    y2 -= 1
    m = []
    costs1 = [[None for j in range(w)] for i in range(h)]
    costs2 = [[None for j in range(w)] for i in range(h)]
    for _ in range(h):
        m.append(list(input().strip()))
    q1 = deque()
    q1.append((x1, y1, 0))
    costs1[x1][y1] = 0
    q2 = deque()
    q2.append((x2, y2, 0))
    costs2[x2][y2] = 0
    directions = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    while q1 and q2:
        (x, y, cost) = q1.popleft()
        if not costs2[x][y] is None:
            print(cost + costs2[x][y])
            return
        for (add_x, add_y) in directions:
            for dist in range(1, k + 1):
                new_x = x + add_x * dist
                new_y = y + add_y * dist
                if new_x >= h or new_x < 0 or new_y >= w or new_y < 0 or m[new_x][new_y] == '@' or ((not costs1[new_x][new_y] is None) and costs1[new_x][new_y] < cost + 1):
                    break
                if costs1[new_x][new_y] is None:
                    costs1[new_x][new_y] = cost + 1
                    q1.append((new_x, new_y, cost + 1))
        (x, y, cost) = q2.popleft()
        if not costs1[x][y] is None:
            print(cost + costs1[x][y])
            return
        for (add_x, add_y) in directions:
            for dist in range(1, k + 1):
                new_x = x + add_x * dist
                new_y = y + add_y * dist
                if new_x >= h or new_x < 0 or new_y >= w or new_y < 0 or m[new_x][new_y] == '@' or ((not costs2[new_x][new_y] is None) and costs2[new_x][new_y] < cost + 1):
                    break
                if costs2[new_x][new_y] is None:
                    costs2[new_x][new_y] = cost + 1
                    q2.append((new_x, new_y, cost + 1))
    print("-1")


if __name__ == '__main__':
    main()


Measured memory_bytes: 214012
#include <iostream>
using namespace std;
string s;
int a[4];
int main(void){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='N')a[0]=1;
        if(s[i]=='S')a[1]=1;
        if(s[i]=='E')a[2]=1;
        if(s[i]=='W')a[3]=1;
    }
    if((a[0]==a[1])&&(a[2]==a[3])){
        cout<<"Yes"<<endl;
        return 0;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 384
# coding: utf-8
# Your code here!
from collections import Counter

S = input()
S = list(S)


if(Counter(S).most_common(2)[0][1]!=4):
    c1 = Counter(S).most_common(2)[0][1]
    c2 = Counter(S).most_common(2)[1][1]
    if(c1==c2):
        if(c1==2):
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")



Measured memory_bytes: 3316
#include <stdio.h>
void Repair(int ,int );
int Preorder[100],Inorder[100],Postorder[100],postnode=0,nownode=0;
int main(void){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&Preorder[i]);
  for(i=0;i<n;i++)
    scanf("%d",&Inorder[i]);

  Repair(0,n);

  for(i=0;i<n;i++){
    printf("%d",Postorder[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n");
  return 0;
}
void Repair(int left,int right){
  int rootnode,distance;
  if(left<right){
    rootnode=Preorder[nownode++];
    distance=0;
    while(distance<right){
      //search for element of root
      if(Inorder[distance]==rootnode)
        break;
      distance++;
    }
    Repair(left,distance);//left tree (include element of root)
    Repair(distance+1,right);//right tree
    Postorder[postnode++]=rootnode;
  }
}


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

using vi = vector<int>;

struct SegTree{
    int N;
    vi dat;
    void init(int _N){
        N=1;
        while(N<_N)N*=2;
        dat=vi(N*2-1,INT_MAX);
    }
    void update(int k,int val){
        k+=N-1;
        dat[k]=val;
        while(k){
            k=(k-1)/2;
            dat[k]=min(dat[k*2+1],dat[k*2+2]);
        }
    }
    int getMin(int a,int b,int k=0,int l=0,int r=-1){
        if(r==-1)r=N;
        if(r<=a||b<=l)return INT_MAX;
        if(a<=l&&b>=r)return dat[k];
        int v1=getMin(a,b,k*2+1,l,(l+r)/2);
        int v2=getMin(a,b,k*2+2,(l+r)/2,r);
        return min(v1,v2);
    }
};

int main(){
    int N, L;
    cin >> N >> L;
    SegTree seg;
    seg.init(N+1);
    for ( int i = 0; i < N; i++ ) {
        int a;
        cin >> a;
        seg.update(i, a);
    }

    for ( int i = 0; i <= N-L; i++ ) {
        cout << seg.getMin(i, i+L);
        if ( i != N-L ) cout << " ";
    }

    cout << endl;
    return 0;
}



Measured memory_bytes: 11044
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = Integer.parseInt(s.nextLine());
        String[] in1 = s.nextLine().split(" ");
        String[] in2 = s.nextLine().split(" ");
        List<Integer> monsters = new ArrayList<Integer>();
        for(int i = 0;i<n+1;i++){
            monsters.add(Integer.parseInt(in1[i]));
        }
        long r = 0;
        for(int i = 0;i<n;i++){
            int power = Integer.parseInt(in2[i]);
            int targets1 = monsters.get(i);
            int targets2 = monsters.get(i+1);
            if(power - targets1 >= 0) {
                r += targets1;
                power -= targets1;
                if(power - targets2 >= 0){
                    r += targets2;
                    monsters.set(i+1,0);
                }else {
                    r += power;
                    monsters.set(i+1,targets2-power);
                }
            }else{
                r += power;
            }
        }
        System.out.println(r);
    }
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
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; }
const ll inf = 1ll << 60;



int main() {
    int n;
    int m = 0;
    int a[200020], res[200020];
    scanf("%d", &n);
    rp(i, 1, n+1) {
        scanf("%d", &a[i]);
        res[i] = 0;
    }
    for (int i = n; i > 0; i--) {
        int sum = 0;
        int k = 1;
        while(k * i <= n) {
            sum += res[k*i];
            k ++;
        }
        if(sum%2 != a[i]) res[i] ++;
        if(res[i]) m++;
    }
    printf("%d\n", m);
    rp(i, 1, n+1) {
        if(res[i]) printf("%d ", i);
    }
    return 0;
}

Measured memory_bytes: 2432
//abc130_c.cpp
//Sun Sep 15 10:00:14 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	double w,h,x,y;
	cin >> w >> h >> x >> y;

	double centerx = w/2;
	double centery = h/2;

	printf("%.10f ",w*h/2);

	if (x==centerx && y==centery){
		cout << 1 << endl;
	}else {
		cout << 0 << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define max(a, b) (a < b ? b : a) 
#define min(a, b) ((a > b) ? b : a) 
#define mod 1e9 + 7 
#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++) 
#define FORL(a, b, c) for (int(a) = (b); (a) <= (c); (a)++) 
#define FORR(a, b, c) for (int(a) = (b); (a) >= (c); (a)--) 
#define INF 1000000000000000003 
typedef long long int ll; 
typedef vector<int> vi; 
typedef pair<int, int> pi; 
#define F first 
#define S second 
#define pb push_back 
#define POB pop_back 
#define MP make_pair 
int main() 
{ 
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    string s,t;
    cin>>s>>t;
	if(s.length()<t.length())
	{
		bool temp=true;
		for(int i=0;i<s.length();i++)
		{
			if(s[i]!=t[i])
			{
				temp=false;
				break;
			}
		}
		if(temp)
		{
			cout<<"Yes"<<endl;
		}
		else
		{
			cout<<"No"<<endl;
		}
	}
	else
	{
		cout<<"No"<<endl;
	}
    return 0; 
} 

Measured memory_bytes: 3612
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s;
    cin >> s;
    int k;cin >> k;
    int tmp = 1;
    int tans= 0;
    int begin = 0;
    int end = 0;
    long long ans = 0;
    if(s.size() == 1){
        cout << k/2 << endl;
        return 0;
    }
    for(int i=1;i<s.size();i++){
        if(s[i] == s[i-1]){
            tmp ++;
        }
        else{
            if(begin == 0){
                begin = tmp;
            }
            else{
                tans += tmp/2;
            }
            tmp = 1;
        }
    }
    end = tmp;
    if(end == s.size()){
        cout << ((long long)s.size()*(long long)k) / (long long )2 << endl;
        return 0;
    }
    int tans2 =0;
    if(s[0] == s[s.size()-1]){
        tans2 += (begin +end)/2;
        ans = (long long)begin/(long long)2 +(long long)tans*(long long)k +  (long long)tans2*(long long)(k-1) + (long long)end/(long long)2;
    }
    else{
        tans += (begin)/2 + end/2;
        ans = (long long)tans*(long long)k;
    }

    cout << ans<< endl;
    return 0;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << ' ';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  string S{}; std::cin >> S;
  
  //ui N{}; std::cin >> N;

  auto ans = 0UL;
  rep(0, S.size() - 1)
  {
    if (S[i] == S[i + 1])
      ++ans;
  }
  std::cout << (ans ? "Bad" : "Good" ) << '\n';

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

int N;
vector<int> A,B;
int dp[404][404];

int candy(int l,int r){
    if(dp[l][r]!=-1){
        return dp[l][r];
    }
    if(r-l==1){
        return A[l]+A[r];
    }
    if(l>=r){
        return 0;
    }
    
    int m = INF;
    for(int i=l;i<r;i++){
        int m1,m2;
        m1 = candy(l,i);
        m2 = candy(i+1,r);
        
        m = min(m,m1+m2);
    }
    
    m+=B[r+1]-B[l];
    
    dp[l][r]=m;
    //cout << l MM r MM m << endl;
    return m;
}

signed main(void){
    int a;
    cin >> N;
    REP(i,N){cin >> a;A.push_back(a);}
    B.push_back(0);
    REP(i,N){B.push_back(B[i]+A[i]);}
    
    //REP(i,B.size()){cout << B[i] << " ";}cout << endl;
    
    REP(i,404){
        REP(j,404){
            dp[i][j]=-1;
        }
    }
    
    int k = candy(0,N-1);
    
    cout << k << endl;
    
    return 0;
}



Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}

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

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


Measured memory_bytes: 3068
#include<stdio.h>
int main()
{
    char s[3],i;
    scanf("%s",&s);
    for(i=0;i<3;i++)
    {
        if(s[i]=='1')
        {
            s[i]='9';
        }
        else if(s[i]=='9')
        {
            s[i]='1';
        }
    }
    for(i=0;i<3;i++)
    {
        printf("%c",s[i]);
    }

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
vi G[MAX_N];

int loop(int v) {
	vector<int> dep;
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		dep.pb(loop(n));
	}
	sort(all(dep));
	// debug(v, dep);
	int res = 0;
	rep(i, 0, sz(G[v])) {
		MAX(res, dep[i] + sz(G[v]) - i);
	}
	return res;
}

void solve() {
	cin >> N;
	rep(i, 1, N) {
		int a; cin >> a; a--;
		G[a].pb(i);
	}
	cout << loop(0) << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 17408
import sys

N_MAX = 200000 + 5
INF = 10**9 + 7
sys.setrecursionlimit(N_MAX)
MOD = 10**9 + 7


def main():

    N, K = map(int, sys.stdin.readline().rstrip().split())
    A = [int(x) for x in sys.stdin.readline().rstrip().split()]

    P, M = [], []
    # A を非負、負で振り分ける
    for i in range(N):
        n = A[i]
        if n < 0:
            M.append(n)
        else:
            P.append(n)

    # 絶対値の大きい方から並べる
    P.sort(reverse=True)
    M.sort()
    n_p = len(P)
    n_m = len(M)
    # print(P, M)

    # 全部使う
    if K == N:
        ans = 1
        for a in A:
            ans = ans * a % MOD
        print(ans)
        return

    # 全部負の場合
    if n_p == 0:
        if K % 2 == 1:  # 奇数なら小さな方から取る
            ans = 1
            for i in range(K):
                ans = ans * M[-(i + 1)] % MOD
            print(ans)
            return
        else:
            ans = 1
            for i in range(K):
                ans = ans * M[i] % MOD
            print(ans)
            return

    i, j = 0, 0
    if K % 2 == 1:
        i += 1
    
    while K > 1:
        p, m = 0, 0
        if i + 1 < n_p:
            p = P[i] * P[i + 1]
        if j + 1 < n_m:
            m = M[j] * M[j + 1]
        if p >= m:
            i += 2
        else:
            j += 2
        K -= 2

    # print(i, j)
    ans = 1
    for u in range(i):
        ans = ans * P[u] % MOD
    for v in range(j):
        ans = ans * M[v] % MOD

    print(ans)


main()


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

#define ll long long
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int, int>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;
template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

int n;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    n %= 10;
    cout << (n == 3 ? 'b' : n == 0 || n == 1 || n == 6 || n == 8 ? 'p' : 'h') << "on\n";
}

Measured memory_bytes: 3604
#include <iostream>

int main()
{
    int n;
    std::cin >> n;

    long long Arr[100];
    Arr[0] = 2;
    Arr[1] = 1;
    for (int i = 2; i <= n; ++i)
    {
        Arr[i] = Arr[i - 2] + Arr[i - 1];
    }

    std::cout << Arr[n] << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi   = vector<int>;
using vll  = vector<ll>;
using vc   = vector<char>;
using vvll  = vector<vll>;
using vvi  = vector<vi>;
using vvc  = vector<vc>;
using vb   = vector<bool>;
using vvb  = vector<vb>;
using pii  = pair<int,int>;
using vpii = vector<pii>;
using posteriority_queue = priority_queue<int, vi, greater<int>>;

int main() {
    string S; cin >> S;
    int l; l = S.size();
    if (S.at(l-1) == 's') cout << S << "es";
    else cout << S << "s";
}


Measured memory_bytes: 3624
#include <stdio.h>

int main()
{
int a,b,i,j,d;
int sum=0;
int c[50];
scanf("%d %d",&a,&b);
for(i=0;i<a;i++){
scanf("%d",&c[i]);
}
for(i=a-1;i>0;i--){
for(j=0;j<i;j++){
if(c[j]>c[j+1]){
d=c[j];
c[j]=c[j+1];
c[j+1]=d;
}
}
}
for(i=a-1;i>a-b-1;i--){
sum+=c[i];
}
printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

typedef pair<long long int, long long int> P;

int main() {

	long long int n;
	cin >> n;

	vector<long long int> a(n);
	vector<long long int> b(n);
	vector<P> c(n);


	for (long long int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		c[i] = P(a[i] + b[i], a[i]);
	}

	sort(c.begin(), c.end(), greater<P>());

	long long int suma = 0;
	long long int sumb = 0;

	for (long long int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			suma += c[i].second;
		}
		else {
			sumb += (c[i].first - c[i].second);
		}
	}

	cout << suma - sumb << endl;

	return 0;
}

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

int main()
{
	for(string s;cin>>s;){
		int cnt[4]={};
		for(char c:s){
			if(c=='E') cnt[0]=1;
			if(c=='W') cnt[1]=1;
			if(c=='S') cnt[2]=1;
			if(c=='N') cnt[3]=1;
		}
		cout<<(cnt[0]==cnt[1]&&cnt[2]==cnt[3]?"Yes":"No")<<endl;
	}
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int H, W, i, j;
	for(;;){
        	scanf("%d %d",&H ,&W);
        	if(H == 0  && W == 0)break ;
        	for ( i = 0; i < H; i++ ){
        		for ( j = 0; j < W; j++ ){
        			if( ( i + j ) %2 == 0){
        				printf("#");
        			} else {
        				printf(".");
        			}           
        		}
        		printf("\n");
        	}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

struct Nbase {
    int n;
    int sz = 1;
    long long max = 1e18;

    Nbase(int k = 2){
        n = k;
        while(max != 0){
            max /= n;
            sz++;
        }
    };

    //繰り返し二乗法
    ll EX(ll x,ll n){
        if(n == 0) return 1;
        else if(n%2 == 1) return EX(x,n-1)*x;
        else return EX(x*x,n/2);
    }

    vector<int> to_n(ll num){
        vector<int> ret(sz);
        for(int i = sz-1; i >= 0; i--){
            long long subtraction = EX(n,i);
            if(subtraction <= num){
                for(int j = 1; j <= n; j++){
                    if(num < j*subtraction){
                        ret[i] = j-1;
                        num -= ret[i]*subtraction;
                    } 
                }
            } else ret[i] = 0;
        }
        return ret;
    }

    long long re_n(vector<int>& vec){
        long long ret = 0;
        vec.resize(sz);
        for(int i = 0; i < sz; i++){
            ret += vec[i]*EX(n,i);
        }
        return ret;
    }

    void supress(const vector<int>& lim,vector<int>& at){
        bool upper = true;
        for(int i = sz; i >= 0; i--){
            if(upper && lim[i] > 0) upper = false;
            if(lim[i] > at[i]) break;
            else if(upper || lim[i] < at[i]) at[i] = lim[i];
        }
    }
};

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    Nbase base = 2;
    vector<int> xnum(base.sz,0);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        vector<int> num = base.to_n(a[i]);
        for(int i = 0; i < num.size(); i++){
            xnum[i] += num[i];
        }
    }
    for(int i = 0; i < xnum.size(); i++){
        if(xnum[i] <= n/2) xnum[i] = 1;
        else xnum[i] = 0;
    }
    vector<int> knum = base.to_n(k);
    base.supress(knum,xnum);
    ll x = base.re_n(xnum);
    ll ans = 0;
    for(int i = 0; i < n; i++) ans += x^a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4036
fun main(args: Array<String>) {
    val A = Array(3) { readLine()!!.split(" ").map(String::toInt) }
    val N = readLine()!!.toInt()
    val B = IntArray(N) { readLine()!!.toInt() }
    val array = arrayOf(
        intArrayOf(A[0][0], A[0][1], A[0][2]),
        intArrayOf(A[1][0], A[1][1], A[1][2]),
        intArrayOf(A[2][0], A[2][1], A[2][2]),
        intArrayOf(A[0][0], A[1][0], A[2][0]),
        intArrayOf(A[0][1], A[1][1], A[2][1]),
        intArrayOf(A[0][2], A[1][2], A[2][2]),
        intArrayOf(A[0][0], A[1][1], A[2][2]),
        intArrayOf(A[0][2], A[1][1], A[2][0])
    )
    val results = array.map { e -> e.subtract(B.asIterable()) }
    println(if (results.any(Set<Int>::isEmpty)) "Yes" else "No")
}

Measured memory_bytes: 38004
N, K = list(map(int, input().split()))
MOD = 10 ** 9 + 7
nmin = K * (K-1) // 2
nmax = nmin + (N - K + 1) * K
count = nmax - nmin + 1
count %= MOD
for i in range(K, N+1):
    nmin += i - 1
    nmax += N - i - 1
    count += nmax - nmin + 1
    count %= MOD
print(count)


Measured memory_bytes: 63792
/*
Greatest Common Divisor
ALDS1_1_b
最大公約数を求めるプログラム
ユークリッド互除法を使う
*/
package main

import "fmt"

func gojo(x, y int) int {
	if x < y {
		x, y = y, x
	}

	amari := x % y
	if amari == 0 {
		return y
	}

	return gojo(amari, y)
}
func main() {
	var x, y int

	fmt.Scanf("%d %d", &x, &y)
	fmt.Println(gojo(x, y))
}


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

int main()
{
    long long A, B;
    cin >> A >> B;
    if ((A + B) % 2 == 0)
    {
        cout << (A + B) / 2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


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

int main() {
  int H, N;  cin >> H >> N;
  int A[N], B[N];
  rep(i, N) {
    int a, b; cin >> a >> b;
    A[i] = a; B[i] = b;
  }
  
  int dp[N][H+1];
//  const int INF = 100000;
  memset(dp, 0, sizeof(dp));
  rep(i, N) {
    rep(j, H+1) {
      if (j == 0)  continue;
      if (i == 0) {
        dp[i][j] = ((j-1) / A[i] + 1) * B[i];
//        cout << dp[i][j] << endl;
        continue;
      }
      
      if (j < A[i]) {
        dp[i][j] = min(dp[i-1][j], B[i]);
//        cout << dp[i][j] << endl;
      }
      else {
        dp[i][j] = min(dp[i-1][j], dp[i][j - A[i]] + B[i]);
//        cout << dp[i][j] << endl;
      }
    }
  }
  
  cout << dp[N-1][H] << endl;
}
              

Measured memory_bytes: 39296
def f(a, b):
    al = len(str(int(a)))
    bl = len(str(int(b)))
    if al > bl:
        return al
    return bl
N = int(input())
result = len(str(N))
for a in range(1, N):
    if a*a > N:
        break
    if (N % a) != 0:
        continue
    b = N / a
    r = f(a, b)
    if r < result:
        result = r
print (result)

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    ll d;
    cin >> n >> d;
    int ans = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        if (x*x+y*y <= d*d) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3524
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
res=0
for i in range(n,0,-1):
    if b[i-1]>=a[i]:
        b[i-1]-=a[i]
        res+=a[i]
    else:
        res+=b[i-1]
        b[i-1]=0
    if b[i-1]>=a[i-1]:
        res+=a[i-1]
        a[i-1]=0
    else:
        res+=b[i-1]
        a[i-1]-=b[i-1]
print(res)

Measured memory_bytes: 82148
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

struct Query {
  int a,b,c,d;
};
int n,m,q;
vector<Query> query;


struct Node {
  int depth;
  vector<int> A;
  int calc_point() {
    int point=0;
    for(const auto& e: query) {
      if (A[e.b]-A[e.a]==e.c) point+=e.d;
    }
    return point;
  }
};
map<vector<int>,bool> seen;
int ans=0;
void dfs(Node now) {
  // 到達を記録
  seen[now.A]=true;
  // 到達したときにしたい処理を追加

  // N個の要素が集まったら，
  if (now.depth==n-1) {
    // for(const auto& e: now.A) {
    //   cout<<e<<" ";
    // }
    // cout<<now.calc_point()<<endl;
    // 完成したAについてqueryを試してpointを計算
    ans=max(ans,now.calc_point());
    return;
  }

  // 今いる点から行ける候補について
  for (int i = 0; i <= m-now.A.back(); ++i)
  {
    Node nxt=now;
    nxt.depth+=1;
    nxt.A.push_back(now.A.back()+i);
    if (seen[nxt.A]) continue;
    dfs(nxt);
  }
}

int main()
{
  cin>>n>>m>>q;
  query.resize(q);
  for(auto&& e: query) 
  {
    cin>>e.a>>e.b>>e.c>>e.d;
    e.a--;
    e.b--;
  }
  for (int i = 1; i <= m; ++i)
  {
    Node start;
    start.depth=0;
    start.A.push_back(i);
    dfs(start);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 26584
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//MIN

bool p_judge(ll p) {

	if (p == 1)return false;
	else if (p == 2)return true;
	else {

		bool flag = true;
		for (int i = 2; i <= sqrt(p); i++) {

			if (p%i == 0) {

				flag = false;
				break;

			}

		}
		return flag;

	}

}
//素数判定,素数=true,合成数=false

ll func(ll num) {

	ll cnt = 0;
	while (num % 2 == 0) {

		cnt++;
		num /= 2;

	}
	return cnt;

}

int main() {

	ll N, K, A[200005], cnt[200005], ans = 0;

	for (int i = 0; i < 200005; i++)cnt[i] = 0;

	cin >> N >> K;
	for (int i = 0; i < N; i++) {

		cin >> A[i];
		cnt[A[i]]++;

	}

	sort(cnt, cnt + 200005);

	for (int i = 200004 - K; i >= 0; i--) {

		ans += cnt[i];

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
x, y = gets.split(" ").map(&:to_i)
red = gets.split(" ").map(&:to_i)
green = gets.split(" ").map(&:to_i)
clear = gets.split(" ").map(&:to_i)

sorted_red = (red.sort{|a, b| a <=> b}.reverse)[0..x-1]
sorted_green = (green.sort{|a, b| a <=> b}.reverse)[0..y-1]
sorted_clear = clear.sort{|a, b| a <=> b}.reverse

# p "sorted_red: #{sorted_red}, sorted_green: #{sorted_green}, sorted_clear: #{sorted_clear}"

# def merge red, green
#   if red.count == 0 then
#     return green
#   end
#
#   if green.count == 0 then
#     return red
#   end
#
#   if red.first > green.first then
#     return [red.first] + merge(red.drop(1), green)
#   else
#     return [green.first] + merge(red, green.drop(1))
#   end
# end

ans = (sorted_red + sorted_green + sorted_clear).sort{|a, b| a <=> b}.reverse[0...x+y]

# red_green = merge(sorted_red, sorted_green).reverse
#
# p "red_green: #{red_green}"
#
# use_clear = []
# while sorted_clear.count != 0 && sorted_clear.first > red_green.first do
#   use_clear << sorted_clear.first
#   sorted_clear = sorted_clear.drop(1)
#   red_green = red_green.drop(1)
# end
#
# p "sorted_clear: #{sorted_clear}, red_green: #{red_green}, use_clear: #{use_clear}"

sum = 0
ans.each{|n| sum += n }

puts sum


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

int main()
{
  int k, x;

  cin >> k >> x;

  int begin = x - k + 1;

  int end = x + k - 1;

  for (int i = begin; i <= end; i++)
  {
    cout << i << " ";
  }
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back

void solve(){
    int a;
    cin >> a;
    vi A;
    while(a) A.pb(a % 10), a /= 10;
    for (int i = 0; i < (int)A.size(); ++i) {
        if (A[i] != A[(int)A.size() - 1 - i]) {
            cout << "No";
            return;
        }
    }
    cout << "Yes";
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3584
s = str(input())

flag = True

res = -1

import sys

if len(s) == 2:
    if s[0] == s[1]:
        print(1,2)
    else:
        print(-1,-1)
    sys.exit()

for i in range(len(s)-2):
    if s[i] == s[i+1]:
        print(i+1,i+3)
        flag = False
        break
    elif s[i] == s[i+2]:
        print(i+1,i+3)
        flag = False
        break

if flag:
    if s[-2] == s[-1]:
        print(len(s)-2,len(s))
    elif s[-3] == s[-1]:
        print(len(s)-2,len(s))
    else:
        print(res,res)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
 
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define ff first
#define ss second
#define ll long long
#define ld long double
#define ull unsigned long long
#define bp(x) __builtin_popcount(x)
#define pr(x) for(auto it: x) cout<<it<<" "; cout<<endl;
#define endl "\n"
typedef vector<int> vi;
typedef vector< pair<int,int> > vii;
typedef vector<long long> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector< pair<ll,ll> > vll;

void nikal_pehli_fursat_mai(){
  ll n,x,t;
  cin>>n>>x>>t;
  cout<<((n+x-1)/x)*t<<endl;
}

int main(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tc=1; 
  //cin>>tc;
  while(tc--){
    nikal_pehli_fursat_mai();
  }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
  for(int i=0;;i++){
    int a,s,d;
    cin>>a>>s>>d;
   
    ;
    if(a==-1 && s==-1 && d==-1) break;
        if(a==-1 || s==-1){
      cout<<'F'<<endl;
      continue;
    }
    
     if(a==-1) a=0;
    if(s==-1) s=0;
     if(d==-1) d=0;


      if(a+s>=80){
      cout<<'A'<<endl;
      continue;
    }
    else if(a+s>=65){
      cout<<'B'<<endl;
      continue;
    }
    else if(a+s>=50){
      cout<<'C'<<endl;
      continue;
    }
    else if(a+s>=30){
      if(d>=50){
        cout<<'C'<<endl;
        continue;
      }
      else{
        cout<<'D'<<endl;
        continue;
        
      }
      
    }
    else{
      cout<<'F'<<endl;
      continue;
    }
  }
}


Measured memory_bytes: 3120
object Main extends App {
  val n = scala.io.StdIn.readLine.toInt
  var ans = false
  (1 to 9).foreach { i =>
    (1 to 9).foreach { j =>
      if (i * j == n)
        ans = true

    }
  }

  if (ans) {
    println("Yes")
  } else {
    println("No")
  }
}


Measured memory_bytes: 27216
import sys

# C - Ubiquity
N = int(input())
all = 1
no_1 = 1
no_1_and_9 = 1
mod = 10 ** 9 + 7

for _ in range(N):
  all *= 10
  all %= mod

  no_1 *= 9
  no_1 %= mod

  no_1_and_9 *= 8
  no_1_and_9 %= mod

print((all - (no_1 * 2 - no_1_and_9)) % mod)

Measured memory_bytes: 9168
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>

using namespace std;

typedef long long ll;

int main() {
    ll N, M;
    cin >> N >> M;

    if(N >= 2 && M >= 2) cout << N*M - 2*((N-1) + (M-1)) << endl;
    if(N == 1 && M >= 2) cout << N*M - 2 << endl;
    if(N >= 2 && M == 1) cout << N*M - 2 << endl;
    if(N == 1 && M == 1) cout << 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////



int main() {

	int N;
	cin >> N;

	int n[MAX];

	repn(i, N) {
		char c;
		cin >> c;
		n[i] = c - '0';
	}

	int u[10] = {};
	int d[100] = {};
	int t[1000] = {};

	repn(i, N) {
		int a = n[i];

		rep(i, 100) {
			if (d[i] == 1) { t[10 * i + a] = 1; }
		}


		rep(i, 10) {
			if (u[i] == 1) { d[10 * i + a] = 1; }
		}

		u[a] = 1;

		

		
	}

	int ans = 0;
	rep(i, 1000) {
		if (t[i] == 1) { ans++; }
	}

	cout << ans;
	

	system("PAUSE");
}

Measured memory_bytes: 2552
#include<iostream>
#include<cstdio>
#include<vector>
#define SUP 300000
using namespace std;



bool is_prime[SUP];
vector<int> prime_list;
int N;


int main(){
  cin >> N;
  for(int i = 2; i < SUP; i++){
    is_prime[i] = true;
  }
  for(int i = 2; i < SUP; i++){
    if(is_prime[i]){
      prime_list.push_back(i);
      for(int j = 2; i*j < SUP; j++){
	is_prime[i*j] = false;
      }
    }
  }


  int cnt = 0;
  for(int i = 0; i < prime_list.size(); i++){
    if(cnt == N){
      cout << endl;
      break;
    }
    if(prime_list[i] % 5 == 1){
      cout << prime_list[i] << " ";
      cnt++;
    }
  }
}

Measured memory_bytes: 768
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] All = new int[2*N];
		int ans = 0;

		for(int i=0; i<2*N; i++) {
			All[i] = sc.nextInt();
			if(i%2 == 0) {
				ans -= All[i];
			}else {
				ans += All[i];
			}
		}
		System.out.println(ans + N);

	}

}


Measured memory_bytes: 25832
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int A[200] = {0};
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> A[i];
  
  int result = 0;
  bool odd = false;
  while(!odd){
    for(int i = 0; i < N; ++i){
      if(0 < A[i] % 2) {
        odd = true;
      	break;
      }
      else{
        A[i] /= 2;
      }
    }
    
    if(!odd) ++result;
  }  
  
  cout << result << endl;
}

Measured memory_bytes: 256
import numpy as np
import sys


#リスト作成
Num_lst = []

#入力
N = int(input())
Num = map(int, input().split())

#イテレータをリストに変換し、さらにnparrayに変換
Num_lst = np.array(list(Num))


#確認
if N!=len(Num_lst):
    sys.exit()

    
#処理回数を計測するためのフラグを設定
flag = 0    

while True:

    #すべて偶数の場合フラグに1を追加し、各要素を2で割る
    if np.all(Num_lst%2==0):
        flag += 1
    
        Num_lst = Num_lst/2
    
    #すべて奇数の場合、処理を終了する
    else:
        break
    
print(flag)

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

ll knapsackModified(ll weight[], ll value[], ll n, ll w){
	// DP array
	ll MAXVAL = n * 1000;
	ll dp[n+1][MAXVAL+1];

	// Base value
	for(ll val=0; val<=MAXVAL; val++){
		dp[1][val] = INT_MAX;
	}
	dp[1][0] = 0;
	dp[1][value[1]] = weight[1];
	
	for(ll i=2; i<=n; i++){
		for(ll val=0; val<=MAXVAL; val++){
			dp[i][val] = dp[i-1][val];
			if(val >= value[i]){
				dp[i][val] = min(dp[i][val], weight[i] + dp[i-1][val-value[i]]);
			}
		}
	}

	// for(int i=0; i<=n; i++){
	// 	for(int val=0; val<=MAXVAL; val++){
	// 		cout<<dp[i][val]<<" ";
	// 	}
	// 	cout<<"\n";
	// }

	int ans = 0;
	for(ll val=0; val<=MAXVAL; val++){
		if(dp[n][val] <= w){
			ans = val;
		}
	}
	return ans;
}

int main(){
	
	ll n,w;
	cin>>n>>w;
	
	ll weight[n+1],value[n+1];
	
	for(ll i=1;i<=n;i++){
		cin>>weight[i]>>value[i];
	}

	cout<<knapsackModified(weight, value, n, w)<<"\n";
}

Measured memory_bytes: 78336
#define _CRT_SECURE_NO_DEPRECATE
#define rep(i, b, e) for (auto i = b; i < e; ++i)
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#ifndef __GNUC__
#include <intrin.h>
#endif // !__GNUC__
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstring>
#include <complex>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <functional>

int bsf(int x) {
#ifdef __GNUC__
    return __builtin_ctz(x);
#else
    unsigned long i;
    _BitScanForward(&i, x);
    return i;
#endif
}
int bsr(int x) {
#ifdef __GNUC__
    return 31 - __builtin_clz(x);
#else
    unsigned long i;
    _BitScanReverse(&i, x);
    return i;
#endif
}

using namespace std;
typedef long long int64;
const double pi = 3.14159265358979323846;
const int inf = (int)2e+9 + 2;
const int mod = (int)1e+7;
const double eps = 1e-8;
const int N = 100001;

int n, m, k;  
int c[N]; 

void solve()
{
    cin >> n;
    rep(i, 0, n) {
        int x;
        cin >> x;
        ++c[x]; ++c[x + 1];
        if (x > 0) ++c[x - 1];
    }
    int ans = 0;
    rep(i, 0, N)
        ans = max(ans, c[i]);
    cout << ans;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int test = 1;
    //cin >> test;
    for (; test; --test)
        solve();
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

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

		if(n==1&&m==0) {
			System.out.println("0");
			return;
		}

		int[] c = new int[n+1];
		for(int i=0;i<n+1;i++) {
			c[i] = -1;
		}
		int s1,s2;
		for(int i=0; i<m;i++) {
			s1 = sc.nextInt();
			s2 = sc.nextInt();
			if(c[s1]==-1) {
				c[s1] = s2;
				continue;
			}
			if(c[s1] == s2) {
				continue;
			}
			System.out.println("-1");
			return;
		}


		if(c[1] == 0) {
			if(n==1) {
				System.out.println("0");
				return;
			}
			System.out.println("-1");
			return;
		}

		int ans = 0;
		for(int i=1;i<n+1;i++) {
			if(c[i]==-1) {
				if(i==1) {
					ans += 1 * Math.pow(10, n-i);
				}
			}else {
				ans += c[i] * Math.pow(10, n-i);
			}

		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 23636
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
map<ll,ll> mp;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,t;
cin>>n>>t;
vector<ll> a(n);
set<ll> b;
for(int i=0;i<n;i++){
    cin>>a[i];
    b.insert(a[i]);
}
ll point=0,cnt=0;
for(int i=0;i<n;i++){
   ll ma=*b.rbegin();
   ma-=a[i];
   b.erase(a[i]);
   if(ma<=0)continue;
   if(point==ma)cnt++;
   else if(point<ma){
       cnt=1;
       point=ma;
   }
}
cout<<cnt<<endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    int a[100009]={};
    long long ans=0;
    int m=0;
    int st=0;
    int mi=1000000009;
    int tmp=0;
    int z=0;
    
    cin >> n;
    
    for(int i=1; i<=n; i++){
        
        cin >> a[i];
        
    }
    
    for(int i=1; i<=n; i++){
        
        /*
        
        if(a[i]==0){
            
            if(m%2==1){
                
                if(a[])
                
            }
            
            m = 0;
            mi = 1000000009;
            st = i;
            
        } else if(a[i]<0){
            
            m += 1;
            
        }
        
        */
        
        if(a[i]==0){
            
            z = 1;
            
        }
        
        if(a[i]<0){
            
            m += 1;
            
        }
        
        ans += abs(a[i]);
        tmp = abs(a[i]);
        mi = min(mi, tmp);
        
    }
    
    if(z==0&&m%2==1){
        
        ans -= mi * 2;
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 640