akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int cnt = (c + b - 1) / b;
	int cnt2 = (a + d - 1) / d;
	cout << (cnt > cnt2 ? "No" : "Yes");
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>

typedef struct Bomb{
	int map[8][8];
} BOMB;

void Input(BOMB *);
void Output(BOMB);
void explode(BOMB *);

int x_cnt, y_cnt;

int main()
{
	int input_times, input_cnt;
	BOMB Bomb[50];
	int x, y;
	
	scanf("%d", &input_times);
	for(input_cnt = 0; input_cnt < input_times; input_cnt++){
		Input(&Bomb[input_cnt]);
		
		scanf("%d\n%d", &x, &y);
		Bomb[input_cnt].map[x - 1][y - 1] = 2;
		
		explode(&Bomb[input_cnt]);
	}
	
	for(input_cnt = 0; input_cnt < input_times; input_cnt++){
		printf("Data %d:\n", input_cnt + 1);
		Output(Bomb[input_cnt]);
	}
	
	return 0;
}

void Input(BOMB *bomb)
{
	char dump;
	dump = getchar();
	for(y_cnt = 0; y_cnt < 8; y_cnt++){
		dump = getchar();
		for(x_cnt = 0; x_cnt < 8; x_cnt++)
			bomb->map[x_cnt][y_cnt] = getchar() - 48;
	}
}

void Output(BOMB bomb)
{
	for(y_cnt = 0; y_cnt < 8; y_cnt++){
		for(x_cnt = 0; x_cnt < 8; x_cnt++)
			printf("%d", bomb.map[x_cnt][y_cnt]);
		printf("\n");
	}
}

void explode(BOMB* bomb_map)
{
	int explode_cnt;
	for(y_cnt = 0; y_cnt < 8; y_cnt++)
		for(x_cnt = 0; x_cnt < 8; x_cnt++)
			/*Find exploded bomb and process*/
			if(bomb_map->map[x_cnt][y_cnt] == 2){
				bomb_map->map[x_cnt][y_cnt] = 0;
				/*Left*/
				explode_cnt = 1;
				while((x_cnt - explode_cnt) >= 0 && explode_cnt <= 3){
				    if((bomb_map->map[x_cnt - explode_cnt][y_cnt]) == 1)
				        (bomb_map->map[x_cnt - explode_cnt][y_cnt]) = 2;
				    explode_cnt++;
				}
				/*Right*/
				explode_cnt = 1;
				while((x_cnt + explode_cnt) <= 7 && explode_cnt <= 3){
				    if((bomb_map->map[x_cnt + explode_cnt][y_cnt]) == 1)
				        (bomb_map->map[x_cnt + explode_cnt][y_cnt]) = 2;
				    explode_cnt++;
				}
				/*Down*/
				explode_cnt = 1;
				while((y_cnt - explode_cnt) >= 0 && explode_cnt <= 3){
				    if((bomb_map->map[x_cnt][y_cnt - explode_cnt]) == 1)
				        (bomb_map->map[x_cnt][y_cnt - explode_cnt]) = 2;
				    explode_cnt++;
				}
				/*Up*/
				explode_cnt = 1;
				while((y_cnt + explode_cnt) <= 7 && explode_cnt <= 3){
				    if((bomb_map->map[x_cnt][y_cnt + explode_cnt]) == 1)
				        (bomb_map->map[x_cnt][y_cnt + explode_cnt]) = 2;
				    explode_cnt++;
				}
				explode(bomb_map);
			}
}

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

int main(){
    string s;
    cin >> s;
    vector<string> in;
    for(int i=0;i<s.size();i++){
        in.push_back(s.substr(i,1));
    }
    for(int i=0;i<8;i++){
        int sum = 0;
        string buf  = "";
        buf += in[0];
        sum += stoi(in[0]);
        for(int k=0;k<3;k++){
            if(i&(1<<k)){
                buf += '-';
                buf += in[k+1];
                sum -= stoi(in[k+1]);
            }
            else{
                buf += '+';
                buf += in[k+1];
                sum += stoi(in[k+1]);
            }
        }
        if(sum == 7){
            buf += "=7";
            cout << buf << endl;
            return 0;
        }
    }
}

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

public class Main {

    public static void main(String[] args) {

        execute();
    }

    private static void execute() {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long[] A = new long[N];
        long[] AbsM = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
            AbsM[i] = Math.abs(A[i]);
        }

        long negativeCount = LongStream.of(A).filter(s -> s < 0).count();
        long absAmount = LongStream.of(AbsM).reduce(0, (s1, s2) -> s1 + s2);

        if (negativeCount % 2 == 0) {
            System.out.println(absAmount);
        } else {
            Arrays.sort(AbsM);
            System.out.println(absAmount - AbsM[0] * 2);
        }
    }

}


Measured memory_bytes: 61992
#include<iostream>
#include<set>
#include<map>

using namespace std;
typedef pair<int,int> pp;


int main()
{
    int point,num;
    char t;
    multiset<pp,greater<pp> > plist;
    while(cin >> num >> t >> point )
    {
        if(num==0&&point ==0)break;
        plist.insert(pp(point,num));
    }
    while(cin >> num)
    {
        int juni=1;
        int nowpoint = (*(plist.begin())).first;
        for(multiset<pp>::iterator it = plist.begin();it!=plist.end();++it)
        {
            if(nowpoint!=(*it).first)
            {
                juni+= 1;
                nowpoint = (*it).first;
            }
            if(num==(*it).second)
            {
                cout << juni << endl;
                break;
            }

        }
    }

    return 0;
}

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

using namespace std;

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

  int count = 0;
  for(int i=0; i < n; i++) {
    if(v[v[i]-1]-1 == i) count++;
  }
  cout << count/2 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

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

   int k;
   string s;
   cin >> k >> s;
   int n = s.size();
   if (n <= k)
      cout << s << endl;
   else {
      string t;
      rep(i, 0, k) t += s[i];
      t += "...";
      cout << t << endl;
   }
   return 0;
}

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

bool check(char me, char query, char left, char right){
  if (
      (me == 'S' && query == 'o') ||
      (me == 'W' && query == 'x')
      ){
    return left == right;
  } else   if (
      (me == 'S' && query == 'x') ||
      (me == 'W' && query == 'o')
      ){
    return left != right;
  }
  assert(false);
}

char decide(char me, char query, char left){
  if (me == 'S'){
    if (query == 'o'){
      return left;
    } else if (query == 'x'){
      return left == 'S' ? 'W' : 'S';
    }
  } else if (me == 'W'){
    if (query == 'o'){
      return left == 'S' ? 'W' : 'S';
    } else if (query == 'x'){
      return left;
    }
  }
  assert(false);
}

string check(const int n, const char a, const char b, const string & query){
  string ret;
  ret += string(1, a);
  ret += string(1, b);
  char last = decide(ret[0], query[0], ret[1]);
  for(int i = 1;i < n-1;i++){
    ret += string(1, decide(ret[i], query[i], ret[i-1]));
  }
  if (last == ret[n-1] &&
      check(ret[n-1], query[n-1], ret[n-2], ret[0])){
    return ret;
  }
  return "";
}

string solve(const int n, const string & in){
  char str[3] = "SW";
  for(int i = 0;i < 2;i++){
    for(int j = 0;j < 2;j++){
      string tmp = check(n, str[i], str[j], in);
      if (tmp.size() != 0)return tmp;
    }
  }
  return "-1";
}


int main(){
  int n;
  string in;
  cin >> n >> in;
  cout << solve(n, in) << endl;

  return 0;
}


Measured memory_bytes: 776
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    int N, K; cin >> N >> K;
    string S; cin >> S;

    if(S.at(K-1)=='A'){
        S.at(K-1)='a';
    }else if(S.at(K-1)=='a'){
        S.at(K-1)='A';
    }else if(S.at(K-1)=='B'){
        S.at(K-1)='b';
    }else if(S.at(K-1)=='b'){
        S.at(K-1)='B';
    }else if(S.at(K-1)=='C'){
        S.at(K-1)='c';
    }else if(S.at(K-1)=='c'){
        S.at(K-1)='C';
    }

    for(int i=0; i<N; i++){
        cout << S.at(i);
    }
    cout << endl;

}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};



int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,x;cin>>n>>x;
  vector<P>v(51);
  v[0]=MP(1,1);
  rep(i,1,51){
    v[i].fi=v[i-1].fi*2+3;
    v[i].se=v[i-1].se*2+1;
  }
  rrep(i,n,0){
    if(x==0)break;
    else if(x<=v[i].fi+1){
      if(i==0)res+=(x-1);
      x--;
      continue;
    }
    else if(x<=v[i].fi*2+2){
      if(i==0)res+=(x-3);
      res+=v[i].se+1;
      x-=v[i].fi+2; 
    }
    else{
      res+=v[i].se*2+1;
      x=0;
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
	rep(i,0,3){
		cout<<s[i];
	}
	
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i * i < N; ++i) {
        ++ans;
        if (i * (i + 1) < N) {
            int Q = N / i;
            if (i * Q < N) {
                // j = i + 1 ~ Q
                ans += 2 * (Q - i);
            } else {
                // j = i + 1 ~ Q - 1
                ans += 2 * (Q - i - 1);
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

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

vector<vector<ll>> edges;
vector<ll> L;
vector<bool> isVisit;

void visit(ll n) {
    if (isVisit[n]) {
        return;
    }

    isVisit[n] = true;
    for (auto next : edges[n]) {
        visit(next);
    }
    L.insert(L.begin(), n);
}

int main() {
    ll N, M;
    cin >> N >> M;
    edges.resize(N);
    isVisit.resize(N, false);
    for (ll i = 0; i < M; i++) {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        edges[x].push_back(y);
    }

    for (ll i = 0; i < N; i++) {
        visit(i);
    }

    vector<ll> node2index(N);
    for (ll i = 0; i < N; i++) {
        node2index[L[i]] = i;
    }

    vector<ll> dp(N, 0);
    for (ll i = 0; i < N; i++) {
        for (ll next : edges[L[i]]) {
            ll j = node2index[next];
            dp[j] = max(dp[j], dp[i] + 1);
        }
    }

    cout << *max_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 10996
fun main(args: Array<String>) {
    val n = readInputLine().toCharArray()
    
    var nineOtherFind = false
    
    for (i in 1..n.size - 1) {
        if (!nineOtherFind && n[i] != '9') {
            nineOtherFind = true
            n[i - 1]--
        }
        if (nineOtherFind) {
            n[i] = '9'
        }
    }
    println(n.map { it.toString().toInt() }.sum())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 34048
#include<stdio.h>
#include<stdlib.h>
#define INFTY 1000000000
void merge(int *,int ,int ,int );
void mergeSort(int *,int ,int );
int sum =0;

int main(){
  int *T;
  int n,i;
  int left,right;
  
  scanf("%d",&n);
  T = malloc(n*sizeof(int *));
  for(i=0 ; i<n ; i++) scanf("%d",&T[i]);

  left = 0;
  right = n;
  
  mergeSort(T,left,right);
 
  for(i=0 ; i<n-1 ; i++) printf("%d ",T[i]);
  printf("%d\n",T[n-1]);
  printf("%d\n",sum);

  return 0;
}


void merge(int *A,int left,int mid,int right){
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1], R[n2];
  
  for(i=0 ; i<n1 ; i++) L[i] = A[left + i];
  for(i=0 ; i<n2 ; i++) R[i] = A[mid + i];

  L[n1] = INFTY;
  R[n2] = INFTY;

  i = 0;
  j = 0;

  for(k=left ; k<right ; k++){
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      sum++;
    }
    else{ 
      A[k] = R[j];
      j = j + 1;
      sum++;
    }
  }
}

void mergeSort(int *A,int left,int right){
  int mid;
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

Measured memory_bytes: 5832
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int a, b, c, k;
  cin >> a >> b >> c >> k;
  long int ans = 0;
  if(a >= k) ans = k;
  else if(a + b >= k) ans = a;
  else ans = 2*a+b-k;
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
    int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b || b==c || c==a){
        if(a==b && b==c){
        cout << "1" << endl;
        }else{
            cout << "2" << endl;
        }
    }
    else{
        cout << "3" << endl;
    }
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  if(a+b>=c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL << 60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
    A[i] -= i+1;
  }
  sort(A.begin(),A.end());
  ll ans = INF;
  if(N%2){
    ll mid = A[N/2];
    ans = 0;
    for(int i=0; i<N; i++){
      ans += abs(mid-A[i]);
    }
  }else{
    ll mid = (A[N/2]+A[N/2-1])/2;
    ll temp = 0;
    for(int i=0; i<N; i++){
      temp += abs(mid - A[i]);
    }
    chmin(ans,temp);
    mid++;
    temp = 0;
    for(int i=0; i<N; i++){
      temp += abs(mid - A[i]);
    }
    chmin(ans,temp);
    mid -= 2;
    temp = 0;
    for(int i=0; i<N; i++){
      temp += abs(mid - A[i]);
    }
    chmin(ans,temp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import collections
import itertools

n = int(input())

per_dict = collections.defaultdict(list)
for i in range(n):
  a = int(input())
  for j in range(a):
    x, y = map(int, input().split())
    per_dict[i + 1].append([x,y]) 

for i in range(n, -1, -1):
  flag = True
  for honests in itertools.combinations(range(1, n + 1), i):
    flag = True
    for h in honests:
      for x, y in per_dict[h]:
        if y == 1 and x not in honests:
          flag = False 
        if y == 0 and x in honests:
          flag = False
    if flag == True:
      break
  if flag == True:
    break
print(i)





Measured memory_bytes: 3444
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll kane=1000;
  ll kabu=0;
  for(int i=0;i<n-1;i++){
    if(a[i] < a[i+1]){
      kabu += kane/a[i];
      kane %= a[i];
    }
    else if(a[i] > a[i+1]){
      kane += kabu * a[i];
      kabu = 0;
    }
  }
  kane += kabu * a[n-1];
  cout << kane << endl;

  return 0;
}


Measured memory_bytes: 3192
#include<stdio.h>

int main(){

	int n;
	scanf("%d",&n);
	int i,R[200010];
	for(i=0;i<n;i++){
		scanf("%d",&R[i]);	
	}
	int maxv,minv,j;
	maxv=R[1]-R[0];
	minv = R[0];
	for(j=1;j<n;j++){
		if(R[j]<minv){minv=R[j];}
		else if(R[j]-minv>maxv){maxv=R[j]-minv;}
	}
	printf("%d\n",maxv);
	return 0;
}


Measured memory_bytes: 2564
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct UnionFind {
  const int n;
  V<> t; // root ? -sz : par
  UnionFind(int n) : n(n), t(n, -1) {}
  int find(int v) { return t[v] < 0 ? v : t[v] = find(t[v]); }
  void unite(int u, int v) {
    if ((u = find(u)) == (v = find(v))) return;
    if (-t[u] < -t[v]) swap(u, v);
    t[u] += t[v];
    t[v] = u;
  }
  bool same(int u, int v) { return find(u) == find(v); }
  int size(int v) { return -t[find(v)]; }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int h, w, c; cin >> h >> w >> c, --c;
    if (!h) break;
    VV<> p(h, V<>(w)); for (auto&& v : p) for (auto&& e : v) cin >> e, --e;
    int res = 0;
    V<> v;
    V<> di{1, 0, -1, 0}, dj{0, 1, 0, -1};
    auto in = [&](int i, int j) -> bool { return 0 <= i and i < h and 0 <= j and j < w; };
    auto _ = [&](int i, int j) -> int { return i * w + j; };
    auto dfs = [&](const auto& dfs) -> void {
      if (v.size() == 5) {
        if (v.back() != c) return;
        UnionFind uf(h * w);
        for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) {
          if (i + 1 < h and p[i][j] == p[i + 1][j]) uf.unite(_(i, j), _(i + 1, j));
          if (j + 1 < w and p[i][j] == p[i][j + 1]) uf.unite(_(i, j), _(i, j + 1));
        }
        for (int e : v) {
          for (int i = 0; i < h; ++i) for (int j = 0; j < w; ++j) if (!uf.same(0, _(i, j)) and p[i][j] == e) {
            for (int d = 0; d < 4; ++d) {
              int ni = i + di[d], nj = j + dj[d];
              if (!in(ni, nj)) continue;
              if (uf.same(0, _(ni, nj))) {
                uf.unite(0, _(i, j));
                break;
              }
            }
          }
        }
        res = max(res, uf.size(0));
        return;
      }
      for (int i = 0; i < 6; ++i) {
        v.push_back(i);
        dfs(dfs);
        v.pop_back();
      }
    };
    dfs(dfs);
    cout << res << '\n';
  }
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

ll mod = 1000000007;

int main() {

    int n;
    char s1[66];
    char s2[66];

    Scd(n);
    Scs(s1);
    Scs(s2);

    ll ans = 0;
    int i = 0;
    bool pre = false;
    if( s1[i] == s2[i] ){
        ans = 3;
        pre = false;
    }else{
        ans = 6;
        pre = true;
        i++;
    }
    i++;

    for (; i < n; i++){
        if( s1[i] == s2[i] ){
            ans *= pre ? 1 : 2;
            ans %= mod;
            pre = false;
        }else{
            ans *= pre ? 3 : 2;
            ans %= mod;
            pre = true;
            i++;
        }
    }

    printf ("%llu\n", ans);

    return 0;
}



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

int main()
{
	string a; cin>>a;

	bool ok=true;

	for(int i=0;i<a.length()-1;i++){
		if(a[i] == a[i+1]) {ok=false; break;}
	}

	if(ok) cout<<"Good";
	else cout<<"Bad";
}

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

int main()
{
  int A,B,C,X,Y ;
  cin>>A>>B>>C>>X>>Y ;
  
  int min_money=0 ;
  if(X>Y){
    if(2*C>A+B) min_money+=Y*(A+B) ;
    else min_money+=2*C*Y ;
    if(2*C<A) min_money+=2*C*(X-Y) ;
    else min_money+=A*(X-Y) ;
  }else if(X<Y){
    if(2*C>A+B) min_money+=X*(A+B) ;
    else min_money+=2*C*X ;
    if(2*C<B) min_money+=2*C*(Y-X) ;
    else min_money+=B*(Y-X) ;
  }else{
    if(2*C>A+B) min_money+=X*(A+B) ;
    else min_money+=X*2*C ;
  }
  
  cout<<min_money<<endl ;
  
  return 0 ;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    double ans = 0;
    vector<int> num(n+1);
    rep(i,n) cin >> num[i];
    int sum = 0;
    rep(i,k) sum += (num[i]+1);
    ans = sum;
    rep(i,n-k){
        sum -= (num[i]+1);
        sum += (num[i+k]+1);
        ans = max(ans, (double)sum);
    }
    ans /= 2.0;
    printf("%.10f",ans);
}

Measured memory_bytes: 3952
n = int(input())
s = input()
r = 0
g = 0
b = 0

for c in s:
    if c == "R":
        r += 1
    elif c == "G":
        g += 1
    elif c == "B":
        b += 1

sub = 0
for i in range(n):
    for j in range(i+1, n):
        k = j * 2 - i
        if k >= n:
            continue
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            sub += 1

print(r*g*b-sub)


Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int ans=0;
    for(int i=0; i<n; i++){
        int temp;
        cin>>temp;
        while(temp%2==0)temp/=2, ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N, K, Q = map(int, input().split())
score = [K for _ in range(N)]

for i in range(Q):
    A = int(input())
    score[A - 1] += 1

for s in score:
    if s - Q <= 0:
        ans = "No"
    else:
        ans = "Yes"
    print(ans)


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

int main(){
  
  int l, a, b, c, d;

  cin>>l>>a>>b>>c>>d;

  if(a%c) a=a/c+1;
  else a/=c;

  if(b%d) b=b/d+1;
  else b/=d;

  cout<<l-max(a, b)<<endl;
  
  return 0;
}

Measured memory_bytes: 3088
def inverse_lookup(d, x):
    a = []
    for k,v in d.items():
        if x == v:
          a.append(k)
    return sorted(a)

n = int(input())
w = {}
for _ in range(n):
  i = input()
  if i in w:
    w[i] += 1
  else:
    w[i] = 1
m = max(w.values())
for j in inverse_lookup(w,m):
  print(j)

Measured memory_bytes: 32988
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>

using namespace std;

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin,(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

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 gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  int x,y;
  cin >> x >> y;
  cout << (x + y/2) << endl;

  return 0;
}


Measured memory_bytes: 256
macro_rules! scan {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };

    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

fn main() {
    let (a, b, c) = scan!(usize, usize, usize);
    for n in 1..b + 1 {
        if (a * n) % b == c {
            println!("YES");
            return;
        }
    }
    println!("NO")
}


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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

ll calc_score(ll D, const vector<ll> &c, const vector<vector<ll>> &s, const vector<ll> &t) {
  vector<ll> last(26, 0);
  ll score = 0;
  REP(d, D) {
    ll i = t[d] - 1;
    score += s[d][i];
    last[i] = d + 1;
    REP(j, 26) {
      score -= c[j] * (d + 1 - last[j]);
    }
  }
  return score;
}

ll calc_diff(ll D, ll pre, ll next, const vector<ll> &c, const vector<vector<ll>> &s, ll d, const vector<ll> &t) {
  ll diff = s[d - 1][next] - s[d - 1][pre];
  {
    ll l = 0;
    for (int i = d - 1; i >= 1; i--) {
      if (t[i - 1] - 1 == next) {
        l = i;
        break;
      }
    }
    ll r = D + 1;
    FOR(i, d + 1, D + 1) {
      if (t[i - 1] - 1 == next) {
        r = i;
        break;
      }
    }
    ll x = r - d;
    ll y = d - l;
    diff += c[next] * x * y;
  }
  {
    ll l = 0;
    for (int i = d - 1; i >= 1; i--) {
      if (t[i - 1] - 1 == pre) {
        l = i;
        break;
      }
    }
    ll r = D + 1;
    FOR(i, d + 1, D + 1) {
      if (t[i - 1] - 1 == pre) {
        r = i;
        break;
      }
    }
    ll x = r - d;
    ll y = d - l;
    diff -= c[pre] * x * y;
  }
  return diff;
}

void solve(ll D, vector<ll> c, vector<vector<ll>> s, vector<ll> t) {
  ll score = calc_score(D, c, s, t);
  ll M;
  scanf("%lld", &M);
  REP(i, M) {
    ll d;
    scanf("%lld", &d);
    ll q;
    scanf("%lld", &q);
    ll pre = t[d - 1] - 1;
    ll next = q - 1;
    t[d - 1] = next + 1;

    score += calc_diff(D, pre, next, c, s, d, t);
    cout << score << "\n";
  }
}

int main() {
  ll D;
  scanf("%lld", &D);
  vector<ll> c(26);
  for (int i = 0; i < 26; i++) {
    scanf("%lld", &c[i]);
  }
  vector<vector<ll>> s(D, vector<ll>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      scanf("%lld", &s[i][j]);
    }
  }
  vector<ll> t(D);
  for (int i = 0; i < D; i++) {
    scanf("%lld", &t[i]);
  }
  solve(D, move(c), move(s), move(t));
  return 0;
}


Measured memory_bytes: 3752
#include <stdio.h>

int main(void)
{
	int x,h,m,s;
	scanf("%d",&x);
	h=0;
	m=0;
	s=0;
	while(x>=3600){
		x=x-3600;
		h++;
	}
	while(x>=60){
		x=x-60;
		m++;
	}
	s=x;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
import Data.List
import Data.Maybe (mapMaybe)

solve :: String -> String
solve xs = if null s then xs else solve (head s)
    where s = mapMaybe ((`stripPrefix` xs) . reverse) ["dream", "dreamer", "erase", "eraser"]

main :: IO ()
main = do
    s <- reverse <$> getLine
    putStrLn $ if null (solve s) then "YES" else "NO"


Measured memory_bytes: 7548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll max_N = 2e5 + 50, INF = 1e15, MOD = 1e9 + 7;
ll N, hts[max_N], beauty[max_N], DP[max_N];

struct custom_comparator
{
    bool operator() (const ll &idx1, const ll &idx2) const
    {
        return hts[idx1] < hts[idx2];
    }
};

ll solve()
{
    set<ll, custom_comparator> meaning;
    ll res = 0;
    DP[0] = beauty[0];
    meaning.insert(0);
    for (int i = 1; i < N; ++i)
    {
        DP[i] = beauty[i];
        auto it = meaning.upper_bound(i);
        if (it != meaning.begin())
        {
            it = prev(it);
            DP[i] = DP[*it] + beauty[i];
        }
        meaning.insert(i);
        it = meaning.upper_bound(i);
        while (it != meaning.end() && DP[*it] <= DP[i])
        {
            auto temp = next(it);
            meaning.erase(it);
            it = temp;
        }
    }
    res = *max_element(DP, DP + N);
    return res;
}

int main()
{
    cin >> N;
    for (int i = 0; i < N; ++i)
        cin >> hts[i];
    for (int i = 0; i < N; ++i)
        cin >> beauty[i];
    cout << solve() << "\n";
    return 0;
}

Measured memory_bytes: 17628
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<double,P> PP;
struct edge { int to; int cost; };
int inv[500000];
int used[500000];
vector<int>ans1;
signed main() {
	int m, k; cin >> m >> k;
	rep(i, 1 << m) {
		inv[i] = i^k;
	}
	if ((1 << m) <= k||(m==1&&k==1)) {
		cout << -1 << endl;
		return 0;
	}
	if (k == 0) {
		rep(i, 1 << m) {
			if (i)cout << ' ' << i << ' ' << i;
			else cout << i << ' ' << i;
		}
		cout << endl;
	}
	else if (m == 0) {
		cout << 0 << ' ' << 0 << endl;
	}
	else {
		rep(i, 1 << m) {
			if (used[i] || used[inv[i]])continue;
			ans1.push_back(i);
			ans1.push_back(inv[i]);
			used[i]++;
			used[inv[i]]++;
			//cout << i << endl;
		}
		vector<int>V;
		for (int i = 0; i < (1 << m); i += 4) {
			int j = ans1[i], k = ans1[i + 2];
		//	cout << j << ' ' << k << endl;
			V.push_back(j);
			V.push_back(inv[j]);
			V.push_back(k);
			V.push_back(inv[k]);
			V.push_back(inv[j]);
			V.push_back(j);
			V.push_back(inv[k]);
			V.push_back(k);
		}
		rep(i, 1 << (m + 1)) {
			if (i)cout << ' '; cout << V[i];
		}cout << endl;
	}
}

Measured memory_bytes: 10096
n = gets.to_i
array_p = gets.split(" ").map!{|i | i.to_i}

swap = 0

array_p.each_with_index do |num, index|
  unless num == (index + 1)
    swap = swap + 1
  end
end

if swap == 0 || swap == 2
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
#include<stdio.h>
#include<stdlib.h>

int main(void){
    int N,i,j;
    int* A;
    scanf("%d",&N);
    A=(int*)malloc(sizeof(int)*N);
    for(i=0;i<N;i++){
        A[i]=0;
    }
    for(i=0;i<N-1;i++){
        scanf("%d",&j);
        A[j-1]++;
    }
    for(i=0;i<N;i++){
        printf("%d\n",A[i]);
    }
    return 0;
}

Measured memory_bytes: 2516
import java.util.*;

public class Main {
    static int[][] dp;
    static Dish[] arr;
 	public static void main (String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		dp = new int[t + 1][n + 1];
		arr = new Dish[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = new Dish(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(arr);
		System.out.println(dfw(t, n));
	}
	
	static int dfw(int time, int idx) {
	    if (idx < 1) {
	        return 0;
	    }
	    if (dp[time][idx] != 0) {
	        return dp[time][idx];
	    }
	    int ans = dfw(time, idx - 1);
	    if (time - arr[idx - 1].time > 0) {
	        ans = Math.max(ans, dfw(time - arr[idx - 1].time, idx - 1) + arr[idx - 1].value);
	    } else {
	        ans = Math.max(ans, arr[idx - 1].value);
	    }
	    dp[time][idx] = ans;
	    return ans;
	}
	
	static class Dish implements Comparable<Dish> {
	    int time;
	    int value;
	    
	    public Dish(int time, int value) {
	        this.time = time;
	        this.value = value;
	    }
	    
	    public int compareTo(Dish another) {
	        return another.time - time;
	    }
	}
}




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

int main() {
  int A, B, count;
  count=0;
  cin >> A >> B;
  for(int i=0; i<1010; i++) {
    if(i*8/100==A && i/10==B && count==0) {
      cout << i <<endl;
      count++;
    }
  if(i==1009 && count==0) {
    cout << "-1" << endl;
  }
  }
}

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

int main() {
  
  long long a, b, c;
  cin >> a >> b >> c;
  
  string res = "No";
  
  if (a + b < c) {
    if ( (4 * a * b) < ((c - a - b) * (c - a - b)) ) {
      res = "Yes";
    }
  } 
  
  
  
  cout << res << endl;
  
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int X = B % N;
    int goal = B - X;
    if (goal >= A && goal <= B) {
      System.out.println("OK");
    } else {
      System.out.println("NG");
    }
  }
}

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

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

    for(int i = 1; i <= 9; ++i)
        for(int j = 1; j <= 9; ++j)
            if(i * j == n)
            {
                cout << "Yes" << "\n";
                return 0;
            }

    cout << "No" << "\n";
    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=10;i++)
		if((1<<i)>n)
		{
			cout<<(1<<i-1)<<endl;
			return 0;
		}
	return 0;
}

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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	int c[3][3];
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < 3; j++)
			cin >> c[i][j];

	for(int a1 = 0; a1 <= c[0][0]; a1++){
		for(int a2 = 0; a2 <= c[1][1]; a2++){
			for(int a3 = 0; a3 <= c[2][2]; a3++){
				int b1 = c[0][0] - a1;
				int b2 = c[1][1] - a2;
				int b3 = c[2][2] - a3;
				if(a1+b1 == c[0][0] &&
					a1+b2 == c[0][1] &&
					a1+b3 == c[0][2] &&
					a2+b1 == c[1][0] &&
					a2+b2 == c[1][1] &&
					a2+b3 == c[1][2] &&
					a3+b1 == c[2][0] &&
					a3+b2 == c[2][1] &&
					a3+b3 == c[2][2]){
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
N,M,C = map(int, input().split())
B=list(map(int, input().split()))
A=[list(map(int, input().split())) for _ in range(N)]
b=0
for i in range(N):
  a=0
  for j in range(M):
    a+=B[j]*A[i][j]
  if a+C>0:
    b+=1
print(b)

Measured memory_bytes: 3060
/*#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
*/

#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr<<#x<<": "<<(x)<<'\n'
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
const ll inf = 0x3f3f3f3f;
const ll nax = 0;
ll a, b;

int main(){
	IOS
	cin >> a >> b;
	if(a%b==0){
		cout << -1 << '\n';
		return 0;
	}
	cout << a << '\n';
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
using ll = long long;

int main() {
    int N;
    std::cin >> N;
    std::set<int> d;
    for (int i = 0; i < N; i++) {
        int input;
        std::cin >> input;
        d.insert(input);
    }

    std::cout << d.size() << std::endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;
const LL MAXN = 400000+9;
LL n;
LL ans[3],tot;
LL num[MAXN];

void solve(){
	sort(num+1,num+n+1);
	LL i;
	for(i=n;i;i--){
		LL tmp=0;
		while(num[i-1]==num[i]){
			i--;
			tmp++;
		}
		if(tmp>=3 && tot==0){
			printf("%lld\n",num[i]*num[i]);
			return;
		}
		else if(tmp>=1){
			ans[++tot]=num[i];
		}
		if(tot==2){
			printf("%lld\n",ans[1]*ans[2]);
			return;
		}
	}
	printf("0\n");
	return;
}

int main(){
	scanf("%lld",&n);
	LL i;
	for(i=1;i<=n;i++){
		scanf("%lld",&num[i]);
	}
	solve();
	return 0;
}


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

int main(){
    string SA, SB, SC;
    vector<string> S(3);
    cin >> S[0] >> S[1] >> S[2];
    int cnt = S[0].length() + S[1].length() + S[2].length();

    char al[3] = {'A','B','C'};
    int label  = 0;
    vector<int> pointer(3,0);
    for (int i = 0; i < cnt; i++)
    {
        int next = S[label][pointer[label]] - 'a';
        pointer[label]++;
        if(pointer[label] > S[label].size()){
            cout << al[label]  << endl;
            break;
        }
        label = next;
    }
}

Measured memory_bytes: 256
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
printout = sys.stdout.write
sprint = sys.stdout.flush
# from heapq import heappop, heappush
# from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
# import math
# from itertools import product, accumulate, combinations, product
# import bisect
# import numpy as np
# from copy import deepcopy
#from collections import deque
# from decimal import Decimal
# from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7


def intread():
    return int(sysread())
def mapline(t=int):
    return map(t, sysread().split())
def mapread(t=int):
    return map(t, read().split())

def run():
    N = int(sysread())
    ans = 0
    for a in range(1, N):
        for b in range(1, N//a+1):
            c = N - a * b
            if c > 0:
                ans += 1
    print(ans)
if __name__ == "__main__":
    run()


Measured memory_bytes: 67652
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxN=2e5+1e2;
const int maxn=4000+10;
const int N=2000;
const int modd=1e9+7;
const int inv2=500000004;
const int Inv=624583629;
struct node {
	int a,b;
}s[maxN];
int n;
int Ans;
int fac[maxn<<1],inv[maxn<<1],dp[maxn][maxn];

inline void file() {
	freopen("AGC001E.in","r",stdin);
	freopen("AGC001E.out","w",stdout);
}

inline int read() {
	int x=0,p=1;
	char c=getchar();
	while (!isdigit(c)) { if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) { x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	return x*p;
}

inline void Add(int &a,int b) {
	a+=b;
	if (a>=modd) a-=modd;
}

inline int C(int n,int m) {
	if (n<m) return 0;
	return 1ll*fac[n]*inv[m]%modd*inv[n-m]%modd;
}

inline void init() {
	fac[0]=inv[0]=1; inv[N<<2]=Inv;
	For (i,1,N<<2) fac[i]=1ll*fac[i-1]*i%modd;
	Forr (i,(N<<2)-1,1) inv[i]=1ll*inv[i+1]*(i+1)%modd;
}

int main() {
//	file();
	init();
	n=read();
	For (i,1,n) s[i].a=read(),s[i].b=read(),Add(dp[N-s[i].a][N-s[i].b],1);
	For (i,0,N<<1) For (j,0,N<<1) {
		if (i) Add(dp[i][j],dp[i-1][j]);
		if (j) Add(dp[i][j],dp[i][j-1]);
	}
	For (i,1,n) Add(Ans,dp[N+s[i].a][N+s[i].b]);
	For (i,1,n) Add(Ans,modd-C(2*s[i].a+2*s[i].b,2*s[i].a));
	Ans=1ll*Ans*inv2%modd;
	printf("%d\n",Ans);
	cerr << clock() << endl;
	return 0;
}

Measured memory_bytes: 64640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,y,z,x,ans=0;
  cin>>a>>b>>c;
  if(a>=c)
  {
  y=a%c;
  z=a+y;
}
else
{
	z=c;
}

if(c<=b)
{
  for(int i=z;i<=b;i++)
  {
  	if(i%c==0)
  	{
  	ans++;
  }
  }
   cout<<ans;
}
else
{
	cout<<0;
}
 
   return 0;
}

Measured memory_bytes: 3632
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
import fractions
#from scipy.misc import comb

N = int(input())
A = list(map(int, input().split()))

ans = A[0]
for i in range(1,N):
    ans = fractions.gcd(ans, A[i])

print(ans)

Measured memory_bytes: 24972
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

vector<int> v[202020];
int sz[202020],depth[202020];

struct p3{
    ll fi,se,th;
};
int szdfs(int x,int d){
    sz[x]=1;
    depth[x]=d;
    for(auto& to:v[x]){
        sz[x]+=szdfs(to,d+1);
    }
    return sz[x];
}

void dfs(int x,deque<p3>& d){
    d.clear();
    int n=0;
    int ma=0;
    for(auto to:v[x]){
        deque<p3> nd;
        dfs(to,nd);
        int m=nd.size();
        if(n<m){
            d.swap(nd);
            swap(n,m);
        }
        rep(i,m){
            ll fi=d[i].fi*nd[i].fi%mod;
            ll se=d[i].se*nd[i].fi+d[i].fi*nd[i].se;
            se%=mod;
            ll th=d[i].th*(nd[i].fi+nd[i].se+nd[i].th)%mod;
            th+=d[i].se*(nd[i].se+nd[i].th)+d[i].fi*nd[i].th;
            th%=mod;
            d[i]={fi,se,th};
        }
        ma=max(m,ma);
    }
    rep(i,ma){
        d[i].fi+=d[i].th;
        d[i].fi%=mod;
        d[i].th=0;
    }
    d.push_front({1,1,0});
}
int main(){
    int n;
    cin>>n;
    rep(i,n){
        int x;cin>>x;
        v[x].push_back(i+1);
    }
    szdfs(0,0);
    vector<int> cnt(n+1);
    rep(i,n+1)cnt[depth[i]]++;
    deque<p3> ret={};
    dfs(0,ret);
    ll p[202020];
    p[0]=1;
    rep(i,n)p[i+1]=2*p[i]%mod;
    ll ans=0;
    int m=ret.size();
    rep(i,m){
        ans+=ret[i].se*p[n+1-cnt[i]];
        ans%=mod;
    }
    cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 171392
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-9;
long double pi = acos(-1);

ll mod = 1e9+7;
template<typename T> void add(T &a,T b){a=(a+b)%mod;}
template<typename T> void sub(T &a,T b){a=(a+mod-b)%mod;}


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

    int a,b;
    cin>>a>>b;
    bool pos = 1;
    if(b%2){
        cout << "No\n";
        return 0;
    }
    for(int i=0;i<=a;i++){
        int cnt = i*2 + (a-i)*4;
        if(cnt == b){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";

}

Measured memory_bytes: 3648
import fractions
a,b,c,d=map(int,input().split())
gcd=fractions.gcd(c,d)
lcm=(c//gcd)*d

def num(a,x):
  return (a-(a%x))//x

n=(b-a+1)-(num(b,c)-num(a-1,c))-(num(b,d)-num(a-1,d))+(num(b,lcm)-num(a-1,lcm))
print(n)

Measured memory_bytes: 5048