akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<double,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = 998244353;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

ll power(ll x, ll n){
    ll res = 1;
    while(n>0){
        if(n&1) res = res*x%MOD;
        x = x*x%MOD;
        n >>= 1;
    }
    return res;
}

int solve(){
    int n, sum = 0;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    vector<ll> dp(sum+1);  // dp[i]=ある1色の総和がiになる通り数
    dp[0] = 1;
    for(int i=0;i<n;i++){
        for(int j=sum;j>=0;j--){
            if(j+a[i] <= sum){
                dp[j+a[i]] += dp[j] %= MOD;  // その色に塗る
            }
            dp[j] = dp[j]*2;  // 他の2色いずれかに塗る
        }
    }
    ll ng = 0, ans = power(3,n);
    for(int i=(sum+1)/2;i<=sum;i++){
        ng = ng+dp[i]%MOD;
    }
    ans = (ans-ng*3%MOD+MOD)%MOD;
    if(sum%2 == 0){
        fill(dp.begin(), dp.end(), 0);
        dp[0] = 1;
        for(int i=0;i<n;i++){
            for(int j=sum;j>=0;j--){
                if(j+a[i] <= sum){
                    dp[j+a[i]] += dp[j] %= MOD;
                }
            }
        }
        ans = (ans + dp[sum/2]*3) % MOD;
    }
    cout << ans << endl;
    return 0;
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long

char c;

int main(){
	cin>>c;
	cout<<(char)(c+1)<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;

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

  cin >> N;
  if (N%2==1){
    float tmp = N/2;
    cout << (tmp+1)/N << "\n";
  } else {
    cout << 0.5 << "\n";
  }

  return 0;
}

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

int main(){
	int n;
	cin>>n;
	int ans=1;
	for(int i=1;i<=n;i*=2) ans = i;
	cout<<ans<<endl;
	return 0;		
}

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

b = []

t = 0
for aa in a:
    t += aa
    b.append(t)
s = b[-1]

ans = 100000000000000000

if N == 2:
    print(abs(a[0] - a[1]))
    exit()

for i in range(N - 1):
    ans = min(ans, abs(s - 2 *b[i]))

print(ans)


Measured memory_bytes: 24824
""" AtCoder """

w = list(input())

w.sort()

if len(w) % 2 == 1:
    print("No")
    exit()

for i in range(0, len(w)//2 + 1, 2):
    if w[i] != w[i+1]:
        print("No")
        exit()

print("Yes")


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

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

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

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

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

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

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

void printVec(vector<int> &vec) {
    for (auto &e : vec) {
        cout << e << " ";
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) { cin >> a[i]; }
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());

    cout << (a.size() == n ? "YES" : "NO") << endl;

    return 0;
}


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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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; }

int main() {
    string s,t;
    cin >> s >> t;
    
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    
    if ( s < t ) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3560
n = int(input())
stack = [['zzzzzzzzzzz', -1]]
for i in range(n):
    s, p = input().split()
    p = int(p)
    stack.append([s, p])
cnt = {0}
for i in range(len(stack)-1):
    x = 0
    for j in range(1,len(stack)):
        if j in cnt:
            continue
        else:
            if stack[x][0] > stack[j][0]:
                x = j
            elif stack[x][0] == stack[j][0] and stack[x][1] < stack[j][1]:
                x = j
    cnt.add(x)
    print(x)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int n; cin >> n;
    string s; cin >> s;
    int rel = 0;
    REP(i, 1, n){
        int cnt=0;
        for(char c = 'a'; c <= 'z'; c++){
            bool left = false, right = false;
            for(int j = 0; j < i; j++){
                if(s[j] == c) left = true;
            }

            for(int j = i; j < n; j++){
                if(s[j] == c) right = true;
            }

            if(left&&right) cnt++;
        }
        rel = max(rel, cnt);
    }
    cout << rel << endl;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//const int mod=(int)998244353;
const llint big=(llint)(2.19e16)+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
using pli=pair<llint,int>;
using daic=priority_queue<pli,vector<pli>,greater<pli>>;
int main(void){
	int n;cin>>n;
	llint nim=0;
	while(n--){
		llint a,k;cin>>a>>k;
		while(a%k!=0){
			a-=(a/k+1);
			a=(a%k)%(a/k+1) + ((a/k)*k);
		}
		nim^=a/k;
	}
	if(nim==0){cout<<"Aoki"<<endl;}
	else{cout<<"Takahashi"<<endl;}
	RE;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

#define INF 1e9
using vi = vector<int>;

int main(int argc, char* argv[]){
  int v,e,r;
  cin >> v >> e >> r;
  vector< vector< pair<int, int> > > edge(v, vector< pair<int, int> >());
  for(int i = 0; i < e; i++){
    int a,b,c;
    cin >> a >> b >> c;
    edge[a].push_back({c, b});
  }
  vi d(v, INF);
  priority_queue<pair<int,int>, vector<pair<int,int>> , greater< pair<int,int> > > q;
  q.push({0, r});
  d[r] = 0;

  while(!q.empty()){
    pair<int, int> now = q.top(); q.pop();
    if(d[now.second] < now.first) continue;
    for(auto next:edge[now.second]){
      if(d[next.second] > d[now.second] + next.first){
        d[next.second] = d[now.second] + next.first;
        q.push({d[next.second], next.second});
      }
    }
  }
  for(int i = 0; i < v; i++){
    if(d[i] == INF) cout << "INF" << endl;
    else cout << d[i] << endl;
  }
}



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

int main() {
  int N,Q;
  string S;
  int l[100000],r[100000];
  int s[100001]={0};
  cin>>N>>Q>>S;
  for (int i(0);i<Q;i++) cin>>l[i]>>r[i];
  int cnt(0);
  for (int i(1);i<N;i++){
    if (S[i]=='C'&&S[i-1]=='A'){
      cnt+=1;
    }
    s[i+1]=cnt;
  }
  for (int i(0);i<Q;i++){
    int ans=s[r[i]]-s[l[i]-1];
    if (s[l[i]]!=s[l[i]-1]) ans-=1;
    cout <<ans <<endl;
  }
//  for (int i(0);i<N;i++)cout<<s[i]<<" ";
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c,d;
  cin >> a;
  cin >>b;
  cin >>c;
  cin >>d;
  
  
  if(abs(a-c)<=d){
    cout << "Yes" << endl;
  }else if(abs(a-b)<=d&&abs(b-c)<=d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
   return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <map>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a <= b) cout<<a<<endl;
	else cout<<a-1<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    double t=sc.nextDouble();

    int start=1;
    int count=0;

    while(t+0.5>=a*start){

      start++;
      count++;
    }

    System.out.println(count*b);

  }
}


Measured memory_bytes: 23252
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//Weather Forecast
public class Main{

	int[][] cover = {
			{0,1,4,5},
			{1,2,5,6},
			{2,3,6,7},
			{4,5,8,9},
			{5,6,9,10},
			{6,7,10,11},
			{8,9,12,13},
			{9,10,13,14},
			{10,11,14,15}
	};
//	int[][] forbid = {
//			{0},
//			{1},
//			{2},
//			{2},
//			{0,3},
//			{0,1,3,4},
//			{1,2,4,5},
//			{2,5},
//			{2,5},
//			{3,6},
//			{3,4,6,7},
//			{4,5,7,8},
//			{5,8},
//			{5,8},
//			{6},
//			{6,7},
//			{7,8},
//			{8},
//			{8}
//	};
	int move[][] = {
			{0,1,2,3,6},
			{0,1,2,4,7},
			{0,1,2,5,8},
			{0,3,4,5,6},
			{1,3,4,5,7},
			{2,3,4,5,8},
			{0,3,6,7,8},
			{1,4,6,7,8},
			{2,5,6,7,8}
	};
	
	long trans(int[] a){
		String s = "";
		for(int x:a)s+=x;
		return Long.parseLong(s);
	}
	
	int n;
	boolean sun[][];
	Set<Long>[][] set;
	
	//xツ禿コツづ可雲ツつェposツづ可仰渉づづヲツつ「ツつゥ
	boolean ok(int x, int pos){
		for(int i=0;i<4;i++)if(sun[x][cover[pos][i]])return false;
		return true;
	}
	
	boolean get(int x, int pos, int[] a){
		if(x==n)return true;
		if(set[x][pos].contains(trans(a)))return false;
		if(!ok(x, pos)){
			set[x][pos].add(trans(a));return false;
		}
		for(int j=0;j<5;j++){
			int[] t = new int[16];
			for(int i=0;i<16;i++)t[i]=a[i]-1;
			int nx = move[pos][j];
			for(int i=0;i<4;i++)t[cover[nx][i]] = 6;
			boolean f = true;
			for(int i=0;i<16;i++)if(t[i]<0)f = false;
			if(!f)continue;
			if(get(x+1, nx, t))return true;
		}
		set[x][pos].add(trans(a));
		return false;
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt();
			if(n==0)break;
			sun = new boolean[n][16];
			for(int i=0;i<n;i++)for(int j=0;j<16;j++)sun[i][j] = sc.nextInt()==1;
			set = new HashSet[n][9];
			for(int i=0;i<n;i++)for(int j=0;j<9;j++)set[i][j] = new HashSet<Long>();
			int[] a = new int[16];
			Arrays.fill(a, 5);
			if(!ok(0, 4)){
				System.out.println(0);continue;
			}
			for(int j=0;j<4;j++)a[cover[4][j]] = 6;
			System.out.println(get(0, 4, a)?1:0);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 23000
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

struct edge{int from,to;ll cost;};

vector<edge> e;
vll d(2550);
int v;
bool MAX=true;

void bellman(int s){
    fill(all(d),-INF);
    d[s]=(ll)0;
    bool update,maxupdate;
    rep(i,2*v+5){
        update=false;maxupdate=false;
        for(auto hen:e){
            if(d[hen.from]!=-INF&&d[hen.to]<d[hen.from]+hen.cost){
                d[hen.to]=(i<v-1)?d[hen.from]+hen.cost:2*INF;
                update=true;
                //if(hen.to==v)maxupdate=true;
            }
        }
        if(!update)break;
        /*if(i>=v&&maxupdate){
            MAX=false;
            break;
        }*/
    }
}

int main(){
    int n,m;ll p;cin>>n>>m>>p;
    v=n;
    vin a(m),b(m);vll c(m);
    rep(i,m){
        cin>>a[i]>>b[i]>>c[i];
        c[i]-=p;
        e.push_back((edge){a[i],b[i],c[i]});
    }
    bellman(1);
    if(d[n]!=2*INF)cout<<max(d[n],(ll)0)<<endl;
    else cout<<-1<<endl;
}

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

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n, m;
  int mass[10][10];
  while(true){
    cin >> n >> m;
    if(n == 0 && m == 0) break;

    REP(i,n){
      REP(j,m){
        cin >> mass[i][j];
      }
    }

    llong ans = 0;
    REP(y1,n){
      for(int y2 = y1+1; y2 < n; ++y2){
        REP(x1,m){
          for(int x2 = x1+1; x2 < m; ++x2){
            
            int mx = INF;
            for(int i = y1; i <= y2; ++i){
              mx = min({mx, mass[i][x1], mass[i][x2]});
            }
            for(int i = x1; i <= x2; ++i){
              mx = min({mx, mass[y1][i], mass[y2][i]});
            }

            llong sum = 0;
            bool pond = true;
            for(int i = x1+1; i < x2; ++i){
              for(int j = y1+1; j < y2; ++j){
                if(mass[j][i] >= mx){
                  pond = false;
                  break;
                }
                sum += mx - mass[j][i];
              }
              if(!pond){
                break;
              }
            }

            if(pond){
              ans = max(ans, sum);
            }

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



Measured memory_bytes: 3028
S = input()
l = int(S[:2])
r = int(S[2:])
a = 0
ans = ['NA', 'MMYY', 'YYMM', 'AMBIGUOUS']
if 0 < l and l < 13:
  a += 1
if 0 < r and r < 13:
  a += 2
print(ans[a])

Measured memory_bytes: 9136
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

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

    vector<vector<int>> edges_list(n, vector<int>());
    FOR(i, 0, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges_list[a].push_back(b);
        edges_list[b].push_back(a);
    }

    vector<int> color(n, 0);
    vector<int> nokori(n, -1);
    int q;
    cin >> q;

    vector<int> vq(q), dq(q), cq(q);
    FOR(i, 0, q) {
        int v, d, c;
        cin >> v >> d >> c;
        v--;
        vq[i] = v, dq[i] = d, cq[i] = c;
    }

    RFOR(i, q - 1, 0) {
        int v = vq[i], d = dq[i], c = cq[i];
        vector<bool> visited(n, false);
        queue<pair<int, int>> q;
        q.push(make_pair(v, 0));
        int cnt = 0;
        while (!q.empty()) {
            auto t = q.front();
            int node = t.first, cnt = t.second;
            q.pop();

            if (color[node] != 0 && nokori[node] >= d - cnt)
                continue;
            visited[node] = true;
            if (color[node] == 0)
                color[node] = c;
            nokori[node] = d - cnt;
            if (cnt == d)
                continue;
            for (int edge : edges_list[node]) {
                if (!visited[edge])
                    q.push(make_pair(edge, cnt + 1));
            }
        }
    }
    FOR(i, 0, n) {
        printf("%d\n", color[i]);
    }

    return 0;
}

Measured memory_bytes: 8952
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int X, t;
    cin >> X >> t;
    cout << max(X - t, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

long long gcd(int a, int b) {
	if (a == 0) return b;
	return gcd(b % a, a);
}

int main()
{
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long cc = b / c - (a / c + (a % c!=0)) + 1;
	long long dc = b / d - (a / d + (a % d!=0)) + 1;
	long long cd = c * d / gcd(c,d);
	long long cdc = b / cd - (a / cd + (a % cd!=0)) + 1;
	long long ans = (b - a + 1) - (cc + dc - cdc);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

static unsigned long long f
(
    int p,
    unsigned long long s,
    unsigned long long s2,
    int n
)
{
    return s2 - 2 * s * p + p * p * n;
}

int main() {
    unsigned long long s = 0, s2 = 0;
    int n;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        s += x;
        s2 += x * x;
    }
    int P = s / n;
    std::cout << std::min(f(P, s, s2, n), f(P+1, s, s2, n)) << std::endl;
    return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b;
  cin >> n >> a >> b;
  if ((b - a) % 2 == 0) {
    cout << "Alice" << endl;
  } else {
    cout << "Borys" << endl;
  }
  return 0;
}


Measured memory_bytes: 892
s=int(input())

def collatz(n):
    if n%2==0:
        return int(n/2)
    else:
        return 3*n + 1

d={}
for i in range(10000001):
    d[i]=0

now =s
d[now]=1
num =1
while True:

    now = collatz(now)
    num +=1

    if d[now]!=0:
        print(num)
        exit(0)
    else:
        d[now]+=1


Measured memory_bytes: 770388
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    string s="CODEFESTIVAL2016";
    string t;
    cin>>t;
    int cnt=0;
    rep(i,16){
        if(s[i]!=t[i]) cnt++;
    }
    cout<<cnt<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n,sum=0;
	string s;
	cin>>n;
	cin>>s;
	for(int i=0;i<n-2;i++)
	{
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(){
  int M[N][N];
  int n,u,k,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;

  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2052
#include <cmath>
#include <iostream>
#include <map>
#include <string>
using namespace std;
map<string, int> mp;
int main(void)
{
    int ans = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        string t;
        cin >> t;
        mp[t]++;
    }
    for (map<string, int>::iterator it = mp.begin(); it != mp.end(); it++)
    {
        ans++;
    }
    cout << ans;
}


Measured memory_bytes: 19176
#include <iostream>

int main()
{
	int a, b;
	std::cin >> a >> b;
	if (a>b) std::cout << "a > b" << std::endl;
	else if (a<b) std::cout << "a < b" << std::endl;
	else std::cout << "a == b" << std::endl;
	return 0;
}



Measured memory_bytes: 3092
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

template <class A, class B> inline int Max(const A &a, const B &b){ return (a < b ? b : a); }
template <class A, class B> inline int Min(const A &a, const B &b){ return (a > b ? b : a); }

int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<int> cnt(n+1);

    rep(i,n-1){
        int a;
        cin >> a;
        ++cnt[a];
    }

    reps(i,n){
        cout << cnt[i] << '\n';
    }

    return 0;
}


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

int main() {
  vector<int> vec(4);
	for (int i = 0; i < 4; i++) {
  	cin >> vec.at(i);
	}
  if(
  (count(vec.begin(),vec.end(),1) == 1) &&
  (count(vec.begin(),vec.end(),9) == 1) &&
  (count(vec.begin(),vec.end(),7) == 1) &&
  (count(vec.begin(),vec.end(),4) == 1)
    ){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
xl = [list(map(int, input().split())) for i in range(n)]
l = [[i[0] + i[1], i[0] - i[1]] for i in xl]
l.sort(key=lambda x:x[0])
ans = 0
m = 10 ** 9 * -1
for i in range(n):
    if m <= l[i][1]:
        ans += 1
        m = l[i][0]
print(ans)

Measured memory_bytes: 42792
#include <iostream> 
#include <math.h>
using namespace std; 

int main(void) { 
	int A[1000000];
	for(int i = 0; i < 1000000; i++){
		A[i] = 1;
	}
	A[0] = A[1] = 0;
	for(int i = 2; i < sqrt(1000000); i++){
	    if(A[i] == 1){
    		for(int j = 2; i * j < 1000000; j++){
                	A[i * j] = 0;
		    }
	    }
	}
	int n;
	while(cin >> n){ 
		int COUNT = 0;
		for(int i = 1; i <= n; i++){
            COUNT += A[i];
		}
		cout << COUNT << endl;
	}
	return 0; 
} 


Measured memory_bytes: 6988
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
 long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
ll bionomial(ll n , ll r){
	
	ll res = 1 ;
	for (ll i =  0 ; i<r;i++){
		res *= (n-i) ;
		res %= MOD ;
	}
	return res ;
}
void solve()
{
	int n ; 
	cin>>n ; 
	bool ok = true ;
	rep(i , n){
		int a ;
		cin>>a ;
		ok &= (a%2==0 ? ((a%3==0 || a%5==0) ? true : false) : true) ;
	}
	if(ok){
		cout<<"APPROVED";
	}
	else{
		cout<<"DENIED";
	}
}
 
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

int main(void){
    int a, b;
    std::cin >> a >> b;
    
    int d = a / b;
    int r = a % b;
    double f = (double)a / b;
    printf("%d %d %.05lf\n", d, r, f);
    return 0;
}


Measured memory_bytes: 3220
/* Filename: AGC021A.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNext()){
			String N = input.next();
			int digitSumN = N.charAt(0) - '0';
			
			for(int i = 1; i < N.length(); ++i){
				if(N.charAt(i) == '9'){
					digitSumN += 9;
				} else {
					break;
				}
			}
			
			int maxDigitSum = Math.max(digitSumN, N.charAt(0) - '0' - 1 + (N.length() - 1) * 9);
			
			System.out.println(maxDigitSum);
		}
	}
}

Measured memory_bytes: 20948
<?php 
$n = fgets(STDIN);
$a_l = explode(" ", trim(fgets(STDIN)) );

$sum = 0;
$now_height = $a_l[0];

for($i=1;$i<$n; $i++){
    if($now_height > $a_l[$i]){
        $sub = $now_height - $a_l[$i];
        $sum += $sub;
    } else {
        $now_height = $a_l[$i];
    }
}

print $sum;

Measured memory_bytes: 32176
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, m;
    cin >> n >> m;
    vec k(n);
    mat a(n);
    rep(i, n) {
        cin >> k[i];
        a[i].resize(k[i]);
        rep(j, k[i]) {
            cin >> a[i][j];
        }
    }

    vec flag(m, 0);

    rep(i, n) {
        rep(j, k[i]) {
            flag[a[i][j]-1]++;
        }
    }

    int res = 0;
    rep(i, m) if (flag[i] == n) res++;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيمِ
//لا إله إلا الله محمد رسول الله

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")

#define ll long long
#define pb push_back
#define fr first
#define sc second
#define in freopen("input.txt", "r" , stdin)
#define out freopen("snakes.out", "w", stdout)
using namespace std;

ll dp[100005][5];
ll n;
ll a[100005], b[100005], c[100005];
int main(){
    //in;
    //out;
    ios_base::sync_with_stdio(false);
    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    dp[1][1] = a[1];
    dp[1][2] = b[1];
    dp[1][3] = c[1];

    for (int i = 2; i <= n; i++) {
        dp[i][1] = max (dp[i-1][2], dp[i-1][3]) + a[i];
        dp[i][2] = max (dp[i-1][1], dp[i-1][3]) + b[i];
        dp[i][3] = max (dp[i-1][1], dp[i-1][2]) + c[i];
    }

    cout << max (dp[n][1], max (dp[n][2] , dp[n][3]));


}




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

int main() {
	long long n;
	cin >> n;
	int cnt = 0;
	int BASE = 26LL;
	char ans[12] = {};
	while (0 < n)  {
		n--;
		ans[cnt] = 'a' + n % BASE;
		cnt++;
		n /= BASE;
	}

	for(int i= 0; i < cnt; i++) {
		cout << ans[cnt-i-1];
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(v) ((ll)v.size())
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define F first
#define S second
#define pii pair<ll,ll> 
const ll mod = 1000000007;
const ll mod1= 1000000009;
const ll base= 2323233;
const ll base1=3424424;
#define MAXN 2000004
#define trace1(x)                cerr << #x << ": " << x << "\n";
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";
ll a[3000002];
bool cmp(const pair<pii,ll> &x,const pair<pii,ll> &y){
  if(x.F.F==y.F.F) return x.F.S>y.F.S;
  return x.F.F<y.F.F;
}
ll L[100002][2], R[100002][2];
int main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   ll n,i;
   cin>>n;
   multiset<ll> s;
   for(i=1;i<=(1<<n);i++) {
    cin>>a[i];
    s.insert(-a[i]);
   }
   sort(a+1,a+1+(1<<n));
   reverse(a+1,a+1+(1<<n));
   vector<ll> v;
   v.pb(a[1]);
   s.erase(s.find(-a[1]));
   while(v.size()<(1<<n)){
    ll nn=v.size();
    for(i=0;i<nn;i++){
      auto it=s.upper_bound(-v[i]);
       if(it==s.end()){
        cout<<"No";
        return 0;
       }
      s.erase(it);
      v.pb(-(*it));
    }
   }
   cout<<"Yes";
 }


Measured memory_bytes: 18804
while True:
    n = int(input())
    if n == 0:
        break
    z = sorted([tuple(map(int, input().split())) for _ in range(n)],  key=lambda x: x[1])
    cnt = total = 0
    for a, b in z:
        total += a
        if total > b:
            break
        cnt += 1
    print("Yes" if cnt == n else "No")

Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,k,sum=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a;
        b=k-a;
        sum+=min(a*2,b*2);
    }
    cout<<sum<<endl;

    return 0;
}


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

int main()
{
    std::string N;
    std::cin >> N;

    if(N[0] == '7' || N[1] == '7' || N[2] == '7')
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int m, d, cnt;
void solve();
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> m >> d;
	solve();
	return 0;
}
void solve()
{
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= d; j++)
		{
			int a = j / 10;
			int b = j % 10;
			if (i == a * b && a != 1 && b != 1)
			{
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	private static int MixJuice(int[] arr, int n, int k) {
		
		Arrays.sort(arr);
		int sum=0;
		for(int i=0;i<k;i++)
		{
			sum+=arr[i];
		}
		return sum;
	}

	public static void main(String[] args) {
			Scanner s= new Scanner(System.in);
//		  char s1= s.next().charAt(0);
//		  
//		  if(s1 >='A' && s1 <= 'Z')
//		    System.out.println("A");
//		   else
//		  	System.out.println("a");
		  
		  int n = s.nextInt();
		  int k=s.nextInt();
		  int[] arr = new int[n];
		  for(int i=0;i<arr.length;i++)
		  {
			  arr[i]=s.nextInt();
		  }
		  
		  int result=MixJuice(arr,n,k);
		  System.out.println(result);
	}

	

}


Measured memory_bytes: 38460
#include<stdio.h>
int max(int a,int b){return a > b ? a : b;}
int main(){
    int h, n, w;
    scanf("%d%d%d",&h,&w,&n);
    int p = max(h, w);
    printf("%d\n",(n + p - 1) / p);
    return 0;
}

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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul n;
  cin >> n;
  vector< ul > a(n);
  ul t=0, t2=0;
  ul cnt=0;
  for (ul i=0; i<n; ++i) {
    cin >> a[i];
    if (t==a[i]) cnt++;
    else if (a[i]>t) {
      t2=t;
      t=a[i];
      cnt=1;
    } else if (a[i]>t2) {
      t2=a[i];
    }
  }
  for (ul i=0; i<n; ++i) {
    cout << (t==a[i]&&cnt==1 ? t2 : t) << endl;
  }
  return 0;
}


Measured memory_bytes: 3200
def half(n):
	return n/2
def half_mod(n):
	return n%2

N = int(input())
A = list(map(int, input().split()))
zero = [0] * N
count = 0

while list(map(half_mod, A)) == zero:
	count += 1
	A = list(map(half, A))
      
print(count)

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

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

#define MY_PATH(i,j)  ( ( ((unsigned long long)1) << i*8+j ) | ( ((unsigned long long)1) << j+8+i) )



int SearchPath(int depth,int path[8][8],int N,int M,int i){
    int cnt=0;
    static int Visited[8]={};

    //printf("%d ",i+1);

    if(depth==N-1){
        //puts("*");
        return 1;
    }
    for(int j=0;j<N;j++){
        if(path[i][j] && Visited[j]==0){
            Visited[i]=1;
            cnt += SearchPath(depth+1,path,N, M-1,j);
            Visited[i]=0;
        }
    }
    return cnt;
}


int main(void){
    int N,M;
    int path[8][8]={};
    
    scanf("%d %d%*c",&N,&M);
    for(int i=0;i<M;i++){
        int a,b;
        
        scanf("%d %d%*c",&a,&b);
        path[a-1][b-1]=path[b-1][a-1]=1;
    }
    printf("%d\n",SearchPath(0,path,N,M,0));

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	int time = A + B;

	if (time >= 24) {
		cout << time - 24 << endl;
	}
	else {
		cout << time << endl;
	}


}


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

using namespace std;

const int MAX = 101;
typedef long long ll;
int N;
ll dp[MAX][21];
vector<int> V;

void print(){
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 21; j++)
      cout << dp[i][j] << " ";
    cout << endl;
  }
}

void solve(){
  dp[1][V[0]] = 1;

  for(int i = 1; i < V.size()-1; i++){
    for(int j = 0; j < 21; j++){
      int next = j+V[i];
      if(0 <= next && next <= 20) dp[i+1][next] += dp[i][j];
      next = j-V[i];
      if(0 <= next && next <= 20) dp[i+1][next] += dp[i][j];
    }
  }
  //print();
   cout << dp[N-1][V.back()] << endl;
}

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    int in;
    cin >> in;
    V.push_back(in);
  }
  solve();
  return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int bubbleSort(int A[],int n)
{
    int ret = 0;
    bool flg = true;
    int i = 0;
    while(flg){
        flg = false;
        for(int j = n-1;j >= i+1;j--){
            if(A[j] < A[j-1]){
                swap(A[j],A[j-1]);
                ret ++;
                flg = true;
            }
        }
        i++;
    }
    return ret;
}
int main()
{
    int n;
    cin >> n;
    int A[100];
    for(int i=0;i<n;i++)
        cin >> A[i];
    int ret = bubbleSort(A,n);
    for(int i=0;i<n;i++){
        if(i>0)
            cout << ' ';
        cout << A[i];
    }
    cout << endl;
    cout << ret << endl;
}



Measured memory_bytes: 3076
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  string S;
  while (cin >> S) {
    bool res = true;
    for (int i = 0; i < S.size(); i++) {
      char c = S[i];
      if (i % 2 == 0) {
        res &= (c != 'L');
      } else {
        res &= (c != 'R');
      }
    }
    cout << (res ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n=input()
s=[raw_input() for i in range(n)]
t=[]
for i in range(n):
	t+=[s[j][i] for j in xrange(n)]*2
s+=s
s=''.join(s)
#print s
t=''.join(t)
#print t
result=0
for shift in xrange(n):
	ok=True
	for i in xrange(n):
		if s[(i+shift)*n: (i+shift)*n+n]!=t[i*n*2+shift: i*n*2+shift+n]:
			ok=False
			break
	if ok:
		result+=n
print result

Measured memory_bytes: 4576
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h,w,k,ans=0;
    cin >> h >>w >>k;
    vector<vector<char>> c (h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >>c.at(i).at(j);
        }
    }
    for(int bith=0;bith <(1<<h);bith++){
        for(int bitw=0;bitw<(1<<w);bitw++){
            int res=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(bith&(1<<i) && bitw&(1<<j)&&c.at(i).at(j)=='#'){
                        res++;
                    }
                }
            }
            if(res==k) ans++;
        }
    }
    
    cout <<ans;
}


Measured memory_bytes: 3612
main(a,b,c,d,e,f,x,i){
  for(i=0;i<3;i++){
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    x=(d*3600+e*60+f)-(a*3600+b*60+c);
    printf("%d %d %d\n",x/3600,x/60%60,x%60);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string a,b,c;cin>>a>>b>>c;
  if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){
    P("YES");
  }else{
    P("NO");
  }
  return 0;
}


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

int main() {
	string s;
	cin >> s;
	
	string ret = "Good";
	for (int i = 0; i < s.length(); i++){
		if (s[i] == s[i+1]) ret = "Bad";
	}

	cout << ret << endl;
}

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

int main() {
    int n; cin >> n;
    vector<long long> v(3*n);
    for (int i = 0; i < 3*n; i++) {
        cin >> v[i];
    }

    sort(v.begin(), v.end(), greater<int>());
    long long sum = 0;
    //大きい順から数え奇数番目の項（0スタート）をn個集めてその和を取ったものが答え
    for (int i = 0; i < 2*n; i++) {
        //奇数番目の項を足していく
        if (i%2 == 1) {
            sum += v[i];
        }
    }

    cout << sum << endl;

   return 0;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    LL x=100,n;
    cin>>n;
    LL cnt=0;
    while(x<n)
    {
        cnt++;
        x+=x/100;
    }
    cout<<cnt;

}


Measured memory_bytes: 3608
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=100000;
int x[N+5],y[N+5],c[N+5];
int y1[N],n,k,Max,cnt;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		char ch;
		scanf("%d %d %c",&x[i],&y[i],&ch);
		x[i]%=(2*k);
		y[i]%=(2*k);
		if(ch=='W')
			c[i]=1;
	}
	for(int i=0;i<=k;i++)
	{
		cnt=0;
		fill(y1,y1+2*k+1,0);
		for(int j=1;j<=n;j++)
		{
			bool p=(i<=x[j]&&x[j]<i+k);
			bool q=(0<=y[j]&&y[j]<k);
			if(p^q==c[j])
				cnt++,y1[y[j]]++;
			else
				y1[y[j]]--;
		}
		for(int j=0;j<=k;j++)
		{
			Max=max(Max,max(cnt,n-cnt));
			if(j!=k)
				cnt=cnt-y1[j]-y1[k+j];
		}
	}
	printf("%d\n",Max);
}


Measured memory_bytes: 1280