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

using namespace std;

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

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

using ll = long long;
ll N, M;
ll fact[1000005];
const ll MOD = 1e9 + 7;
int main() {
    fact[0] = 1;
    rep(i, 1000005) if (i) { fact[i] = (fact[i - 1] * i) % MOD; }
    cin >> N >> M;
    if (abs(N - M) > 1) {
        cout << "0" << endl;
        return 0;
    }
    ll ans = fact[N] * fact[M];
    ans %= MOD;
    if (N == M) {
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int y, m, d;
  scanf("%d/%d/%d",&y, &m, &d);
  if(m>=5){
    cout << "TBD" << endl;
  }else{
    cout << "Heisei" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//People only find me interesting because they can't tell whether I'm serious or not
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
typedef __int128 s128;
typedef __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define P 1000000007
#define Q 1000000006
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 100005
#define PI 3.14159265359
#define inf LLONG_MAX
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
ll a[N][3], dp[N][3];
void solve(){
    ll n,ans=0;
    cin>>n;
    f(i,0,n) f(j,0,3) cin>>a[i][j];
    f(j,0,3) dp[0][j] = a[0][j], ans = max(ans, dp[0][j]);
    f(i,1,n){
        f(j,0,3){
            dp[i][j] = a[i][j] + max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]);
            ans = max(ans,dp[i][j]);
        }
    }
    cout<<ans;
}
signed main() {
    teevra_gati
    
    solve();

    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); 
	cout.tie(NULL);
int a,b,c,k;
cin>>a>>b>>c>>k;
while(a>=b&&k>0)
{
  b*=2;
  k--;
}
while(b>=c&&k>0)
{
    c*=2;
    k--;
}
if(a<b&&b<c)
cout<<"Yes";
else
cout<<"No";
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> s(H, vector<int>(W, 0));
    vector<string> ss(H);
    REP(i, H) cin >> ss[i];
    REP(i, H) REP(j, W) s[i][j] = ss[i][j] - '0';

    int ans = W * H;
    REP(i, 1<<(H-1)){
        vector<int> sp(H, 0);
        int ii = 0;
        REP(j, H){
            sp[j] = ii;
            if (((i >> j) & 1) == 1) ii++; 
        }
        ii++;
        //REP(j, H) cout << sp[j];
        //cout << endl;
        vector<int> acc(ii, 0), tmp(ii, 0);
        int ans_tmp = ii - 1;
        REP(j, W){
            REP(k, H) acc[sp[k]] += s[k][j];
            
            bool hoge = false;
            REP(k, ii) if (acc[k] > K) {ans_tmp = H * W; hoge = true;}
            if (hoge) break;

            hoge = true;
            REP(k, ii) hoge &= (acc[k] + tmp[k] <= K);
            if (hoge){
                REP(k, ii) {tmp[k] += acc[k]; acc[k] = 0;}
            }else{
                REP(k, ii) {tmp[k] = acc[k]; acc[k] = 0;}
                ans_tmp++;
                //cout << j;
            }
        }
        //REP(j, H) cout << sp[j];
        //cout << " " << ans_tmp << endl;
        ans = min(ans, ans_tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18
const int N = 100010;//10^5+10

const int MAX_N = 2000;
int a[MAX_N], n, x;
int f[MAX_N][MAX_N];

int main() {
	
	string s; int k; cin >> s >> k;

	for (int i = 0; i < s.length(); i++) {
		while (s[i] != 'a'&& i != s.length() - 1) {
			int d = 26 - (s[i] - 'a');

			if (k - d >= 0) {
				k -= d;
				s[i] = 'a';
			}
			else {
				break;
			}
		}

		if (i == s.length() - 1) {
			if (s[i] + k <= 'z') {
				s[i] = s[i] + k;

			}
			else {
				s[i] = s[i] + (k % 26) - 26;
			}

			if (s[i] < 'a')s[i] += 26;
		}
	}

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) { 
        Scanner sc = new Scanner(System.in);
        String[] abt = sc.nextLine().split(" ");
        int N = Integer.parseInt(abt[0]);
        int K = Integer.parseInt(abt[1]);

        String S = sc.nextLine();
        char[] Sarr = S.toCharArray();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N; i++) {
            if (i == K - 1) {
                String s = String.valueOf(Sarr[i]);
                sb.append(s.toLowerCase());
            } else {
                sb.append(Sarr[i]);
            }
        }

        System.out.println(sb.toString());
    }

}


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

int main(){
  string S ;
  cin>>S;
  if(S=="Sunny"){
    cout<<"Cloudy";
  }
  else if(S=="Cloudy"){
    cout<<"Rainy";
  }
  else {
    cout<<"Sunny";
  }
 
return 0; 
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void uniq(vector<int> &vec){sort(vec.begin(), vec.end());vec.erase(unique(vec.begin(), vec.end()), vec.end());}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}


signed main(){start();
    int n,m,Q;
    cin>>n>>m>>Q;
    Vi l(m),r(m),p(Q),q(Q);
    VVi train(n,Vi(n)),sum(n,Vi(n));
    REP(i,0,m){
        cin>>l[i]>>r[i];
        l[i]--;r[i]--;
        train[l[i]][r[i]]++;
    }
    REP(i,0,n){
        REP(j,0,n){
            if(j==0) sum[i][j]=train[i][j];
            else sum[i][j]=sum[i][j-1]+train[i][j];
        }
    }
    // REP(i,0,n){
    //     REP(j,0,n){
    //         cout<<sum[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    // cout<<endl;
    
    REP(i,0,Q){
        cin>>p[i]>>q[i];
        p[i]--;q[i]--;
        int ans=0;
        REP(j,p[i],q[i]+1){
            if(p[i]>0) ans+=sum[j][q[i]]-sum[j][p[i]-1];
            else ans+=sum[j][q[i]];
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
    long long int n,ac = 0,wa = 0,tle = 0,re = 0;
    scanf("%lld\n",&n);
    char s[3];
    long long int i;
    for(i = 0 ; i < n ; i++)
    {
        scanf("%s",s);
        if(strcmp(s,"AC") == 0)
        {
            ac++;
        }
        if(strcmp(s,"WA") == 0)
        {
            wa++;
        }
        if(strcmp(s,"TLE") == 0)
        {
            tle++;
        }
        if(strcmp(s,"RE") == 0)
        {
            re++;
        }
    }
    printf("AC x %lld\n",ac);
    printf("WA x %lld\n",wa);
    printf("TLE x %lld\n",tle);
    printf("RE x %lld\n",re);
    return 0;
}

Measured memory_bytes: 1728
#include<stdio.h>

int main()
{
	char c;

	while (1)
	{
		scanf("%c", &c);
		if (c >= 'A' && c <= 'Z')
			printf("%c", c + 32);
		else if (c >= 'a' && c <= 'z')
			printf("%c", c - 32);
		else if (c == '\n')
			break;
		else
			printf("%c", c);
	}
printf("\n");
	return 0;
}


Measured memory_bytes: 2040
#include <cstdio>
#include <cctype>
#include <cassert>
#include <string>
#include <map>
#include <algorithm>

char parse(const std::string& s, size_t& i, std::map<char, int>& vic) {
  if (islower(s[i])) return s[i++];

  assert(s[i] == '[');
  char c1=parse(s, ++i, vic);
  assert(s[i] == '-');
  char c2=parse(s, ++i, vic);
  assert(s[i] == ']');
  ++i;

  if (vic[c1] == vic[c2]) throw 0;
  if (vic[c1] > vic[c2]) std::swap(c1, c2);
  if (vic[c1] != 0) throw 0;
  --vic[c2];
  return c2;
}

int main() {
  char buf[1024];
  scanf("%s", buf);

  std::map<char, int> vic;
  while (true) {
    char a;
    int v;
    if (scanf(" %c %d", &a, &v) == EOF) break;
    vic[a] = v;
  }

  std::string s=buf;
  size_t i=0;
  try {
    if (vic[parse(s, i, vic)] != 0) throw 0;
    puts("Yes");
  } catch (int) {
    puts("No");
  }
}



Measured memory_bytes: 2908
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    map<ll,ll>m;
    ll ans=1;
    ll cval=7;
    while(true){
        ll r=cval%n;
        if(r==0){
            cout<<ans<<endl;
            return 0;
        }
        if(m.count(r)){
            cout<<-1<<endl;
            return 0;
        }
        m[r]++;
        ans++;
        string s=to_string(r);
        s+='7';
        cval=stoi(s);
    }
    return 0;
}



Measured memory_bytes: 66228
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define hahashad ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
#define VL vector<ll> 
#define what(A) cout<<#A<<" is "<<A<<endl;
int main()
{
	ll l,r,d,count=0;
    cin>>l>>r>>d;
    FOR(i,l,r+1)
    {
        if(i%d==0)
        {
            count++;
            i+=d-1;
        }
    }
    cout<<count<<endl;
}

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

double getLength(pair<int,int> u, pair<int,int> v)
{
	return sqrt((u.first - v.first)*(u.first - v.first) + (u.second - v.second)*(u.second - v.second));
}

int main()
{
	int n, amount = 0;
	double sum = 0;
	cin >> n;

	vector<pair<int,int>> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i].first >> a[i].second;

	sort(a.begin(), a.end());

	do
	{
		double LengthOfPath = 0;
		for (int i = 0; i < n - 1; i++)
			LengthOfPath += getLength(a[i], a[i + 1]);
		
		sum += LengthOfPath;
		amount++;
	} while (next_permutation(a.begin(), a.end()));

	cout.precision(12);
	cout << fixed << sum / amount;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		try {
			while (input.ready()) {
				int num = Integer.valueOf(input.readLine());
				int ans = 0;
				for (int i = 0; i < 10; i++) {
					if(i > num) break;
					for (int j = 0; j < 10; j++) {
						if(j > num) break;
						for (int k = 0; k < 10; k++) {
							if(k > num) break;
							for (int l = 0; l < 10; l++) {
								if(l > num) break;
								if (i + j + k + l == num) {
									ans += 1;
								}
							}
						}
					}
				}
				System.out.println(ans);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 24848
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = int.Parse(ReadLine());
		var set = new HashSet<int>();
		for(int i = 0; i < n; i++)
		{
			var a = int.Parse(ReadLine());
			if(set.Contains(a))
				set.Remove(a);
			else
				set.Add(a);
		}
		WriteLine(set.Count);
	}
}


Measured memory_bytes: 27072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int C, A, B;
    cin >> C >> A >> B;
    int ans;
    ans = min({C*A, A*B, B*C}) / 2;
    cout << ans << endl;
    return 0;
}

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

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

    int count0 = 0, count1 = 0;
    for(int i=0; i<S.size(); i++){
        if(S[i] == '0') count0++;
        if(S[i] == '1') count1++;
    }
    int ans = count0 < count1 ? S.size() - (count1 - count0) : S.size() - (count0 - count1);
    std::cout << ans << std::endl;
}

Measured memory_bytes: 512
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M = in.next().toInt
  val a = new Array[Int](M+1)
  val b = new Array[Int](M+1)
  val c = Array.ofDim[Int](M+1, N+1)
  for (i <- 1 to M) {
    val _a, _b = in.next().toInt
    a(i) = _a; b(i) = _b
    for (k <- 1 to _b) {
      c(i)(k) = in.next().toInt
    }
  }


  //
  def toKey(lst: Array[Boolean]): Int = {
    var res = 0
    for (i <- 1 to N) {
      if(lst(i)) {
        res += 1 << (i-1)
      }
    }
    res
  }

  def toArray(key: Int): Array[Boolean] = {
    val res = new Array[Boolean](N+1)
    res(0) = true

    var i = 1
    var k = key
    while (k > 0) {
      if(k%2 == 1)
        res(i) = true
      k /= 2
      i += 1
    }

    res
  }

  //var hash = Map[String, Int]() // (opened, price)
  val imax = Int.MaxValue
  var hash = Array.fill[Int](1<<N)(imax)
  hash(0) = 0

  for (i <- 1 to M) {
    val nextHash = hash.clone

    for (opened <- 0 until 1<<N) {
      if (hash(opened) != imax) {
        val price = hash(opened)

        val hoge = toArray(opened)
        for (k <- 1 to b(i)) {
          val ind = c(i)(k)
          if(!hoge(ind))
            hoge(ind) = true
        }
        val key = toKey(hoge)

        val nowPrice = price + a(i)

        if(nowPrice < nextHash(key)) {
          nextHash(key) = nowPrice
        }

      }
    }

    hash = nextHash
  }
  
  
  var ans = -1
  val k = (1<<N) - 1
  if(hash(k) != imax)
    ans = hash(k)

//  println(hash.deep)
  println(ans)
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

int main (void) {
  int N, K;
  cin >> N >> K;
  double ans = 0;

  /* 出目がiのとき */
  for (int i = 1; i <= N; i++) {
    double p = 1. / N;
    int num = 0;
    for (int point = i; point <= K - 1; point *= 2) {
      p *= 1. / 2.;
      num++;
    }
    ans += p;
  }
  cout << fixed << setprecision(15) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#!usr/bin/perl
chomp($N=<>);
@_=split(" ",<>);
my %num;
my $ans;
for $_ (@_){
    last if($num{$_});
    $num{$_}++;
    $ans++;
}
if($ans == $N){
    print 'YES';
} 
else{
    print 'NO';
}


Measured memory_bytes: 50468
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	string s;cin>>s;
	string ans;
	rep(i,s.length()){
		if(s[i]=='B'){
			if(!(ans.empty())){
				ans.pop_back();
				}
		}else ans+=s[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define txt freopen("ip.txt", "r", stdin); freopen("op.txt", "w", stdout)
#define a3 INT_MAX
#define i3 INT_MIN
#define a6 INT64_MAX
#define i6 INT64_MIN
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define div2(a) (!(a&1))
#define deb(x) cout<<(#x)<<" "<<(x)<<"\n";
#define newl cout<<"\n" 
#define all(s) s.begin(),s.end()
#define pi 3.14159265358979323846
#define fp(x) fixed<<setprecision(x)<<
template<class T>
T mod(T a){
    if(a < 0){
        a += 1000000007;
    }
    return a%1000000007; 
}
template<class T>
T addmod(T a, T b){
    return (mod(a) + mod(b)) % 1000000007;
}
template<class T>
T prodmod(T a, T b){
    return (mod(a) * mod(b)) % 1000000007;
}
template<class T>
T bin_exp(T a, T b)
{
    T res = 1;
    T temp = 1;
    if (b <= 1)
        return a;
    if (b %2 == 0)
        res = bin_exp(a * a, b / 2);
    else
    {
        res *= a;
        temp = bin_exp(a, --b);
    }
    return res * temp;
}
template<class T>
T bin_expmod(T a, T b)
{
    T res = 1;
    T temp = 1;
    if (b <= 1)
        return a;
    if (b %2 == 0)
        res = bin_expmod(prodmod(a,a), b / 2);
    else
    {
        res = prodmod(a,res);
        temp = bin_exp(a, --b);
    }
    return prodmod(res , temp);
}

template<class T>
int digit(T a)
{
    vector<long long> dig = {
        0,
        9,
        99,
        999,
        9999,
        99999,
        999999,
        9999999,
        99999999,
        999999999,
        9999999999,
        99999999999,
        999999999999,
        9999999999999,
        99999999999999,
        999999999999999,
        9999999999999999,
        99999999999999999,
        999999999999999999,
        INT64_MAX};
    auto it = lower_bound(dig.begin(), dig.end(), a);
    int idx = (it - dig.begin());
    return idx;
}
template<class T>
int sumAllInts(T n){
    int a = 1;
    int su = 0;
    while(n){
        su += n%10;
        n/=10;
    }
    return su;
}
template<class T>
void split(char c,T s){
    int n = s.size();
    int i = 0;
    while ((cout<<s[i],i+=1) && (i<n) && (cout<<c<<' '));
}

void solve(){
    long long int A,B,C;
    cin>>A>>B>>C;
    int found=0;
    for(int i=1;i<=B;i++)
    {
        if((A*i)%B==C)
        {
            found++;
            cout<<"YES";
            break;
        }        
    }
   if(found==0)
   cout<<"NO";
}
int main(){
    quickie;
    //txt;
    int t=1;
    while(t--){
        solve(); 
        newl; 
    } 
    return 0;
}

Measured memory_bytes: 3656
n=int(input())
p=list(map(int,input().split()))
cnt=0
p2=[]
for i,x in enumerate(p):
    if (i+1)==p[i]:
        p2.append(False)
    else:
        p2.append(True)

for i in range(n-1):
    if p2[i]==False and p2[i+1]==True:
        p2[i]=True
        cnt+=1
    if p2[i]==False and p2[i+1]==False:
        p2[i]=True
        p2[i+1]=True
        cnt+=1
if p2[-1]==False:
    cnt+=1
print(cnt)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n')
//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18

ll power(int a, int b){
    return (ll)(pow(a,b)+0.5);
}

/*vector<int> gV(int n){
    vector<int> v;
    int input;
    fo { cin>>input; v.pb(input); }
    return v;
}*/

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}

void solve(){

}



int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);
    int a;
    cin>>a;
    cout<<a+power(a,2)+power(a,3)<<endl;

	return 0;
}




Measured memory_bytes: 4112
#include<bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

int main(){
  string s;
  cin >> s;
  cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
import numpy as np

N, L = map(int, input().split())
Nstr = []
Lstr = []
ans = 0

for i in range(N):
  Nstr.append(i)

for i in range(N):
  Lstr.append(i + L)

Lstr.remove(Lstr[np.abs(np.asarray(Lstr) - 0).argmin()])

for i in range(len(Lstr)):
  ans += Lstr[i]

print(ans)

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

int main(){  
    string s;
    int count = 0;
    cin >> s;

    for (int i = 0; i < s.size(); i++) {
        if ( s[i] == '1' ) {
            count += 1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int X, Y, ans;
	scanf("%d %d", &X, &Y);
	ans = max(0, 4 - X) + max(0, 4 - Y);
	if (ans == 6) ans += 4;
	printf("%d", ans * 100000);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>

using lli = long long int;

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)


template <class T> inline T& chmin(T& a, T b){return (a > b) ? a = b : a;}
template <class T> inline T& chmax(T& a, T b){return (a < b) ? a = b : a;}

std::vector<lli> A, B;

constexpr lli inf = 5e18;

int main(void){
    int n, m; scanf("%d%d", &n, &m);
    int SET_SIZE = 1 << n;
    A.resize(SET_SIZE, inf), B.resize(SET_SIZE);
    A[0] = 0;
    REP(i, m){
        B = A;
        int a, b; scanf("%d%d", &a, &b);
        int p = 0;
        REP(_, b){
            int t; scanf("%d", &t); t--;
            p |= (1 << t);
        }
        REP(j, SET_SIZE){
            chmin(B[j | p], A[j] + a);
        }
        A = B;
        //std::swap(A, B);
    }
    if(A[SET_SIZE-1] == inf) puts("-1");
    else printf("%lld\n", A[SET_SIZE-1]);


    return 0;
}

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

int main(){
	int n;
	scanf("%d", &n);
	vector<int> a(n);
	for(int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int q;
	scanf("%d", &q);
	int k;
	for(int i = 0; i < q; i++) {
		scanf("%d", &k);
		printf("%d\n", binary_search(a.begin(), a.end(), k));
	}
}



Measured memory_bytes: 3408
#include <bits/stdc++.h>
using namespace std;
double pi = 2 * acos(0.0);
int main(){
        map<string, int> m;
        string s1, s2;
        int x1, x2;
        cin >> s1 >> s2 >> x1 >> x2;
        m[s1] = x1, m[s2] = x2;
        string t; cin >> t;
        m[t]--;
        cout << m[s1] << " " << m[s2];
    return 0;
}



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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> vis(n * m);
	queue<int> q;
	for (int i = 0; i < n; i++) {
		string str;
		cin >> str;
		for (int j = 0; j < m; j++) {
			int now = i * m + j;
			if (str[j] == '#') {
				vis[now] = 1;
				q.push(now);
			}
		}
	}
	int ans = 0;
	while (q.size()) {
		queue<int> nq;
		while (q.size()) {
			int u = q.front();
			q.pop();
			int x = u / m;
			int y = u % m;
			if (x && !vis[u - m]) {
				vis[u - m] = 1;
				nq.push(u - m);
			}
			if (y && !vis[u - 1]) {
				vis[u - 1] = 1;
				nq.push(u - 1);
			}
			if (x < n - 1 && !vis[u + m]) {
				vis[u + m] = 1;
				nq.push(u + m);
			}
			if (y < m - 1 && !vis[u + 1]) {
				vis[u + 1] = 1;
				nq.push(u + 1);
			}
		}
		if (nq.size()) {
			ans++;
		}
		q = nq;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

const int MOD=1e9+7;
const double PI=3.14159265359;


int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m;
    cin>>n>>m;
    int ans=1;
    
    for(int i=1; i*i<=m; i++){
        if(!(m%i)){
            int f2=m/i;
            if(f2>=n) ans=max(ans,i);
            if(i>=n) ans=max(ans,f2);
        }
    }
    cout<<ans;
    
    return 0;
    
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        StringBuilder print=new StringBuilder();
        st=new StringTokenizer(br.readLine());
        int a=Integer.parseInt(st.nextToken());
        int b=Integer.parseInt(st.nextToken());
        int c=Integer.parseInt(st.nextToken());
        int d=Integer.parseInt(st.nextToken());
        int maxxneg=a;
        int maxxpos=b;
        int maxypos=d;
        int maxyneg=c;
        long ans=Long.MIN_VALUE;
        if(maxxpos>0&&maxypos>0){
            ans=Math.max(ans,1l*maxxpos*maxypos);
        }
        if(maxxneg<0&&maxyneg<0){
            ans=Math.max(ans,1l*maxxneg*maxyneg);
        }
        ans=Math.max(ans,1l*a*d);
        ans=Math.max(ans,1l*b*c);
        System.out.println(ans);
    }
}


Measured memory_bytes: 25384
#include<iostream>
using namespace std;
int a[10];
int main(){
	int n=5;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		if(a[i]==0){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3568
n=int(input())
arr=[int(i) for i in input().split()]
dp=[0]*(n)
dp[0]=0
dp[1]=abs(arr[1]-arr[0])

for i in range(2,n):
    dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2])
print(dp[-1])

Measured memory_bytes: 13980
//__professor_
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define lld long double
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define ub upper_bound
#define lb lower_bound
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define test ll t;cin>>t;while(t--)
#define mod 1000000007
#define inf 1000000000000000001
const double pi  =3.141592653589793238463;
using namespace std;

int main()
{
	FAST;
	ll n,total;
	cin>>n>>total;
	ll t=n;
	vector<pair<ll,ll>> v;
	ll dp[n][total+1];
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<=total;j++)
		{
			dp[i][j]=-1;
		}
	}
	while(t--)
	{
		ll w,val;
		cin>>w>>val;
		v.pb(mk(w,val));
	}
	sort(v.begin(),v.end());
	for(ll i=0;i<n;i++)
	{
		dp[i][0]=0;
	}

	for(ll i=0;i<=total;i++)
	{
		pair<ll,ll> p;
		p=v[0];
		if(i<p.ff)
		{
			dp[0][i]=0;
		}
		else
		{
			dp[0][i]=p.ss;
		}
	}

	for(ll i=1;i<n;i++)
	{
		for(ll j=0;j<=total;j++)
		{
			pair<ll,ll> p;
			p=v[i];
			if(j<p.ff)
			{
				dp[i][j]=dp[i-1][j];
			}
			else
			{
				dp[i][j]=max(dp[i-1][j],p.ss+dp[i-1][j-p.ff]);
			}
		}
	}

	// for(ll i=0;i<n;i++)
	// {
	// 	for(ll j=0;j<=total;j++)
	// 	{
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	cout<<dp[n-1][total];


	return 0;
}



Measured memory_bytes: 78336
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
	int n, m; cin >> n >> m;
	for (int i = 1, j = m + 1; i < j; i++, j--)
		cout << i << ' ' << j << '\n';
	for (int i = m + 2, j = m + m + 1; i < j; i++, j--)
		cout << i << ' ' << j << '\n';
	return 0;
}


Measured memory_bytes: 3628
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    d,t,s=MI()
    if t*s>=d:
        print("Yes")
    else:
        print("No")
if __name__=="__main__":
    main()


Measured memory_bytes: 65464
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left
#from copy import deepcopy
#import heapq
#import math
import string
#from time import time
#from functools import lru_cache
setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
s=input().rstrip()
abc=string.ascii_uppercase*2
ans=""
for i in s:
    ans+=abc[abc.index(i)+n]
print(ans)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int res = 0;
    rep(i, 4)
    {
        char s;
        cin >> s;
        if (s == '+')
            res++;
        else
            res--;
    }
    cout << res << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector <ll> arr(n);
	ll s = 0;
	for (int z=0;z<n;z++){
		cin >> arr[z];
		s += arr[z];
	}
	vector <ll> pre(n);
	pre[0] = 2*arr[0];
	pre[1] = 2*arr[0];
	for (int z=2;z<n-1;z+=2){
		pre[z] = pre[z-2]+2*arr[z];
		pre[z+1] = pre[z];
	}
	vector <ll> suff(n);
	suff[n-1] = 2*arr[n-2];
	suff[n-2] = 2*arr[n-2];
	for (int z=n-3;z>0;z-=2){
		suff[z] = suff[z+2]+2*arr[z-1];
		suff[z-1] = suff[z]; 
	}
	vector <ll> ans(n);
	for (int z=0;z<n;z+=2){
		ans[z] = s;
		if (z < n-1) ans[z] -= suff[z+1];
		if (z > 0) ans[z] -= pre[z-1];
		if (z < n-1)ans[z+1] = 2*arr[z]-ans[z];
	}
	for (ll i : ans){
		cout << i << " ";
	} cout << endl;
}

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

#define null				 ""
#define all(dat)			 dat.begin(), dat.end()
#define over(msg)			 cout << msg << endl, exit(0);
#define loop(i, to)			 for (int i = 0; i < to; ++i)
#define cont(i, to)			 for (int i = 1; i <= to; ++i)
#define foreach(i, dat)      for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long			 num;

using namespace std;

int n, l, r, a[105], c1, c2, ans;

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> l >> r;
	cont (i, n) {
		cin >> a[i];
		if (a[i] <= l) {
			++c1;
		} else if (a[i] <= r) {
			++c2;
		}
	}
	ans = min(min(c1, c2), n - c1 - c2);
	cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int A = intArray[0];
            int B = intArray[1];
            int C = intArray[2];
            int K = intArray[3];
            if(A >= K)
            {
                Console.WriteLine(K);
            }
            else if(A + B >= K)
            {
                Console.WriteLine(A);
            }
            else
            {
                Console.WriteLine(A - (K - (A + B)));
            }
        }
    }
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 27968
# A - Connection and Disconnection
def count(s, c):
	count_ = s.count(c*2)
	
	while c*3 in s:
		s = s.replace(c*3, c+'_'+c)
	
	while c*2 in s:
		s = s.replace(c*2, c+'_')
	
	return min(count_, s.count('_'))


def get_startswith(s, c):
	key = c
	
	while s.startswith(key+c):
		key += c
	
	return len(key)
	
	
def get_endswith(s, c):
	key = c
	
	while s.endswith(key+c):
		key += c
	
	return len(key)


import string

S = input()
K = int(input())

lower = string.ascii_lowercase
ans = 0

if S[0] == S[-1:]:
	start = get_startswith(S, S[0])
	end = get_endswith(S, S[0])	
	
	if start == end == len(S):
		print(len(S) * K // 2)
	else:
		ans = 0
		
		ans += start // 2
		ans += end // 2
		ans += ((start + end) // 2) * (K - 1)
		
		for c in lower:
			ans += count(S[start:len(S)-end], c) * K

		print(ans)	
else:
	for c in lower:
		ans += count(S, c)

	print(ans * K)

Measured memory_bytes: 9872
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define int long long int

using namespace std;
typedef pair<int, int> PII;
typedef pair<PII, int> PPI;
typedef pair<int, PII> PIP;
typedef pair<PII, PII> PPP;
typedef vector<PII> VP;
typedef VP::iterator VPI;
typedef vector<int> VI;
const int INF = 3e18;
const double PI = acos(-1);
const int MOD = 1e9 + 7;

int n, a, b;
string s;

int in = 0, out = 0;
bool ans[100010];
signed main()
{
  cin >> n >> a >> b >> s;

  for(int i = 0; i < n; i++){
    if(s[i] == 'a' && in + out < a + b){
      ans[i] = true;
      in++;
    }
    else if(s[i] == 'b' && in + out < a + b && out < b){
      ans[i] = true;
      out++;
    }
  }

  for(int i = 0; i < n; i++){
    cout << (ans[i] ? "Yes" : "No") << endl;
  }
  return 0;
}


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

#define ll long long
int main() {
    
    ll n,m;cin>>n>>m;
    priority_queue<ll> pq;
    for(ll i=0;i<n;i++)
    {
        ll t;cin>>t;
        pq.push(t);
    }
    
    while(m!=0)
    {
        ll a = pq.top();
        if(a==0)
            break;
        a=(a/2);
        // cout<<a<<" ";
        pq.pop();
        pq.push(a);
        m--;
    }
    ll sum=0;
    while(pq.size()!=0)
    {
        sum+=pq.top();
        pq.pop();
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define mp make_pair
// GCD inbuilt func: __gcd(a,b)
// LCM formula: (a*b)/__gcd(a,b)

int main(){
	ios::sync_with_stdio(false);
    cin.tie(NULL);
	// CODE goes here
    int d,t,s;
    cin >> d >> t >> s;
    if(t*s>=d) cout << "Yes";
    else cout << "No";
	return 0;
}


Measured memory_bytes: 3648
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
import time


_, = map(int,readline().split())
D = 365
*c, = map(int,readline().split())
s = tuple(tuple(map(int,readline().split())) for _ in range(D))

def output(ans):
    for i in ans: print(i+1)

def score(ans,s,c): # ans: 0-indexed としたときのスコアの計算
    last = [-1]*26
    score = 0
    for i, ai in enumerate(ans):
        score += s[i][ai]
        last[ai] = i
        for ci,li in zip(c,last):
            score -= ci*(i-li)
        #print(score) # i日目のスコア
    return score


#ans = [max(range(26),key=lambda x: si[x]) for si in s]
#ans = (list(range(26))*20)[:365]

def first_solution(s,c):
    minus = c[:]
    ans = [0]*365
    for i, si in enumerate(s):
        ans[i] = idx = max(range(26), key=lambda x:si[x]+minus[x])
        for i in range(26):
            minus[i] += c[i]
        minus[idx] = 0
    return ans        


"""
solution = 初期解(ランダム生成や、貪欲法など他の手法で求めたものを利用)
while 時間のある限り:
    solution を(ランダムに)少し変形
    if 変形前より解が悪化:
        solution を変形前の状態に戻す
"""


from bisect import bisect_left, bisect_right
"""
i 日目と i+1 日目を入れ替え
"""
def swap(i,ans,days,c,s):
    j = i+1
    ai = ans[i]
    aj = ans[j]
    di = days[ai]
    dj = days[aj]
    idx_i = bisect_left(di,-i)
    idx_j = bisect_left(dj,-j)
    
    #print(di,i,idx_i,ai)
    #print(dj,j,idx_j,aj)
    #assert di[idx_i] == -i and dj[idx_j] == -j 
    
    i_prev = -di[idx_i - 1]
    i_next = -di[idx_i + 1] if di[-1] != -i else -1

    j_prev = -dj[idx_j - 1]
    j_next = -dj[idx_j + 1] if dj[-1] != -j else -1

    delta_i = -c[ai]*(2*i-i_prev-i_next) + s[j][ai] - s[i][ai]
    delta_j = -c[aj]*(j_prev+j_next-2*i) - s[j][aj] + s[i][aj]
    #delta = delta_i + delta_j

    return delta_i + delta_j,idx_i,idx_j


def main(ans,s,c):
    from random import randrange
    #best = ans[:]
    start = time.time()
    days = [[-365] for _ in range(26)]
    for i in range(364,-1,-1):
        days[ans[i]].append(-i)

    while time.time() - start < 0.5:
        i = randrange(364)
        if ans[i] != ans[i+1]:
            delta,idx_i,idx_j = swap(i,ans,days,c,s)
            if delta > 0:
                days[ans[i]][idx_i] -= 1
                days[ans[i+1]][idx_j] += 1
                ans[i],ans[i+1] = ans[i+1],ans[i]
                    
        idx = randrange(26)
        a0 = ans[0]
        if a0 != idx:
            delta = s[0][idx] - s[0][a0] + c[a0]*(days[a0][-2]) - c[idx]*(days[idx][-1]+1)
            
            if delta > 0:
                ans[0] = idx
                days[idx].append(0)
                days[a0].pop()
                
        
        

    return ans

#print(score(ans,s,c))
output(main(first_solution(s,c),s,c))







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

int main() {
  ll x,ans;
  cin >>x;
  ans = x/11*2;
  if(ans==0){
    if(x<=6){
      cout<<1<<endl;
    }else{
      cout<<2<<endl;
    }
    return 0;
  }
  if(x%11==0){
    cout<<ans<<endl;
  }else if(x%11<7){
    cout<<ans+1<<endl;
  }else{
    cout<<ans+2<<endl;
  }
}

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

using namespace std;

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

#define F first
#define S second

const int MAXN = 1e5 + 10, C = 70;
const ld eps = 1e-9;

int n;
ll a[MAXN], b[MAXN], c[MAXN];
int sec[MAXN], gec[MAXN], pos[MAXN];

ld zz;
bool cmp(int u, int v){
	if ((b[v] < 0) ^ (b[u] < 0))
		return -a[u]*b[v] < -a[v]*b[u];
	return -a[u]*b[v] > -a[v]*b[u];
}
bool cmp2(int u, int v){
	return (-a[u]*zz+c[u])/ld(b[u]) < (-a[v]*zz+c[v])/ld(b[v]);
}

int fen[MAXN];
void add(int v){for (v++; v<MAXN; v+=v&-v) fen[v]++;}
int gg(int v){
	int ret = 0;
	for (; v; v-=v&-v) ret += fen[v];
	return ret;
}

ll get(ld mid){
	zz = mid;
	iota(gec, gec + n, 0);
	sort(gec, gec + n, cmp2);

	ll ret = 0;
	memset(fen, 0, sizeof(fen));
	for (int i = n-1; ~i; i--){
		ret += gg(pos[gec[i]]);
		add(pos[gec[i]]);
	}
	
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	ll mm = 1ll*n*(n-1)/2;
	mm = mm+1>>1;
	for (int i = 0; i < n; i++)	cin >> a[i] >> b[i] >> c[i];
	iota(sec, sec + n, 0);
	sort(sec, sec + n, cmp);
	for (int i = 0; i < n; i++) pos[sec[i]] = i;
	
	ld lo = -3e8, hi = 3e8;
	for (int i = 0; i < C; i++){
		ld mid = (hi+lo)/2.;
		if (get(mid) < mm)
			lo = mid;
		else
			hi = mid;
	}
	cout << fixed << setprecision(12);
	cout << hi << " ";

	for (int i = 0; i < n; i++) swap(a[i], b[i]);
	iota(sec, sec + n, 0);
	sort(sec, sec + n, cmp);
	for (int i = 0; i < n; i++) pos[sec[i]] = i;
	lo = -3e8, hi = 3e8;
	for (int i = 0; i < C; i++){
		ld mid = (hi+lo)/2.;
		if (get(mid) < mm)
			lo = mid;
		else
			hi = mid;
	}
	cout << hi << "\n";
	return 0;
}


Measured memory_bytes: 2432
#include <iostream>
using namespace std;
int main(void){
// Your cod
int S,s,h,t;
cin>>S;
s=S/1000; S-=s*1000;
h=S/100; S-=h*100;
t=S/10; S-=t*10;
if(s==h|h==t|t==S) cout<<"Bad";
else cout<<"Good";
}


Measured memory_bytes: 256
void main() {
	auto N = readAs!long;
	ulong current = ulong.max;

	foreach(long i; 1..N.to!real.sqrt.ceil.to!long+1) {
		if(N % i == 0) {
			current = min(current, abs(i + N / i));
		}
	}
	(current-2).writeln;
}

ulong[] getDivisors(ulong N) {
	ulong[] res;
	foreach(i; 1..N.to!real.sqrt.ceil.to!ulong) {
		if(N % i == 0) {
			res ~= i;
			res ~= N / i;
		}
	}
	return res;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	
#include<list>
#include<set>

constexpr auto PI = 3.14159265359;

using namespace std;

int main() {
	int q;
	string x;
	string y;
	cin >> q;

	

	for (int k = 0; k < q; ++k) {
		cin >> x;
		cin >> y;
		x = ' ' + x;
		y = ' ' + y;
		vector<vector<int>> LCS(x.length() + 1, vector<int>(y.length() + 1, 0));

		for (int i = 1; i < x.length(); ++i) {
			for (int j = 1; j < y.length(); ++j) {
				if (x[i] == y[j]) {
					LCS[i][j] = LCS[i - 1][j - 1] + 1;
				}
				else {
					LCS[i][j] = max(LCS[i - 1][j], LCS[i][j - 1]);
				}
			}
		}
		cout << LCS[x.length() - 1][y.length() - 1] << endl;
	}


	return 0;
}


Measured memory_bytes: 6856
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

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

    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        for (int j = i; j < s.size(); ++j) {
            char c = s[j];
            if (c != 'A' && c != 'T' && c != 'G' && c != 'C') break;
            ans = max(ans, j - i + 1);
        }
    }

    cout << ans << endl;

    return 0;
}


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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define AI(a,size,n) array<int,size> a;REP(i,n){assert(0<scanf("%d",&a[i]));}
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}
#define MSET(arr,val)  memset(arr,val,sizeof(arr))

int main(){
  INT(n);
  map<int, vector<pair<int, int>>> gr;
  REP(n -1){
    INT(a); INT(b); INT(c);
    gr[a].PB(MP(b, c));
    gr[b].PB(MP(a, c));
  }
  INT(q); INT(k);
  ull dist[n + 1]; MSET(dist, -1);
  dist[k] = 0;
  queue<int> qu; qu.push(k);
  while (!qu.empty()){
    int u = qu.front(); qu.pop();
    for(auto p: gr[u]){
      int v = p.first, c = p.second;
      if (dist[v] == -1){
        dist[v] = dist[u] + c;
        qu.push(v);
      }
    }
  }
  REP(q){
    INT(x); INT(y);
    printf("%llu\n", dist[x] + dist[y]);
  }
  return 0;
}

Measured memory_bytes: 14196