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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  rep1(i, n) cin >> a[i];


  ll m = 0;
  vector<ll> sum(n+1, 0);
  vector<ll> b(n+1, 0);
  for(ll i = n; 0 < i; i--){
    for(ll j = i; j <= n; j += i) sum[i] += b[j];
    
    if(n/2 < i){
      if(a[i] == 1) b[i] = 1;
    }
    else{
      if(sum[i]%2 != a[i]) b[i] = 1;
    }
    if(b[i] == 1) sum[i]++, m++;
    
    if(sum[i]%2 != a[i]){
      cout << -1 << endl;
      return 0;
    }
  }


  cout << m << endl;
  string pt = "";
  rep1(i, n){
    if(b[i] == 1) cout << pt << i, pt = " ";
  }
  cout << endl;



  return 0;
}



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

const int maxn = 1e3 + 10;

int n, maxd, p[maxn];

bool dfs(int d) {
	if(p[d] == n) return true;
	if(d == maxd) return false;

	int maxi = 0;
	for(int i = 0; i <= d; i++) maxi = max(maxi, p[i]);
	if(maxi*pow(2, maxd-d) < n) return false;

	for(int i = d; i >= 0; i--) {
		p[d+1] = p[d] + p[i];
		if(dfs(d+1)) return true;
		p[d+1] = p[d] - p[i];
		if(dfs(d+1)) return true;
	}

	return false;
}

int main()
{
	p[0] = 1;

	while(scanf("%d", &n) && n) {
		for(maxd = log2(n);; maxd++) if(dfs(0)) break;
		printf("%d\n", maxd);
	}

	return 0;
}

Measured memory_bytes: 3376
from itertools import product
N, M = map( int, input().split())
K = [ list( map( int, input().split())) for _ in range(M)]
P = list( map( int, input().split()))
ans = 0
for p in product( range(2), repeat = N):
    t = 1
    for i in range(M):
        cnt = 0
        for j in range(1, K[i][0]+1):
            if p[K[i][j]-1] == 1:
                cnt += 1
        if cnt%2 != P[i]:
            t = 0
            break
    if t == 1:
        ans += 1
print( ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<string> vs;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	set<ll> s = { 4,6,9,11 };
	ll a, b;
	cin >> a >> b;
	if (a == b == 2) cout << "Yes" << endl;
	else if (a == 2 || b == 2) cout << "No" << endl;
	else if (!(s.count(a) ^ s.count(b))) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main() {
	int r,d,x;
  	cin>>r>>d>>x;
  
  vector<int> A(110);
  A[0]=r*x-d;
  cout<<r*x-d<<endl;
  
  for(int i=1;i<10;i++){
  		cout<<r*A[i-1]-d<<endl;
    	A[i]=r*A[i-1]-d;
    	}
}

Measured memory_bytes: 3600
#include<iostream>                                                                                                                                
#include<stdio.h>                                                                                                                                 
using namespace std;                                                                                                                              
                                                                                                                                                  
int main()                                                                                                                                        
{                                                                                                                                                 
        int a, b, x;                                                                                                                              
        scanf("%d%d%d", &a, &b, &x);                                                                                                              
        if (a <= x) {                                                                                                                             
                if (a + b >= x)                                                                                                                   
                        printf("YES");                                                                                                            
                else                                                                                                                              
                        printf("NO");                                                                                                             
        }                                                                                                                                         
        else                                                                                                                                      
                printf("NO");                                                                                                                     
        return 0;                                                                                                                                 
}

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n;cin >> n;

  vi h(n);
  rep(i,n)  cin >> h[i];

  vi c(n,INF);
  c[0] = 0;

  for(int i = 0; i < n; i++)
  {
    if(i == n - 1)
    {
      // 何もしない
    }
    else if(i == n - 2)
    {
      c[i + 1] = min(c[i + 1] , c[i] + abs(h[i + 1] - h[i]));
    }
    else
    {
      c[i + 1] = min(c[i + 1] , c[i] + abs(h[i + 1] - h[i]));
      c[i + 2] = min(c[i + 2] , c[i] + abs(h[i + 2] - h[i]));
    }
  }

  cout << c[n - 1] << endl;





  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
vector<vector<ll>> A(2000, vector<ll>(2000));
using llp = pair<ll, ll>; // score
vector<llp> Score(2000 * 2000);

int main() {
  ll H, W;
  cin >> H >> W;
  for (ll i = 0; i < H; i++) {
    for (ll j = 0; j < W; j++) {
      char c = '\0';
      cin >> c;
      if (c == '#') {
        A[i][j] = 0;
      } else {
        A[i][j] = 1;
      }
    }
  }

  for (ll i = 0; i < H; i++) {
    ll sum = 0;
    vector<ll> TempVec;
    for (ll j = 0; j < W; j++) {
      if (A[i][j] == 0) {
        if (!TempVec.empty()) {
          for (const auto &x : TempVec) {
            Score[i + x * W].first = sum;
          }
          TempVec.clear();
        }
        sum = 0;
      } else {
        TempVec.push_back(j); // index
        sum++;
      }
    }
    // ごみ処分する
    if (!TempVec.empty()) {
      for (const auto &x : TempVec) {
        Score[i + x * W].first = sum;
      }
      TempVec.clear();
    }
    sum = 0;
  }

  for (ll j = 0; j < W; j++) {
    ll sum = 0;
    vector<ll> TempVec;
    for (ll i = 0; i < H; i++) {
      if (A[i][j] == 0) {
        if (!TempVec.empty()) {
          for (const auto &x : TempVec) {
            Score[x + j * W].second = sum;
          }
          TempVec.clear();
        }
        sum = 0;

      } else {
        TempVec.push_back(i); // index
        sum++;
      }
    }

    // ごみ処分する
    if (!TempVec.empty()) {
      for (const auto &x : TempVec) {
        Score[x + j * W].second = sum;
      }
      TempVec.clear();
    }
    sum = 0;
  }
  const llp anspair = *max_element(cbegin(Score), cend(Score), [](auto x, auto y) {
    return x.first + x.second < y.first + y.second;
  });

  const ll ans = anspair.first + anspair.second - 1;
 
  cout << ans << endl;

  return 0;
}


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

int main() {
    int ss;
    cin >> ss;
    for (int i = 0; i < 999; ++i) {
      if(ss/100 == (ss%100)%10 &&  (ss%100)%10 == (ss/10)%10){
        break;
      }else{
      ss+=1;
      }
    }
  
    cout << ss << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def main():
    n = int(input().strip())
    for i in range(1, 10):
        if n % i == 0 and 1 <= n // i < 10:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

cnt = sum(B)

for i in range(N-1):
  if A[i] + 1 == A[i+1]:
    s = A[i]-1
    cnt = cnt + C[s]
  
print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
    char b;
    cin>>b;
    if(b=='A')cout<<'T'<<endl;
    else if(b=='T')cout<<'A'<<endl;
    else if(b=='C')cout<<'G'<<endl;
    else cout<<'C'<<endl;
}

Measured memory_bytes: 256
import math

X=int(input())
# a=int(input())
#A,B=map(int,input().split(" "))
#a=[int(_) for _ in input().split(" ")]

i=0
t=100

while t < X:
  t = math.floor(t * 1.01)
  i += 1

#print(a,b)
print(i)

Measured memory_bytes: 9160
#include <stdio.h>

int main(void)
{
	int num;
	int temp[5];
	int i;
	int sum, min, max;
	
	while (1){
		scanf("%d", &num);
		
		if (num == 0) break;
		
		for (i = 0; i < num; i++){
			scanf("%d%d%d%d%d", &temp[0], &temp[1], &temp[2], &temp[3], &temp[4]);
			sum = temp[0] + temp[1] + temp[2] + temp[3] + temp[4];
			
			if (i == 0) min = max = sum;
			else {
				if (sum < min) min = sum;
				if (sum > max) max = sum;
			}
		}
		printf("%d %d\n", max, min);
	}
	
	return (0);
}

Measured memory_bytes: 0
import Data.Bits
import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import Control.Monad.ST
import Data.Maybe (fromMaybe)
import qualified Data.ByteString.Lazy.Char8 as B
--import Debug.Trace

printList :: (Show a) => [a] -> IO ()
printList list = do
  forM_ list $ \x -> do
    putStr (show x)
    putStr " "
  putStrLn ""

main :: IO ()
main = do
  [k,x] <- map read.words <$> getLine :: IO [Int]

  printList $ [max (x-k+1) (-1000000) .. min (x+k-1) 1000000]


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
using P = pair<int,int>;
//int dy[4] = {-1,0,1,0};
//int dx[4] = {0,-1,0,1};


int main()
{
    string s,t;
    cin >>s >> t;
    
    for(int i=0;i<(int)s.size();i++)
    {
        if(s[i] != t[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}


/*
int main()
{
    int N;
    cin >> N;
    
 
 int ans;
 cout << ans << endl;
    return 0;
}
*/

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n, r;
  cin >> n >> r;
  int h=0;
  
  if(n >= 10){
    h = r;//内部レーティングは表示レーティング
  }else{
    h = r + 100*(10-n); //内部レーティングは表示＋100*(10-k)
  }
  cout << h;
}

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 k;
  string s;
  cin >> k >> s;

  if(s.size()<=k){
    cout << s << endl;
  }
  else{
    rep(i,k){
      cout << s[i];
    }
    cout << "..." << endl;
  }

  return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>
#include<math.h>
int main(void){
  int q;
  double x;
  for(;;){
    scanf("%d",&q);
    if(q==-1)
      break;
    x=q/2.0;
    while(fabs(x*x*x-q)>=0.00001*q)
      x-=(x*x*x-q)/x/x/3;
    printf("%lf\n",x);
  }
  return 0;
}



Measured memory_bytes: 2108
#include <stdio.h>
#include <stdlib.h>
#pragma GCC optimize ("O3")

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

inline static void pl(unsigned int s){
    char str[9];
    int pos=9;
    if(s==0){
        putchar_unlocked('0');
        return;
    }
    do{
        pos--;
        str[pos]=s%10+48;
        s/=10;
    }while(s!=0);
    for(; pos<9; pos++){
        putchar_unlocked(str[pos]);
    }
}

//char a[501];
//unsigned short out[1000000];

int main(void){
    char* a = (char*)malloc(501);
    unsigned short* out = (unsigned short*)malloc(200000000);
    const int h=gl(), w=gl();
    int pos=0;
    char haveCoin = 0;
    short old_y, old_x;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            int t = getchar_unlocked() - 48;
            getchar_unlocked();
            a[j] = t;
        }
        if(i%2==1){
            for(int j=1; j<=w; j++){
                if(haveCoin){
                    out[4*pos+0]=old_y;
                    out[4*pos+1]=old_x;
                    out[4*pos+2]=i;
                    out[4*pos+3]=j;
                    pos++;
                }
                haveCoin ^= a[j]&1;
                old_y = i;
                old_x = j;
            }
        }else{
            for(int j=w; j>0; j--){
                if(haveCoin){
                    out[4*pos+0]=old_y;
                    out[4*pos+1]=old_x;
                    out[4*pos+2]=i;
                    out[4*pos+3]=j;
                    pos++;
                }
                haveCoin ^= a[j]&1;
                old_y = i;
                old_x = j;
            }
        }
    }
    pl(pos); putchar_unlocked('\n');
    for(int i=0; i<pos; i++){
        pl(out[4*i+0]); putchar_unlocked(' ');
        pl(out[4*i+1]); putchar_unlocked(' ');
        pl(out[4*i+2]); putchar_unlocked(' ');
        pl(out[4*i+3]); putchar_unlocked('\n');
    }
    return 0;
}


Measured memory_bytes: 4608
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

class UnionFind {
public:
    vector<int>Parent;

    //コンストラクタ
    UnionFind(int N) {
        Parent = vector<int>(N + 1, -1);
    }

    //親を返す
    int root(int A) {
        if (Parent[A] < 0)return A;
        return Parent[A] = root(Parent[A]);
    }

    //サイズを返す
    int size(int A) {
        return -Parent[root(A)];
    }

    //くっつける
    bool connect(int A, int B) {
        A = root(A); B = root(B);
        if (A == B)return false;

        if (size(A) < size(B))swap(A, B);
        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }

    //グループにその数があるか
    int belong(int A, int P) {
        if (root(P) == root(A))return 1;
        return 0;
    }

};

int main() {

    int N,M;
    cin >> N >> M;
    UnionFind Uni(N);

    vector<int>P(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        Uni.connect(x, y);
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += Uni.belong(i+1, P[i]);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 1024
package main

import (
    "fmt"
    "os"
    "bufio"
    "strings"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func StrStdin() (stringInput string){
  sc.Scan()
  OneLineString := sc.Text()
  stringInput = strings.TrimSpace(OneLineString)
  return 
}

func IntStdin() (int, error){
  stringInput := StrStdin()
  return strconv.Atoi(stringInput)
}

// ?????????????l??????????Split()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
    stringSplited := strings.Split(stringTargeted, delim)

    for _, str := range stringSplited {
        if str != "" {
            stringReturned = append(stringReturned, str)
        }
    }

    return
}

// ?f???~?^??????????????X???C?X???��
func SplitStrStdin(delim string) (stringReturned []string) {
    // ???????1?s?��
    stringInput := StrStdin()
  
    // ???????
    // stringSplited := strings.Split(stringInput, delim)
    stringReturned = SplitWithoutEmpty(stringInput, delim)

    return
}

// ?f???~?^?????????????l?X???C?X???��
func SplitIntStdin(delim string) (intSlices []int, err error) {
    // ??????X???C?X???��
    stringSplited := SplitStrStdin(delim)
	
    // ?????X???C?X????
    for i := range stringSplited {
        var iparam int
        iparam, err = strconv.Atoi(stringSplited[i])
        if err != nil {
            return
        }
        intSlices = append(intSlices, iparam)
    }
    return
}

func main(){
  intlist, _ := SplitIntStdin(" ")
  result := 0
  num := intlist[0]
  for num <= intlist[1] {
    num *= 2
    result++
  }
  fmt.Println(result)
}

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

using namespace std;

const int MAXN = 18;

int n;
int a[MAXN][2], b[MAXN];
int f[1 << MAXN][55];

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

  cin >> n;
  for(int j = 0; j < 2; ++j) {
    for(int i = 0; i < n; ++i) cin >> a[i][j];
  }

  memset(f, 60, sizeof f);

  f[0][0] = 0;
  for(int mask = 0; mask + 1 < (1 << MAXN); ++mask) {
    int cur = __builtin_popcount(mask);
    int current_cost = 0;
    int cst[MAXN];
    for(int i = 0; i < n; ++i) {
      cst[i] = current_cost;
      if(!(mask & (1 << i))) {
        ++current_cost;
      }
    }
    for(int j = 0; j <= 50; ++j) {
      for(int i = 0; i < n; ++i) {
        if(!(mask & (1 << i))) {
          int dst = abs(i - cur) % 2;
          if(a[i][dst] >= j) {
            f[mask ^ (1 << i)][a[i][dst]] = min(f[mask ^ (1 << i)][a[i][dst]], f[mask][j] + cst[i]);
          }
        }
      }
    }
  }

  int ans = (int) 1e9;
  for(int i = 0; i <= 50; ++i) {
    ans = min(ans, f[(1 << n) - 1][i]);
  }

  if(ans > 2000000) {
    cout << -1;
  }
  else cout << ans;

  return 0;
}


Measured memory_bytes: 56576
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

typedef long long int ll;
typedef vector<ll> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int mxn = 1e5;
// int cnt1[mxn+2],cnt2[mxn+2];

void solve(){
	ll n,cpyn;
	cin >> n;
	cpyn=  n;
	vi divn;
	divn.pb(n);
	vi divn1;
	divn1.pb(n-1);

	for(ll i =2;i*i<=n;i++){
		if(n%i==0){
			divn.pb(i);
			if(i*i!=n)
				divn.pb(n/i);
		}
	}
	n--;
	for(ll i =2;i*i<=n;i++){
		if(n%i==0){
			divn1.pb(i);
			if(i*i!=n)
				divn1.pb(n/i);
		}
	}

	ll ans = 0;
	ans+=divn1.size();
	n = cpyn;
	for(auto e:divn){
		n = cpyn;
		while(n%e==0){
			n/=e;
		}
		if(n%e==1){
			// cout << e << endl;
			ans++;
		}
	}
	if(cpyn==2)
		ans--;
	cout << ans << endl;
}

int main(){
	fast;
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3724
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int A[3];
	cin>>A[0]>>A[1]>>A[2];
	sort(A,A+3);
	if(A[0]==A[1]&&A[1]!=A[2] || A[0]!=A[1]&&A[1]==A[2])cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main(){

    int a;
    for (int i = 0; i < 5; ++i ){
        cin >> a;
        if(a==0){
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	string s, t, u;
	cin >> s >> t >> u;
	string a = "";
	a += s[0];
	a += t[0];
	a += u[0];
	for( auto c : a ){
		putchar(toupper(c));
	} cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ull unsigned long long
#define ll long long
#define ld long double
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
#define MX LLONG_MAX
#define MN LLONG_MIN
 
const int N=1e2 + 5;
const ll mod=1e9+7;
 
ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

int main()                  
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    if(b%a==0)
        cout<<a+b;
    else
        cout<<b-a;
    return 0;
}  

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;


int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int c = 1;
	for (int i = 0; i < n; i++) {
		int t;
		scanf("%d", &t);
		if (t == c) {
			c++;
		}
	}
	if (c == 1) {
		cout << -1 << endl;
		return 0;
	}
	cout << n - c + 1 << endl;
}









Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC";
    else cout<<"ABC";

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
char s[111111];
int x[111111],cnt;
int main(){
	scanf("%s",s+1); int n=strlen(s+1);
//	puts("WTF");
	if (s[1]=='0') {return puts("-1"),0;}
	if (s[n]=='1') {return puts("-1"),0;}
	for (int i=1,j=n-1;i<=j;i++,j--){
		if (s[i]!=s[j]) return puts("-1"),0;
		if (s[i]=='1') x[++cnt]=i;
	}
	x[++cnt]=n;
	for (int i=1;i<cnt;i++) {
		printf("%d %d\n",i,i+1);
	} 
	int id=cnt;
	for (int i=2;i<=cnt;i++){
		int sz=x[i]-x[i-1]-1;
		for (int j=0;j<sz;j++) printf("%d %d\n",i,++id);
	}
	return 0;
}
	
	
	

Measured memory_bytes: 1664
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>

using namespace std;

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

    int N, A, B;
    cin >> N >> A >> B;

    int a = 0;
    for (int i = 0; i <= N; i++)
    {
        int t = 0, n = i;
        for (int j = 0; j < 5; j++) t += n % 10, n /= 10;
        if (A <= t && t <= B) a += i;
    }

    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
    int a,b,cou,maxn;
    while(cin>>b&&b>=1&&b<=100)
    {
         maxn=0;
    for(int i=1;i<=b;i++)
    {
        int t=i;
        cou=0;
    while(t%2==0)
    {
        t=t/2;
        cou++;
    }
    if(cou>=maxn)
        {maxn=cou;
        a=i;}
    }
        cout<<a<<endl;

    }
return 0;
    }


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int nums[59];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K;
    cin>>N>>K;
    
    rep(i,N) cin>>nums[i];
    sort(nums,nums+N);
    reverse(nums,nums+N);
    
    ll sum=0;
    rep(i,K) sum+=nums[i];
    
    cout1(sum)
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll y[50] = {};
ll x[50] = {};
int main() {
	ll n, k; cin >> n >> k;
	rep(i, 0, n) {
		cin >> x[i] >> y[i];
	}

	ll minV = 1e20;
	rep(x1, 0, n) {
		rep(x2, 0, n) {
			rep(y1, 0, n) {
				rep(y2, 0, n) {
					ll cnt = 0;
					rep(i, 0, n) {
						if (x[x1] <= x[i] && x[i] <= x[x2] && y[y1] <= y[i] && y[i] <= y[y2]) {
							cnt++;
						}
					}
					if (cnt >= k) {
						minV = min(minV, abs(x[x2] - x[x1])* abs(y[y2] - y[y1]));
					}
				}
			}
		}
	}
	cout << minV << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    for(;;){
        int n,m,q;cin>>n>>m>>q;
        if(n==0&&m==0&&q==0)return 0;
        string s[q+1],t[q+1];
        rep(i,1,q+1)cin>>s[i]>>t[i];
        rep(i,0,n){
            s[0]+="0";
        }
        rep(i,0,m)t[0]+="0";
        rep(i,0,m){
            bool ok[n];
            fill(ok,ok+n,true);
            rep(j,1,q+1){
                int mae=t[j-1][i]-'0';
                int now=t[j][i]-'0';
                if(mae!=now){
                    rep(k,0,n){
                        if(s[j][k]=='0')ok[k]=false;
                    }
                }
                else{
                    rep(k,0,n){
                        if(s[j][k]=='1')ok[k]=false;
                    }
                }
                //rep(k,0,n)cout<<ok[k]<<" ";
                //cout<<endl;
            }
            int cnt=0;
            int num;
            rep(j,0,n){
                if(ok[j]){
                    cnt++;
                    num=j;
                    if(cnt>=2)break;
                }
            }
            if(cnt!=1)cout<<"?";
            else{
                if(num<=9)cout<<num;
                else{
                    char ans='A';
                    ans+=num-10;
                    cout<<ans;
                }
            }
        }
        cout<<endl;
    }
}










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

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

  int H, A;
  cin >> H >> A;
  if(H % A == 0){
    cout << H / A <<endl;
  } else{
    cout << H / A + 1 <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const i64 MOD = 998244353;

int main()
{
  i64 N, S;
  cin >> N >> S;
  vector<i64> A(N);
  for (i64 i = 0; i < N; i++)
    cin >> A[i];
  vector<vector<i64>> dp(N + 1, vector<i64>(S + 1));
  dp[0][0] = 1;
  for (i64 i = 0; i < N; i++)
  {
    for (i64 j = 0; j <= S; j++)
      (dp[i + 1][j] = dp[i][j] * 2) %= MOD;
    for (i64 j = 0; j <= S - A[i]; j++)
      (dp[i + 1][j + A[i]] += dp[i][j]) %= MOD;
  }
  cout << dp[N][S] << endl;
  return 0;
}


Measured memory_bytes: 73684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define inf (ll)1e9

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x, i, j) cerr << #x << "------------" << "\n";cerr << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cerr << x[k] << " ";cerr << "\n"; cerr.flush();

#define MAXN 10010

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

	int n, k;
	cin >> n >> k;
	for(int i=1; i<=n; i++){
		char ch;
		cin >> ch;
		if(i == k){
			if(ch == 'A') cout << 'a';
			else if(ch == 'B') cout << 'b';
			else cout << 'c';
		}
		else{
			cout << ch;
		}
	}
	return 0;
}

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

void print_vector(vector<int>& v)
{
    for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
    {
        std::cout << *it;
        if (it != v.end() - 1)
        {
            std::cout << " ";
        }
    }
    std::cout << endl;
}

int main()
{
#ifdef LOCAL
    // ??\??? cin ?????\????????? 'xxx.txt' ?????????
    std::ifstream in("alds1_2_a.txt");
    std::cin.rdbuf(in.rdbuf());
#else
#endif        

    vector<int> vec;
    int n = 0;
    int change_num = 0;

    cin >> n;
    for(int i = 0; i < n; ++i)
    {
        int tmp;
        cin >> tmp;
        vec.push_back(tmp);
    }
    
    for (int i = 0; i < n; i++)
    {
        for (int j = n - 1; j > 0; j--)
        {
            if (vec[j-1] > vec[j])
            {
                int tmp = vec[j-1];
                vec[j-1] = vec[j];
                vec[j] = tmp;
                change_num++;
            }
        }
        
    }

    print_vector(vec);
    cout << change_num << endl;
    return 0;
}

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

const int MAX_N = 1e5;
const int MOD = 1e9 + 7;
int N, K;
vector<vector<int> > tree(MAX_N + 1);
vector<bool> visited(MAX_N + 1, false);
vector<int> memo(MAX_N+1, 0);

int dfs(int frm, int obj) {
    ll ret = 1;
    memo[obj]++;
    ret *= K - memo[obj] - memo[frm];
    ret %= MOD;
    for (int x : tree[obj]) {
        if (!visited[x]) {
            visited[x] = true;
            ret *= dfs(obj, x);
            ret %= MOD;
            memo[obj]++;
        }
    }
    return ret;
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N-1; i++) {
        int a, b; cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    ll ans = 1;
    visited[1] = true;
    memo[1] = -1;
    ans *= dfs(0, 1);
    cout << ans << endl;
}


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

int stones;
int i;
int n;
int change[100000];
int change_i;
int last;

int solve(int color){
    int a=1;
    if(i & 1 && last != color){
        color ? stones-=i-change[change_i-1] : stones+=i-change[change_i-1];
        a=0;
    }
    if(!color) stones++;
    i++;
    return a;
}

int main(){
    int color;
    cin >> n;
    while(n){
        i = 0;
        last = 2;
        stones = 0;
        change_i = 0;
        for(int j=0;j<n;j++){
            cin >> color;
            if(solve(color)){
                if(last != color){
                    change[change_i] = j;
                    change_i++;
                }
            }else if(change_i>1){
                change_i--;
            }
            /*for(int k=0;k<change_i;k++){
                cout << change[k] << " ";
            }
            cout << endl;
            */
            last = color;
        }
        cout << stones << endl;
        cin >> n;
    }
}

Measured memory_bytes: 872
#include <stdio.h>
#include <string.h>

int main(void)
{
  int A,B,M;
  scanf("%d %d %d", &A, &B, &M);
  int a[A], b[B], m[M], x[M], y[M];
  int a_min = 999999 , b_min = 999999;
  for (int i = 0; i < A; i++) {
    scanf("%d", &a[i]);
    if (a[i] < a_min) a_min = a[i];
  }
  for (int i = 0; i < B; i++) {
    scanf("%d", &b[i]);
    if (b[i] < b_min) b_min = b[i];
  }

  int min = a_min + b_min;
  
  for (int i = 0; i < M; i++) {
    scanf("%d %d %d", &x[i], &y[i], &m[i]);
    if ((a[x[i] - 1] + b[y[i] - 1] - m[i]) < min) {
      min = (a[x[i] - 1] + b[y[i] - 1] - m[i]);
    }
  }
  printf("%d", min);
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    int n, k, x[100], ans = 0, ndif, kdif;
    std::cin >> n >> k;
    for(int i = 0;i < n;i++){
        std::cin >> x[i];
    }

    for(int i = 0;i < n;i++){
        if(x[i] - k < 0){
            kdif = -(x[i] - k);
        }
        else{
            kdif = x[i] - k;
        }
        ndif = x[i];

        if(kdif > ndif){
            ans += ndif;
        }
        else{
            ans += kdif;
        }
    }

    ans *= 2;

    std::cout << ans;
    return 0;
}

Measured memory_bytes: 256
squre :: Int -> Int
squre x = x * x

solve' n as = minimum $ fmap (\v -> solve n as v) [ -100 .. 100 ]

solve :: Int -> [Int] -> Int -> Int
solve n as v = foldr (\x acc -> acc + squre (x - v)) 0 as

main = do
  n <- read <$> getLine :: IO Int
  line <- getLine
  let as = fmap read (words line) :: [Int]
  putStrLn $ show $ solve' n as


Measured memory_bytes: 1020
fun main(args: Array<String>) {
    val (l, r) = readLine()!!.split(' ').map(String::toLong)
    if (r - l >= 2019) {
        println(0)
        return
    }
    var min = Long.MAX_VALUE
    for (i in l until r) {
        for (j in (l + 1)..r) {
            min = Math.min(min, ((i) * (j) % 2019))
        }
    }
    println(min)
}


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

using namespace std;
using ll = long long;

constexpr int MOD = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n + 1, 0);
  vector<ll> q;
  for (int i = 1; i <= n; ++i) {
    int buf;
    cin >> buf;
    a[i] = a[i - 1] + buf;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      q.push_back(a[j] - a[i - 1]);
    }
  }
  ll comp = (ll)1 << 40;
  ll ans = 0;
  while (comp > 0) {
    int f = 0;
    for (auto &x : q) {
      if (x >= comp) {
        f++;
      }
      x -= comp;
    }
    if (f >= k) {
      ans += comp;
    } else {
      for (auto &x : q) {
        if (x < 0)
          x += comp;
      }
    }
    comp >>= 1;
  }
  cout << ans << endl;
}


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

int compare_int(const void *a, const void *b){
    return *(int*)b - *(int*)a;
}

int main(){
    int n, k, cnt=0, l[100]={0};

    scanf("%d%d", &n, &k);
    for(int i=0; i<n; i++){ scanf("%d", &l[i]); }
    qsort( l, n, sizeof(int), compare_int );
    
    for(int i=0; i<k; i++){ cnt += l[i]; }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 1700
#include <cstdio>
static const int MAXH = 102;
static const int MAXN = MAXH * MAXH;

int n, m, k;
int a[MAXN];

int g[MAXH][MAXH] = {{ 0 }};

int main()
{
    scanf("%d%d%d", &n, &m, &k);

    int pos = 0;
    for (int i = 0; i < k; ++i) {
        scanf("%d", &a[i]);
        for (int j = pos; j < pos + a[i]; ++j) {
            int r = j / m, c = j % m;
            if (r & 1) c = m - 1 - c;
            g[r][c] = i + 1;
        }
        pos += a[i];
    }
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            printf("%d%c", g[i][j], j == m - 1 ? '\n' : ' ');

    return 0;
}


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

int main(){
  string S, T;
  cin >> S >> T;
  
  for(int i=0; i<S.size(); i++){
    if(S == T){
      cout << "Yes" << endl;
      return 0;
    }
    
    S = S.back() + S.substr(0, S.size()-1);
    
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i;
    int j;
    int a,b;
    while(1){
        name:scanf("%d%d",&a,&b);
        if(a==0&&b==0){
            break;
        }
        else if(a==0||b==0){
            printf("\n");
            goto name;
        }
        for(i = 1;i <= a;i++){
            if(i==1||i==a){
                for(j = 1;j <= b;j++){
                    printf("#");
                }
            }
            else{
                for(j = 1;j <= b;j++){
                    if(j==1||j==b){
                        printf("#");
                    }
                    else{
                        printf(".");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
/*  Author:  Hariom_Pandey
    Created: 2/9/2020 5:27:57 PM
*/
 
#include "bits/stdc++.h"
using namespace std;

#define ll              long long int
int32_t main(){
    string str,str2="",str3;
    cin>>str;
    for(int i=0; i<str.size(); i++) str2+='x';
        cout<<str2;

   
   
}





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

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,cost;
};
int main(){

	string s;
	int s2[11]={};
	cin>>s;

	int t=0;
	rep(i,s.size()){
		if(s[i]=='0')s2[t]=0;
		if(s[i]=='1')s2[t]=1;
		if(s[i]=='B'&&t>0)t--;
		if(s[i]=='0'||s[i]=='1')t++;
	}
	rep(i,t){
		cout<<s2[i];
	}
	cout<<endl;
	return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
ll a, b, c, d, e, f, n, m, x, y, z, w, h, mn;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> a >> b >> c >> d >> e >> f){
        a *= 100, b *= 100;
        ll ans[2] = {a, 0};
        for(ll i = 0; a * i <= f; i++)
        for(ll j = 0; a * i + b * j <= f; j++)
        if(i + j){
            for(ll k = 0; a * i + b * j + k * c <= f; k++)
            for(ll l = 0; a * i + b * j + k * c + l * d <= f; l++){
                ll water[2] = {a * i + b * j, k * c + l * d};
                if((ans[0] * water[1] > ans[1] * water[0]) && (water[1] * (100 + e) <= (water[0] + water[1]) * e)){
                    ans[0] = water[0], ans[1] = water[1];
                }
            }
        }
        out(ans[0] + ans[1]), out(' '), print(ans[1]);
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = unsigned long long;

int main() {
  int n;
  string s;

  cin >> n;
  cin >> s;

  for (char& c : s) {
    cout << (char)((c - 'A' + n) % 26 + 'A');
  }
  cout << endl;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    X = list(map(int, readline().split()))

    mul_mod = [0] * N

    cur = 1
    for i in range(1, N):
        cur *= i
        cur %= MOD
    mul_mod[1] = cur

    for i in range(2, N):
        mul_mod[i] = (mul_mod[1] * pow(i, MOD - 2, MOD)) % MOD

    p = [0] * (N - 1)
    p[-1] = sum(mul_mod[1:N]) % MOD

    for i in range(2, N):
        p[-i] = p[-i + 1] - mul_mod[N - i + 1]
        p[-i] %= MOD

    ans = 0

    for i in range(N - 1):
        ans += (X[i + 1] - X[i]) * p[i]
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 87016
n,m = [int(i) for i in input().split()]

n_left = 1
n_right = n
result = 0

for i in range(m):
    l_i,r_i = [int(i) for i in input().split()]
    if(l_i > n_left):
        n_left = l_i
    if(r_i < n_right):
        n_right = r_i

if(n_left > n_right):
    print(0)
else:
    print(n_right - n_left + 1)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------


ll n, k;

/*nCk*/
//nCkをmod(この例では10^9 + 7)で割った余りを求めるプログラム 下処理としてinit()を実行しておくこと
//---------------------------------------------------------------------------------------------------
//この例での制約はn < 10^6
vector<long long> f(200021);   //f.at(i): i!(をmodで割りながら求めたもの)
vector<long long> rf(200021);  //rf.at(i): 1/(i!)をmodで割りながら求めたもの
long long inv(long long x) {//ここでは逆元を求める
    long long res = 1;
    long long k = mod - 2;
    long long y = x;
    while (k) {//繰り返し二乗法を用いている
        if (k & 1) res = (res * y) % mod;//kが存在かつ値 k == 1
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {//ここで
    f.at(0) = 1;
    for(long long i = 1; i < 200020; i++){
        f.at(i) = (f.at(i - 1) * i) % mod;
        rf.at(i) = inv(f.at(i));//逆元も同時にメモ
    }//n!をmodで割っていったものを求めている
}
//---------------------------------------------------------------------------------------------------
long long C(int n, int k) {
    long long a = f.at(n); // = n!%mod
    long long b = rf.at(n - k); // = (n-k)!%mod
    long long c = rf.at(k); // = k!%mod

    long long bc = (b * c) % mod;

    if(k == 0 || n == k){
        return 1;
    }
    return (a * bc) % mod;
}
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
/*modに対する逆元の計算*/
long long modinv(long long a, long long m) { //modの逆元を求める
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
void solve(){
}
int main(){
    cin >> n >> k;
    init();
    if(k >= n){
        k = n - 1;
    }
    ll ans = 0;
    ll tmp;
    ll tmp2;
    for(int i = 0; i <= k; i++){
        tmp = C(n, n - i);
        tmp %= mod;
        tmp2 = C(n - 1, i);
        tmp2 %= mod;
        tmp *= tmp2;
        tmp %= mod;
        ans += tmp;
        ans %= mod;
    }
    ans += mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3328