akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  string s;
  while(cin>>s,s!="#"){
    reverse(all(s));
    int to=0;
    int co=0;
    int out[2]={0};
    if(s[0]=='h'){
      out[0]=0;
      out[1]=1;
      while(s[to]=='h'){
	to+=5;
	co++;
	if(s.size()<=to)break;
      }
    }else{
      out[0]=90;
      out[1]=1;
      while(s[to]=='t'){
	to+=4;
	co++;
	if(s.size()<=to)break;
      }
    }
    while(s.size()>to){
      int a=90;
      int b=pow(2,co);
      co++;
      while(b>out[1]){out[0]*=2;out[1]*=2;}
      while(b<out[1]){a*=2;b*=2;}
      if(s[to]=='h'){
	to+=5;
	out[0]-=a;
      }else{
	to+=4;
	out[0]+=a;
      }
      while(out[0]%2==0&&out[1]%2==0){out[0]/=2;out[1]/=2;}
    }
    if(out[1]!=1)cout<<out[0]<<'/'<<out[1]<<endl;
    else cout<<out[0]<<endl;
  }	
}

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

class RollingHash {
    typedef unsigned long long ull;
    typedef std::string string;

    private:
        string S;
        int N;
        vector<ull> h;
        vector<ull> p; // cache for pow

        const ull m = 10009;

    public:
        RollingHash(string S) {
            this->S = string(S);
            N = S.size();

            h.resize(N+1);
            p.resize(N+1);

            h[0] = 0;
            p[0] = 1;

            for (int i = 0; i < N; ++i) {
                p[i+1] = p[i]*m;
            }

            for (int i = 0; i < N; ++i) {
                h[i+1] = h[i]*m + S[i];
            }
        }

        ull hash(int l, int r) { // l, l+1, ... , r-1
            return h[r] - h[l] * p[r-l];
        }
};


int N;
string S;
string T;

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

    cin >> N;

    cin >> S;
    cin >> T;

    //cout << S << endl;
    //cout << T << endl;

    RollingHash hs(S);
    RollingHash ht(T);

    string U;

    for (int i = N; i >= 0; --i) {
        //cout << "i: " << i << endl;
        if (i == 0) {
            U = S + T;
        } else if (hs.hash(N-i, N) == ht.hash(0, i)) {
            U = S.substr(0,N) + T.substr(i,N);
            break;

            //cout << i << endl;
            //cout << S.substr(N-i,N) << endl;
            //cout << T.substr(0,i) << endl;
            //cout << U << endl;
            //break;
        }
    }

    cout << U.size() << endl;

    return 0;
}



Measured memory_bytes: 256
xy=input().split()
x=xy[0]
y=xy[1]
if x=="A":
    x1=10
elif x=="B":
    x1=11
elif x=="C":
    x1=12
elif x=="D":
    x1=13
elif x=="E":
    x1=14
elif x=="F":
    x1=15
if y=="A":
    y1=10
elif y=="B":
    y1=11
elif y=="C":
    y1=12
elif y=="D":
    y1=13
elif y=="E":
    y1=14
elif y=="F":
    y1=15
if x1<y1:
    print("<")
elif x1==y1:
    print("=")
else:
    print(">")

Measured memory_bytes: 3064
x1, y1, x2, y2 = map(int, input().split())

dx = abs(x1 - x2)
dy = abs(y1 - y2)

if x1 >= x2 and y1 >= y2:
    print(x2 + dy, y2 - dx, x1 + dy, y1 - dx)
elif x1 >= x2 and y1 < y2:
    print(x2 - dy, y2 - dx, x1 - dy, y1 - dx)
elif x1 < x2 and y1 >= y2:
    print(x2 + dy, y2 + dx, x1 + dy, y1 + dx)
else:
    print(x2 - dy, y2 + dx, x1 - dy, y1 + dx)


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int a,b,h,m;
void solve(){
	cin >> a >> b >> h >> m;
	double H = h*PI*2/12 + m*PI*2/60/12;
	double M = m*PI*2/60;
	
	double hx = cos(H)*a, hy = sin(H)*a;
	double mx = cos(M)*b, my = sin(M)*b;
	printf("%.15f\n", sqrt(pow(hx-mx,2)+pow(hy-my,2)));
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
using cd = complex<ld>;
const ld PI = acos(-1);

int inverse(int x, int lg_n) {
  int y = 0;
  for (int i = 0; i < lg_n; i++) {
    if (x & (1 << i)) {
      y ^= (1 << (lg_n - 1 - i));
    }
  }
  return y;
}

void fft(vector<cd> &a, bool inv) {
  int n = (int) a.size(), lg_n = log2(n);
  for (int i = 0; i < n; i++) {
    int j = inverse(i, lg_n);
    if (i < j) {
      swap(a[i], a[j]);
    }
  }
  for (int len = 2; len <= n; len *= 2) {
    double ang = 2 * PI / len * (inv ? -1 : 1);
    cd mul(cos(ang), sin(ang));
    for (int i = 0; i < n; i += len) {
      cd w(1);
      for (int j = 0; j < len / 2; j++) {
        cd x = a[i + j], y = a[i + len / 2 + j] * w;
        a[i + j] = x + y;
        a[i + len / 2 + j] = x - y;
        w *= mul;
      }
    }
  }
  if (inv) {
    for (int i = 0; i < n; i++) {
      a[i] /= n;
    }
  }
}

vector<ll> multiply(vector<ll> &xa, vector<ll> &xb) {
  vector<cd> a(xa.begin(), xa.end()), b(xb.begin(), xb.end());
  int n = 1;
  while (n < (int) a.size() + (int) b.size()) {
    n *= 2;
  }
  a.resize(n);
  b.resize(n);
  fft(a, 0);
  fft(b, 0);
  for (int i = 0; i < n; i++) {
    a[i] *= b[i];
  }
  fft(a, 1);
  vector<ll> sol(n);
  for (int i = 0; i < n; i++) {
    sol[i] = round(real(a[i]));
  }
  return sol;
}


const int M = 200003;
int pt[M], goback[2 * M];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll sol = 0;
  int x = 1;
  for (int i = 0; i < M; i++) {
    pt[x] = i;
    goback[i] = x;
    goback[i + M - 1] = x;
    x = 2 * x % M;
  }
  vector<ll> a(M, 0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == 0) {
      continue;
    }
    sol -= (ll) x * x % M;
    a[pt[x]]++;
  }
  a = multiply(a, a);
  for (int i = 0; i < 2 * M; i++) {
    if (a[i]) {
      int val = goback[i];
      sol += a[i] * val;
    }
  }
  sol /= 2;
  cout << sol << "\n";
  return 0;
}


Measured memory_bytes: 46272
//===================== Author Info ==================
//  Khaled Alam (Ninjo)   ~   khaledalam.net@gmail.com
//====================================================
import java.util.*;

public class Main {
	public long res = 1;

	public static long ans(int n) {
		if (n == 1)
			return 1;
		return n + ans(n - 1);
	}

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

		int n = in.nextInt();
		System.out.println(ans(n));

	}
}

Measured memory_bytes: 9940
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int N,M;
  int str[200][2];
  int ans = 0;
  int fin = 0;
  cin >> N >> M;
  for(int i=0;i<M;i++){
    cin >> str[i][0] >> str[i][1];
  }
  
  int mmax = 0;
  bool used[200];
  int here=-1;
  for(int i=0;i<M;i++)used[i] = false;

  for(int i=1;i<=N;i++){
    //cout << "i = " << i << endl;
    for(int j=0;j<M;j++){

      if(str[j][0] <=fin+1 && str[j][1]-fin > mmax && !used[j]){
	mmax = str[j][1]-fin;
	here = j;
	//cout << "here is " << here << ", and value is " << str[here][1] << endl;
      }
    }
    //cout << "final here is " << here << endl;
    if(here != -1){
      ans++;
      fin = str[here][1];     //cout << "fin = " << fin << endl;
      used[here] = true;
      here = -1;
      i = fin-1;
      mmax = 0;
    }
    if(fin == N)break;
  }


 
  if(fin == N){
  cout << ans << endl;
  }
  else cout << "Impossible" << endl;


  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  string s;
  cin >> s;
  REP(i, s.size()){
    if(i%2 == 0) cout << s[i];
  }
  cout << endl;
  return 0;
}

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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,ans=0;
	cin>>k>>n;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n-i;j++)
		{
			if(n-i-j<=k&&i<=k&&j<=k) ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

bool solve() {
    ll h, w; cin >> h >> w;
    vector<ll> cnt(26, 0);
    rep(i, h) {
        string s; cin >> s;
        rep(j, w) cnt[s[j]-'a']++;
    }
    if (h % 2 == 0 && w % 2 == 0) { // even * even
        rep(i, 26) if (cnt[i] % 4) return false;
        return true;
    }
    else if (h % 2 != 0 && w % 2 != 0) { // odd * odd
        ll one = 1;
        ll two = w/2 + h/2;
        ll four = (w*h - one - two*2) / 4;
        rep(i, 26) if (cnt[i] % 2) --cnt[i], --one;
        if (one < 0) return false;
        rep(i, 26) if (cnt[i] % 4) --two;
        return two >= 0;
    }
    else { // even * odd
        if (h % 2 == 0) swap(w, h);
        ll even = w, odd = h;
        ll two = even / 2;
        ll four = even * (odd-1) / 2;
        rep(i, 26) if (cnt[i] % 2) return false;
        rep(i, 26) {
            if (cnt[i] % 4) --two;
        }
        return two >= 0;
    }
    assert(false);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << vector<string>{"No", "Yes"}[solve()] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
//	string a[3]={"Sunny","Cloudy","Rainy"};
	string s;
	string ans="";
	cin >>s;
	if(s=="Rainy"){
		ans="Sunny";
	}else if(s=="Sunny"){
		ans="Cloudy";
	}else{
		ans="Rainy";
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input().strip())
#-----


class factorization():
    def get_divisor(self, n :int) -> dict:
        divisor_dic={}
        
        tmp_num = n
        for i in range(2,n):
            
            while tmp_num % i == 0:
                divisor_dic.setdefault(i,0)
                divisor_dic[i] += 1
                
                tmp_num //= i
        
        return divisor_dic




divisor_dic={}  # 階乗を素因数分解し、結果を入れる
for num in range(2,N+1):
    # 階乗の、それぞれの数字について、約数を抽出
    fa = factorization()
    ret = fa.get_divisor(num)
    
    if ret == {}:
        divisor_dic.setdefault(num,0)
        divisor_dic[num] += 1
    else:
        for key,v in ret.items():
            divisor_dic.setdefault(key,0)
            divisor_dic[key] += v

cnt=1
for key,v in divisor_dic.items():
    cnt = cnt * (divisor_dic[key] + 1) % (10**9 + 7)

print(cnt)


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int i,j,n;	cin>>n;
	vector<int> a(n+1),b(n+1);
	for(i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	sort(a.rbegin(), a.rend());
	sort(b.begin(), b.end());

	ll ans=0;
	for(i=0;i<n+1;i++){
		if(a[i] > b[i])	ans+=2*(a[i]-b[i]);
		else	break;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        if(a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        scan.close();
    }
}


Measured memory_bytes: 26404
#include<iostream>
#include<map>
#define F first
#define S second
using namespace std;

typedef pair<char,char> P; // P(1,0)

int main()
{
  string ope;
  map<char,P> graph;
  graph['A'] = P('Y','X');
  graph['Y'] = P('N','X');
  graph['X'] = P('Z','N');
  graph['Z'] = P('B','W');
  graph['W'] = P('Y','B');
  graph['B'] = P('X','Y');


  while(true)
    {
      cin >> ope;
      if(ope == "#")
	break;
      char now = 'A';
      for(int i=0;i<ope.size();i++)
	{
	  P p = graph[now];
	  if(ope[i] == '1')
	    now = p.F;
	  else
	    now = p.S;  
	}
      if(now == 'B')
	cout << "Yes" << endl;
      else 
	cout << "No" << endl;
    }

  return 0;
}

Measured memory_bytes: 1184
n,k= map(int,input().split())
d=[0]*k
a=[0]*k
ans=[]
for i in range(k):
    d=int(input())
    a[i] = list(map(int,input().split()))

for zzz in range(k):
    for i in a[zzz]:
        if i in ans:
            pass
        else:
            ans.append(i)

print(n-len(ans))



Measured memory_bytes: 67464
#include<cstdio>
int N,c[110];
bool chk(){
	int d=N;
	while(!c[d])--d;
	// 4: 2(1) 3(2) 4(2)
	// 5: 3(2) 4(2) 5(2)
	int m=d+1>>1;
	for(int i=0;i<m;i++)if(c[i])return 0;
	if(c[m]!=d%2+1)return 0;
	for(int i=m+1;i<=d;i++)if(c[i]<2)return 0;
	return 1;
}
int main(){
	scanf("%d",&N);
	for(int i=N,a;i--;)scanf("%d",&a),c[a]++;
	puts(chk()?"Possible":"Impossible");
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 5005, MAX_M = 205;
typedef long long i64;

int N, M, B[MAX_N][MAX_M];
i64 d[MAX_N], sum[MAX_N], value[MAX_N];
int q[MAX_M][MAX_N], top[MAX_M];

int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i < N; ++i) {
    scanf("%lld", &d[i + 1]);
    d[i + 1] += d[i];
  }
  
  for (int i = 1; i <= N; ++i) value[i] = d[i];
  
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j)
      scanf("%d", &B[i][j]);

  i64 result = 0;
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j <= i; ++j) sum[j] = 0;
    for (int j = 1; j <= M; ++j) {
      int &t = top[j], *st = q[j];
      value[i] += B[i][j];
      while (t > 0 && B[st[t]][j] <= B[i][j]) {
	sum[st[t]] += B[i][j] - B[st[t]][j];
	sum[st[t - 1]] -= B[i][j] - B[st[t]][j];
	t--;
      }
      st[++t] = i;
    }
    for (int j = i; j; --j) {
      sum[j] += sum[j + 1];
      value[j] += sum[j];
      result = max(result, value[j] - d[i]);
    }
  }

  printf("%lld\n", result);
  return 0;
}


Measured memory_bytes: 6656
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,M=map(int,readline().split())
    a=1
    b=N-1
    if N%2==1:
        for _ in range(M):
            print(a,b)
            a+=1
            b-=1
    else:
        flag=False
        for _ in range(M):
            if flag==False and b-a<=N//2:
                flag=True
                b-=1
                print(a,b)
                a+=1
                b-=1
            else:
                print(a,b)
                a+=1
                b-=1

if __name__=="__main__":
    main()

Measured memory_bytes: 9192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int A = cin.nextInt();
        int B = cin.nextInt();
        int C = cin.nextInt();

        int count = 0;

        if (A + B + 1 < C)
        {
            count = A + B + 1;
        }
        else
        {
            count = C;
        }

        count += B;

        WriteLine(count);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(){
	const int INF=1<<29;
	for(int n;scanf("%d",&n),n;){
		vector<pair<int,int> >v(n+1);
		vector<vector<int> >m(n+1);
		for(int i=0;i<=n;i++){
			if(i)scanf("%d%d",&v[i].first,&v[i].second);
			m[i].resize(4),fill(m[i].begin(),m[i].end(),INF);
		}
		int fail=0;
		m[0][0]=0;
		int r=INF;
		for(int i=0;i<n;i++){
			bool x=false;
		for(int j=0;j<4;j++)if(m[i][j]<INF){
			int dist=abs(v[i+1].first-v[i].first),dt=v[i+1].second-v[i].second;
			bool f,g;
			if(f = j<3&&dist*(j+1)<=dt)m[i+1][j+1]=min(m[i+1][j+1],m[i][j]+dist);
			if(g = v[i+1].first+v[i].first*(j+1)<=dt)m[i+1][1]=min(m[i+1][1],m[i][j]+v[i+1].first+v[i].first);
			if(!f&&!g){
				
				//goto NEXT;
			}else{
				x=true;
			}
		}
			if(!x){
				printf("NG %d\n",i+1);
				goto NEXT;
			}
		}
		//int r=INF;
		for(int i=0;i<4;i++)r=min(r,m[n][i]+v[n].first);
		if(r==INF)printf("NG %d\n",fail);
		else printf("OK %d\n",r);
		NEXT:;
	}
}

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

ll a(ll n) { return (9 * pow(5, n - 1) - 1) * pow(2, n) / 16; }

int main() {
  string s;
  cin >> s;
  reverse(all(s));
  ll ans = 0;
  rep(i, s.size()) {
    int x = s[i] - '0';
    ans += pow(2, s.size() - i - 1) * a(i + 1) * x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,X,Y;
    cin >> n >> m >> X >> Y;
    int x[n],y[m];
    for(int i = 0;i < n;i++)
    {
        cin >> x[i];
    }
    for(int i = 0;i < m;i++)
    {
        cin >> y[i];
    }
    sort(x,x + n);
    sort(y,y + m);
    if(max(x[n - 1],X) >= min(Y,y[0]))
    {
        cout << "War";
    }
    else
    {
        cout << "No War";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>


using namespace std;


int main() {
    string str;
    cin >> str;
    
    string str2(str);

    reverse(str2.begin(), str2.end());

    cout << (str == str2 ? "Yes" : "No") << endl;


    return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {

	ll n; cin >> n;
	const ll p = 5;
	vector<ll> c(p);
	ll minIndex;
	ll minValue = 9223372036854775807LL;
	ll ans = 4;
	for (ll i = 0; i < p; i++) {
		cin >> c[i];
		if (chmin(minValue, c[i])) {
			minIndex = i;
		}
	}
	ans += (n + minValue - 1) / minValue;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#define mod 998244353
#define pb push_back
using namespace std;
int main(){
	int n,cnt=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		while(x%2==0){
			x=x/2;
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
    	Scanner scanner = new Scanner(System.in);
    	int n = scanner.nextInt(), m = scanner.nextInt();
    	Map<Integer, Integer> map = new HashMap<Integer, Integer>();
    	boolean flag = true;
    	for (int i = 0; i < m; i++) {
    		int key = scanner.nextInt(), value = scanner.nextInt();
    		if (map.containsKey(key)) {
    			if (map.get(key) != value) {
    				flag = false;
    			}
    		}else {
    			map.put(key, value);
    		}
    	}
    	if (!flag) {
    		System.out.println(-1);
    		return;
    	}else {
    		for(int i=0;i<=999;i++) {
    			if (ok(i, map, n)) {
    				System.out.println(i);
    				return;
    			}
    		}
    		flag = false;
    	}
    	if (!flag) {
    		System.out.println(-1);
    	}

    }
    
    static boolean ok(int n , Map<Integer, Integer> map, int length) {
    	String string = n + "";
    	int len = string.length();
    	if (len != length) return false;
    	for(Integer k : map.keySet()) {
    		if (k > len) {
    			return false;
    		}
    		int value = map.get(k);
    		if (string.charAt(k - 1) - '0' != value) {
    			return false;
    		}
    	}
    	return true;
    }
}


Measured memory_bytes: 21844
# 2019-11-22 16:25:33(JST)
import sys


def main():
    n, a, b = [int(x) for x in sys.stdin.readline().split()]


    if a > b:
        ans = 0
    elif a == b:
        ans = 1
    elif b > a:
        if n == 1:
            ans = 0
        else:
            min_possible = a * (n - 1) + b
            max_possible = b * (n - 1) + a
            ans = max_possible - min_possible + 1
    
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
S = input()
ans = False
if S == S[::-1]:
    s1 = S[:(len(S) - 1) // 2]
    if s1 == s1[::-1]:
        s2 = S[(len(S) + 3) // 2 - 1:]
        if s2 == s2[::-1]:
            ans = True
print("Yes" if ans else "No")

Measured memory_bytes: 3060
# ＢＦＳ, パターン列挙_竹'n'本の使用パターン

from collections import deque

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

queue = deque([[0],[1],[2],[-1]]) # 初期化_ここでは竹の使用パターン4つを設置
ptns = [] # パターン候補の器_初期化
 
while queue: # queueが空になるまでループ
    tmp = queue.popleft() # パターンの候補を popleft
    if len(tmp) == n: # 条件に合えば append
        ptns.append(tmp)
    elif len(tmp) < n: # 条件に合わなければ...
        w = tmp + [0] # パターンの候補を作成して...
        x = tmp + [1] # 〃
        y = tmp + [2] # 〃
        z = tmp + [-1]
        queue += [w, x, y, z]  # キューに追加

#print(ptns) # 竹の使用パターン

ans = 10**9
for i in range(len(ptns)):
    if 0 not in ptns[i] or 1 not in ptns[i] or 2 not in ptns[i]:
        continue
    abc = [0, 0, 0, -30]
    for j in range(n):
        tmp = ptns[i][j]
        if tmp >= 0:
            abc[tmp] += l[j]
            abc[3] += 10
    mp = abc[3]
    mp += abs(abc[0] - a)
    mp += abs(abc[1] - b)
    mp += abs(abc[2] - c)
    ans = min(ans, mp)

print(ans)

'''
# パターン列挙と探索を並行して処理

from collections import deque

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

queue = deque([[0],[1],[2],[-1]])

ans = 10**9
while queue:
    tmp = queue.popleft()
    if len(tmp) == n:
        if 0 not in tmp or 1 not in tmp or 2 not in tmp:
            continue
        abc = [0, 0, 0, -30]
        for j in range(n):
            if tmp[j] >= 0:
                abc[tmp[j]] += l[j]
                abc[3] += 10
        mp = abc[3]
        mp += abs(abc[0] - a)
        mp += abs(abc[1] - b)
        mp += abs(abc[2] - c)
        ans = min(ans, mp)

    elif len(tmp) < n:
        w = tmp + [0]
        x = tmp + [1]
        y = tmp + [2]
        z = tmp + [-1]
        queue += [w, x, y, z]

print(ans)

'''

Measured memory_bytes: 13768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)


using namespace std;
using ll = long long;

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(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll a,b,n;
    cin >> a >> b >> n;
    ll x=n;
    if(n >= b-1) x = b-1;
    ll ans = a*x/b;
    cout << ans << endl;
   

    return 0;
}


Measured memory_bytes: 3648
import math
def main():
    X = int(input())
    max_p = 1
    if X < 4: return max_p

    for p in range(2, int(math.sqrt(X))+1):
        q = p * p
        while q <= X:
            max_p = max(max_p, q)
            q *= p
    return max_p


if __name__ == '__main__':
    print(main())




Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(A: int, B: int):
    return (A + B) if B % A == 0 else (B - A)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    result = solve(A, B)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5524
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  }
}

struct Scanner<R: BufRead> {
  reader: R,
  iter: std::vec::IntoIter<String>
}

#[allow(dead_code)]
impl<R: BufRead> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader, iter: vec![String::new()].into_iter() }
  }
  fn new_line(&mut self) {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    self.iter = line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>().into_iter();
  }
  fn get<T: FromStr>(&mut self) -> T {
    self.iter.next().unwrap().parse().ok().unwrap()
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut scanner = Scanner::new(cin);
  scanner.new_line();
  let (n, m, l) = scan!(scanner; usize, usize, usize);
  let mut a: Vec<Vec<i64>> = Vec::with_capacity(n);
  let mut b: Vec<Vec<i64>> = Vec::with_capacity(m);
  let mut c: Vec<Vec<i64>> = Vec::with_capacity(n);
  for i in 0..n {
    a.push(Vec::with_capacity(m));
    scanner.new_line();
    for _ in 0..m {
      a[i].push(scanner.get());
    }
  }
  for i in 0..m {
    b.push(Vec::with_capacity(l));
    scanner.new_line();
    for _ in 0..l {
      b[i].push(scanner.get());
    }
  }
  for i in 0..n {
    c.push(Vec::with_capacity(l));
    for j in 0..l {
      let mut s = 0;
      for k in 0..m {
        s += a[i][k] * b[k][j];
      }
      c[i].push(s);
    }
    let col: Vec<String> = c[i].iter().map(|v| v.to_string()).collect();
    println!("{}", col.join(" "));
  }
}



Measured memory_bytes: 5060
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;






int main(void) {
    string s;
    int K;
    cin >> s;
    cin >> K;

    set<string> mem;
    for( int i=0; i< s.size(); i++ ) {
        string temps; 
        for( int j=0; j< K && i+j < s.size(); j++ ) {
            temps.push_back(s[i+j]);
            mem.insert(temps);
        }
    }

    int k =1 ;
    for( auto it=mem.begin(); it != mem.end(); it++ ) {
        if( k == K ) {
            cout << *it << endl;
        }
        k++;
    }
    
    return 0;
}

Measured memory_bytes: 1664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CSkillUp solver = new CSkillUp();
        solver.solve(1, in, out);
        out.close();
    }

    static class CSkillUp {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int min = Integer.MAX_VALUE;
            int n = in.nextInt();
            int m = in.nextInt();
            int x = in.nextInt();
            int[] c = new int[n];
            int[][] book = new int[n][m];

            for (int i = 0; i < n; i++) {
                c[i] = in.nextInt();
                for (int j = 0; j < m; j++) {
                    book[i][j] = in.nextInt();
                }
            }

            for (int i = 0; i < 1 << n; i++) {
                int cmp = 0;
                int[] skill = new int[m];
                boolean f = true;
                for (int j = 0; j < n; j++) {
                    if ((i & (1 << j)) != 0) {
                        cmp += c[j];
                        for (int k = 0; k < m; k++) {
                            skill[k] += book[j][k];
                        }
                    }
                }

                for (int k = 0; k < m; k++) {
                    if (skill[k] < x) {
                        f = false;
                        break;
                    }
                }

                if (f) {
                    min = Math.min(min, cmp);
                }

            }

            out.println(min == Integer.MAX_VALUE ? -1 : min);
        }

    }
}



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

using namespace std;

int n,i,j,a[100005];

int main(){
	
	scanf("%d", &n);
	for(i = 1; i <= n; i++)
	scanf("%d", &a[i]);
	
	sort(a + 1, a + 2 + n);
	reverse(a + 1, a + 2 + n);
	
	bool up = 0;
	bool right = 0;
	bool res = 0;
	
	for(i = 1; i <= n + 1; i++){
		if(i > a[i]){
			
			if((a[i - 1] - i + 1) % 2)
			up = 1;
			
			int s = 0;
			for(j = i; j <= n + 1; j++)
			s += (a[j] >= i - 1);
			if(s % 2)
			right = 1;
			
			res = (up | right);
			
			if(res)
			printf("First\n");
			else
			printf("Second\n");
			
			return 0;
		}
	}
}


Measured memory_bytes: 640
n,t=map(int,input().split())
X=[]
for i in range(n):
    
    b,c=map(int,input().split())
    X.append([b,c])

X.sort(key=lambda x:x[1])
if X[0][1]>t:
    print('TLE')
else:
    Y=[i for i in X if i[1]<=t]
    Y.sort(key=lambda x:x[0])
    print(Y[0][0])

Measured memory_bytes: 3064
def main():
    A = input()[::-1]
    A = "0" + A
    # lis_num = [int(s) for s in A]

    # print(lis_num)

    # S = [0] * len(lis_num)
    S = [0] * len(A)
    cnt = [0] * 2019
    cnt[0] = 1

    for i in range(len(A) - 1):
        S[i + 1] = (S[i] + int(A[i + 1]) * pow(10, i, 2019)) % 2019
        cnt[S[i + 1] % 2019] += 1

    # print(S)

    # for i in S:
    #     cnt[i % 2019] += 1

    ans = 0

    for i in cnt:
        ans += i * (i - 1) // 2

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16328
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define INF 2140000000
#define MOD 1000000007

int main() {
	string s;

	cin >> s;
	
	int min1 = 0, min2 = 0;

	for (int i = 0; i < (int) s.size(); ++i) {
		if (i % 2) {
			if (s[i] != '0') {
				min1++;
			}
		}
		else {
			if (s[i] != '1') {
				min1++;
			}
		}
	}

	for (int i = 0; i < (int) s.size(); ++i) {
		if (i % 2) {
			if (s[i] != '1') {
				min2++;
			}
		}
		else {
			if (s[i] != '0') {
				min2++;
			}
		}
	}	

	if (min1 < min2) {
		cout << min1 << endl;
	}
	else {
		cout << min2 << endl;
	}

	return 0;
}

Measured memory_bytes: 512
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las



main = do
    (a, b, c) <- readTuple3
    putStrLn $ if (== 2) . length  . nub $ [a, b, c] then "Yes"  else "No"


Measured memory_bytes: 380
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

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

const ll mod = static_cast<ll>(1e9) + 7;

const ll MAXN = 10;
const ll MAXD = 10;
ll X[MAXN][MAXD];

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

    rep (i, N)
    rep (j, D)
    {
        cin >> X[i][j];
    }

    ll ans = 0;

    for (ll i=0;i<N;++i)
    for (ll j=i+1;j<N;++j)
    {
        ll d = 0;

        for (ll k=0;k<D;++k)
        {
            d += abs(X[i][k] - X[j][k]) * abs(X[i][k] - X[j][k]);
        }

        ll t = 0;
        while (t * t < d) { ++t; }

        if (t * t == d)
        {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
integer N,ans(-1:10**5+1)
integer,allocatable,dimension(:)::A
read*,N
allocate(A(N))
read*,A
ans=0
do i=1,N
  ans(A(i)-1)=ans(A(i)-1)+1
  ans(A(i)  )=ans(A(i)  )+1
  ans(A(i)+1)=ans(A(i)+1)+1
end do
print"(i0)",maxval(ans)
end

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
int main(){
  string S;
  cin >> S;
  if(S=="ABC")
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;
}
  

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int t;
    cin >> t;
    rep(ti, t) {
        int n;
        cin >> n;
        vector<ll> a(n);
        rep(i, n) cin >> a[i];
        string s;
        cin >> s;
        
        if (s[n-1]=='1') {
            cout << "1" << endl;
            continue;
        }
        
        vector<ll> v;
        int ans = 0;
        for (int i=n-1; i>=0; i--) {
            ll now = a[i];
            for (ll e: v) {
                chmin(now, now^e);
            }
            if (now>0) {
                if (s[i]=='1') {
                    ans = 1;
                    debug(i);
                    break;
                }
                v.push_back(now);
            }
        }
        cout << ans << endl;
    }

    
    return 0;
}


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

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
  int n;
  cin >> n;
  int zero = 0;
  map<pair<ll, ll>, P> mp;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) {
      zero++;
      continue;
    }
    ll g = __gcd(x, y);
    x /= g;
    y /= g;
    if (y < 0) {
      x = -x;
      y = -y;
    }
    if (y == 0 && x < 0) {
      x = -x;
      y = -y;
    }
    bool rot90 = (x <= 0);
    if (rot90) {
      ll tmp = x;
      x = y;
      y = -tmp;
    }
    if (rot90)
      mp[{x, y}].first++;
    else
      mp[{x, y}].second++;
  }
  mint ans = 1;
  for (auto p : mp) {
    int s = p.second.first;
    int t = p.second.second;
    mint now = 1;
    now += mint(2).pow(s) - 1;
    now += mint(2).pow(t) - 1;
    ans *= now;
  }
  ans -= 1;
  ans += zero;
  cout << ans << endl;
}

Measured memory_bytes: 16040
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
#define v(T) vector<T>
#define vv(T) vector<v(T)>
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
template<class T>bool chmax(T &a, const T &b){
    if (a < b) {a = b; return true;}
    return false;
}
template<class T>bool chmin(T &a, const T &b){
    if (a > b) {a = b; return true;}
    return false;
}

int comb(int n, int k){
    if (n<k or k < 0) return 0;
    int ret = 1;
    for (int i = n; i> n-k; i--){
        ret *= i;
    }
    for (int i = 1;i<k+1;i++){
        ret /= i;
    }
    return ret;
}

int dp[1000][4][2];
int main()
{
    string s;
    cin >> s;
    int N = s.size();
    int K; cin >> K;
    dp[0][0][0] = 1;
    rep(i, N){
        int num = s[i]-'0';
        rep(j, K+1) rep(k, 2){
            rep(d, 10){
                int nj = j, nk = k;
                if (d!= 0) nj++;
                if (nj > K) continue;
                if (k==0) {
                    if (d > num) continue;
                    else if (d < num) nk++;
                }
                dp[i+1][nj][nk] += dp[i][j][k];
            }

        }
    }
    cout << dp[N][K][0]+dp[N][K][1] << endl;
}



Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <stdlib.h>
#define ll long long
#define MOD_P 1000000007
using namespace std;

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

	vector<int>value(n);
	int cost;

	for (int i = 0; i < n; i++) {
		cin >> value[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> cost;
		if (value[i] > cost) {
			sum += value[i] - cost;
		}
	}

	printf("%d", sum);

	return 0;
}

Measured memory_bytes: 256
<?php
  $res = 0;
  $min = 0;
  $max = 0;
  $k = 0;
  const MAX = 6;

  for($i=0;$i<MAX;$i++) {
    $input = fgets(STDIN);
    if($i === 0) {
      $min = intval($input);
    }
    else if ($i === MAX - 2) {
      $max = intval($input);
    }
    else if( $i === MAX - 1 ) {
      $k = intval($input);
    }
    else continue;
  }
  $res = ($max - $min) > $k ? ':(' : 'Yay!';
  echo $res;
?>

Measured memory_bytes: 4604
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int a,b;
  int sump=0;
  int num=0;
  int i=0;
  while(scanf("%d,%d",&a,&b)+1){
    //if(a==0)break;
    i++;
    sump+=a*b;
    num+=b;
  }
  int ave=(int)((double)num/(double)i+0.5);
  cout<<sump<<endl<<ave<<endl;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i < (n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;




int main(){
  int a,b,c; cin >> a >> b >> c;
  cout << (a+b-1)/b*c << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}



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

int main(){
    int n;
    long long sum=0;
    scanf("%d",&n);
    vector<int> a(n);
    for (int i=0;i<n;i++) scanf("%d", &a[i]);
    sort(a.begin(),a.end());
    for (int i=0;i<n;i++) sum+=a[i];
    printf("%d %d %lld\n",a[0],a[n-1],sum);
    return 0;
}



Measured memory_bytes: 3268
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    vector<vector<bool>> on(M,vector<bool> (N,false));
    for(int i=0; i<M; i++){
        int k;
        cin >> k;
        for(int j=0; j<k; j++){
            int a;
            cin >> a;
            a--;
            on[i][a] = true;
        }
    }
    vector<int> p(M);
    for(int i=0; i<M; i++){
        cin >> p[i];
    }
    int ans = 0;
    for(int bit=0; bit<(1<<N); bit++){
        vector<int> cnt(M,0);
        for(int i=0; i<N; i++){
            for(int j=0; j<M; j++){
                if(on[j][i] and (bit & (1<<i))) cnt[j]++;
            }
        }
        bool ok = true;
        for(int i=0; i<M; i++){
            if(p[i] != cnt[i]%2) ok = false;
        }
        if(ok) ans++;
    }
    cout << ans << enld;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in A:
    if i % 2 == 0:
        if (i % 3 != 0) and (i % 5 != 0):
            ans += 1

if ans == 0:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 2940