akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2){
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}
 
// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;
 
int main(){
    ll a,b,c,y=0,n,m,k,l,r,w,sum=0,sum2=0,ans=0;
    string s,t;
    bool f=true;
    cin >> n;
    double tax=1.08;
    double x = n / tax;
    for(double i=1; i<=50000;i++){
        if(floor(i*1.08) == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

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

ll solve() {
    ll N, K;
    map<char, ll> m;
    string T;
    cin >> N >> K >> m['s'] >> m['p'] >> m['r'] >> T;
    map<char, bool> u;
    u['r'] = u['s'] = u['p'] = false;
    ll ans = 0;
    for ( int k = 0; k < K; k++ ) {
        u['r'] = u['s'] = u['p'] = false;
        for ( int i = k; i < N; i+=K ) {
            if ( i >= K ) {
                if ( T[i] == T[i-K] ) {
                    if (u[T[i]]) {
                        ans += m[T[i]];
                        u[T[i]] = false;
                    } else {
                        u[T[i]] = true;
                    }
                } else {
                    ans += m[T[i]];
                    u[T[i]] = false;
                }
            } else {
                ans += m[T[i]];
            }
        }
    }



    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ACC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mod 1000000007
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int dx8[]={1,-1,0,0,1,1,-1,-1};
int dy8[]={0,0,1,-1,1,-1,1,-1};
bool isvowel(char c)
{
    switch(c)
    {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':return true;
        default : return false;
    }
}
bool isValid(ll x,ll y,ll n,ll m)
{
    if(x<0||x>n-1||y<0||y>m-1)return false;
    return true;
}
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    if(x.first==y.first)
        return x.second<y.second;
    return x.first<y.first;
}
int main()
{
    ACC
    int T;
    T=1;
    //cin>>T;
    while(T--)
    {
      string s;
      cin>>s;
      ll i,su=0;
      for(i=0;i<s.length();i++)
      {
          su+=s[i]-'0';
      }
      if(su%9)cout<<"No\n";
      else cout<<"Yes\n";
    }
    return 0;
}


Measured memory_bytes: 3764
import java.util.*;
class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = a;
    int d = 0;
    while(b != 0){
    d = d + b % 10;
      b = b / 10;
    }
   if(0 == a % d){
    System.out.println("Yes");
   } else {
   System.out.println("No");
   }
 } 
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main{
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Long ans = 0L;
    for(int i =0;i<N;i++){ans += pow(sc.nextLong());}
    System.out.println(ans);
    sc.close();
  }
  public static Long pow(Long a){
    Long ret = 0L;
    while(a%2==0){
      ret+=1;
      a = a/2;
    }
    return  ret;
  }
}
  

Measured memory_bytes: 38368
s = input()
l=0
r=len(s)-1
fl=True
fr=True
while fl or fr:
    if fl:
        if s[l]=='A':
            fl=False
        else:
            l+=1
    
    if fr:
        if s[r]=='Z':
            fr=False
        else:
            r-=1
print(r-l+1)

Measured memory_bytes: 40304
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    char c; cin >> c;
    cout << (char)(c + 1) << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H, W, K = mapint()
y1, x1, y2, x2 = mapint()
pond = [list(input()) for _ in range(H)]
from collections import deque
Q = deque([(y1-1, x1-1)])

inf = 10**18
dist = [[inf]*W for _ in range(H)]
dist[y1-1][x1-1] = 0
while Q:
    y, x = Q.popleft()
    if y==y2-1 and x==x2-1:
        break
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        for i in range(1, K+1):
            ny, nx = y+dy*i, x+dx*i
            if ny<0 or ny>=H or nx<0 or nx>=W:
                break
            if pond[ny][nx]=='@':
                break
            if dist[ny][nx]<=dist[y][x]:
                break
            if dist[ny][nx]>dist[y][x]+1:
                dist[ny][nx] = dist[y][x]+1
                Q.append((ny, nx))
if dist[y2-1][x2-1]>=10**17:
    print(-1)
else:
    print(dist[y2-1][x2-1])

Measured memory_bytes: 135324
#include <iostream>
#include <fstream>

using namespace std;

int main() {
    int n;
    cin>>n;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++) {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum % 10 == 0) {
        int mx = 0;
        for(int i=0;i<n;i++) {
            if((sum - a[i]) % 10) {
                mx = max(mx,sum - a[i]);
            }
        }
        cout<<mx;
        return 0;
    }
    cout<<sum;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a[N];
  bool color[8];
  for(int i=0; i<8; i++){
    color[i] = false;
  }
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  int ans = 0;
  for(int i=0; i<N; i++){
    int rate = a[i];
    if(rate < 400){
      color[0] = true;
    }else if(rate < 800){
      color[1] = true;
    }else if(rate < 1200){
      color[2] = true;
    }else if(rate < 1600){
      color[3] = true;
    }else if(rate < 2000){
      color[4] = true;
    }else if(rate < 2400){
      color[5] = true;
    }else if(rate < 2800){
      color[6] = true;
    }else if(rate < 3200){
      color[7] = true;
    }else{
      ans++;
    }
  }

  int count = 0;
  for(int i=0; i<sizeof(color); i++){
    if(color[i]) count++;
  }

  cout << (count == 0 ? 1 : count) << " " << (count+ans) << endl;
}


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

int main()
{
    string S;
    cin >> S;
    int ans = 0;
    int tmp = 0;
    int n = S.length();
    for(int i=0; i<n; ++i)
    {
        if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T')
        {
            tmp += 1;
            if(i==n-1)
                ans=max(ans,tmp);
        }
        else
        {
            ans = max(ans,tmp);
            tmp = 0;
        }
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> V(N,vector<int>(0));
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    a--;b--;
    V[a].push_back(b);
    V[b].push_back(a);
  }
  
  vector<int> ans(N,-1);
  queue<int> Q;
  Q.push(0);
  ans[0] = -2;
  while(!Q.empty()){
    int u = Q.front();
    Q.pop();
    for(int i=0;i<V[u].size();i++){
      int v = V[u][i];
      if(ans[v]==-1){
        ans[v] = u;
        Q.push(v);
      }
    }
  }
  
  for(int i=1;i<N;i++){
    if(ans[i]==-1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for(int i=1;i<N;i++) cout << ans[i]+1 << endl;
  return 0;
}


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

int main()
{
  int a[5];
  
  while (cin >> a[0] && a[0] != 0){
    cin >> a[1] >> a[2] >> a[3] >> a[4];
    int c[4] = {0};
    int cnt = 0;
    c[a[0]]++;
    for (int i = 1; i < 5; i++){
      c[a[i]]++;
      if (a[i] == a[i - 1]){
        cnt++;
      }
    }
    if (cnt == 4){
      for (int i = 0; i < 5; i++){
        cout << 3 << endl;
      }
      continue;
    }
    if (c[1] > 0 && c[2] > 0 && c[3] > 0){
      for (int i = 0; i < 5; i++){
        cout << 3 << endl;
      }
      continue;
    }
    for (int i = 1; i < 4; i++){
      if (c[i] == 0) cnt = i;
    }

    for (int i = 0; i < 5; i++){
      if (cnt == 1){
        if (a[i] == 2) cout << 1 << endl;
        if (a[i] == 3) cout << 2 << endl;
      }
      if (cnt == 2){
        if (a[i] == 3) cout << 1 << endl;
        if (a[i] == 1) cout << 2 << endl;
      }
      if (cnt == 3){
        if (a[i] == 1) cout << 1 << endl;
        if (a[i] == 2) cout << 2 << endl;
      }
    }
  }
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main(){
    int a,b,c,cou=0;
    
    cin >> a >> b >>c;
    
    for(;a<=b;a++){
        if(c % a == 0)
            cou++;
    }
    
    cout <<cou<<"\n";
    
    return 0;

}



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

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        new Main().run();
    }

    public Main() {
    }

    FastScanner sc;

    void run() {
        sc = new FastScanner();
        String s = sc.next();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == ',') {
                System.out.print(' ');
            } else {
                System.out.print(c);
            }
        }

        System.out.print("\n");
    }
}

/** 標準入力読み込み用クラス */
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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


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

  int r=0;
  int l=0;
  int ans=0;
  while(l<n){
    int cnt=0;
    for(r=l;r<n-1;r++){
      if(h[r]>=h[r+1])
      cnt++;
      else
      break;
    }
    ans=max(ans,cnt);
    l=r+1;
  }

  cout<<ans<<endl;
  

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define MOD 1000000007
#define Long long long 
#define maxn 100003
#define pb push_back
using namespace std;
int par[maxn];
int anc(int p) { 
	if(par[p]==p) return p;
	return par[p] = anc(par[p]);
}
void join(int p, int q){
	par[anc(p)] = anc(q);
}
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
vector<ii> vtxCood1,vtxCood2;
vector<iii> vtxCood;

int n;
main(){	
	int x,y,ans = 0;
	cin >> n;
	 For(i,1,n) par[i]=i;
	For(i,1,n){
		scanf("%d%d",&x,&y);
		vtxCood1.pb(ii(x,i));
		vtxCood2.pb(ii(y,i));
	}
	sort(vtxCood1.begin(), vtxCood1.end());		
	sort(vtxCood2.begin(), vtxCood2.end());		
	For(i,0,n-2){
		vtxCood.pb(iii(vtxCood1[i+1].first-vtxCood1[i].first,ii(vtxCood1[i].second,vtxCood1[i+1].second)));
		vtxCood.pb(iii(vtxCood2[i+1].first-vtxCood2[i].first,ii(vtxCood2[i].second,vtxCood2[i+1].second)));
	}
	sort(vtxCood.begin(), vtxCood.end());		
	
	vector<iii>::iterator it;
    for (it=vtxCood.begin(); it!=vtxCood.end(); it++){
    	int v1 = it->second.first;
    	int v2 = it->second.second;
        if (anc(v1) != anc(v2)){
            join(v1,v2);
            ans += it->first;
        }
    }    
    
	cout << ans;
}

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

void lcs( string X, string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
   string LL[m+1][n+1];
   int i, j; 

   for (i=0; i<=m; i++) 
   { 
     for (j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
   
       else if (X[i-1] == Y[j-1]) 
       {
         L[i][j] = L[i-1][j-1] + 1; 
       }
       else
       {
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
       }
     } 
   } 

   string ss;
   int size=L[m][n];

   while(i>0 && j>0)
   {
	   	if(X[i-1]==Y[j-1])
	   	{
	   		ss.push_back(X[i-1]);
	   		i--;
	   		j--;
	   	}

   		else if(L[i-1][j]>L[i][j-1])
   			i--;
   		else
   			j--;
   }

   size=ss.size();
  	for(int i=size-1;i>0;i--)
  		cout<<ss[i];

} 

int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
	string s;
	string t;
	cin>>s;
	cin>>t;
	int ss=s.size();
	int tt=t.size();

	lcs(s,t,ss,tt);
	
}

Measured memory_bytes: 105856
while True:
    m,f,r = list(map(int, input().split()))
    b = m + f
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif 80 <= b:
        print("A")
    elif 65 <= b < 80:
        print("B")
    elif 50 <= b < 65:
        print("C")
    elif 30 <= b < 50:
        if 50 <= r:
            print("C")  
        else:
            print("D")
    else:
        print("F")

Measured memory_bytes: 5588
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using pci = pair<char, int>;
using vpci = vector<pci>;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
#define GetAuto(_N,vect) {cin>>_N;vect.resize(_N);REP(i,_N){cin>>vect[i];}}
#define beginend(vec) (vec).begin(),(vec).end()
#define pb(item) push_back(item)
#define removeAll(vec,deleg) auto itr=remove_if(beginend(vec),deleg);vec.erase(itr,vec.end());
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}
bool isPrime(ll x) {if (x == 2) return true;if (x < 2 || x % 2 == 0) return false;ll i = 3;while (i <= sqrt(x)) {if (x%i == 0) return false;i += 2;}return true;}


int h, w;
vl box;
void solve() {


}

int main() {
	FOR(i, 0, 151) box.pb(i*i);
	//ShowAll(box);
	while (cin>>h>>w,(h||w))
	{
		ll target = box[h] + box[w];
		ll m = INF;
		pii ans = pii(1, 1);
		FOR(i, 1, 151) {
			FOR(n, i+1, 151) {
				ll md = box[i] + box[n];
				if (m <= md) break;
				if (target < md || target == md&&h < i) {
					m = md;
					ans = pii(i, n);
				}
			}
		}
		cout <<  ans.first << " " << ans.second << endl;
	}

	return 0;
}

Measured memory_bytes: 3124
#                          JAI SHREE RAM

import math; from collections import *
import sys; from functools import reduce

# sys.setrecursionlimit(10**6)
def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())
def get_string(): return list(input().strip().split())
def printxsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9)+7; SEXYMOD = 998244353; MAXN = int(1e5)

# sys.stdin=open("input.txt","r");sys.stdout=open("output.txt","w")

# for _testcases_ in range(int(input())):
d = OrderedDict()
d['AC'] = 0
d['WA'] = 0
d['TLE'] = 0
d['RE'] = 0
n = int(input())
for i in range(n):
    d[input()] += 1
for key, val in d.items():
    print(key, 'x', val)

'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

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

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

    long long N;
    cin >> N;

    long long ans = 0;
    for (long long i=1; i*i<=N; ++i) {
        if (N % i == 0) {
            if (i-1 > 0 && N / (i-1) == N % (i-1)) {
                ans += i-1;
            }
            if (i*i != N && (N/i)-1 > 0 && N / (N/i-1) == N % (N/i-1)) {
                ans += N/i-1;
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int m1=sc.nextInt(),d1=sc.nextInt(),m2=sc.nextInt(),d2=sc.nextInt();
        System.out.println((m1==m2)?0:1);
    }
}

Measured memory_bytes: 23764
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
from collections import defaultdict
ns = defaultdict(set)
sc = [None]*n
nodes = []
for i in range(n):
    s,c = input().split()
    c = int(c)
    sc[i] = (s,c)
    nodes.extend([(0,s[i:]) for i in range(len(s))])
    nodes.extend([(1,s[:i]) for i in range(1, len(s)+1)])

for u in nodes:
    for s,c in sc:
        if u[0]==0 and s.endswith(u[1][::-1]):
            v = (1, s[:-len(u[1])])
            ns[u].add((c,v))
        elif u[0]==0 and u[1][::-1].endswith(s):
            v = (0, u[1][len(s):])
            ns[u].add((c,v))
        elif u[0]==1 and s.startswith(u[1][::-1]):
            v = (0, s[len(u[1]):])
            ns[u].add((c,v))
        elif u[0]==1 and u[1][::-1].startswith(s):
            v = (1, u[1][:-len(s)])
            ns[u].add((c,v))
start = 0
for s,c in sc:
    ns[start].add((c, (0,s)))
    ns[start].add((c, (1,s)))
def dijkstra(start):
    import heapq
    vals = {}
    h = [(0, start)] # (距離, ノード番号)
    vals[start] = 0
    while h:
        val, u = heapq.heappop(h)
        for d, v in ns[u]:
            if v not in vals or vals[v]>val+d:
                vals[v] = val+d
                heapq.heappush(h, (vals[v], v))
    return vals
vals = dijkstra(start)
ans = float("inf")
for k,v in vals.items():
    if k==0:
        continue
    if k[1]==k[1][::-1]:
        ans = min(ans, v)
if ans==float("inf"):
    ans = -1
print(ans)

Measured memory_bytes: 71852
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    string s;
    int n,k;

    cin>>n>>k;
    cin>>s;

    if (s[k-1] == 'A'){
        s[k-1] = 'a';
    } else if (s[k-1] == 'B') {
        s[k-1] = 'b';
    } else {
        s[k-1] = 'c';
    }

    cout<<s<<endl;

    return 0;
}



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

#define FOR(i,a,b) for (ll i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (ll i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<ll>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s; cin >> s;

    ll total = 0;

    char last = s[0];
    vi segs;
    ll curSize = 0;
    for (char c : s) {
        if (c == last) {
            curSize += 1;
        } else {
            segs.push_back(curSize);
            curSize = 1;
        }
        last = c;
    }
    segs.push_back(curSize);

    char parity = s[0];
    ll peak = 0;
    for (ll seg : segs) {
        if (parity == '<') {
            peak = seg;
            parity = '>';
        } else {
            total += max(peak, seg);
            parity = '<';
        }
        total += seg * (seg - 1) / 2;
    }
    if (s[s.size()-1] == '<') total += peak;
    cout << total  << endl;
}

Measured memory_bytes: 3352
s = gets.to_i
a = Array.new(1000000, false)
m = 1
while true
  if a[s] 
    break
  end

  a[s] = true
  m += 1

  if s % 2 == 0
    s /= 2
  else
    s = 3 * s + 1
  end
end

p m


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

using namespace std;

typedef long long ll;
typedef string sr;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = (n / (a + b)) * a;
    ll x = n % (a + b);
    if (x > a) x = a;
    ans += x;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
	int t;
	cin>>t;
	cout<<t/3600<<":"<<t/60%60<<":"<<t%3600%60<<endl;
	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a * b ) / 2 << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int NPrime=3000000;
bool prime[NPrime+1];
vi EnumeratePrime(){
	fill(prime+2,prime+NPrime+1,true);
	vi a;
	for(int i=2;i<=NPrime;i++) if(prime[i]){
		a.emplace_back(i);
		for(int j=2*i;j<=NPrime;j+=i) prime[j]=0;
	}
	return a;
}

int n;

int main(){
	while(1){
		cin>>n;
		if(n==0) break;
		vi a(n);
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			a[i]=s.size();
		}
		int b[5]={5,7,5,7,7};
		for(int i=0;i<n;i++){
			int I=i;
			bool B=1;
			for(int j=0;j<5;j++){
				int t=0;
				while(t<b[j]&&I<n) t+=a[I++];
				if(t!=b[j]){
					B=0;
					break;
				}
			}
			if(B){
				cout<<i+1<<endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int n ,m;
		cin >> n >> m;
		cout <<(n<=m ? "unsafe":"safe");

	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

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

using namespace std;

const int inf = 2e9;

int main(int argc, char *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> g(n + 1);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    g[u].push_back({v, w});
    g[v].push_back({u, -w});
  }
  vector<int> dis(n + 1, inf);
  for (int i = 1; i <= n; i++) {
    if (dis[i] == inf) {
      queue<int> q;
      dis[i] = 0;
      q.push(i);
      while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto e : g[u]) {
          int v = e.first, w = e.second;
          if (dis[v] == inf) {
            dis[v] = dis[u] + w;
            q.push(v);
          } else if (dis[v] != dis[u] + w) {
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main()
{
	ll N;
	cin >> N;
	vector<ll> w(N),sum(N + 1, 0);
	for (ll i = 0; i < N; i++) {
		cin >> w[i];
		sum[i + 1] = sum[i] + w[i];
	}
	vector< vector<ll> > dp(N, vector<ll>(N, -1)), mo(N, vector<ll>(N));
	for (ll i = 0; i < N; i++) {
		dp[i][i] = 0;
		mo[i][i] = i;
	}
	for (ll i = 0; i + 1 < N; i++) {
		dp[i][i + 1] = sum[i + 2] - sum[i];
		mo[i][i + 1] = i;
	}

	for (ll l = 2; l < N; l++) {
		for (ll i = 0; i + l < N; i++) {
			for (ll k = mo[i][i + l - 1]; k <= mo[i + 1][i + l]; k++) {
				if (dp[i][i + l] == -1 || dp[i][i + l] > dp[i][k] + dp[k + 1][i + l]) {
					dp[i][i + l] = dp[i][k] + dp[k + 1][i + l];
					mo[i][i + l] = k;
				}
			}
			dp[i][i + l] += sum[i + l + 1] - sum[i];
		}
	}
	cout << dp[0][N - 1] << endl;
	return 0;
}

Measured memory_bytes: 253384
#include<stdio.h>

int main(){
        int a,b,c,i,sum;
        scanf("%d %d %d",&a,&b,&c);
        for(i=a;i<=b;i++){
                if(c%i==0){
                        sum++;
                }
        }
        printf("%d\n",sum);

        return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;  
inline int read()  
{  
    int x=0,f=1;
    char s=getchar();  
    while(s<'0'||s>'9')
        {
            if(s=='-')
                f=-1;
            s=getchar();
        }  
    while(s<='9'&&s>='0')
        {
            x=x*10+s-'0';
            s=getchar();
        }  
    return x*f;  
}  
int main()  
{  
    char ch[50];  
    scanf("%s",ch);  
    bool flag=true;  
    for(int i=1;i<strlen(ch);i++)  
        if(ch[i]!='9')
            flag=false;  
    if(flag)
        printf("%d\n",(strlen(ch)-1)*9+ch[0]-'0');
    else  
        printf("%d\n",(strlen(ch)-1)*9+ch[0]-'0'-1);  
    return 0;  
}  

Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 17.07.2020 11:06:30
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
long double eps = 1.0E-14;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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<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 gcd(a,b)*(a/gcd(a,b))*(b/gcd(a,b));}

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

  ll n;
  cin>>n;

  vector<ll> v;
  ll tmp;
  REP(i,n)
  {
    cin>>tmp;
    v.emplace_back(tmp);
  }
  SORT(v);
  vector<ll> vv;
  vv=v;
  UNIQUE(vv);
  
  ll a[SZ(vv)];
  MEMSET(a,0);

  a[0]++;
  ll idx=0;
  FOR(i,1,n-1)
  {
    if(v[i-1]==v[i])a[idx]++;
    else a[++idx]++;
  }

  string ans="No";

  if(SZ(vv)==1)
  {
    if((vv[0]^vv[0]^vv[0])==0)ans="Yes";
  }
  else if(SZ(vv)==2)
  {
    if((vv[1]^vv[0]^vv[1])==0 && vv[0]==0 && a[0]*3==n && a[1]*3==2*n)ans="Yes";
  }
  else if(SZ(vv)==3)
  {
    if((vv[0]^vv[2]^vv[1])==0 && a[0]*3==n && a[1]*3==n && a[2]*3==n)ans="Yes";
  }
  
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
string s;
int p,n;
int bnf1();
int g_A(){
  int r=0;
  if(s[p]=='(')p++,r=bnf1(),p++;
  else
    while(isdigit(s[p])) r=r*10+(s[p++]-'0');
  return r;
}
int bnf2(){
  int res=g_A();
  while(s[p]=='*'||s[p]=='/'){
    int t=p++;
    if(s[t]=='*')res*=g_A();
    if(s[t]=='/')res/=g_A();
  }
  return res;
}
int bnf1(){
  int res=bnf2();
  while(s[p]=='+'||s[p]=='-'){
    int t=p++;
    if(s[t]=='+')res+=bnf2();
    if(s[t]=='-')res-=bnf2();
  }
  return res;
}
int main(){
  cin>>n;
  while(n--){
    cin>>s;
    p=0;
    cout<<bnf1()<<endl;
  }
}

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

typedef long long ll;

int main() {
    int n;
    int w;

    cin >> n >> w;

    vector<ll> weights(n);
    vector<ll> vals(n);
    
    for (int i = 0; i < n; i++)
        cin >> weights[i] >> vals[i];

    vector<ll> dp(w + 1, -1);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = w; j >= 0; j--) {
            ll new_weight = j + weights[i];
            if (new_weight > w || dp[j] == -1)
                continue;

            dp[new_weight] = max(dp[new_weight], dp[j] + vals[i]);
        }
    }

    ll ans = 0;
    for (int i = 0; i <= w; i++)
        ans = max(ans, dp[i]);

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    int X[n];
    REP(i, n) cin >> X[i];
    // 連続するK＝３個の頂点のパターンn＝５
    // i      0   1  2  3  4
    // X[i] -30 -10 10 20 50
    int mi = 1e9;
    for(int left=0; left<=n-k; left++){
        int right = left+k-1;
        int  broad = X[right]-X[left];
        mi = min(mi, min(abs(X[right])+broad, abs(X[left])+broad));
    }
    cout << mi << endl;
    return 0;
}

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

int main(){
  string A ,B ; 
  cin >> A >> B ; 
  
  if(A.size() > B.size()){
    cout << "GREATER" << endl ; 
  }
  else if (A.size() < B.size()){
    cout << "LESS" << endl;
  }
  else{
    for(int i = 0 ; i < A.size() ; i++){
      if(A.at(i) > B.at(i)){
        cout << "GREATER" << endl ; 
        return 0 ; 
      }
      else if(A.at(i) < B.at(i) ){
        cout << "LESS" << endl ; 
        return 0 ; 
      }
    }
    
    cout << "EQUAL" << endl ; 
  }
  
  
}


Measured memory_bytes: 3536
#include<iostream>
#include<set>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define N 100005

int h[N];
int d[N];

int main(){
//    memset(d,0,sizeof(d));
    int n,i,m,ans=0,a,b;
    cin>>n>>m;
    for(i=1;i<=n;i++){
        cin>>h[i];
    }
    for(i=1;i<=m;i++){
        cin>>a>>b;
        if(h[a]<=h[b])
            d[a]=1;
        if(h[a]>=h[b])
            d[b]=1;
    }
    for(i=1;i<=n;i++)
        ans+=!d[i];
        
    cout<<ans;
    return 0;
}


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

using namespace std;
typedef long long LL;

vector<int> a;
int n;
LL p = 998244353;
map<int,LL> dpn[301],dpj[301];
int sum;

LL pow3(int n) { return n ? (pow3(n-1)*3)%p : 1ll; }
LL nlt(int i, int psum) {
  if(psum*2>sum) psum = sum/2 + 1;
  if(dpn[i].count(psum)) return dpn[i][psum];
  if(i==n) {
    if(psum*2>=sum) return 1ll;
    else return 0ll;
  }
  dpn[i][psum] = (nlt(i+1,psum+a[i]) + nlt(i+1,psum) * 2)%p;
  return dpn[i][psum];
}
LL just(int i, int psum) {
  if(psum*2>sum) psum = sum/2 + 1;
  if(dpj[i].count(psum)) return dpj[i][psum];
  if(i==n) {
    if(psum*2==sum) return 1ll;
    else return 0ll;
  }
  dpj[i][psum] = (just(i+1,psum+a[i]) + just(i+1,psum))%p;
  return dpj[i][psum];
}

int main(void) {
  cin >> n;
  a.resize(n);
  for(int &x: a) cin >> x;
  sum = 0;
  for(int x: a) sum += x;
  vector<LL> pat(sum+1,0),pat2(sum+1,0);
  pat[0]=1ll;
  pat2[0]=1ll;
  for(int x: a) for(int i=sum-x;i>=0;--i) {
    pat[i+x] = (pat[i]+pat[i+x])%p;
    pat[i] = (pat[i]+pat[i])%p;
    pat2[i+x] = (pat2[i]+pat2[i+x])%p;
  }
  LL answer = pow3(n);
  for(int i=0;i<=sum;++i) if(i*2>=sum)answer -= pat[i]*3;
  for(int i=0;i<=sum;++i) if(i*2==sum)answer += pat2[i]*3;
  answer %= p;
  answer += p;
  answer %= p;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 1664
while 1:
    N, M = map(int, input().split())
    if N == M == 0:
        break
    ans = ["#"]*N
    for i in range(M):
        a = input()
        if a == 'A':
            for j in range(N):
                if ans[j] == '#':
                    ans[j] = 'A'
                    break
        elif a == 'B':
            for j in range(N-1, -1, -1):
                if ans[j] == '#':
                    if (j == 0 or ans[j-1] != 'A') and (j == N-1 or ans[j+1] != 'A'):
                        ans[j] = 'B'
                        break
            else:
                for j in range(N):
                    if ans[j] == '#':
                        ans[j] = 'B'
                        break
        elif a == 'C':
            if i:
                for j in range(N):
                    if ans[j] != '#':
                        if j < N-1 and ans[j+1] == '#':
                            ans[j+1] = 'C'
                            break
                        if j > 0 and ans[j-1] == '#':
                            ans[j-1] = 'C'
                            break
            else:
                ans[N//2] = 'C'
        else:
            if i:
                d = 0; k = -1
                for j in range(N):
                    if ans[j] == '#':
                        d0 = N
                        p = j
                        while p >= 0 and ans[p] == '#':
                            p -= 1
                        if p >= 0:
                            d0 = min(d0, j-p)
                        q = j
                        while q < N and ans[q] == '#':
                            q += 1
                        if q < N:
                            d0 = min(d0, q-j)
                        if d < d0:
                            k = j; d = d0
                ans[k] = 'D'
            else:
                ans[0] = 'D'
    print(*ans, sep='')



Measured memory_bytes: 5620
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;
int main()
{
	string A, B,U;
	int C, D;
	cin >> A >> B >> C >> D >> U;

	if (U == A) {
		cout << C - 1 << " " << D << endl;
	}
	else {
		cout << C << " " << D-1 << endl;
	}

}

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

int main()
{
  int m,n,i;
  string a,b,c;
  while(1){
    cin >> a;
    if(a=="-") break;
    cin >> m;
    for(i=1;i<=m;i++){
      cin >> n;
      b=a.substr(0,n);
      c=a.erase(0,n);
      a=c+b;
    }
    cout << a << endl;
  }
}

Measured memory_bytes: 1232
def roop(onoff, n):
    swit[n] = onoff
    if n == N-1:
        flag = True
        for i in range(M):
            if flag == False: break
            cur = 0
            for s in range(1,data[i][0]+1):
                cur += swit[data[i][s]-1]
            if cur%2 != p[i]:
                flag = False
                break
        if flag:
            return 1
        else:
            return 0
    else:
        return roop(0,n+1) + roop(1,n+1)
        

N,M = map(int,input().split())
data = [[] for i in range(M)]
for i in range(M): data[i] = list(map(int,input().split()))
p = list(map(int,input().split()))

swit = [0]*N
print(roop(0,0) + roop(1,0))

Measured memory_bytes: 3064
N = int(input())
city2l = {}
for i in range(N):
    s,p = input().split()
    p = int(p)
    if s not in city2l:
        city2l[s]=[]
    city2l[s].append([p,i+1])
l = []
for key in city2l:
    ins = city2l[key]
    ins = sorted(ins, key=lambda x:-x[0])
    for one in ins:
        l.append([key, one[1]])
l = sorted(l, key=lambda x:x[0])
for o in l:
    print(o[1])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <string>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> p(N);
	int max_num = INT_MIN;
	int ret = 0;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		if (p[i] > max_num)
			max_num = p[i];
		ret += p[i];
	}
	ret -= max_num / 2;
	cout << ret;
	return 0;
}

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

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

    int h,w;
    while(cin>>h>>w){
        if(h==0) break;
        int s=h*h+w*w;
        int m=1e9,x=0,y=0;
        for(int i=1;i<=150;i++){
            for(int j=i+1;j<=150;j++){
                if(i==h && j==w) continue;
                int k=i*i+j*j;
                if(k>s && m>k){
                    m=k;
                    x=j,y=i;         
                }
                if(k>s && m==k){
                    if(y>i){
                        y=i,x=j;
                    }
                }
                if(k==s){
                    if(x*x+y*y==s && i>h && y>i){
                        y=i,x=j;
                    }
                    if(x*x+y*y!=s && i>h){
                        m=s;
                        y=i,x=j;
                    }
                }
            }
        }
        cout<<y<<" "<<x<<"\n";
    }
    
}


Measured memory_bytes: 3096
//#include <bits/stdc++.h>
#include <cstdlib> // exit(0)
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <map>
using namespace std;
#define forr(i,m,n) for (int i=(m); i<=(n); i++)
#define forall(it,p) for (auto it = p.begin(); it != p.end(); ++it)
#define DBG 0

#define MAXN 301
int a[MAXN];
double g[MAXN][MAXN][MAXN];

int main() {
  int n;
  int q[4] = {0,0,0,0};
  cin >> n;
  double nd = n;
  double ni = 1.0/n;
  forr(i,0,n-1) {
    cin >> a[i];
    q[a[i]]++;
  }
  string sp = " ";
  if (DBG) cout << "q: " << q[0] << sp << q[1] << sp
                << q[2] << sp << q[3] << endl;
  g[0][0][0] = 0.0;
  forr(k, 1, n)
    g[0][0][k] = g[0][0][k-1] + nd/k;
  forr(j, 1, n)
    forr(k, 0, n-j)
      g[0][j][k] = (nd + j*g[0][j-1][k+1] + k*g[0][j][k-1])
                     / (j+k);
  forr(i, 1, n)
    forr(j, 0, n-i)
      forr(k, 0, n-j-i)
          g[i][j][k] = (nd + i*g[i-1][j+1][k] +
                j*g[i][j-1][k+1] + k*g[i][j][k-1]) / (i+j+k);
  if (DBG) {
    forr(i, 0, n) {
      cout << "i " << i << ")" << endl;
      forr(j, 0, n) {
        cout << "j " << j << ": ";
        forr(k, 0, n)
          cout << g[i][j][k] << " ";
        cout << endl;
      }
    }
  }
  printf("%.11f", g[q[3]][q[2]][q[1]]);

}


Measured memory_bytes: 213248
#include<bits/stdc++.h>
#define mp make_pair
#define ss second
#define ff first
#define ll long long int
#define tcase ll t;cin>>t;while(t--)
#define sz(a) int((a).size())
#define pb push_back
#define present(c,x) (�.find(x) != �.end())
#define cpresent(c,x) (find(all�,x) != �.end())
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define Yes cout<<"Yes\n";
#define No cout<<"No\n";
#define yes cout<<"yes\n";
#define no cout<<"no\n";
#define f(i,a) for(int i=0;i<a;i++)
#define in insert
#define matrix vector<vector<ll> >
#define E endl
#define I(x) cin>>x;
#define O(x) cout<<x;
const ll M=1000000000;

using namespace std;
/*
ll modexpo(ll a,ll b,ll p)
{
    ll ans=1;
      a=a%p  // update a if(a>=p)

        if(a==0)
            return 0;

                while(b!=0)
                {
                    if(b%2==1)
                        ans=(ans*a)%p;

                    a=a*a;
                    b=b/2;

                }
                return ans;
}*/
/*
ll countbit(ll n)
{
    ll c=0;
    while(n!=0)
    {
        c+=n&1;
        n>>=1;
    }
    return c;
}*/



/*  vector<int> prime1;
  int prime[10000001];

void sieve(int n)
{
       for(long long i=2;i<=n;i++)
       {
         if(prime[i]==0)
         {  prime[i]=i;
            prime1.pb(i);
         }

            for(long long j=0;j<sz(prime1) && prime1[j]<=prime[i] && i*prime1[j]<=n;j++)
            {

                   prime[i*prime1[j]]=prime1[j];


            }


      }

 return ;
}*/

void fastio()
{
       ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

}


int main()
{
    fastio();


   int n;
   cin>>n;
   int v[4];
   for(int i=0;i<4;i++)
    v[i]=0;
   string s;
   while(n--)
   {
       cin>>s;
       if(s=="AC")
         v[0]++;
       else if(s=="WA")
        v[1]++;
       else if(s=="TLE")
        v[2]++;
       else
        v[3]++;
   }
   cout<<"AC x "<<v[0]<<E;
   cout<<"WA x "<<v[1]<<E;
   cout<<"TLE x "<<v[2]<<E;
   cout<<"RE x "<<v[3]<<E;
}


Measured memory_bytes: 3660
//17-2 ポイントカード
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#define LL long long
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define ROOP() while(true)
int main(){
    int N,M;
    cin >> N >> M;
    int maxmum = 0;
    int ans = 0;
    for(int i=0; i<M; i++){
        int A,B;
        cin >> A >> B;
        if(B>A){
            ans += (B-A)/2;
            maxmum = max(maxmum,(B-A)/2);
        }
    }
    cout << ans - maxmum << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
using namespace std;

int N,v,j;
void insertionSort(int *list, int size);
void print(int *list, int size);

int main()
{
    scanf("%d", &N);
    int list[N];
    REP(i, N){
      scanf("%d", &list[i]);
    }
    insertionSort(list, N);
    return 0;
}

void insertionSort(int *list, int size)
{
    print(list, size);
    FOR(i, 1, size){
        v = list[i];
        j = i - 1;
        while( j >= 0 && list[j] > v) {
            list[j+1] = list[j];
            j--;
        }
        list[j+1] = v;
        print(list, size);
    }
}

void print(int *list, int size) {
    REP(i, size){
      if (i == size - 1) {
        cout << list[i] << endl;
      } else {
        cout << list[i] << " ";
      }
    }
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a;
  cin >> a;
  char c;
  cin >> c;
  int b;
  cin >> b;
  if(c == '+') cout << a+b << endl;
  else cout << a-b << endl;
  return 0;
}

Measured memory_bytes: 3564