akhauriyash/Code-Regression huggingface dataset:
//




#include <bits/stdc++.h>
using namespace std;


#define spdio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pp pop_back()
#define pf push_front
#define ppf pop_front()
#define ff first
#define ss second
#define mp make_pair
#define fr(i,j,n) for(ll i=j; i<n; i++)
#define rfr(i,j,n) for(ll i=n-1; i>=j; i--)
#define pll pair<ll,ll>
#define plb pair<ll,bool>
#define psl pair<string,ll>
#define psb pair<string,bool>
#define srt(v) sort((v).begin(),(v).end())
#define ub(v,val) upper_bound((v).begin(),(v).end(),(val))-(v).begin()
#define lb(v,val) lower_bound((v).begin(),(v).end(),(val))-(v).begin()


typedef long double ld;
typedef long long int ll;


//getline(cin,string);
const ll inf = (ll) 1e18 + 19;
const ll mod = (ll) 1e9  +  7;




ll func(vector <vector <char> > &v,ll n,ll m,ll i,ll j,vector <vector <ll> > &dp) {
    if(i>=n || j>=m) return 0;
    if(v[i][j]=='#') return 0;
    if(dp[i][j]!=-1) return dp[i][j]%mod;
    if(i==n-1 && j==m-1) {
        dp[i][j]=1;
        return dp[i][j];
    }
    return dp[i][j]=(func(v,n,m,i+1,j,dp)+func(v,n,m,i,j+1,dp))%mod;
}




void cazz() {
    ll t=1,i=0,j,n;
    //cin>>t;
    while(t--) {
        ll m;
        cin>>n>>m;
        vector <vector <char> > v(n,vector <char> (m));
        fr(i,0,n)
            fr(j,0,m)
                cin>>v[i][j];
        vector <vector <ll> > dp(n,vector <ll> (m,-1));
        cout<<func(v,n,m,0,0,dp)%mod<<"\n";
    }
}




int main() {
    spdio;
	cazz();
	return 0;
}


Measured memory_bytes: 12140
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int N; cin >> N;
  int cnt = 25-N;
  cout << "Christmas";
  while(cnt-- > 0) {
    cout << " Eve";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795

#define fill(x, v)  fillchar(x, v, sizeof(x))
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector< pii >   vpii;

#define MAXN 16
#define MAXM (1 << MAXN)
int n, M;
ll  s[MAXM];
ll  f[MAXM];
int a[MAXN][MAXN];

int main() {
    scanf("%i", &n);
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j) scanf("%i", &a[i][j]);

    M = 1 << n;

    for(int m = 0; m < M; ++m)
        for(int i = 0; i < n; ++i) if ((m >> i) & 1)
            for(int j = i; j < n; ++j) if ((m >> j) & 1) {
                s[m] += a[i][j];
            }

    for(int m = 0; m < M; ++m) {
        ll q = s[m];
        for(int t = (m - 1) & m; t; t = (t - 1) & m)
            q = max(q, f[t] + f[m ^ t]);
        f[m] = q;
    }

    printf("%lld\n", f[M - 1]);
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1005;
int n,k;
LL a[N];
vector <LL> v;
bool check(LL x){
	int tot=0;
	for (auto y : v)
		if ((y&x)==x)
			tot++;
	return tot>=k;
}
int main(){
	cin >> n >> k;
	for (int i=1;i<=n;i++)
		cin >> a[i];
	for (int i=1;i<=n;i++)
		a[i]+=a[i-1];
	v.clear();
	for (int i=1;i<=n;i++)
		for (int j=i;j<=n;j++)
			v.push_back(a[j]-a[i-1]);
	sort(v.begin(),v.end());
	LL ans=0;
	for (int i=40;i>=0;i--)
		if (check(ans|(1LL<<i)))	
			ans|=1LL<<i;
	cout << ans;
	return 0;
}

Measured memory_bytes: 6128
import java.util.*;

public class Main {

    static final int INF = Integer.MAX_VALUE;

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

        List<List<Integer>> out = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            out.add(new ArrayList<>());
        }

        for (int i = 0; i < N; i++) {
            String S = sc.next();
            for (int j = 0; j < N; j++) {
                if (S.charAt(j) == '1') out.get(i).add(j);
            }
        }


        boolean[] visited = new boolean[N];
        int sol = 0;
        for (int i = 0; i < N; i++) {
            if (!visited[i]) {
                Set<Integer> component = component(i, out);
                for (int u : component) visited[u] = true;
                int best = 0;
                for (int u : component) {
                    int longest = bfs(u, out);
                    if (longest == -1) {
                        System.out.println(-1);
                        return;
                    }
                    best = Math.max(longest, best);
                }
                sol += best + 1;
            }
        }

        System.out.println(sol);
    }


    static Set<Integer> component(int s, List<List<Integer>> out) {
        Set<Integer> component = new HashSet<>();
        component.add(s);
        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(s);

        while (!deque.isEmpty()) {
            int u = deque.pollLast();

            for (int v : out.get(u)) {
                if (!component.contains(v)) {
                    component.add(v);
                    deque.addFirst(v);
                }
            }
        }

        return component;
    }

    static int bfs(int s, List<List<Integer>> out) {
        int[] dist = new int[out.size()];
        Arrays.fill(dist, INF);
        dist[s] = 0;
        Deque<Integer> deque = new ArrayDeque<>();
        deque.add(s);

        while (!deque.isEmpty()) {
            int u = deque.pollLast();
            for (int v : out.get(u)) {
                if (dist[v] < INF && dist[v] % 2 == dist[u] % 2) return -1;
                if (dist[v] < INF) continue;
                dist[v] = dist[u] + 1;
                deque.addFirst(v);
            }
        }

        int longest = 0;
        for (int d : dist) {
            if (d < INF) longest = Math.max(d, longest);
        }

        return longest;
    }
}

Measured memory_bytes: 29620
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int  LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int main(){
	LL n,m;
	cin>>n>>m;
	
	priority_queue<LL> que;
	for(int i=0;i<n;i++)
	{
		LL x;cin>>x;que.push(x);
	}
	for(int i=0;i<m;i++)
	{
		LL y=que.top();
		que.pop();
		que.push(y/2);
	}
	
	LL ans=0;
	for(int i=0;i<n;i++)
	{
		ans+=que.top();
		que.pop();
	}
	cout<<ans<<"\n";
	return 0;
}

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(S[i] != S[i-1]) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
l = input()
MOD = 10**9 + 7
lower = {0: 1}
equal = {0: 2}


for i, d in enumerate(l):
    if i == 0:
        continue
    if d == "1":
        lower[i] = (3 * lower[i - 1] + equal[i - 1]) % MOD
        equal[i] = (2 * equal[i - 1]) % MOD
    else:
        lower[i] = (3 * lower[i - 1]) % MOD
        equal[i] = equal[i - 1] % MOD

print((lower[len(l) - 1] + equal[len(l) - 1]) % MOD)


Measured memory_bytes: 26836
import java.util.Scanner;

public class Main {

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

        final int n = sc.nextInt();
        final int a = sc.nextInt();
        final int b = sc.nextInt();

        System.out.println(Math.min(n*a, b));
    }
}


Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC067A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b,ab;
			string[] word = Console.ReadLine().Split(' ');
			a = int.Parse(word[0]);
            b = int.Parse(word[1]);

            ab = a + b;
            if (a == 0 || b == 0)
                Console.WriteLine("Impossible");
            else if (a % 3 == 0 || b % 3 == 0 || ab % 3 == 0)
                Console.WriteLine("Possible");
            else
                Console.WriteLine("Impossible");
		}
	}
}

Measured memory_bytes: 27536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define IT ::iterator
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);


int main()
{
	ll n,k,i;
	lsc(n);lsc(k);
	string s;
	cin >> s;
	ll happy=0LL;
	rep1(i,n-1)
	{
		if(s[i]==s[i-1])
		{
			happy++;
		}
	}
	cout << min(n-1,(happy+(2LL*k)));
    return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  map<long long,long long>mp;
  for(int X=0;X<N;X++){
    long long A;cin>>A;
    mp[A]++;
  }
  int M=0;
  for(auto p:mp){
    auto value=p.second;
    if(value%2==1){
      M++;
    }
  }
  cout<<M<<endl;
}


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

int main(){
  string S,out;
  cin >> S;
  out = "Yes";

  for(int i=0; i<S.length();i+=2){
    if(S.substr(i,1)=="L"){
      out = "No";
    }
  }

  for(int i=1; i<S.length(); i+=2){
    if(S.substr(i,1)=="R"){
      out = "No";
    }
  }
  cout << out;
}

Measured memory_bytes: 256
S=input()
A=S[0:int((len(S)-1)/2)]
B=S[int((len(S)+3)/2):-1]
def kaibun(s):
    a,b="",""
    for i in range(len(s)):
        a = a+s[i]
        b = s[i]+b
    return a==b
print('Yes' if (kaibun(S) and kaibun(A) and kaibun(B)) else 'No')

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  if (N * A < B){
    cout << N * A << endl;
  }
  else if (N * A > B){
    cout << B << endl;
  }
  else {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b, c;
    cin >> a >> b >> c ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    //*/
    
    /*
    if( a == b ){
        cout << a + b << endl;
    } else {
        cout << max(a, b) * 2 - 1 << endl;
    }
    //*/
    
    cout << c / a * b << endl;

    return 0; 
}


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

int main()
{
    int K, S;
    cin >> K >> S;
    int counter = 0;
    for (int i = 0; i <= K; i++)
    {
        for (int j = i; j <= K; j++)
        {
            for (int k = j; k <= K; k++)
            {
                if ((i + j + k) == S)
                {
                    if (i != j && j != k && k != i)
                        counter += 6;
                    else if (i == j && j != k)
                        counter += 3;
                    else if (i != j && j == k)
                        counter += 3;
                    else
                        counter++;
                }
            }
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
# coding: utf-8;

def main():
    s = input()
    unbalance = True

    if len(s) == 2 and s[0:1] == s[1:2]:
        unbalance = False
        print(1, 2)
    else:
        for i in range(len(s) - 2):
            if s[i:i+1] == s[i+1:i+2] or s[i+1:i+2] == s[i+2:i+3] or s[i:i+1] == s[i+2:i+3]:
                unbalance = False
                print(i+1, i+3)
                break

    if unbalance: print(-1, -1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 3e5 + 9;
const ll mod = 1e9 + 7;
typedef pair<ll,ll> LL;

ll n,ans;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>n;
    ans += (n/500) * 1000; n %= 500;
    ans += (n/5) * 5;
    cout<<ans;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int m;
    cin >> m;
    cout << 48-m << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
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; }

struct edge { int to; int cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int dp[1010][1<<12];

int main(){
	int n,m;
	cin >> n >> m;
	vi a(m),b(m),c[m];
	for(int i = 0; i < m; i++){
		cin >> a[i] >> b[i];
		for(int j = 0; j < b[i]; j++){
			int ct;
			cin >> ct;
			c[i].push_back(ct);
		}
	}

	rep(i,1010) rep(j,1<<n) dp[i][j] = INF;
	dp[0][0] = 0;

	for(int i = 0; i < m; i++){
		for(int j = 0; j < 1<<n; j++){
			int mask = j;
			for(auto k : c[i]) mask |= 1<<(k-1);
			dp[i+1][j] = min(dp[i+1][j],dp[i][j]); // i番目の鍵を取らない
			dp[i+1][mask] = min(dp[i+1][mask],dp[i][j]+a[i]); // i番目の鍵を取る
		}
	}
	cout << (dp[m][(1<<n)-1] == INF ? -1 : dp[m][(1<<n)-1]) << endl;

	/*for(int i = 0; i <= m; i++){
		for(int j = 0; j < 1<<n; j++){
			if(dp[i][j] == INF) cout << "x";
			else cout << dp[i][j];
		}
		cout << endl;
	}*/
	
	return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 25;
const ll INFL = 1223372036854775807;
const ll mod = 1000000007;

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}


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

	int n = gcd(a, b);
	int i;
	for (i = n; i >= 0; i--) {
		if (n%i == 0) {
			c--;
			if (c == 0) {
				cout << i << endl;
				return 0;
			}
		}
	}
	

	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;
ll const MOD = 1000000007;
ll const MAX = 100005;
ll x[MAX];

ll mod_m(ll x, ll y) {
	return x * y%MOD;
}

ll f(ll n) {
	if (n == 0) {
		return 1;
	}
	else {
		return f(n - 1)*n%MOD;
	}
}

int main() {
	ll n;
	cin >> n;
	REP(i, 1, n) {
		cin >> x[i];
	}
	ll ans = 1;
	ll removed = 0;
	REP(i, 1, n) {
		ll t = i * 2;
		ll mech = upper_bound(x + 1, x + n + 1, t) - x - 1 - removed;

		if (mech > i) {
			removed++;
			ans = mod_m(ans,mech);
		}

	}
	ans = mod_m(ans,f(n - removed));
	cout << ans << endl;

}

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

int main(){
	int i,j,n,m,d,ans=0;
	cin >> n >> m;
	int a[m],b[m];
	for(i=0;i<m;i++){
		cin >> a[i] >> b[i];
	}
	
	bool c[10][10];
	
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			c[i][j] = false;
		}
	}
	
	for(i=0;i<m;i++){
		c[a[i]][b[i]] = true;
		c[b[i]][a[i]] = true;
	}
	
	vector<int> v(n);
	for(i=0;i<n;i++){
		v[i] = i+1;
	}
	
	d = 0;
	for(i=0;i<n-1;i++){
		if(c[v[i+1]][v[i]]){
			d++;
		}
		if(d==n-1){
		ans +=1;
		}
	}
	
	while(next_permutation(v.begin(),v.end())){
		d = 0;
		if(v[0]!=1){
			continue;
		}
		
		for(i=0;i<n-1;i++){
			if(c[v[i+1]][v[i]]){
			d++;
			}
			if(d==n-1){
			ans +=1;
			}
		}
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 764
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)
#define max(p,q)((p)>(q)?(p):(q))

int main(){
	ll x,y,s;
	while(scanf("%lld%lld%lld",&x,&y,&s),x){
		ll M=0;
		x+=100;
		y+=100;
		ll t=s*100/x;//大体税抜き価格
		rep(i,1,t)rep(j,max(0,t-i-2),t-i+3)if(i*x/100+j*x/100==s){
			M=max(M,i*y/100+j*y/100);
		}
		printf("%lld\n",M);
	}
}


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

int num_from_roma(string roma, int x) {
	if (roma[x] == 'I')return 1;
	else if (roma[x] == 'V')return 5;
	else if (roma[x] == 'X')return 10;
	else if (roma[x] == 'L')return 50;
	else if (roma[x] == 'C')return 100;
	else if (roma[x] == 'D')return 500;
	else if (roma[x] == 'M')return 1000;
}
int main() {
	string roma; int total;
	while (cin >> roma) {
		total = 0;
		for (int i = 0; i < roma.size()-1; i++) {
			if (num_from_roma(roma, i) < num_from_roma(roma, i + 1))total -= num_from_roma(roma, i);
			else total += num_from_roma(roma, i);
		}
		cout << total+num_from_roma(roma,roma.size()-1) << endl;
	}
}


Measured memory_bytes: 3164
from statistics import median

n = int(input())
a = [None] * n
b = [None] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

if n % 2 == 1:
    print(median(b) - median(a) + 1)
else:
    print(int((median(b) - median(a)) * 2) + 1)

Measured memory_bytes: 28800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

ll M, N, p[10005], c[505], e[505];
ll dp[505][20005];  // dp[i][j] = i番目の箱まで見てj個詰められるようにするときの最小コスト

int main() {
    cin >> M >> N;
    for(int i=0;i<M;i++){
        cin >> p[i+1];
    }
    sort(p+1,p+M+1);
    reverse(p+1,p+M+1);
    for(int i=0;i<M;i++){
        p[i+1] += p[i];
    }
    for(int i=0;i<N;i++){
        cin >> c[i] >> e[i];
    }
    for(int i=0;i<=N;i++){
        fill(dp[i],dp[i]+20001,LLINF/2);
    }
    dp[0][0] = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<=M;j++){
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            int k = min(M, j+c[i]);
            dp[i+1][k] = min(dp[i+1][k], dp[i][j]+e[i]);
        }
    }
    ll ans = 0;
    for(int i=0;i<=M;i++){
        ans = max(ans, p[i] - dp[N][i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81536
#include <iostream>
#include <string>
#include <map>
#include <math.h>
using namespace std;

#define ll long long

int main(){
    int N;
    cin >> N;
    int H[N];
    for(int i = 0;i < N;i++)cin >> H[i];
    int h = 0,count = 0;
    for(int i = 0;i < N;i++){
        if(h <= H[i]){
            h = H[i];
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 998244353;

struct edge {
  int from, to, cost;
};
vector<edge> ed(2000);
vector<ll> score(1001);
vector<bool> reach(1001);
vector<int> graph[1001];

void dfs(int i) {
  reach.at(i) = true;
  for(auto e: graph[i]) {
    //debug(i); debugln(e);
    if (!reach.at(e)) {
      dfs(e);
    }
  }
}


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

  int n, m; cin >> n >> m;

  rep(i, m) {
    int a, b, c; cin >> a >> b >> c;
    ed[i].from = a;
    ed[i].to = b;
    ed[i].cost = c;
    graph[b].push_back(a);
  }

  dfs(n);

  for(int i=1; i<=n; i++) {
    score.at(i) = LONG_MIN;
  }

  score.at(1) = 0;
  int cnt = 0;
  while (true) {
    bool update = false;
    rep(i, m) {
      if (!reach[ed[i].from] || !reach[ed[i].to]) continue;
      if (score[ed[i].from] != LONG_MIN && score[ed[i].to] < score[ed[i].from] + ed[i].cost) {
        update = true;
        score[ed[i].to] = score[ed[i].from] + ed[i].cost;
      }
    }
    if (!update) break;
    cnt++;
    if (cnt > 1001) {
      cout << "inf" << endl;
      return 0;
    }
  }

  cout << score[n] << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<math.h>
using namespace std;

int digit(long a){
    int d=1;
    while(a>9){
        a/=10;
        d++;
    }
    return d;
}

int main(){
    long N;
    cin >> N;
    long A, B;
    int F, Fmin=100;
    
    for(A=1; A<=sqrt((double)N); A++){
        if( N%A!=0 ){
            //cout << A << ":fuck" << endl;
            continue;
        }else{
            B=N/A;
            F=max(digit(A),digit(B));
            //cout << "A=" << A << " B=" << B << " F=" << F << endl;
            if(F<Fmin){
                Fmin=F;
            }
        }
    }
    
    cout << Fmin << endl;
    

    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  int N=s.size();
  int i=0;int a=2;
  while(i<N-1){
  if(a==2){ans++; a=1;i++;}
    else{
    if(s.at(i)==s.at(i-1)){ans++; a=2; i+=2;}
      else{ans++; i++;}
    }
  }if(i==N-1 &&(a==2 || s.at(N-1)!=s.at(N-2)))ans++;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {

  long long X;cin>>X;
  long long my=100;
  int ans=0;
  
  while(my<X){
    my+=my/100;
      ans++;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(3*n);
	REP(i, 3 * n)cin >> v[i];
	vl p(n+1), s(n+1);
	ll a = 0, b = 0;
	REP(i, n)a += v[i];
	priority_queue<int,vi,greater<int>> q;
	REP(i, n)q.push(v[i]);
	REP(i, n+1) {
		p[i] = a;
		a += v[i + n];
		q.push(v[i + n]);
		a -= q.top();
		q.pop();
	}
	priority_queue<int> qu;
	REP(i, n) {
		b += v[i + 2 * n];
		qu.push(v[i + 2 * n]);
	}
	REP(i, n + 1) {
		s[i] = b;
		b += v[2 * n - 1 - i];
		qu.push(v[2 * n - 1 - i]);
		b -= qu.top();
		qu.pop();
	}
	ll ans = -INF*INF;
	REP(i, n + 1)ans = max(ans, p[i] - s[n - i]);
	cout << ans << endl;
}


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

int main() {
    int n, l;
    cin >> n >> l;
    int whole = l * n + (n - 1) * n / 2;
    int diff = 1e9, ans = 0;
    for (int i = l; i < l + n; i++) {
        if (diff > abs(i)) {
            ans = whole - i;
            diff = abs(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=(b);a<(c);a++)
#define PER(a,b,c) for(ll a=(b);a>=(c);a--)

ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ode(ld x){ cout << fixed << setprecision(10) << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }

int main(){
    ll N=ii();
    map<ll,ll> m;
    vector<ll> a;
    
    PER(i,N-2,0){
        m[ii()]++;
    }

    REP(i,0,N){
        oie(m[i+1]);
    }

    return 0;
}


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

#define rep( i, n ) for( int i = 0; i < ( n ); i++ )
#define PI 3.14159265
typedef long long ll;

int main( void ) {

    int n;
    while(1){
    cin >> n;
    if( n == 0 ) break;
    vector<double> score( n );
    ll             sum = 0;
    double         avg = 0;
    rep( i, n ) {

        cin >> score.at( i );
        sum += score.at( i );
    }
    avg = (double)sum / n;

    //分散
    double aa = 0;
    double     dis   = 0;
    rep( i, n ) dis += pow( score.at( i ) - avg, 2 );
    aa = (double)dis / n;
    double a  = sqrt( aa );

    printf( "%.8lf\n", a );
    }
    return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }

    int abs_max_i = 0;
    for(int i=1;i<N;i++){
        if(abs(a[i]) > abs(a[abs_max_i])){
            abs_max_i = i;
        }
    }

    if(a[abs_max_i] == 0){
        cout << 0 << endl;
    }else if(a[abs_max_i] < 0){
        cout << 2 * N << endl;
        cout << abs_max_i + 1 << " " << 1 << endl;
        cout << abs_max_i + 1 << " " << 1 << endl;
        cout << abs_max_i + 1 << " " << 1 << endl;
        cout << abs_max_i + 1 << " " << 1 << endl;
        // 1 is new abs_max_i
        for(int i=N-1;i>=2;i--){
            cout << 1 << " " << i << endl;
            cout << 1 << " " << 1 << endl;
        }
    }else{
        cout << 2 * N << endl;
        cout << abs_max_i + 1 << " " << N << endl;
        cout << abs_max_i + 1 << " " << N << endl;
        cout << abs_max_i + 1 << " " << N << endl;
        cout << abs_max_i + 1 << " " << N << endl;
        // N is new abs_max_i
        for(int i=2;i<=N-1;i++){
            cout << N << " " << i << endl;
            cout << N << " " << N << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=110,Mo=1000000007;
int f[N][N],a[N],v[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline int Pow(int x,int y) {
    int ret=1;
    while(y) {
	if(y&1) ret=1LL*ret*x%Mo;
	x=1LL*x*x%Mo,y>>=1;
    }
    return ret;
}
int main() {
    int n,k,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) a[i]=v[i]=gi();
    sort(v+1,v+1+n);
    k=unique(v+1,v+1+n)-v-1;
    for(int i=1;i<=n;i++) a[i]=lower_bound(v+1,v+1+k,a[i])-v;
    f[0][0]=1;
    for(int i=1;i<=n;i++) {
	f[i][0]=2LL*f[i-1][0]%Mo;
	for(int j=a[i]+1;j<=a[i-1];j++)
	    f[i][0]=(f[i][0]+2LL*f[i-1][j])%Mo;
	int t=(a[i]<=a[i-1]?1:Pow(2,v[a[i]]-v[a[i-1]]));
	for(int j=min(a[i],a[i-1]);j;j--)
	    f[i][j]=1LL*t*f[i-1][j]%Mo;
	for(int j=a[i-1]+1;j<=a[i];j++) {
	    int t=(j==1?Pow(2,v[j])-2:Pow(2,v[j]-v[j-1]+1)-2);
	    f[i][j]=(f[i][j]+1LL*f[i-1][0]*t%Mo*Pow(2,v[a[i]]-v[j]))%Mo;
	}
    }
    for(int i=0;i<=k;i++) ans=(ans+f[n][i])%Mo;
    cout<<ans;
    return 0;
}

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

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  double ans=n*M_PI*2.0;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3780
{-
IPT1_1_C

????????¢?????¢?????¨??¨?????????

?????? a cm ?????? b cm ???????????¢?????¢?????¨??¨?????????????±???????????????°?????????????????????????????????
Input

a ??¨ b ????????????????????§????????????????????????????????????
Output

??¢?????¨??¨?????????????????????????????§????????£????????????????????????????????????
Sample Input

3 5

Sample Output

15 16
-}
import Data.List.Split
main = do
  s <- getLine
  putStrLn $ aux s

aux :: String -> String
aux str = (show s) ++ " " ++ (show l)
  where
    [a,b] = map (\x->read x :: Int) $  (splitOn " " str)
    s = a * b
    l = (a + b) * 2

Measured memory_bytes: 3632
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;
const int mod2 = 998244353;

int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }

int main() {
  std::cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::setprecision(20) << std::fixed;

  int n;
  cin >> n;

  string s;
  cin >> s;
  // cnt[i][j] := j番目より右にあるi(r or g or b) の数
  vector<vector<int>> cnt(3, vector<int>(n, 0));
  string R = "RGB";
  for (int c = 0; c < 3; c++) {
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = i + 1; j < n; j++) {
        if (s[j] == R[c]) {
          sum++;
        }
      }
      cnt[c][i] = sum;
    }
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (s[i] == s[j]) {
        continue;
      }
      if ((s[i] == 'G' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'G')) {
        ans += cnt[0][j];
        if (j + (j - i) < n && s[j + j - i] == 'R') {
          ans--;
        }
      }
      if ((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R')) {
        ans += cnt[1][j];
        if (j + (j - i) < n && s[j + j - i] == 'G') {
          ans--;
        }
      }
      if ((s[i] == 'G' && s[j] == 'R') || (s[i] == 'R' && s[j] == 'G')) {
        ans += cnt[2][j];
        if (j + (j - i) < n && s[j + j - i] == 'B') {
          ans--;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int main(){
  int a;
  cin >> a;
  for(int i = 1; i < 10; i++){
    if(a%i!=0)continue;
    if(a/i<10){
      cout << "Yes" << endl;
      exit(0);
    }
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define takearr(a,n) int a[n];for(int i=0;i<n;i++)cin>>a[i]
#define rep(i,n) for(int i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define mods 1000000007

int main()
{

  int n;cin>>n;
  double p[n];rep(i,n)cin>>p[i];
  double ans[n+1][n+1];memset(ans,0,sizeof(ans)); double anss=0;
  rep(i,n+1)
    {
      f(j,0,i)
        {
          if((i==0)&&(j==0)){ans[i][j]=1;continue;}
          if(j==0){ans[i][j]=(1-p[i-1])*ans[i-1][j];continue;}
          ans[i][j]=(1-p[i-1])*ans[i-1][j]+p[i-1]*ans[i-1][j-1];
          if((i==n)&&(j>(n/2)))anss+=ans[i][j];
        }
    }
  //rep(i,n+1){rep(j,n+1)cout<<ans[i][j]<<" ";cout<<endl;}
  cout<<setprecision(100)<<anss<<endl;
}


Measured memory_bytes: 70528
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, m; cin >> n >> m;
  vector<P> v(m), w(m);
  map<ll, ll> ord;
  rep(i, m) {
    ll pi, yi; cin >> pi >> yi;
    v[i] = make_pair(pi, yi);
    w[i] = v[i];
  }
  sort(w);

  ll bef = -1, cnt = 1;
  rep(i, m) {
    if (bef != w[i].first) {
      cnt = 1;
      bef = w[i].first;
    }
    ord[w[i].second] = cnt;
    cnt++;
  }

  rep(i, m) {
    ll pi = v[i].first;
    ll yi = v[i].second;
    printf("%06lld%06lld\n", pi, ord[yi]);
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define mp(i,j) make_pair(i,j)
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

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

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

void Main()
{
	string S; cin >> S;
	int res = 0;
	rep(i,4) {
		if (S[i] == '+') {
			++res;
		} else {
			--res;
		}
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int S;
    
    cin >> S;
    
    int h = S / 3600;
    
    int m = (S % 3600) / 60;
    
    int s = S % 60;
    
    
    cout << h << ":" << m << ":" << s << endl;
} 



Measured memory_bytes: 3096
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
 
int n,m;
 
int a[1000][1000];
bool use[1000];
int c[1000];
 
bool is_fin(){
    bool f = false;
    REP(i,m)
        f = (f || use[i]);
    return f;
}
 
int main(){
    scanf("%d%d",&n,&m);
    REP(i,n){
        REP(j,m){
            scanf("%d",&a[i][j]);
            a[i][j]--;
        }
    }
    int mini = 10000;
    REP(i,m)
        use[i] = true;
    while(is_fin()){
        REP(i,m)
            c[i] = 0;
        REP(i,n){
            int j = 0;
            while(!use[a[i][j]])j++;
            c[a[i][j]]++;
        }
        int maxi = 0;
        REP(i,m)
            maxi = max(maxi,c[i]);
        REP(i,m)
            if(maxi <= c[i])
                use[i] = false;
        mini = min(mini,maxi);
    }
    printf("%d\n",mini);
    return 0;
}
 


Measured memory_bytes: 1408
A, B, C = map(int, input().split())

arr = [A, B, C]
fives = 0
sevens = 0

for num in arr:
    if num == 5:
        fives += 1
    if num == 7:
        sevens += 1

if fives == 2 and sevens == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	int s[5];
	char c[5];
	for (int i=0; i<M; i++) {
		cin >> s[i] >> c[i];
	}

	int ans = -1;
	for (int i=0; i<=999; i++) {
		string n = to_string(i);
		if (n.size() != N) continue;

		bool ok = true;
		for (int j=0; j<M; j++) {
			if (s[j] > n.size()) ok = false;
			if (n[s[j] - 1] != c[j]) ok = false;
		}

		if (ok) {
			ans = i;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string s; cin>>s;
    rep(i,s.size()-8)cout<<s[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break

        a = [S() for _ in range(n)]
        e = collections.defaultdict(set)
        for c in string.ascii_lowercase:
            e[''].add(c)

        f = True
        for i in range(n):
            ai = a[i]
            for j in range(i+1,n):
                aj = a[j]
                for k in range(len(ai)):
                    if len(aj) <= k:
                        f = False
                        break
                    if ai[k] == aj[k]:
                        continue
                    e[ai[k]].add(aj[k])
                    break
        if not f:
            rr.append('no')
            continue

        v = collections.defaultdict(bool)
        v[''] = True

        def g(c):
            if v[c] == 2:
                return True
            if v[c] == 1:
                return False
            v[c] = 1
            for nc in e[c]:
                if not g(nc):
                    return False
            v[c] = 2
            return True

        for c in list(e.keys()):
            if v[c]:
                continue
            if not g(c):
                f = False
                break

        if f:
            rr.append('yes')
        else:
            rr.append('no')


    return '\n'.join(map(str,rr))



print(main())



Measured memory_bytes: 9128
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main(){
	int A, B;
	cin >> A >> B;
	cout << (A + B) % 24 << endl;
}



Measured memory_bytes: 764
import itertools
 
N, M, X = map(int, input().split())
l = []
for _ in range(N):
  l.append(list(map(int, input().split())))

b = [i for i in range(N)]
n = len(b)

b_pairs = []
for i in range(1, n+1):
    b_pairs += list(itertools.combinations(b, i))

cnt = 0
A = [0] * M
B = []
C = []
for i in range(2 ** N - 1):
  w = len(b_pairs[i])
  for j in range(M):
    for k in range(w):
      A[j] += l[b_pairs[i][k]][j + 1]
  B.append(A)
  A = [0] * M
  
for i in range(2 ** N - 1):
  w = len(b_pairs[i])
  for k in range(w):
    cnt += l[b_pairs[i][k]][0]
  C.append(cnt)
  cnt = 0

for i in range(len(B)):
  for j in range(M):
    if B[i][j] >= X:
      pass
    else:
      B[i] = 0
      break
if B == [0] * len(B):
  print(-1)
  exit()

for i in range(len(B)):
  if B[i] != 0:
    B[i] = C[i]
  else:
    B[i] = 1000000000000

print(min(B))

Measured memory_bytes: 11772
// Problem : B - Minor Change
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		string s,t;
		cin>>s>>t;
		int n = s.size();
		int ct = 0;
		for(int i=0;i<n;++i)
		{
			if(s[i]!=t[i])
			++ct;
		}
		cout<<ct;		
    }
    return 0;
}


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

int a, b;

int main(){
	cin >> a >> b;
	if(a < b){
		for(int i = 0; i < b; i++) cout << a;
		cout << "\n";
	}else if(a > b){
		for(int i = 0; i < a; i++) cout << b;
		cout << "\n";
	}else{
		for(int i = 0; i < min(a, b); i++) cout << a;
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
using namespace std;
const int maxn = 200100;
ll tree[4*maxn];
ll lazy[4*maxn];

ll n, m;
vector<pll>intervals[maxn];
ll dp[maxn];

void push_update(int li, int ri, int index) {
	if(lazy[index] != 0) {
		tree[index] += lazy[index];

		if(li != ri) {
			lazy[2*index] += lazy[index];
			lazy[2*index+1] += lazy[index];
		}

		lazy[index] = 0;
	}
}

void update(int ul, int ur, ll val, int li=0, int ri=n+1, int index=1) {
	push_update(li, ri, index);
	if(li > ur || ri < ul) return;
	else if(li >= ul && ri <= ur) {
		lazy[index] += val;
		push_update(li, ri, index);
	}
	else {
		int mid = (li + ri) / 2;

		update(ul, ur, val, li, mid, 2*index);
		update(ul, ur, val, mid+1, ri, 2*index+1);

		tree[index] = min(tree[2*index], tree[2*index+1]);
	}
}

ll query(int ql, int qr, int li=0, int ri=n+1, int index=1) {
	push_update(li, ri, index);
	if(li > qr || ri < ql) return 0LL;
	else if(li >= ql && ri <= qr) return tree[index];
	else {
		int mid = (li + ri) / 2;

		ll lq = query(ql, qr, li, mid, 2*index);
		ll rq = query(ql, qr, mid+1, ri, 2*index+1);

		tree[index] = min(tree[2*index], tree[2*index+1]);

		return min(lq, rq);
	}
}

int main() {
	cin>>n>>m;
	ll a, b, c;
	ll score = 0LL;
	for(int i=0;i<m;i++) {
		cin>>a>>b>>c;
		intervals[b].pb({a, c});
		score += c;
	}

	ll result = LLONG_MAX;
	for(int i=1;i<=n+1;i++) {
		for(pll p:intervals[i-1]) {
			update(0, p.first-1, p.second);
		}

		dp[i] = query(0, i-1);
		update(i, i, dp[i]);

		if(dp[i] < result) result = dp[i];
	}
	cout<<score-result<<"\n";
}

Measured memory_bytes: 24960
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  VEC<int> x(n), y(m);
  REP(i, 0, n) cin >> x[i];
  REP(i, 0, m) cin >> y[i];
  sort(ALL(x));
  sort(ALL(y));
  int xmax = x[n - 1];
  int ymin = y[0];
  string ans = xmax < ymin ? "No War" : "War";
  DUMP(xmax, ymin);
  if (xmax < ymin && X < ymin && ymin <= Y) {

    ans = "No War";
  } else
    ans = "War";
  cout << ans << endl;
 

  return 0;
}


Measured memory_bytes: 256