akhauriyash/Code-Regression huggingface dataset:
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    ll n1,i;cin>>n1;
    ll t,e,n;t=e=n=1ll;
    fo(i,0,n1)
    {
        t=(t*10)%MOD7;if(t<0)t+=MOD7;
        e=(e*8)%MOD7;if(e<0)e+=MOD7;
        n=(n*9)%MOD7;if(n<0)n+=MOD7;
    }
    ll ans=0ll;
    ans=(ans+t)%MOD7;if(ans<0)ans+=MOD7;
    n=(n*2ll)%MOD7;if(n<0)n+=MOD7;
    ans=(ans-n+MOD7)%MOD7;if(ans<0)ans+=MOD7;
    ans=(ans+e)%MOD7;if(ans<0)ans+=MOD7;
    cout<<ans<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//**always check if you are not killing input in between
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//string2=string1.substr(pos,length);if len no specified then till end
//void fill (ForwardIterator first, ForwardIterator last, const T& val);
//The range filled is [first,last), which contains all the elements between first and last, including the element pointed by first but not the element pointed by last.


//If wrong on pretest 2 means logically wrong
/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


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

using namespace std;

#define ll long long
#define ld long double
#define ff first
#define ss second
#define rsz resize
#define ins insert 
#define mp make_pair
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define ft front() 
#define bk back()
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define deb(x) cout<<#x<<" "<<x<<'\n';
#define rep(i,a,b) for (int i = (a); i < (b); ++i)

const ll mod = 1e9+7; // 998244353;
const ll inf = 1e18; 
const ld pie = acos((ld)-1);

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



int main(){
    
	string s;
	cin>>s;	
	int x=-1,y=-1;
	for(int i=0;i<s.length()-1;++i){
		if(s[i]==s[i+1]){
			x=i+1;
			y=i+2;
			break;
		}
	}

	for(int i=0;i<s.length()-2;++i){
		if(s[i]==s[i+2]){
			x=i+1;
			y=i+3;
			break;
		}
	}

	printf("%d %d\n",x,y);

	return 0;

	/*STUFF TO LOOK:	
		1. Check the constraints
		2. Corner cases(n==0||n==1)
		3. Variables in loops
		4. Make sure two ints aren’t multiplied to get a long long
		5. Don't use scanf or printf while using ios_base
		6. using the local variable of the same name when global variable was required to be used
	*/
}


Measured memory_bytes: 3828
import java.util.*;

public class Main {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(b < a ? 0 : Math.min(b / a, c));
    }
}

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

typedef long long ll;
//typedef ll int;
ll mod = 1000000007;

bool comp(pair<ll, ll> a, pair<ll, ll> b){
    if(a.first == b.first){
        return a.second < b.second;
    }
    else return a.first > b.first;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, m;
    cin >> n >> m;
    vector<vector<ll> > v(m+1);
    ll a, b;
    for(int i=0; i<n; i++){
        cin >> a >> b;
        if(a > m) continue;
        v[a].push_back(b);
    }
    ll total = 0;
    priority_queue<int> q;
    for(int i=1; i<=m; i++){
        for(auto j:v[i])
            q.push(j);
        if(!q.empty()){
            total += q.top(); q.pop();
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 5632
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

struct WarshallFloyd {
  vector<int> a,b,c;
  int V,E; // 辺の数
  int INF;
  vector<vector<int> > dist;
  WarshallFloyd(int V, int E):V(V),E(E){
    INF = 2e9;
    a.resize(E,INF);
    b.resize(E,INF);
    c.resize(E,INF);
    dist.resize(V, vector<int>(V, INF));
  }
  void calc(){
    for(int i=0;i<V;i++){
      dist[i][i]=0;
    }
    for(int i=0;i<E;i++){
      dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
    }
    for(int k=0;k<V;k++){
      for(int i=0;i<V;i++){
        for(int j=0;j<V;j++){
          if(dist[i][k]==INF||dist[k][j]==INF) continue;
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int V,E;
  cin>>V>>E;
  WarshallFloyd WF(V, E);
  FOR(i,0,E){
    cin>>WF.a[i]>>WF.b[i]>>WF.c[i];
  }
  WF.calc();
  FOR(i,0,V){
    if(WF.dist[i][i]<0){
      cout<<"NEGATIVE CYCLE"<<endl;
      return 0;
    }
  }
  FOR(i,0,V) {
    FOR(j,0,V) {
      if(j) cout<<" ";
      if(WF.dist[i][j]==2e9) cout<<"INF";
      else cout<<WF.dist[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 3268
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int S,h,m,s;
	cin>>S;
	h=S/3600;
	m=(S%3600)/60;
	s=S-(h*3600)-(m*60);
	cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int INF=(int)1e9;
const int MOD=(int)1e9+7;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};



int main(){
  string s,t;
  cin>>s>>t;
  vector<int> vs(26,-1);
  vector<int> vt(26,-1);

  for(int i=0;i<s.size();i++){
    int a=s[i]-'a';
    int b=t[i]-'a';

    if(vs[a]!=-1||vt[b]!=-1){
      if(vs[a]!=b||vt[b]!=a){
        cout<<"No"<<endl;
        return 0;
      }
    }else{
      vs[a]=b;
      vt[b]=a;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

const int mod = 1e9+7;
const ll INF = 1e18;



int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll N,Q;
    cin >> N;
    unordered_map<ll, int> m;
    ll sum = 0;
    for(int i = 0 ; i < N ; i++){
        ll temp;
        cin >> temp;
        m[temp]++;
        sum += temp;
    }
   cin >> Q; 
    ll B,C;
   for(int i = 0 ; i < Q ;i++){
        cin >> B >> C;
        sum += C*m[B];
        sum -= B*m[B];
        m[C] += m[B];
        m.erase(B);
        cout << sum << "\n";
   }

}


Measured memory_bytes: 6660
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#define int long long
using namespace std;
signed main(){
  int n,p[10],ans=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>p[i];
  sort(p,p+n);
  p[n-1]=p[n-1]/2;
  for(int i=0;i<n;i++)ans+=p[i];
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include    <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include  <cstdlib>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long lint;
#define SZ(x) ((int)(x).size())
int main()
{
	int a[3];
	rep(i, 3) cin >> a[i];
	
	int b[3];
	b[0] = abs(a[1] - a[0]);
	b[1] = abs(a[2] - a[1]);
	b[2] = abs(a[2] - a[0]);
	int max = -100000000;

	rep(i, 3) {
		if (max < b[i])max = b[i];
	}
	cout <<b[0]+b[1]+b[2]-max << endl;
	return 0;
}



Measured memory_bytes: 256
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut cube = HashMap::new();
 
    cube.entry('0').or_insert(0);
    cube.entry('1').or_insert(0);
 
    for c in s.iter() {
        let count = cube.entry(*c).or_insert(0);
        *count += 1;
    }
 
    let min = cube.values().min().unwrap();
 
    if min == &0 {
        println!("{:?}", 0);
    }else{
        println!("{:?}", min * 2);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  string a;
  cin >> a;
  
  if((a[0]==a[1] && a[1]==a[2]) || (a[2]==a[3] && a[1]==a[2])) cout << "Yes" << endl;
  else cout << "No" << endl;
 
 
}

Measured memory_bytes: 256
import numpy as np
n, m = map(int, input().split())
result = [[0, 0] for _ in range(n)]

for i in range(m):
    a, b = input().split()
    a = int(a) - 1

    if b == "AC":
        result[a][0] = 1
    elif not result[a][0]:
        result[a][1] += 1
print(np.sum(result, axis=0)[0], np.prod(result, axis=-1).sum())


Measured memory_bytes: 25656
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        if (input == "Sunny") { Console.WriteLine("Cloudy"); }
        else if (input == "Cloudy") { Console.WriteLine("Rainy"); }
        else if (input == "Rainy") { Console.WriteLine("Sunny"); }
    }
}


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

#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define ss second
#define ff first
#define sz(s) (int)s.size()
#define all(a) a.begin(),a.end()

#ifndef ONLINE_JUDGE
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

#else
#define trace(args...) { }
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
  IOS;
  int n, m, c;
  cin >> n >> m >> c;
  int b[m], a[n][m];
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    int val = 0;
    for(int j = 0; j < m; j++){
      val += a[i][j] * b[j];
    }
    val += c;
    ans += (val > 0);
  }
  cout << ans << '\n';
  return 0;
}

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

const int mod = 1e9 + 7;

void add_self (int & a, int b) {
	a += b;
	if (a >= mod) a -= mod;
}

int mul (int a, int b) {
	return (int) (((ll) a * b) % mod);
}

int power (int a, int k) {
	int ans = 1;
	while (k >= 1) {
		if (k & 1) ans = mul (ans, a);
		a = mul (a, a);
		k >>= 1;
	}
	return ans;
}

int inverse (int a) {
	return power (a, mod - 2);
}

int main() {
	int n, m, p;
	string s;
	cin >> n >> m;
	vector < int > penalties (n), ac (n);
	while (m--) {
		cin >> p >> s;
		p--;
		if (s == "AC") {
			ac[p] = 1;
		} else {
			if (ac[p] == 0) {
				penalties[p]++;
			}
		}
	}
	int sum1 = 0, sum2 = 0;
	for (int i = 0; i < n; i++) {
		sum1 += ac[i] * penalties[i];
		sum2 += ac[i];
	}
	cout << sum2 << " " << sum1 << endl;
	return 0;
}



Measured memory_bytes: 1024
t;main(a,b,c){
    long int k;
    scanf("%d%d%d%ld",&a,&b,&c,&k);
    
  t=k%2?b-a:a-b;
    
    if(abs(a-b)>pow(10,18)){
        printf("Unfair");
    }else{
        printf("%d",t);
    }
}

Measured memory_bytes: 1728
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXX 1e12
#define MAXN 100005
ll dp[101][MAXN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N,W; cin>>N>>W;
    ll wei[N],val[N];
    
    for(ll i=0;i<N;++i)
        cin>>wei[i]>>val[i];
    
    dp[0][0] = 0;
    for(ll i=1;i<MAXN;++i) //base case
        dp[0][i] = MAXX;
    
    //cout<<dp[0][MAXN]<<endl;
    
    for(ll i=1;i<=N;++i)
    {
        for(ll j=0;j<MAXN;++j)
        {
            dp[i][j] = dp[i - 1][j];
            
            if((j >= val[i - 1]) && (dp[i - 1][j - val[i - 1]] != MAXX))
                dp[i][j] = min(dp[i][j],dp[i - 1][j - val[i - 1]] + wei[i - 1]);
        }
    }
    
    //cout<<dp[0][MAXN]<<endl;
    
    ll ans = 0;
    for(ll j=0;j<MAXN;++j)
    {
        if((dp[N][j] != MAXX) && (dp[N][j] <= W))
            ans = j;
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 82532
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

ll s=0,n; cin>>n;
for(ll i=1;i<=n;i++)
{
	if(i%3!=0 && i%5!=0) s+=i;
}
cout<<s;




return 0;
}

Measured memory_bytes: 3636
import math

N = int(input())
x, y = map(int, input().split())
for _ in range(N-1):
  a, b = map(int, input().split())
  # n = max(math.ceil(x/a), math.ceil(y/b))
  na = nb = 0
  if x%a == 0:
    na = x//a
  else:
    na = x//a+1
  if y%b == 0:
    nb = y//b
  else:
    nb = y//b+1
  n = max(na, nb)
  x, y = n*a, n*b
print(x+y)


Measured memory_bytes: 3064
n,k=map(int,input().split())
s=[]
for i in range(n):
	x,y=map(int,input().split())
	s.append([x,y])
s.sort()
for i in range(n):
	k-=s[i][1]
	if k<=0:
		print(s[i][0])
		break
	

Measured memory_bytes: 20104
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T> bool chmax(T &a, const T &b) {
  if(a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if(b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];

  ll ans = LINF;

  k--;
  for(int i = 0; i < n; i++) {
    if(i - k >= 0) {
      ll d = abs(x[i] - x[i - k]);
      d += min(abs(x[i]), abs(x[i - k]));
      chmin(ans, d);
    }
    if(i + k < n - 1) {
      ll d = abs(x[i] - x[i + k]);
      d += min(abs(x[i]), abs(x[i + k]));
      chmin(ans, d);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _for(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FOR(...)   _for (__VA_ARGS__)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n, m;
  cin >> n >> m;
  vector <set <int>> sc (n);

  rep (i, m)
  {
    int s, c;
    cin >> s >> c;
    -- s;

    sc[s].insert (c);
  }
  vector <int> ans (n, 0);
  bool success = true;

  rep (i, sc.size ())
  {
    auto && elem = sc[i];
    if (elem.empty ())
    {
      if (i == 0 && n > 1) ans[i] = 1;
      else ans[i] = 0;
    }
    else if (elem.size () == 1)
    {
      auto c = * begin (elem);
      if (i == 0 && c == 0 && n > 1)
      {
        success = false;
        break;
      }
      ans[i] = c;
    }
    else
    {
      success = false;
      break;
    }
  }
  if (success)
  {
    for (auto && elem : ans) cout << elem;
    cout << endl;
  }
  else cout << -1 << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BRGBBoxes {
public:
    void solve(std::istream &in, std::ostream &out) {
        int r, g, b, n;
        in >> r >> g >> b >> n;
        int res = 0;
        FOR(i, 0, n / r + 1) {
            int n2 = n - i * r;
            FOR(j, 0, n2 / g + 1) {
                int n3 = n2 - j * g;
                res += n3 % b == 0;
            }
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BRGBBoxes solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
let (k, a, b) = Scanf.sscanf (read_line ()) "%d %d %d" @@ fun k a b -> (k, a, b)

let () = Printf.printf "%d\n" @@ 
  if b < a then k + 1
  else max (k + 1) (a + (k - a + 1) / 2 * (b - a) + (k - a + 1) mod 2)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

#define __STDC_FORMAT_MACROS
#define p64 PRId64

using namespace std;

using ll = int64_t;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || '9' < c) break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    int N;

    gc(N);

    map<int, int> mp;

    REP(i, N)
    {
        int a;
        gc(a);

        // value index
        mp[a] = i;
    }

    set<int> st;

    ll ans = 0;
    for (auto &&m : mp)
    {
        st.insert(m.second);

        auto s = st.find(m.second);

        // 0-indexed
        int start = -1;
        int end = N;
        if (s != st.begin())
        {
            s--;
            start = (*s);
            s++;
        }

        if (++s != st.end())
        {
            end = (*s);
        }

        ll L = max((ll)1, (ll)m.second - start);
        ll R = max((ll)1, (ll)end - m.second);
        ans += L * R * m.first;
    }

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


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int K, X;
	cin >> K >> X;

	int idx = X-K+1;
	while(idx < X+K) {
		cout << idx << " ";
		idx++;
	}
	cout << "\n";



	return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
mod=10**9+7
if N>M+1 or M>N+1:
    print(0)
    exit()
value=1
if N==M:value*=2
for n in range(1,N+1):
    value*=n
    if value>mod:
        value%=mod
for m in range(1,M+1):
    value*=m
    if value>mod:
        value%=mod
print(value)


Measured memory_bytes: 3060
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(N, K):
    ans = 1
    while N >= K:
        N = N // K
        ans += 1
    return ans


if __name__ == "__main__":

    # N K
    #
    N, K = map(int, input().split())
    ans = solv(N, K)

    print(ans)


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e9;

int GCD(int a,int b){
	if(a < b){
		return GCD(b,a);
	}
	if(b == 0) return a;
	if(b == 1) return 1;
	return GCD(b,a%b);
}

int main()
{
	int N,X;
	cin>>N>>X;
	int *x = new int[N];
	int minimumX = INF;
	int ans;
	rep(i,N){
		int num;
		cin>>x[i];
		minimumX = min(minimumX,x[i]);
	}
	ans = abs(minimumX - X);
	rep(i,N){
		x[i] = x[i] - minimumX;
	}
	sort(x,x+N);
	for(int i = 1; i<N; i++){
		ans = GCD(x[i],ans);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=400 +117;
const int MM=10000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
LL ans[NN][NN]={};
LL lcm(LL a,LL b){
	return a/__gcd(a,b)*b;
}
int pr[MM]={},psiz=0;
int np[MM]={};
void getprime(int n){
	np[1]=1;
	for(int i=2;i<=n;++i){
		if(!np[i]){
			pr[psiz++]=i;
		}
		for(int j=0;pr[j]*i<=n;++j){
			np[pr[j]*i]=1;
			if(!(i%pr[j]))break;
		}
	}
}
int main(){
	//open();
	n=read();
	if(n==2){
		printf("2 5\n");
		printf("7 36\n");
		return 0;
	}
	getprime(10000);
	int mn=(1-n)/2,mx=(n-1)/2;
	mx-=mn;
	for(int i=0;i<=n+1;++i){
		for(int j=0;j<=n+1;++j){
			ans[i][j]=1;
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if((i+j)&1)continue;
			int c=(i-j)/2;
			int d=(i+j)/2;
			LL res=pr[c-mn]*pr[mx+d];
			ans[i][j]=res;
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if((i+j)&1){
				LL now=1;
				now=lcm(now,ans[i][j-1]);
				now=lcm(now,ans[i][j+1]);
				now=lcm(now,ans[i-1][j]);
				now=lcm(now,ans[i+1][j]);
				ans[i][j]=now+1;
			}
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			printf("%lld ",ans[i][j]);
		}
		putchar('\n');
	}
	close();
	return 0;
}

Measured memory_bytes: 5248
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author jcg
 */

#include <iostream>

#include <iostream>
#include <vector>

class DPreparingBoxes
{
public:
    void solve(std::istream& in, std::ostream& out)
    {
        int N;
        in >> N;

        std::vector<int> boxes(N), rem(N);
        for (int &x : rem) in >> x;

        int balls = 0;
        for (int i = N - 1; i >= 0; --i)
        {
            int sum = 0;
            for (int j = i; j < N; j += i + 1)
                sum += boxes[j];
            if (sum % 2 != rem[i] % 2)
                boxes[i] = 1, ++balls;
        }

        out << balls << '\n';
        for (int i = 0; i < N; ++i)
            if (boxes[i]) out << i + 1 << '\n';
    }
};


int main()
{
    std::ios_base::sync_with_stdio(0);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    in.tie(0);
    DPreparingBoxes solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
int main(){
  int N,X,Y,i,j;
  scanf("%d%d%d",&N,&X,&Y);
  int count[N+1];
  for(i=1;i<N;i++)
    count[i]=0;
  for(i=1;i<N;i++){
    for(j=i+1;j<=N;j++){
      if(j-i>abs(i-X)+abs(j-Y)+1)
        count[abs(i-X)+abs(j-Y)+1]++;
      else
        count[j-i]++;
    }
  }
  for(i=1;i<N;i++)
    printf("%d\n",count[i]);
  return 0;
}
    
  

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

int main() {
  string N;
  cin >> N;
  int COUNT1 = 0;
  int COUNT0 = 0;
  for (int i = 0; i < N.size(); i++){
    if (N.at(i) == '1')
      COUNT1++;
    else
      COUNT0++;
  } 
     cout << min(COUNT1,COUNT0)*2 << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int ans = 0;
  rep(i, (int)s.size() - 1) {
    if (s[i] ^ s[i + 1]) ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3744
A, B, C = [int(x) for x in input().split()]
r_set = set()
i = 1
can = False
while True:
    r = A * i % B
    if r == C:
        can = True
        break
    else:
        if not r in r_set:
            r_set.add(r)
            i += 1
        else:
            break
print('YES') if can else print('NO')


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {


	public static void main(String[] args){

		Scanner sc =new Scanner(System.in);
 
		int Count =0;
	String	s=sc.next();


  
	


for(int i=0;i<s.length();i++){
	if (s.charAt(i)=='1'){

	Count++;
}

}

System.out.println(Count);

	}
}

Measured memory_bytes: 21332
#include<stdio.h>
#include<math.h>
int main()
{
	double a,b,C;
	double S,L,h;
	scanf("%lf%lf%lf",&a,&b,&C);
	S=0.5*a*b*sin(M_PI*C/180);
	L=sqrt(a*a+b*b-2*a*b*cos(M_PI*C/180))+a+b;
	h=S*2/a;
	printf("%.20lf\n%.20lf\n%.20lf\n",S,L,h);
	return 0;
} 


Measured memory_bytes: 3136
import sys

n, m, o = map(int, sys.stdin.readline().strip().split())

mat1 = []
for _ in range(n):
    mat1.append(list(map(int, sys.stdin.readline().strip().split())))

mat2 = []
for _ in range(m):
    mat2.append(list(map(int, sys.stdin.readline().strip().split())))

for i in range(n):
    row = (sum(mat1[i][k] * mat2[k][j] for k in range(m)) for j in range(o))
    print(' '.join(map(str, row)))



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

int m, n;
string s, t;
int ans = 0;

int dp[2001][2001][2];
int main()
{
  cin >> m >> n;
  cin >> s >> t;

  for(int i = 0; i <= m; i++)
    for(int j = 0; j <= n; j++){
      if(i != 0){
	if(s[i - 1] == 'I'){
	  dp[i][j][1] = dp[i - 1][j][0] + 1;
	  ans = max(ans, dp[i][j][1]);
	}
	else if(dp[i - 1][j][1] > 0){
	  dp[i][j][0] = dp[i - 1][j][1] + 1;
	}
      }
      if(j != 0){
	if(t[j - 1] == 'I'){
	  dp[i][j][1] = max(dp[i][j][1], dp[i][j - 1][0] + 1);
	  ans = max(ans, dp[i][j][1]);
	}
	else if(dp[i][j - 1][1] > 0){
	  dp[i][j][0] = max(dp[i][j][0], dp[i][j - 1][1] + 1);
	}
      }
    }  
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 32488
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long
#define lli long long int

using namespace std;
using P = pair<int,int>;

int main(){

  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  int ans = 0;

  vector<P> p(5);
  p[0].first  = A%10;
  p[0].second = A;
  p[1].first  = B%10;
  p[1].second = B;
  p[2].first  = C%10;
  p[2].second = C;
  p[3].first  = D%10;
  p[3].second = D;
  p[4].first  = E%10;
  p[4].second = E;
  sort(p.begin(), p.end());

  bool flag = false;
  for (int i = 0; i < 5; i++) {
    if(p[i].first == 0){
      ans += p[i].second;
    }else{
      if(flag == false){
        ans += p[i].second;
        flag = true;
      }else{
        ans += (p[i].second/10 + 1)*10;
      }
    }
    // cout << p[i].first << " -> " << p[i].second << endl;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15

//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";

//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

//ライブラリ終わり

int main() {
  char X, Y;
  cin >> X >> Y;
  if (X > Y) {
    cout << ">" << endl;
  }
  else if (X == Y) {
    cout << "=" << endl;
  }
  else {
    cout << "<" << endl;
  }
}

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

using namespace std;
string a;
int main()
{
    cin>>a;
    int len=a.size();
    if(len%2==1) 
    {
        cout<<"No";
        cout<<endl;
        return 0;
    }
    int r=0;
    for(int i=0,j=len-1;i<j;i++,j--)
    {
        if((a[i]=='p' && a[j]=='q') || (a[i]=='q' && a[j]=='p') ||(a[i]=='d' && a[j]=='b') || (a[i]=='b' && a[j]=='d')) ;
        else 
        {
            r=1;
            break;
        }
    }
    if(r==0) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    
    return 0;
}

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

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

  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> l(n), r(n);
  rep(i, q) {
    cin >> l[i] >> r[i];
    --l[i], --r[i];
  }

  vector<int> sum(n);
  sum[0] = 0;
  rep2(i, 1, n) {
    if (s[i-1] == 'A' && s[i] == 'C') {
      sum[i] = sum[i-1] + 1;
    } else {
      sum[i] = sum[i-1];
    }
  }
  rep(i, q) {
    cout << sum[r[i]] - sum[l[i]] << endl;
  }
  return 0;
}


Measured memory_bytes: 2256
#include "bits/stdc++.h"
using namespace std;

const int N=2e5+5;


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

    int n; cin>>n;
    vector<int>freq(n+5, 0);
    for(int i=1; i<n; i++){
        int a; cin>>a; freq[a]++;
    }
    for(int i=1; i<=n; i++) cout<<freq[i]<<'\n';
    return 0;
}


Measured memory_bytes: 3988
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

internal class Program {
    static void Main() => CustomMain();

    static void Solve() {
        var n = ReadInt();
        var a = ReadInt();
        var ans = n % 500 <= a ? "Yes" : "No";
        WriteAnswer(ans);
    }


    static void CustomMain() {
#if DEBUG
        // ファイルからテストケースを読み込む
        ChangeStdIn();
        // 時間計測
        var stopwatch = new Stopwatch();
        stopwatch.Start();
#endif
        // 出力高速化
        var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(streamWriter);
        // 回答
        Solve();
#if DEBUG
        stopwatch.Stop();
        Console.WriteLine(stopwatch.Elapsed);
#endif
        Console.Out.Flush();
    }

    static string ReadString() => Console.ReadLine().Trim();
    static int ReadInt() => int.Parse(ReadString());
    static long ReadLong() => long.Parse(ReadString());
    static float ReadFloat() => float.Parse(ReadString());
    static double ReadDouble => double.Parse(ReadString());

    static string[] ReadStringArray() => ReadString().Split(' ');
    static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
    static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
    static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
    static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

    static T TypeConversion<T>(string s) {
        if (typeof(T) == typeof(int)) {
            return (T) Convert.ChangeType(int.Parse(s), typeof(T));
        } else if (typeof(T) == typeof(long)) {
            return (T) Convert.ChangeType(long.Parse(s), typeof(T));
        } else if (typeof(T) == typeof(double)) {
            return (T) Convert.ChangeType(double.Parse(s), typeof(T));
        } else {
            return (T) Convert.ChangeType(s, typeof(T));
        }
    }

    static void ReadMulti<T, U>(out T a, out U b) {
        var str = ReadStringArray();
        a = TypeConversion<T>(str[0]);
        b = TypeConversion<U>(str[1]);
    }

    static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
        var str = ReadStringArray();
        a = TypeConversion<T>(str[0]);
        b = TypeConversion<U>(str[1]);
        c = TypeConversion<V>(str[2]);
    }

    static void WriteAnswer(object ans) => Console.WriteLine(ans);

    static bool IsOdd(long num) {
        return (num & 1) == 1;
    }

    static bool IsEven(long num) {
        return (num & 1) == 0;
    }

    static long GCD(long a, long b) {
        return b != 0 ? GCD(b, a % b) : a;
    }

    static long RoundUp(long a, long b) {
        return (a + b - 1) / b;
    }


    static void ChangeStdIn() {
        var path = "./../../TestCase.txt";
        var exStdIn = new System.IO.StreamReader(path);
        Console.SetIn(exStdIn);
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(void)
{
	int i, j;
	int a, b;
	int top[3];
	
	j = 0;
	a = 0;
	b = 0;
	top[0] = 0;
	top[1] = 0;
	top[2] = 0;
	for (i = 0; i < 10; i++){
		scanf("%d", &j);
		if (top[0] < j){
			b = top[1];
			top[1] = top[0];
			top[2] = b;
			top[0] = j;
		}
		else if (top[1] < j){
			top[2] = top[1];
			top[1] = j;
		}
		else if (top[2] < j){
			top[2] = j;
		}
	}
	printf("%d\n%d\n%d\n", top[0], top[1], top[2]);
	
	return (0);
}

Measured memory_bytes: 0
using System;

namespace AtCoder
{
    static class Program
    {
        private static int passes = 0;
        private static int passedO = 0;

        static void Main()
        {
            int[] nbrs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int A = nbrs[1];
            int B = nbrs[2];

            string s = Console.ReadLine();

            for(int i = 0; i < s.Length; i++)
            {
                if(s[i] == 'a')
                {
                    if (passes < A + B)
                        Passed();
                    else
                        Failed();
                }
                else if(s[i] == 'b')
                {
                    if (passes < A + B && passedO < B)
                    {
                        Passed();
                        passedO++;
                    }
                    else
                        Failed();
                }
                else
                    Failed();
            }
        }

        public static void Passed()
        {
            Console.WriteLine("Yes");
            passes++;
        }

        public static void Failed()
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13664
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

bool visited[14500000];

/*
int mypow(int x,int n){
	int res = 1;
	while(n>0){		
		res *= x;
		if(n & 1) x = x*x;
		n>>=1;
	}
	return res;
}
*/

int conv(vector<int>& sets,int n){
	int res = 0;
	for(int i=0;i<sets.size();i++){
		for(int j=0;j<n;j++){
			if(sets[i] & (1<<j)){
				res += i * pow(3.0,j);
			}
		}
	}
	return res;
}

int bfs(int m,int n,vector<int>& root,bool* visited){

	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,root));
	visited[conv(root,n)] = 0;
	vector<int> tmp;
	vector<int> sets;
	while(!que.empty()){
		int cost = que.top().first;
		
		sets = que.top().second;

		if(sets[1]==0 && sets[2]==0) return cost;
		if(sets[0]==0 && sets[1]==0) return cost;

		if(cost >= m) break;
		que.pop();
		for(int i=0;i+1<sets.size();i++){
			if((sets[i] && sets[i+1] && sets[i] < sets[i+1]) 
				|| (!sets[i] && sets[i+1])){
				tmp = sets;

				int pos=0;
				for(int j=n;j>=0;j--){
					if(tmp[i+1] & (1<<j)){
						pos = j;
						break;
					}
				}
				tmp[i+1] &= ~(1<<pos);
				tmp[i] |= (1<<pos);

				
				int next;
				if(!visited[(next = conv(tmp,n))]){
					visited[next] = cost+1;
					que.push(P(cost+1,tmp));
				}
			}

			else if((sets[i] && sets[i+1] && sets[i] > sets[i+1]) 
				|| (sets[i] && !sets[i+1])){
				tmp = sets;

				int pos=0;
				for(int j=n;j>=0;j--){
					if(tmp[i] & (1<<j)){
						pos = j;
						break;
					}
				}
				tmp[i] &= ~(1<<pos);
				tmp[i+1] |= (1<<pos);

				int next;
				if(!visited[(next = conv(tmp,n))]){
					visited[next] = cost+1;
					que.push(P(cost+1,tmp));
				}
			}
		}
	}
	return -1;
}

int main(){

	int n,m;
	while(~scanf("%d %d",&n,&m)){
		if(n==m && m==0) break;
		vector<int> sets(3);	
		memset(visited,0,sizeof(visited));
		for(int i=0;i<3;i++){
			int amount;
			scanf("%d",&amount);
			for(int j=0;j<amount;j++){
				int size;
				scanf("%d",&size);
				sets[i] |= (1<<(size-1)); 
			}
		}

		printf("%d\n",bfs(m,n,sets,visited));
	}
	//printf("%d %d %d\n",mypow(3,0),mypow(3,1),mypow(3,2));
}

Measured memory_bytes: 14000
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define int long long

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

vector<int> vs;

bool solve(int idx, int m, int len) {
    if (m == 0) {
        return true;
    }
    if (idx >= len) {
        return false;
    }

    bool ok = solve(idx + 1, m, len) || solve(idx + 1, m - vs[idx], len);
    return ok;
}

signed main() {
    int n;
    cin >> n;
    vs.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> vs[i];
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int m;
        cin >> m;
        if (solve(0, m, n)) {
            puts("yes");
        } else {
            puts("no");
        }
    }
}



Measured memory_bytes: 3128
import std.stdio, std.array;

void main() {
  while(true) {
    int[101] field;
    for(int n, m; readf("%d %d\n", &n, &m), n + m != 0;) {
      field[n]++;
      field[m]++;
    }
    if(stdin.eof) break;

    bool ans = (field[1] & 1) == 1 && (field[2] & 1) == 1;
    for(int i = 3; i <= 100; i++)
      ans &= ((field[i] & 1) == 0);
    
    writeln(ans ? "OK" : "NG");
  }
}

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

int main(){
  char c;
  cin >> c;
  string vowel = "aeiou";
  if (vowel.find(c) == string::npos) {
    cout << "consonant" << endl;
  } else {
    cout << "vowel" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	string s;
	cin>>s;
	int count=0,len=s.length();
	for(int i=0;i<len/2;i++){
		if(s[i]!=s[len-i-1]){
			count++;
		}
	}
	cout<<count;
}

Measured memory_bytes: 256
S=str(input())
s1=[0]
s2=[1]
for i in range(len(S)-1):
  if(s1[-1]==0): s1.append(1)
  else: s1.append(0)
for i in range(len(S)-1):
  if(s2[-1]==0): s2.append(1)
  else: s2.append(0)

d1=0
d2=0
for i,v in enumerate(S):
  d1 += abs(s1[i]-int(v))
  d2 += abs(s2[i]-int(v))

if(d1>d2): print(d2)
else: print(d1)

Measured memory_bytes: 4852
#include <iostream>
#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long
#define read freopen("input/test (4).txt","r",stdin)
#define write freopen("output/test (4).txt","w",stdout)
#define fr first
#define sc second
#include <sstream>
#define ii pair < int , int >
using namespace std;
int main()
{
 ll n,k;
 cin>>n>>k;
 ll sum = k;
 for(int i=1;i<n;i++)
 {
     sum = sum*(k-1);
 }
 cout<<sum;
}


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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, M, ans=0, tmp=0;
vector<ll> A;
map<ll,ll> MP1, MP2;

signed main(){
    cin >> N >> M;
    MP1[0]++;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        tmp += a;
        tmp %= M;
        MP1[tmp]++;
    }
    for(map<ll,ll>::iterator itr=MP1.begin();itr!=MP1.end();itr++) {
        pair<ll,ll> p = *itr;
        MP2[p.second]++;
    }
    
    for(map<ll,ll>::iterator itr=MP2.begin();itr!=MP2.end();itr++) {
        pair<ll,ll> p = *itr;
        if(p.first>=2) {
            ans += p.second*p.first*(p.first-1)/2;
        }
    }

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

Measured memory_bytes: 4224
def reachable(es, source):
	ret = {source}
	Q = [source]
	while Q:
		cur = Q.pop()
		for nxt in es[cur]:
			if nxt not in ret:
				Q.append(nxt)
				ret.add(nxt)
	return ret

def BellmanFord(V: int, es: list, source=0):
	INF = float("inf")
	D = [INF] * V
	D[source] = 0
	for _ in range(V):
		upd = False
		for f, t, c in es:
			tmp = D[f] + c
			if D[t] > tmp:
				D[t] = tmp
				upd = True
		if not upd:
			return D[-1]
	else:
		# Negative Cycle
		return None


def main():
	N, M, *L = map(int, open(0).read().split())
	fwd = [[] for _ in range(N)]
	bwd = [[] for _ in range(N)]
	tmp = []
	for a, b, c in zip(*[iter(L)] * 3):
		fwd[a - 1].append(b - 1)
		bwd[b - 1].append(a - 1)
		tmp += [(a - 1, b - 1, - c)]
	ra = reachable(fwd, 0) & reachable(bwd, N - 1)
	ans = BellmanFord(N, [(a, b, c) for a, b, c in tmp if a in ra and b in ra])
	if ans == None:
		print("inf")
	else:
		print(-ans)


if __name__ == "__main__":
	main()

Measured memory_bytes: 4084
n=int(input())
dic={}
max=0
list=[]

for i in range(n):
    s=input()
    dic.setdefault(s,0)
    dic[s]+=1
    if dic[s]>max:
        list=[s]
        max=dic[s]
    elif dic[s]==max:
        list.append(s)

list.sort()

for word in list:
    print(word)



Measured memory_bytes: 33420
import itertools
S=list(input())
T=list(itertools.product(["+","-"],repeat=3))
for seq in T:
    tmp=""
    for i in range(3):
        tmp+=S[i]+seq[i]
    tmp=tmp+S[3]
    if eval(tmp)==7:
        print(tmp+"=7")
        exit()
print("Baka!")

Measured memory_bytes: 3188
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(int i = 0; i < x; i++)
using namespace std;
typedef long long ll;
ll MOD = (ll)1e9 + 7;
const ll N = 2e5+5, inf = 1e18+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll mod_exp(ll x, ll e) {
    ll ans = 1;
    while (e > 0) {
        if (e & 1) ans = mult(ans, x);
        x = mult(x, x);
        e >>= 1;
    }
    return ans;
}

vector<ll> fact(N), inv_fact(N);
ll binom(ll n, ll k) {
    if (k == 0) return 1;
    if (n < k || n < 0 || k < 0) return 0;
    return mult(fact[n], mult(inv_fact[k], inv_fact[n-k]));
}

struct Block {
    ll x, y;
    bool operator==(const Block &rhs) const {
        return x == rhs.x &&
               y == rhs.y;
    }
};

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    ll h, w, n; cin >> h >> w >> n;
    h--, w--;
    vector<Block> blocked(n+1);
    rep (i, n) {
        cin >> blocked[i].y >> blocked[i].x;
        blocked[i].x--, blocked[i].y--;
    }
    fact[0] = inv_fact[0] = 1;
    for (ll i = 1; i < N; ++i) {
        fact[i] = mult(fact[i-1], i);
        inv_fact[i] = mod_exp(fact[i], MOD-2);
    }

    vector<ll> dp(n+1);
    blocked[n] = {w, h};
    sort(begin(blocked), end(blocked), [](auto& x, auto& y) {
        return x.x+x.y < y.x+y.y;
    });

    for (int i = 0; i <= n; ++i) {
        dp[i] = binom(blocked[i].x+blocked[i].y, blocked[i].x);
        for (int j = 0; j < i; ++j) {
            if (blocked[i].x >= blocked[j].x && blocked[i].y >= blocked[j].y) {
                dp[i] = sub(dp[i], mult(dp[j], binom(blocked[i].x-blocked[j].x+blocked[i].y-blocked[j].y, blocked[i].x-blocked[j].x)));
            }
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 3456