akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
int main(){
  int count,oorc,flag,n,m,i,j,k,len;
  char u[258][11],t[258][11];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",u[i]);
  }
  oorc=0;
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%s",t[i]);
    flag=0;
    len=strlen(t[i]);
   
  
    for(j=0;j<n;j++){
      count=0;
      for(k=0;k<len;k++){
    if(t[i][len]=='\0'&&u[j][len]!='\0'){
          break;
    }
    if(t[i][k]==u[j][k]){
      count++;
    }
        if(count==len){
          flag=1;
          break;
    }
      }
    }
    if(flag==1&&oorc==0){
      oorc=1;
      printf("Opened by ");
      for(j=0;j<len;j++){
    printf("%c",t[i][j]);
      }
      printf("\n");
    }
    else if(flag==1&&oorc==1){
      oorc=0;
      printf("Closed by ");
      for(j=0;j<len;j++){
    printf("%c",t[i][j]);
      }
      printf("\n");
    }   
    else if(flag==0){
      printf("Unknown ");
      for(j=0;j<len;j++){
    printf("%c",t[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}

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

using namespace std;

#define ll long long int
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<ll>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)

void solve()
{
    int n;
    cin>>n;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int res=(int)round(sum/(double)n);
    int reqd=0;
    for(int i=0;i<n;i++)
    {
        reqd+=abs(res-a[i])*abs(res-a[i]);
    }
    cout<<reqd;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  vector<string> ans(h);
  rep (i, h) cin >> v[i];
  rep (i, h){
    rep (j, w){
      if (v[i][j] == '#'){
        ans[i] += "#";
      } else {
        int count = 0;
        for (int k = -1; k < 2; ++k){
          if (i+k < 0) continue;
          if (i+k >= h) continue;
          for (int l = -1; l < 2; ++l){
            if (j+l < 0) continue;
            if (j+l >= w) continue;
            if (v[i+k][j+l] == '#'){
              ++count;
            }
          }
        }
        ans[i] += to_string(count);
      }
    }
  }
  rep (i, h){
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3680
#include <iostream>

class ModInt {
    using ll = long long;

public:
    int value;
    static int MOD;

    ModInt(ll value = 0) {
        this->value = (-MOD < value && value < MOD ? value : value % MOD);
        if (this->value < 0) this->value += MOD;
    }

    operator int() const noexcept { return this->value; }
    operator ll() const noexcept { return this->value; }

    ModInt& operator=(const ModInt& x) {
        if (this != &x) { this->value = x.value; }
        return *this;
    }

    bool operator==(const ModInt& x) const { return this->value == x.value; }
    bool operator!=(const ModInt& x) const { return !(*this == x); }

    ModInt operator+() const { return value; }
    ModInt operator-() const { return MOD - value; }
    ModInt operator~() const { return (*this) ^ ModInt(MOD - 2); }

    ModInt operator++() { return *this += 1; }
    ModInt operator--() { return *this -= 1; }

    ModInt operator++(int) {
        ModInt before = *this;
        ++(*this);
        return before;
    }
    ModInt operator--(int) {
        ModInt before = *this;
        --(*this);
        return before;
    }

    ModInt& operator+=(const ModInt& x) {
        int sum = this->value + x.value;
        return *this = (sum < MOD ? sum : sum - MOD);
    }
    ModInt& operator-=(const ModInt& x) {
        int diff = this->value - x.value;
        return *this = (diff >= 0 ? diff : diff + MOD);
    }
    ModInt& operator+=(int x) { return *this += ModInt(x); }
    ModInt& operator-=(int x) { return *this -= ModInt(x); }

    template <class T>
    ModInt& operator*=(const T& x) { return *this = ll(this->value) * ll(x) % MOD; }
    template <class T>
    ModInt& operator/=(const T& x) { return *this = (this->value % int(x) == 0 ? ModInt(this->value / int(x)) : *this * ~ModInt(x)); }
    template <class T>
    ModInt& operator^=(const T& x) {
        int n = int(x);
        ModInt b = *this;
        *this = 1;
        while (n > 0) {
            if (n & 1) *this *= b;
            n >>= 1;
            b *= b;
        }
        return *this;
    }

    template <class T>
    ModInt operator+(const T& b) const { return ModInt(*this) += b; }
    template <class T>
    ModInt operator-(const T& b) const { return ModInt(*this) -= b; }
    template <class T>
    ModInt operator*(const T& b) const { return ModInt(*this) *= b; }
    template <class T>
    ModInt operator/(const T& b) const { return ModInt(*this) /= b; }
    template <class T>
    ModInt operator^(const T& b) const { return ModInt(*this) ^= b; }
};

std::ostream& operator<<(std::ostream& os, const ModInt& x) { return os << x.value; }
std::istream& operator>>(std::istream& is, ModInt& x) { return is >> x.value; }

int ModInt::MOD = 1000000007;

int main() {
    int N, K;
    std::cin >> N >> K;
    std::cout << (ModInt(K) ^ N) << std::endl;
}


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

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

typedef long long LL;

const int oo = 0x3f3f3f3f;

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m, K;
	scanf("%d%d%d", &n, &m, &K);
	REP(i, 0, n + 1)
		REP(j, 0, m + 1)
			if (i * (m - j) + j * (n - i) == K)
			{
				puts("Yes");
				exit(0);
			}
	puts("No");
	return 0;
}


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

using namespace std;

int main(void) {
    long h, w;
    cin >> h >> w;
    if((h == 1) || (w == 1)){
        cout << 1 << endl;
    }
    else{
        cout << (h * w + 1) / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5]){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3616
import math

k = int(input())
ans = 0
ans += sum(range(1, k + 1))
for i in range(1, k + 1):
    for j in range(i + 1, k + 1):
        ans += math.gcd(i, j) * 6
if k > 2:
    for i in range(1, k + 1):
        for j in range(i + 1, k + 1):
            for l in range(j + 1, k + 1):
                ans += math.gcd(i, math.gcd(j, l)) * 6
print(ans)

Measured memory_bytes: 9204
n = int(input())
c = []
for i in range(n - 1):#h:高さ
    c.append([int(m) - 1 for m in input().split()])
for i in range(n - 1):
    c[i].append(1)

def DFS(K, w,edges,N):
  cnt = 0
  roots=[ [] for i in range(N)]
  for a,b,c in edges:
    roots[a]+=[(b,c)]
    roots[b]+=[(a,c)]
  dist=[-1]*N
  stack=[]
  stack.append(K)
  dist[K]=0
  while stack:
    label=stack.pop(-1)
    cnt += 1
    if label != w:
        for i,c in roots[label]:
          if dist[i]==-1:
            dist[i]=dist[label]+c
            stack+=[i]
  return cnt - 1

def DFS2(K,w,edges,N):
  htg = []
  prl = []
  for i in range(n):
      """htg.append([])"""
      prl.append([])
  roots=[ [] for i in range(N)]
  for a,b,c in edges:
    roots[a]+=[(b,c)]
    roots[b]+=[(a,c)]
  dist=[-1]*N
  stack=[]
  stack.append(K)
  dist[K]=0
  """htg[0].append(0)"""
  while stack:
      label = stack.pop(-1)
      """if label != 0:
        htg[label] += htg[prl[label][0]]
        htg[label].append(label)"""
      for i,c in roots[label]:
        if dist[i]==-1:
          dist[i]=dist[label]+c
          stack+=[i]
          prl[i].append(label)
        if i==w:
            htg.append(i)
            while i != 0:
                gg = prl[i][0]
                htg.append(gg)
                i = gg
            return htg
#点は0始まり
htgn = DFS2(0, n - 1, c, n)
sroot = len(htgn) // 2
pnt = htgn[sroot - 1]

fenneccnt = DFS(0, pnt, c, n)#点は0始まり
snukecnt = n - fenneccnt
if fenneccnt > snukecnt:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 62384
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  bool operator< (const Point &p1) const {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

Int N, K;
vector<Int> A;
#define INFTY 9223372036854775807

void input() {
  cin >> N >> K;
  Int a;
  rep(N) {
    cin >> a;
    A.push_back(a);
  }
}

Int dfs(Int n = 0, Int k = 0, Int cost = 0, Int max_h = 0) {
  if (n == N) {
    if (k >= K) return cost; // Kを満たしている場合はそれまでにかかった総コスト
    else return INFTY; // K満たしていないので無駄コスト
  }

  if (n == 0) {
    return dfs(1, 1, 0, A.at(0));
  }

  Int h = A.at(n);
  bool highest = max_h < h; // これまでで過去最高の高さ（=修正不要）

  // この建物の高さを前のよりも高くする or しないのbit全探索
  Int min_ = dfs(n+1, k + highest, cost, max(max_h, h));

  if (!highest) {
    cost += max_h + 1 - h; // これまでの最高+1の高さが必要
    Int yes = dfs(n+1, k+1, cost, max_h + 1);
    min_ = min(min_, yes);
  }

  return min_;
}

void solve() {
  cout << dfs() << endl;
}

int main() {
  input();
  solve();
  return 0;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, a, b;
  cin >> n >> a >> b;
  vl x(n);
  rep(i,n) cin >> x[i];
  ll ans = 0;
  rep(i,n-1){
    ans += min((x[i+1] - x[i]) * a, b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,cnt=0,min;
    scanf("%d",&n);
    int arr[n];
    for(int i=0;i<n;i++)
    scanf("%d",&arr[i]);
     for(int i=0;i<n-1;i++)
       {
         min=i;
         for(int j=i+1;j<n;j++)
         {
             if(arr[j]<arr[min])
             {

                 min=j;
                 //cnt++;
             }
         }
        if(i!=min)
        {swap(arr[min],arr[i]);
         cnt++;
}
         }
 for(int i=0;i<n-1;i++)
    printf("%d ",arr[i]);
printf("%d\n",arr[n-1]);
 printf("%d\n",cnt);
}

Measured memory_bytes: 3172
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


void err() {
	puts(-1);
	exit(0);
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	cin >> N;
	vector<int>A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	int nxt;
	ll ans = 0;

	if (N == 1) {
		if (A[0] != 0)err();
		puts(0);
		return 0;
	}
	for (int i = N - 1; i >= 0; i--) {
		if (i == N - 1) {
			ans += A[i];
			if (A[i] > 0)nxt = A[i]-1;
			else nxt = 0;
		}
		else if(i > 0){
			if (nxt != A[i]) {
				if (A[i] > nxt) {
					ans += A[i];
					nxt = A[i] - 1;
				}
				else err();
			}
			else {
				if (A[i] == 0)continue;
				else nxt--;
			}
		}
		else {
			if (nxt != 0 || A[i] != 0)err();
		}
	}
	puts(ans);

	return 0;
}

Measured memory_bytes: 1024
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def main():
    s = input()
    print(s.count("1"))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 100000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n ; cin >> n ;
	ll ans = 0 ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		while(a%2==0){
			ans++ ;
			a /= 2 ;
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define INF 10000000000000000LL

using namespace std;
typedef long long ll;

bool is_palindrome(string &s) {
  int n = s.size();
  for (int i = 0; i < n / 2; ++i)
    if (s[i] != s[n - i - 1])
      return false;
  return true;
}

int n;
unordered_map<string, ll> memo[2];
unordered_set<string> vis[2];
vector<string> S[2];
vector<ll> C;
ll dfs(string s, int p) {
  if (memo[p].count(s))
    return memo[p][s];
  if (is_palindrome(s))
    return 0;
  if (vis[p].count(s))
    return INF;
  vis[p].insert(s);
  ll ans = INF;
  int ls = s.size();
  for (int i = 0; i < n; ++i) {
    string t = S[!p][i];
    int lt = t.size();
    int l = min(ls, lt);
    string ps = s.substr(0, l);
    string pt = t.substr(0, l);
    if (ps != pt)
      continue;
    ll cost =
        ls > lt ? dfs(s.substr(l, ls - l), p) : dfs(t.substr(l, lt - l), !p);
    if (cost < ans)
      ans = min(ans, cost + C[i]);
  }
  vis[p].erase(s);
  memo[p][s] = ans;
  return ans;
}

int main() {
  cin >> n;
  S[0] = vector<string>(n);
  S[1] = vector<string>(n);
  C = vector<ll>(n);
  ll ans = INF;
  for (int i = 0; i < n; ++i) {
    cin >> S[0][i] >> C[i];
    S[1][i] = string(S[0][i].rbegin(), S[0][i].rend());
  }
  for (int i = 0; i < n; ++i)
    ans = min(ans, dfs(S[0][i], 0) + C[i]);
  cout << (ans == INF ? -1 : ans);
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int ans=0;
  for(int i=1; i<=n; i++){
    int cnt=0;
    for(int j=1; j<=i; j++){
      if(i%j==0) cnt++;
    }
    if(cnt==8 && i%2==1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<long ,long> pll; 	
const ll mod=1e9+7;

int main(){
	long long a,b,c,ans=0;
  cin>>a>>b>>c;
  for(ll i=a; i<=b; i++){
    if(i%c==0){
      ans++;
    }
  }
  cout<<ans;

	return 0;
} 


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
全部計算はちょいむり
ループするはず？


*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N, X, M;
  cin >> N >> X >> M;
  vector<int> seen(100010, 0);
  ll now = X, ans = 0, count = 0;
  rep(i, N){
    if (seen[now] == 2)
      break;
    seen[now]++;
    count++;
    ans += now;
    now *= now;
    now %= M;
//cout << now << endl;
  }
  if (count == N){
    cout << ans << endl;
    return 0;
  }
  ll loop = 0, point = 0;
  rep(i, 100001){
    if (seen[i] == 2){
      loop++;
      point += i;
    }
  }
  N -= count;
  ll loop_count = N / loop;
  ans += loop_count * point;
  N %= loop;
  while (N > 0){
    ans += now;
    now *= now;
    now %= M;
    N--;
  }
  cout << ans << endl;
}


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

int main(){
    int N, W; cin >> N >> W;
    int dp[N + 1][W + 1]; //dp[i][j] はi番目までの品物の中から重さj以下となるようにした時の最大の価値
    int v[N]; int w[N];
    for(int i = 0; i < N; i++){
        cin >> v[i] >> w[i];
    }
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= W; j++){
          dp[i][j] = 0;
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= W; j++){
            dp[i + 1][j] = dp[i][j]; //i+1番目は取らない場合
            if(j - w[i] >= 0) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]); //i+1番目の品を含める
        }
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 7032
def ext_euc(a, b):
    if b == 0:
        return 1, 0, a
    y, x, v = ext_euc(b, a % b)
    y -= (a // b) * x
    return x, y, v


def mod_inv(a, mod):
    x, _, _ = ext_euc(a, mod)
    return x % mod


def main():
    p = int(input())
    A = list(map(int, input().split()))
    # comb(p - 1, i)
    comb = [1] * p
    for i in range(1, p):
        v = comb[i - 1]
        v *= p - i
        v *= mod_inv(i, p)
        comb[i] = v % p
    b = [0] * p
    for k, a in enumerate(A):
        if a == 0:
            continue
        pw = [1] * p  # (- k)**(p - 1 - i)
        for i in range(1, p):
            pw[- (i + 1)] = (pw[- i] * (- k)) % p
        for i in range(p):
            if i == 0:
                b[i] += 1
            b[i] -= comb[i] * pw[i]
            b[i] %= p
    print(' '.join(map(str, b)))            


if __name__ == '__main__':
    main()

Measured memory_bytes: 75672
#include <bits/stdc++.h>
#include <chrono>
#include <regex>
using namespace std;
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define ll long long
#define fastIO  ios_base::sync_with_stdio(false); cin.tie(0); 
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>=a && (x)<=b	
#define incE(a,b,x)(x)>=a && (x)<=b	
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
//#define DEBUG


ll modo(ll a)
{
	return a % (int)(1e9+7);
}

set<char> s;
int main()
{
	Iint(n);
	int a = 0;
	for (int i = 0; i < n; ++i)
	{
		char t;
		std::cin >> t;
		if (s.insert(t).second)a++;
	}
	std::cout << (a == 3 ? "Three" : "Four");
}





Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.Queue
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val N, A = sc.nextInt
    println(if (N % 500 <= A) ("Yes") else ("No"))
  }

  def gcd(i: Int, j: Int): Int = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 25660
# frozen_string_literal: true

_n = gets
numbers = gets.split(" ").map(&:to_i)

alice = []
bob = []
numbers.sort {|a, b| b <=> a }.each_slice(2) {|pair|
  alice << pair[0]
  bob << pair[1] if pair[1]
}

answer = alice.inject(:+) - bob.inject(:+)
puts answer


Measured memory_bytes: 1788
if __name__ == '__main__':
   n, m = map(int,input().split())
   a = set([int(input()) for i in range(m)])
   broken = [False] * (n+1)
   for i in range(n+1):
      if i in a:
         broken[i] = True

   MOD = 1000000007

   dp = [0 for i in range(n+1)]
   dp[0] = 1
   if 1 in a:
      dp[1] = 0
   else:
      dp[1] = 1

   for i in range(2,n+1):
      if broken[i-1] and broken[i-2]:
         dp[i] = 0
      elif broken[i-1]:
         dp[i] = dp[i-2] % MOD
      elif broken[i-2]:
         dp[i] = dp[i-1] % MOD
      else:
         dp[i] = (dp[i-1] + dp[i-2]) % MOD

   print(dp[n])



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

int main(){
  int A,B;
  cin>>A>>B;
  int count=0;
  for(A;A<=B;A++){
    if(A/10000==A%10 && A%10000/1000==A%100/10) count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3600
def solve(dpt, cur, nxt)
  ser = Array.new(0)
  flag = 0
  nxt.each do |nx|
    @ans[nx[0]] = nx[1]
    @pt[nx[0]].each do |thr|
    if @dps[thr] == 0
      flag = 1
      @dps[thr] = dpt+1
      ser.push([thr,nx[0]])
    end
    end
  end
  solve(dpt+1, nxt, ser) if flag == 1
end

n,m = gets.split.map(&:to_i)
a,b = m.times.map{gets.split.map(&:to_i)}.transpose

@pt = Array.new(n+1).map{Array.new(0)}
for i in 0..(m-1)
  @pt[a[i]].push(b[i])
  @pt[b[i]].push(a[i])
end

@dps = Array.new(n+1,0)
@ans = Array.new(n+1,0)
@dps[1] = 1
nxtid = Array.new(0)
@pt[1].each do |nxt|
  nxtid.push([nxt,1])
  @dps[nxt] = 2
end
solve(1, [1], nxtid)

puts "Yes"
for i in 2..n
  puts @ans[i]
end

Measured memory_bytes: 58060
#include<stdio.h>
int main(){
	int num[100],i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
	}
	for(i=n-1;i>=0;i--){
		if(i!=n-1) printf(" ");
		printf("%d",num[i]);
	}
	printf("\n");

return 0;
}

Measured memory_bytes: 600
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

MOD=10**9+7
S=get_nsp.reverse
#S=["?"]*(10**5)
L=S.size
dp=Array.new(13){0}
dp[0]=1
b=1
S.each_with_index do|s,i|
    dp2=Array.new(13){0}
    k=0
    while k<13
        if s!="?"
            dp2[(k+s.to_i*b)%13]+=dp[k]
        else
            d=0
            while d<10
                dp2[(k+d*b)%13]+=dp[k]
                d+=1
            end
        end
        dp2[k]%=MOD
        k+=1
    end
    dp=dp2
    b*=10
    b%=13
end
puts dp[5]%MOD

Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

ll modpow(ll a, ll N) {
  ll ans = 1;
  ll tmp = a;
  while(N > 0) {
    if(N % 2 == 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    N /= 2;
  }
  return ans;
}
#define MAX_N 2000005
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r);
  ans = (ans * finv[r]) % mod;
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  make();
  int n; cin >> n;
  vector<int> A(n);
  int p1 = 0, p2 = 0;
  map<int, int> mp;
  rep(i, n+1) {
    cin >> A[i];
    if(mp.count(A[i])) {
      p1 = mp[A[i]];
      p2 = i;
    }
    mp[A[i]] = i;
  }
  for(int k=1; k<=n+1; k++) {
    ll ans = 0;
    ans += comb(n-1, k);
    if(k >= 2) (ans += comb(n-1, k-2)) %= mod;
    if(k >= 1) {
      (ans += comb(n-1, k-1) * 2 + mod - comb(p1+n-p2, k-1)) %= mod;
    }
    cout << ans << endk;
  }
  return 0;
}


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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

const ll INF = 1LL << 60;

int main() {
  int N;
  std::cin >> N;
  std::vector<std::pair<ll, int>> A(N);
  rep(i, N) {
    ll a;
    std::cin >> a;
    A[i] = {a, i};
  }

  std::sort(A.rbegin(), A.rend());

  std::vector<std::vector<ll>> dp(N + 1, std::vector<ll>(N + 1, -INF));
  dp[0][0] = 0;
  rep(c, N) {
    rep(x, c + 1) {
      int y = c - x;
      ll a = A[c].first;
      int i = A[c].second;
      dp[x + 1][y] = std::max(dp[x + 1][y], dp[x][y] + a * (i - x));
      dp[x][y + 1] = std::max(dp[x][y + 1], dp[x][y] + a * (N - 1 - y - i));
    }
  }

  ll ans = - INF;
  rep(x, N + 1) {
    int y = N - x;
    ans = std::max(ans, dp[x][y]);
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 34676
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    ll N,H;
    cin >> N >> H;
    vector<ll> a(N),b(N);
    ll maxv = 0,bmax = 0,cnt = 0,ans = 0;
    REP(i,N){
        cin >> a[i] >> b[i];
        maxv = max(maxv,a[i]);
        if(maxv >= H){
            cout << 1 << endl;
            return 0;
        }
    }
    sort ALL(b);
    reverse ALL(b);
    REP(i,N){
        if(maxv <= b[i]){
            cnt++;
            bmax += b[i];
            if(bmax >= H){
                cout << cnt << endl;
                return 0;
            }
        }
    }
    do{
        ans++;
        H -= maxv;
    }while(H > bmax);
    cout << ans + cnt << endl;
}

Measured memory_bytes: 1792
def main():
    n,k=map(int,input().split())
    r,s,p=map(int,input().split())
    t=input()
    cnt = 0
    check=[0]*n
    for i in range(0,k,1):
        for j in range(i+k,n,k):
            if t[j] == t[j-k] and check[j-k] == 0 and check[j]==0:
                check[j] = 1


    i=0
    for tmp in t:
        if check[i] == 1:
            i+=1
            continue
        if tmp == 'r' :
            cnt += p
        elif tmp == 's':
            cnt+=r
        elif tmp == 'p':
            cnt+=s
        i+=1
    # for i in range(n-1,k-1,-1):
    #     if i >= k and t[i] == t[i-k]:
    #         if check[i-k] == 0 and check[i] == 0:
    #             check[i-k] = 1
    #         if check[i] == 1:
    #             if t[i] == 'r':
    #                 cnt -= p
    #                 print(i)
    #
    #             elif t[i] == 's':
    #                 cnt-=r
    #                 print(i)
    #             elif t[i] == 'p':
    #                 cnt-=s
    #                 print(i)

    print(cnt)
if __name__=='__main__':
    main()


Measured memory_bytes: 41712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	int N, Q;
	string S;
	cin >> N >> Q >> S;
	vector<int> D(N, 0);
	for(int i = 1; i < N; i++){
		D[i] = D[i - 1];
		if(S[i - 1] == 'A' && S[i] == 'C')D[i]++;
	}//i文字目までの"AC"数(DP的な)
	
	rep(i, Q){
		int L, R;
		cin >> L >> R;
		cout << D[R - 1] - D[L - 1] << endl;
	}
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;

#define mod             1000000007
#define what_is(x)      cerr<<#x<<" is "<<x<<"\n";
#define read(x)         freopen("in.txt","r",stdin);
#define write(x)        freopen("out.txt","w",stdout);
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define sz              10
char arr[sz][sz];

int solve(int n, int m, int k){

    int tot=0;
    for(int maskR=0; maskR<(1<<n); maskR++){
        for(int maskC=0; maskC<(1<<m); maskC++){
            int black=0;
            for(int i=0; i<n; i++){
                for(int j=0; j<m; j++){
                    if(((maskR>>i)&1)==0 && ((maskC>>j)&1)==0 && arr[i][j]=='#')black++;
                }
            }
            tot+=(black==k);
        }

    }
    return tot;

}

int main(){
    Fast;///using Fast I/O
    int n,m,k;

    cin>>n>>m>>k;
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin>>arr[i][j];
        }
    }

    cout<<solve(n, m, k)<<endl;
    return 0;
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
double n,m;

int main(){
    int count=0;
    cin>>n>>m;
    vector<int>a(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i]; 
    }

    sort(a.begin(),a.end(),greater<int>()); 
    for(int i=0;i<m;i++){
        double w=1/(m*4);
        double b=sum*w;
        if(a[i]<b)break;
        count++;
    }
    if(count>=m)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void){
    int NUM[3000];
    int i,n,m;
    int a = 0;

    scanf("%d",&n);


    //スキャン
    for(i = 0; i<n; i=i+1){
        scanf("%d",&NUM[i]);
    }
    for(m = 0; m<n; m=m+1){
        NUM[m] = NUM[m] - 1;
        a = a + NUM[m];
    }



printf("%d",a);

    return 0;
}

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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }
#define fi first
#define se second
#define mkp std::make_pair
typedef long long ll;
typedef double ff;
typedef std::pair <int, int> pii;
const int kN = 1e5 + 5, kInf = 0x3f3f3f3f;
const ll kMod = 998244353, kInfLL = 0x3f3f3f3f3f3f3f3fLL;

int n, a[kN], bud1[kN], bud2[kN], idx1[kN], idx2[kN];

int main() {
	int T = 1; //rd(T);
	while(T--) {
		rd(n);
		for(int i = 1; i <= n; ++i) {
			rd(a[i]);
		}
		int ans = 0;
		for(int i = 1; i <= n; i += 2) ++bud1[a[i]];
		for(int i = 2; i <= n; i += 2) ++bud2[a[i]];
		int len = 1e5;
		for(int i = 1; i <= len; ++i) idx1[i] = i;
		for(int i = 1; i <= len; ++i) idx2[i] = i;
		std::sort(idx1 + 1, idx1 + len + 1, [](const int &x, const int &y) {
			return bud1[x] > bud1[y];
		});
		std::sort(idx2 + 1, idx2 + len + 1, [](const int &x, const int &y) {
			return bud2[x] > bud2[y];
		});
		if(idx1[1] != idx2[1]) printf("%d\n", n - bud1[idx1[1]] - bud2[idx2[1]]);
		else printf("%d\n", n - std::max(bud1[idx1[1]] + bud2[idx2[2]], bud1[idx1[2]] + bud2[idx2[1]]));
	} return 0;
}

Measured memory_bytes: 5688
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

int main() {
    ll ans=0, n, a, b;
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++) {
        int t = i, sum=0;
        while (t != 0) {
            sum += t % 10;
            t /= 10;
        }
        if (a <= sum&&sum <= b) ans += i;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n,a,b,c,x;
  int y[110];

  while( cin>>n>>a>>b>>c>>x &&(n|a|b|c|x) ){
    for( int i=0;i<n;i++ )
      cin >> y[i];

    int frame, k=0;
    for( frame=0;frame<=10000;frame++ ){
      if( x==y[k] ){
	k++;
	if(k==n ) break;
      }
      x=( a*x+b )%c;
    }
    if( frame>10000 )
      cout << "-1" << endl;
    else
      cout << frame<< endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N,K = read_int()
h = [read_int()[0] for _ in range(N)]
h.sort()

def solve():
    ans = float('INF')
    for i in range(N - K + 1):
        ans = min(ans, h[i + K - 1] - h[i])
    return ans

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 7496
package main

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

func main() {
	s := IOInitialize()
	A := Int(s)
	B := Int(s)
	area := A*B - (A + B - 1)
	fmt.Println(area)
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


Measured memory_bytes: 640
h, w = map(int, input().split())
result = []

while (h and w):
    result.append((h, w))
    h, w = map(int, input().split())

for item in result:
    h = item[0]
    w = item[1]
    for i in range(0, h):
        for j in range(0, w):
            if i > 0 and i < h - 1 and j > 0 and j < w - 1:
                print('.', end = '')
            elif (j == w - 1):
                print('#')
            else :
                print('#', end = '')
    print()


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

int main()
{
    char a[10];
    scanf(" %[^\n]",&a);
    
    if(a[2]==a[3] && a[4]==a[5])
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}


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

int main() {
    int d, n, result;
    cin >> d >> n;
    if (n == 100) {
        result = pow(100,d) * n + pow(100,d);
    } else {
        result = pow(100,d) * n;
    }
    cout << result << endl;
}


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

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

  string ans = "";
  rep (i, n) {
    ans += s[i];
    ans += t[i];
  }

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

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


void solve(long long A, long long P){
    cout << (A * 3 + P) / 2 << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long P;
    scanf("%lld",&P);
    solve(A, P);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        String[] S1 = sc.next().split("");
        String[] S2 = sc.next().split("");
        String[] S3 = sc.next().split("");

        System.out.println(Character.toUpperCase(S1[0].charAt(0)) + "" + Character.toUpperCase(S2[0].charAt(0)) + "" + Character.toUpperCase(S3[0].charAt(0)));
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const ll inf = (ll)1e9 + 7;
int main()
{
    ll i, j, k;
    ll n, a, b;
    cin >> n >> a >> b;
    j = n / (a + b);
    k = n % (a + b);
    if (k >= a)
    {
        cout << (j + 1) * a;
    }
    else
    {
        cout << j * a + k;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A == 1) {
      A += 20;
    }
    if (B == 1) {
      B += 20;
    }
    if (A == B) {
      System.out.println("Draw");
    } else if (A > B) {
      System.out.println("Alice");
    } else {
      System.out.println("Bob");
    }
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 8140
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	vector<pair<ll,ll>> arr;
	while(cin>>n>>m){
		arr.resize(n);
		for(int i=0;i<n;i++){
			cin>>arr[i].first>>arr[i].second;
		}
		sort(arr.begin(),arr.end());
		ll cnt=0,ans=0;
		for(int i=0;i<n;i++){
			if(cnt+arr[i].second<=m){
				cnt+=arr[i].second;
				ans+=arr[i].first*arr[i].second;
			}
			else{
				ans+=arr[i].first*(m-cnt);
				break;
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1792
sub f{$_[$_[1]<$_[0]]}
 
@N=1..<>;
/ .* /,$_[$`][$&]=$_[$&][$`]=$' for@M=<>;
 
for$m(@N){
	for$x(@N){
		for$y(@N){
			$_[$x][$y]=f($_[$x][$y]||1e9,($_[$x][$m]||1e9)+($_[$m][$y]||1e9));
		}
	}
}
/ .* /,$\+=$_[$`][$&]<$' for@M;
 
print


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

int main(){
    int A,B,C;
    std::cin >> A >> B >> C;
    std::string ans;
    if(A == B && A != C)
        ans = "Yes";
    else if(A == C && A != B)
        ans = "Yes";
    else if(B == C && B != A)
        ans = "Yes";
    else
    {
        ans = "No";
    }
    
    std::cout << ans << std::endl;
    return 0;
}

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

typedef long long ll;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<int> d(n);
    for (int i=0; i<n; i++) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    int count = 0;
    int pre = d.at(0);
    for (int i=1; i<n; i++) {
        if (d.at(i) == pre) count++;
        pre = d.at(i);
    }
    cout << n - count << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0
for a in range(min(n, k) + 1):
    for b in range(min(n - a, k - a) + 1):
        v_use = v[:a] + v[-b:] if b >= 1 else v[:a]
        t = k - a - b
        s = 0
        for j in sorted(v_use):
            if j < 0 and t > 0:
                s += -j
                t -= 1
        ans = max(ans, sum(v_use) + s)

print(ans)

Measured memory_bytes: 41580