akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
#define endl '\n'
#define pb(a) push_back(a)
#define al(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define IOS ios::sync_with_stdio(0);
int n, m;
ll k;
ll a[N], b[N];
ll pre1[N], pre2[N];
int main() {
    scanf("%d%d%lld", &n, &m, &k);
    for (int i = 1; i <= n; ++i)
        scanf("%lld", &a[i]), pre1[i] = pre1[i - 1] + a[i];
    for (int i = 1; i <= m; ++i)
        scanf("%lld", &b[i]), pre2[i] = pre2[i - 1] + b[i];
    int i = 0, j = m;
    int ans = 0;
    for (; i <= n; ++i) {
        if (pre1[i] > k) break;
        while (pre2[j] > k - pre1[i]) j--;
        ans = max(ans, i + j);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 10040
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool check(int n) {
    while (n > 1) {
        if (n%2 == 1) {
            return false;
        }
        n /= 2;
    }
    return true;
}

long long keta(int n) {
    int ret = 0;
    while (n > 1) {
        n /= 2;
        ret++;
    }
    return ret;
}

int main() {
    long long n = 0;
    cin >> n;
    if (n == 1) cout << "No" << endl;
    else if (check(n)) cout << "No" << endl;
    else if ((n+1)%2 == 0) {
        if ((n+1)%4 == 0) {
            cout << "Yes" << endl;
            long long a = 1, b = 2;
            while (b <= n*2) {
                cout << a << " " << b << endl;
                a++;
                b++;
            }
        }
        else {
            cout << "Yes" << endl;
            long long a = 1, b = 2;
            while (b <= n-2) {
                cout << a << " " << b << endl;
                cout << a+n << " " << b+n << endl;
                a++;
                b++;
            }
            cout << n-2 << " " << n+1 << endl;
            cout << n-1 << " " << n << endl;
            cout << n << " " << 2 << endl;
            cout << 3 << " " << 2*n-1 << endl;
            cout << 2*n-1 << " " << 2*n << endl;
        }
    }
    else {
        if (n%4 == 0) {
            cout << "Yes" << endl;
            long long a = 1, b = 2;
            while (b <= n-5) {
                cout << a << " " << b << endl;
                cout << a+n << " " << b+n << endl;
                a++;
                b++;
            }
            long long buf = pow(2, keta(n));
            cout << n-5 << " " << n+1 << endl;
            cout << n-1 << " " << n-2 << endl;
            cout << n-1 << " " << n-buf << endl;
            cout << n-buf+1 << " " << 2*n-2 << endl;
            cout << 2*n-2 << " " << 2*n-1 << endl;
            cout << n-3 << " " << n-4 << endl;
            cout << n-3 << " " << n-buf-2 << endl;
            cout << n-buf-1 << " " << 2*n-4 << endl;
            cout << 2*n-4 << " " << 2*n-3 << endl;
            cout << n << " " << n-1 << endl;
            cout << 2*n << " " << n-buf-1 << endl;
        }
        else {
            cout << "Yes" << endl;
            long long a = 1, b = 2;
            while (b <= n-3) {
                cout << a << " " << b << endl;
                cout << a+n << " " << b+n << endl;
                a++;
                b++;
            }
            long long buf = pow(2, keta(n));
            cout << n-3 << " " << n+1 << endl;
            cout << n-1 << " " << n-2 << endl;
            cout << n-1 << " " << n-buf << endl;
            cout << n-buf+1 << " " << 2*n-2 << endl;
            cout << 2*n-2 << " " << 2*n-1 << endl;
            cout << n << " " << n-1 << endl;
            cout << 2*n << " " << n-buf-1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2816
n=int(input())
a=[]
for i in range(n-1):
    for j in range(i+1,n):
        a.append([i+1,j+1])
print((n*(n-1)//2)-n//2)
for i in a:
    if n%2==1:
        if sum(i)!=n:
            print(i[0],i[1])
    else:
        if sum(i)!=n+1:
            print(i[0],i[1])

Measured memory_bytes: 4124
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      ps: [usize; n],
    }
    let mut max_v = ps[0];
    let mut ans = 0;
    for p in ps {
        max_v = max(max_v, p);
        ans += p;
    }
    println!("{}", ans - max_v/2);
}


Measured memory_bytes: 4476
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N;
    int T, A;
    vector<int> H;

    void input() {
        cin >> N;
        cin >> T >> A;

        rep(i, 0, N) {
            int tmp;
            cin >> tmp;
            H.push_back(tmp);
        }

    }

    double ondo(int h) {
        return 1.0 * T - h * 0.006;
    }

    void solve() {
        input();

        vector<double> diff;

        for(int i = 0; i < N; ++i){
            double tmp = abs(1.0 * A - ondo(H[i]));
            diff.push_back(tmp);
        }

        double minv = INFl;
        int key = -1;

        for(int i = 0; i < N; ++i){
            if(diff[i] < minv){
                minv = diff[i];
                key = i;
            }
        }

        cout << key + 1 << endl;




    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
# Graph
import heapq
INF = 10**18

def dijkstra(start, G):
    done = [False]*(len(G))
    dist = [INF]*(len(G))
    dist[start] = 0
    fr = [0]*N
    h = []
    heapq.heappush(h, [0, start])
    while h:
        _, cur = heapq.heappop(h)
        if done[cur]: continue
        done[cur] = True
        for to, cost in G[cur]:
            if dist[cur]+cost < dist[to]:
                dist[to] = dist[cur]+cost
                fr[to] = cur
                heapq.heappush(h, [dist[to], to])
    return fr, dist

N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append((b, 1))
    G[b].append((a, 1))
ans, dis = dijkstra(0, G)
print("Yes")
for i in range(1, N):
    print(ans[i]+1)


Measured memory_bytes: 114468
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define deb(a) cout<<#a<<" "<<a<<endl
#define WW 100000
#define INF 1000000000000000000 //1e18
#define EPS 0.000000001 //1e-9
//get<a>(t) gives ath element of tuple named t, numbering starts from 0
//max({_,......,_}) can give maximum of any number of elements. Similarly min also.
//don't forget to initialise freq arrays
//reverse(all(v)) would reverse a vector  
//pow(10.0, 2.0) can give exactly 100.0, slightly greater, or slightly less. 
//Therefore use(int)(pow(10.0,zz)+EPS)
int32_t main()
{
    IOS;
    int n; cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    int dp[n][3];
    dp[0][0]=a[0][0], dp[0][1]=a[0][1], dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,k;
  cin>>n>>k;
  if((n+1)/2 < k)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

vector<vector<ll> > dp(13,vector<ll>(10));

void dfs(ll si, ll sj, ll k){
 // cout << endl;
//  cout << "con " << si << " " <<  sj << endl;
    sj--;
    if(si!=0){
      si--;
      if(dp[sj][si] >= k){
        cout << si;
        if(sj==0) return;
        dfs(si,sj,k);
        return;
      }
      else k -= dp[sj][si];
      si++;
    }
    if(dp[sj][si] >= k){
      cout << si;
      if(sj==0) return;
      dfs(si,sj,k);
      return;
    }
    else k-=dp[sj][si];
    si++;    
    cout << si;
    if(sj==0) return;
    dfs(si,sj,k);
    return;
}




int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k;
  cin >> k;
  if(k<=9) {
    cout << k << endl;
    return 0;
  }
  rep(i,10) dp[0][i] = 1;
  ll tot = 9;
  ll sj,si;
  rep1(j,12){
    rep(i,10){
      ll add =0;
//      cout << j << " " << i << endl;
//      cout << tot << endl;
      if(i!=0) add += dp[j-1][i-1];
      add += dp[j-1][i];
      if(i!=9) add += dp[j-1][i+1];
      if(i!=0) tot += add;
      dp[j][i] = add;
      if(tot>=k){
        sj = j;
        si = i;
        tot = k - (tot - add);
        j = 13;
        break;
      }
    }
  }
  cout << si;
  dfs(si,sj,tot);
  cout << endl;

  return 0;
    

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
//vector <bool> prime(boolsize,1);
//void seive()
//{
//    ll n=boolsize;
//    prime[0]=prime[1]=0;
//    for(ll i=2;i<=sqrt(boolsize);i++)
//    {
//        if(prime[i]==1)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//            {
//                prime[j]=0;
//            }
//        }
//    }
//}

/// check for test case before submitting
void vfun()
{
    ll n;
    cin>>n;
ll    ans=n/11;
    ans*=2;
  ll  x=n%11;
    if(x)
    {
        if(x>6)
            ans+=2;
        else
            ans+=1;
    }
    cout<<ans;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    //cin>>test;
    while(test--)
    {

        //fun();
        vfun();
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not



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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int a, b;
  cin >> a >> b;
  string ans;
  if((a*b)%2==0) ans = "No";
  else ans = "Yes";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]
ans=[]
for i in range(H):
  for j in range(W):
    if i%2 == 0:
      if j != W-1:
        if A[i][j]%2 == 1:
          A[i][j+1]+=1
          ans.append([i+1,j+1,i+1,j+2])
      else:
        if A[i][j]%2 == 1 and i < H-1:
          A[i+1][j]+=1
          ans.append([i+1,j+1,i+2,j+1])
    else:
      if j != W-1:
        if A[i][W-1-j]%2 == 1:
          A[i][W-2-j]+=1
          ans.append([i+1,W-j,i+1,W-j-1])
      else:
        if A[i][W-1-j]%2 == 1 and i < H-1:
          A[i+1][W-1-j]+=1
          ans.append([i+1,W-j,i+2,W-j])
print(len(ans))
for i in range(len(ans)):
  print(ans[i][0],ans[i][1],ans[i][2],ans[i][3])


Measured memory_bytes: 30288
import java.util.Scanner;

public class Main {

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

      String a = in.next();
      String b = in.next();

      StringBuffer sb = new StringBuffer(b);
      String b2 = sb.reverse().toString();

      if(a.equals(b2)) {
          System.out.println("YES");
      }
      else {
          System.out.println("NO");
      }


    }
}

Measured memory_bytes: 21972
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public static readonly int LEN1 = 0;
	public static readonly int LEN2 = 1;

	public void Solve()
	{
		string S = GetString();
		int N = S.Length;

		int[,] dp = new int[N + 1, 2];
		dp[1, LEN1] = 1;
		for(int i = 2; i <= N; i++)
		{
			dp[i, LEN1] = dp[i - 1, LEN2] + 1;
			dp[i, LEN2] = dp[i - 2, LEN1] + 1;
			if(S[i - 1] != S[i - 2])
				dp[i, LEN1] = Math.Max(dp[i, LEN1], dp[i - 1, LEN1] + 1);
		}

		Console.WriteLine(Math.Max(dp[N, LEN1], dp[N, LEN2]));		
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
}


Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=100005;
vi e[N];
int d[N],vis[N];
void dfs(int v){
	vis[v]=1;
	int s=e[v].size(),u;
	while(s--)if(!vis[u=e[v][s]])dfs(u);
}
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,m,i,j,v,u;
    scanf("%d%d",&n,&m);
	if(m<n+2){puts("No");return 0;}
    rep(i,1,m){
		scanf("%d%d",&v,&u);
		++d[v];
		++d[u];
		e[v].pb(u);
		e[u].pb(v);
	}
	rep(i,1,n)if(d[i]& 1){puts("No" );return 0;}
	rep(i,1,n)if(d[i]>=6){puts("Yes");return 0;}
	if(m==n+2){
		rep(i,  1,n)if(d[i]==4)break;
		rep(j,i+1,n)if(d[j]==4)break;
		rep(v,0,3){
			if(e[i][v]==i){puts("Yes");return 0;}
			rep(u,1,n)vis[u]=0;
			vis[i]=1;
			dfs(e[i][v]);
			if(!vis[j]){puts("Yes");return 0;}
		}
		puts("No");
	}else puts("Yes");
    return 0;
}

Measured memory_bytes: 8960
import sys
BASE, MOD1, MOD2 = (1<<30), (1<<61)-1, (1<<31)-1

class RollingHash():
	def __init__(self, s, base, mod):
		self.mod = mod
		self.pw = pw = [1]*(len(s)+1)

		l = len(s)
		self.h = h = [0]*(l+1)

		v = 0
		for i in range(l):
			h[i+1] = v = (v * base + s[i]) % mod
		v = 1
		for i in range(l):
			pw[i+1] = v = v * base % mod

	# [l. r)
	def get(self, l, r):
		return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod

	def concatenate(self, l1, r1, l2, r2):
		return (self.get(l1, r1) * self.pw[r2-l2] + self.get(l2, r2)) % self.mod


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if n == 1:
	print(0, a[0]^b[0])
	sys.exit()
x = [a[n-1]^a[0]]
y = [b[n-1]^b[0]]
for i in range(n-1):
	x.append(a[i]^a[i+1])
	y.append(b[i]^b[i+1])

rh1_x, rh1_y = RollingHash(x, BASE, MOD1), RollingHash(y, BASE, MOD1)
rh2_x, rh2_y = RollingHash(x, BASE, MOD2), RollingHash(y, BASE, MOD2)
for k in range(n):
	if rh1_y.concatenate(n-k, n, 0, n-k) == rh1_x.get(0, n) and rh2_y.concatenate(n-k, n, 0, n-k) == rh2_x.get(0, n):
		print(k, a[0]^b[(n-k)%n])

Measured memory_bytes: 100768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?middle:'\n'));
}
void array_show(LL *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?middle:'\n'));
}

int main(){
	char ca[105];
	cin>>ca;
	int i,j,k;
	int s=0;
	for(i=0,k=0;i<strlen(ca);i++){
		if(ca[i]=='A' || ca[i]=='T' || ca[i]=='G' || ca[i]=='C')k++;
		else k=0;
		if(s<k)s=k;
	}
	cout<<s<<endl;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n;cin>>n;
    vl t(n);
    rep(i,n)cin>>t[i];
    ll sum = accumulate(all(t),0LL);
    int m;cin>>m;
    rep(i,m){
        int idx,va;cin>>idx>>va;
        idx--;
        out(sum-t[idx]+va);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i,s,n) for(int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int a = (h2 * 60 + m2) - (h1 * 60 + m1) - k;
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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 n;
ll k, a[200010];

int main() {
    cin >> k >> n;
    rep(i, n) cin >> a[i];

    ll m = (k - a[n-1]) + a[0];
    rep(i, n) {
        if (i == 0) continue;
        chmax(m, a[i] - a[i-1]);
    }
    cout << k - m << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

ll gcd(ll x,ll y){
  if(x>y)swap(x,y);
  if(y%x==0)return x;
  return gcd(y-x*(y/x),x);
}

int main(){
  ll n,k;cin >> n >> k;
  vl a(n);
  ll M=0;
  ll g;
  rep(i,n){
    cin >> a[i];
    if(M<a[i])M=a[i];
    if(i==0)g=a[0];
    else g=gcd(g,a[i]);
  }
  
  if(k>M){
    cout << "IMPOSSIBLE" << endl;
  }else{
    if(k%g==0)cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 1024
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;

       cin>>n;
       b=n/500;
       m=b*1000;
       n=n-(b*500);
       a=n/5;
       m=m+(a*5);
       cout<<m<<endl;

}


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

#define forn(x,n,s) for(int i = x; i < n; i += s )
#define forr(x,n,s) for(int i = x; i>=n; i -= s)
#define PI 3.14159265358979323846264338327950L

using namespace std;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
} 
long long int mod = 1e9+7;

int main(){
    go(); 

    // code here
    int n,m;cin>>n>>m;
    unordered_map<int,vector<int>> List;
    unordered_set<int> st;
    forn(0,m,1){
        int a,b;cin>>a>>b;
        List[a].push_back(b);
        List[b].push_back(a);
    }
    vector<pair<int,int>> visited(n+1,{0,INT_MAX});
    queue<pair<pair<int,int>,int>> q;
    q.push({{1,0},0});
    visited[0] = {0,0};
    st.insert(1);
    while(!q.empty()){
        auto node = q.front();
        q.pop();
        int cur_node = node.first.first;
        int parent = node.first.second;
        if(visited[cur_node].second>=(visited[parent].second+node.second)){
             visited[cur_node] = {parent,visited[parent].second+node.second};
        }
        for(int nei:List[cur_node]){
            if(nei==parent) continue;
            if(st.find(nei)!=st.end()) continue;
            st.insert(nei);
            q.push({{nei,cur_node},node.second+1});
        }
    }
    int flag = 0;
    for(auto x:visited){
        if(x.second==INT_MAX) {
            flag = 1;
            break;
        }
    }
    if(flag == 0){
        cout<<"Yes"<<endl;
        forn(2,n+1,1) cout<<visited[i].first<<endl;
    }else{
        cout<<"No";
    }
}






Measured memory_bytes: 18772
N = int(input())
blue = [input() for _ in range(N)]
M = int(input())
red = [input() for _ in range(M)]

cards = set(blue) | set(red)
blue_map = {}
red_map = {}
for x in blue:
    if blue_map.get(x) is None:
        blue_map[x] = 1
    else:
        blue_map[x] += 1

for x in red:
    if red_map.get(x) is None:
        red_map[x] = 1
    else:
        red_map[x] += 1

result = max([blue_map.get(key, 0) - red_map.get(key, 0) for key in cards])
if result < 0:
    result = 0
print(result)


Measured memory_bytes: 3064
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $s = <STDIN>);
my ($f, $c) = (0, 0);
my @p;
for my $i (0..length($s)-1) {
  if (substr($s, $i, 1) eq 'R') {
    if ($f == 1) {
      push @p, $c;
      $f = 0;
      $c = 0;
    }
    $c++;
  } else {
    if ($f == 0) {
      push @p, $c;
      $f = 1;
      $c = 0;
    }
    $c++;
    push @p, $c if $i == length($s) - 1;
  }
}
my $ans;
while (@p) {
  my $x = shift @p;
  my $y = shift @p;
  $ans .= "0 " x ($x - 1);
  if (($x + $y) % 2 == 0) {
    $ans .= ($x + $y) / 2;
    $ans .= ' ';
    $ans .= ($x + $y) / 2;
    $ans .= ' ';
  } elsif ($x % 2 == 0) {
    $ans .= int(($x + $y) / 2);
    $ans .= ' ';
    $ans .= int(($x + $y) / 2) + 1;
    $ans .= ' ';
  } else {
    $ans .= int(($x + $y) / 2) + 1;
    $ans .= ' ';
    $ans .= int(($x + $y) / 2);
    $ans .= ' ';
  }
  $ans .= "0 " x ($y - 1);
}
say substr($ans, 0, length($ans) - 1);

Measured memory_bytes: 4864
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)

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

ll go(int i, int j, vector <vector <ll>> &grid, vector <vector <ll>> &dp) {
	if(i == grid.size()) return 0;

	if(dp[i][j] != -1) return dp[i][j];
//	ll ans = &dp[i][j];
	rep(k, 0, 3) {
		if(k != j) {
			dp[i][j] = max(dp[i][j], grid[i][j] + go(i + 1, k, grid, dp));		
		}
	}
	return dp[i][j];

}

void solve() {
	int n;
	cin >> n;
	vector <vector <ll>> grid;
	vector <vector <ll>> dp;	
	grid.resize(n, vector <ll > (3, 0));
	dp.resize(n, vector <ll >(3, -1));

	rep(i, 0, n) {
		rep(j, 0, 3) cin >> grid[i][j];
	}
	ll ans = 0;
	rep(i, 0, 3) ans = max(ans, go(0, i, grid, dp));
	cout << ans << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	while(t--)
		solve();

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

using namespace std;
using ll = long long;

using vec = bitset<100001>;

bool solve(vector<vec> A, int N, int M) {
  int r = 0;
  for (int j = 0; j < M; j++) {
    int p = -1;
    for (int i = r; i < N; i++) {
      if (A[i][j]) {
        p = i;
        break;
      }
    }
    if (p == -1) continue;
    swap(A[r], A[p]);
    for (int i = r + 1; i < N; i++) {
      if (A[i][j]) {
        A[i] ^= A[r];
      }
    }
    r++;
  }
  for (int i = r; i < N; i++) if (A[i][M]) return false;
  return true;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<ll> A(N); rep(i, N) cin >> A[i];
  ll ans = 0;
  vector<int> f;
  vector<int> taken;
  repr(i, 60) {
    int cnt = 0;
    rep(j, N) if (A[j] >> i & 1) cnt++;
    if (cnt % 2 == 1) {
      ans += 1LL << i;
    } else {
      f.push_back(i);
      vector<vec> X(f.size());
      rep(r, f.size()) {
        rep(j, N) {
          X[r][j] = A[j] >> f[r] & 1;
        }
      }
      rep(r, taken.size()) {
        X[r][N] = taken[r];
      }
      X[taken.size()][N] = 1;
      if (solve(X, f.size(), N)) {
        taken.push_back(1);
      } else {
        taken.push_back(0);
      }
    }
  }
  rep(r, f.size()) {
    if (taken[r]) {
      ans += 1LL << f[r] + 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2712
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
const int inf=0x3f3f3f3f;
int l,top,n,k,Q,a[N],b[N],ans,q[N];
vector<int> vec;
int solve(int x)
{
	l=1;vec.clear();
	for (int i=1;i<=n+1;i++)
	  if (a[i]<x)
	  {
	  	  if (i-l>=k)
	  	  {
	  	  	  top=0;
	  	  	  for (int j=l;j<i;j++) q[++top]=a[j];
	  	     sort(q+1,q+top+1);
	  	     for (int j=1;j<=i-l-k+1;j++) vec.push_back(q[j]);
		  }
	  	  l=i+1;
	  }
	sort(vec.begin(),vec.end());
	if (Q-1>=vec.size()) return inf;
	return vec[Q-1]-x;
}
int main()
{
	scanf("%d%d%d",&n,&k,&Q);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),b[i]=a[i];
	sort(b+1,b+n+1);ans=inf;
	for (int i=1;i<=n;i++) ans=min(ans,solve(b[i]));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#include <vector>
#include <array>
#include <cmath>

#define r(i, v, n) for(int i = v; i < n; i++)
#define re(i, v, n) for(int i = v; i <= n; i++)

using namespace std;

int main() {
    unsigned long h, w;
    string s;

    cin >> h >> w;
    auto vc = vector<vector<char>>(h*2, vector<char>(w*2));
    auto vi = vector<vector<int>>(h*4, vector<int>(w*4, 0));

    r(i, 0, h) {
        cin >> s;
        vc[i] = vector<char>(s.begin(), s.end());
    }

    r(i, 0, h) {
        r(j, 0, w) {
            if('#' == vc[i][j]) {
                vi[h+i-1][w+j-1]++;
                vi[h+i-1][w+j+2]--;
                vi[h+i+2][w+j-1]--;
                vi[h+i+2][w+j+2]++;
            }
        }
    }

    r(i, 0, h*3) {
        r(j, 0, w*3) {
            if (i == 0 && j == 0) {
                continue;
            } else if (i == 0 && j != 0) {
                vi[i][j] += vi[i][j - 1];
            } else if (i != 0 && j == 0) {
                vi[i][j] += vi[i - 1][j];
            } else {
                vi[i][j] += vi[i][j - 1] + vi[i - 1][j] - vi[i - 1][j - 1];
            }
        }
    }

    r(i, 0, h) {
        r(j, 0, w) {
            if ('#' == vc[i][j]) {
                cout << vc[i][j];
            } else {
                cout << vi[h+i][w+j];
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 200005

int N;
int input_A[2*SIZE],A[2*SIZE],B[SIZE];
int P[3*SIZE];
int z_algorithm[3*SIZE];

//文字列aの後ろに文字列bをくっつけた場合に、何文字重なるかを計算する関数
void calc(){

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

		P[i] = B[i];
	}
	P[N] = -1;
	for(int i = 0; i < 2*N; i++){
		P[N+1+i] = A[i];
	}

	int P_length = 3*N+1;

	z_algorithm[0] = P_length;
	int index = 1,diff = 0,diff_2;

	while(index < P_length){
		while(index+diff < P_length && P[index+diff] == P[diff])diff++; //不一致箇所はP[diff]とP[index+diff]
		z_algorithm[index] = diff;

		if(diff == 0){ //1文字も一致しない場合
			index++;
			continue;
		}else{ //先頭からdiff文字一致したという事実を利用する

			diff_2 = 1;

			//一致長が[比較の先頭をずらした分だけ]減っていく間、以前の計算結果を再利用する
			while(index+diff_2 < P_length && z_algorithm[diff_2] < diff-diff_2){

				z_algorithm[index+diff_2] = z_algorithm[diff_2];
				diff_2++;
			}

			index += diff_2;
			diff -= diff_2;
		}
	}
}

int main(){

	scanf("%d",&N);

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

		scanf("%d",&A[i]);
		A[N+i] = A[i];

		input_A[i] = A[i];
	}
	int A0 = A[0];

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

		scanf("%d",&B[i]);
	}
	int B0 = B[0];
	for(int i = 0; i < 2*N-1; i++){

		A[i] ^= A[i+1];
	}
	A[2*N] ^= A0;

	for(int i = 0; i < N-1; i++){

		B[i] ^= B[i+1];
	}
	B[N-1] ^= B0;

	calc();

	for(int i = 0; i < N; i++){
		if(z_algorithm[N+1+i] == N){

			printf("%d %d\n",i,B0^input_A[i]);
		}
	}

	return 0;
}


Measured memory_bytes: 11648
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

abc = lma()
abc.sort()
b = abc[2] - abc[0]
c = abc[2]  -abc[1]
if b%2 == 0 and c%2 == 0:
    ans = b//2+c//2
elif b%2==1 and c%2 ==1:
    ans = (b-1)//2 + (c-1)//2 +1
else:
    ans = b//2 + c//2 +2   
print(ans)


Measured memory_bytes: 9332
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int A, B; cin >> A >> B;
    int ans;
    ans = max(ceil(A / 0.08), ceil(B / 0.10));
    if (floor(ans * 0.08) != A | floor(ans * 0.10) != B) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
ans (xa:ya:ra:xb:yb:rb:_) =
  let d = sqrt( (xa-xb)**2 + (ya-yb)**2 )
  in
    if d > ra + rb
    then 0
    else if ra > d+rb
         then 2
         else if rb > d+ra
              then -2
              else 1
main = do
  n <- getLine
  c <- getContents
  let n' = read n :: Int
      i  = map (map read) $ map words $ take n' $ lines c :: [[Double]]
      o  = map ans i
  mapM_ print o

Measured memory_bytes: 4436
import collections, math, bisect, re

local = False
if local:
    file = open("input.txt", "r")
    import time

def inp():
    if local:
        return file.readline().rstrip()
    else:
        return input().rstrip()

def ints():
    return [int(_) for _ in inp().split()]


if local:
    start=time.time()


phrases = ints()

if phrases.count(5)==2 and phrases.count(7)==1:
    print("YES")
else:
    print("NO")



if local:
    fin = (time.time()-start)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 38384
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int qual[];
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			if( (a|b|c) == 0 ) break;
			int n = sc.nextInt();
			qual = new int[a+b+c];
			Test[] tests = new Test[n];
			fill(qual, 2);
			for(int i=0;i<n;i++) {
				tests[i] = new Test(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
			}
			sort(tests);
			for(int i=0;i<n;i++) {
				if( tests[i].t == 1 ) {
					for(int j=0;j<3;j++)
						qual[tests[i].ps[j]-1] = 1;
				}
				else {
					for(int j=0;j<3;j++) {
						if( qual[tests[i].ps[j]-1] == 1 && qual[tests[i].ps[(j+1)%3]-1] == 1 )
							qual[tests[i].ps[(j+2)%3]-1] = 0;
					}
						
				}
			}
			
			for(int i=0;i<a+b+c;i++) {
				System.out.println(qual[i]);
			}
			
		}
	}
	
	class Test implements Comparable<Test>{
		int t;
		int[] ps;
		Test(int a, int b, int c, int t) {
			ps = new int[3];
			ps[0] = a;
			ps[1] = b;
			ps[2] = c;
			this.t = t;
		}
		@Override
		public int compareTo(Test o) {
			// TODO 自動生成されたメソッド・スタブ
			return o.t - t;
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  int N,K,X,Y;
  cin>>N>>K>>X>>Y;
  long long int ans;
  if(K>=N)ans=N*X;
  else ans=K*X+(N-K)*Y;
   cout<<ans<<endl;
  }

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000
typedef long long LL;
typedef long double LD;

class Solver{
private:
  int n;
  vector<string> a,b;
  map<string,int> mp;
public:
  Solver(int nn){
    n=nn;
    a=vector<string>(n);
    b=vector<string>(n);
    for(int i=0;i<n;i++){
      cin >> a[i] >> b[i];
    }
  }
  int solve(string s,string t){
    if(s==t) return 0;
    string tmp;
    int mi=INF;
    for(int i=0;i<n;i++){
      if(s.length()<a[i].length()) continue;
      tmp=s;
      for(int j=0;j<=tmp.length()-a[i].length();j++){
        if(tmp.substr(j,a[i].length())==a[i]){
          tmp=tmp.substr(0,j)+b[i]+tmp.substr(j+a[i].length(),tmp.length()-(j+a[i].length()));
          j+=b[i].length()-1;
        }
      }
      if(tmp!=s&&tmp.length()<=t.length()){
        if(mp.find(tmp)==mp.end()){
          int x=solve(tmp,t);
          mp[tmp]=x;
          mi=min(mi,x);
        }else{
          mi=min(mi,mp[tmp]);
        }
      }
    }
    return min(mi+1,INF);
  }
};

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    Solver s(n);
    string c,d;
    cin >> c >> d;
    int ans=s.solve(c,d);
    cout << (ans==INF?-1:ans) << endl;
  }
  return 0;
}



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

using namespace std;

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

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())
#define UNIQUE(v) \
    SORT(v);      \
    v.resize(distance(v.begin(), unique(v.begin(), v.end())))

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

const ll md = 1e9 + 7;
ll MOD(ll x) {
    ll r = x % md;
    if (r < 0) {
        r += md;
    }
    return r;
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF DBL_MAX
// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 1e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;
    ll res = 0;
    ll cnt = 0;
    bool happened = false;
    REP(i, n) {
        ll d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2) {
            cnt++;
        } else {
            cnt = 0;
        }
        if (cnt >= 3) {
            happened = true;
        }
    }
    if (happened) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }

// #ifdef DEBUG
//     for (int t = 1; t <= tt || cin.rdbuf()->in_avail(); t++) {
//         // cout << "Case #" << t << ": ";
//         solve();
//     }
// #else
//     for (int t = 1; t <= tt; t++) {
//         // cout << "Case #" << t << ": ";
//         solve();
//     }
// #endif

    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

map<ll, ll> prime_factor(ll n){
    map<ll, ll> mp;
    for(int i = 2; i * i <= n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1)mp[n]++;
    return mp;
}

int main() {
    ll n, ans = 1;
    cin >> n;
    vector<ll> num(n+1);
    for(int i = 2; i <= n; i++){
        for(auto p : prime_factor(i)){
            while(p.second--)num[p.first]++;
        }
    }
    rep(i, n+1){
        if(num[i] > 0)ans = (ans * (num[i]+1)) % mod;
    }
    cout << ans << endl;
}      

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
#include <map>
#include <cstring>
 
using namespace std;

int main(){

	string s;
	cin>>s;

	deque<char> d;
	for(int i=0;i<s.size();i++) d.push_back(s[i]);

	int res=0;
	while(!d.empty()){
		if(d.front() == d.back()){
			d.pop_front();
			if(!d.empty())d.pop_back();
		}
		else if(d.front()=='x') d.push_back('x'),res++;
		else if(d.back()=='x') d.push_front('x'),res++;
		else{
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

bool connected[10][10];
int cnt=0;
int N,M,a,b;

bool isOk(vector<int> v){
    rep(i, v.size()-1){
        if (!connected[v[i]][v[i+1]]) return false;
    }
    return true;
}

int main(){

    cin >> N >> M;

    rep(i,10){
        rep(j,10){
            connected[i][j] = false;
        }
    }

    rep(i,M){
        cin >> a >> b;
        connected[a][b] = connected[b][a] = true;
    }

    vector<int> v(N);
    iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
    do {
        if (v[0] != 1) continue;
        if (isOk(v)){
            // rep(i,v.size()){
            //     cout << v[i] << " ";
            // }
            cnt ++;
            // cout << "" << endl;
        }
    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成

    cout << cnt << endl;

    return 0;
}


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

int main() {
    int n, m; cin >> n >> m;
    while (m--) {
        int a; cin >> a;
        n -= a;
        if (n < 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << n << endl;
}



Measured memory_bytes: 3632