akhauriyash/Code-Regression huggingface dataset:
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	string n;
	cin >> n;
	print("ABC" + n);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

int main() {
    long long a;
    long long b;
    cin >> a >> b;
    string A;
    for (long long i = 0; i < b; ++i) {
        A += ('0' + a);
    }  
    string B;
    for (long long i = 0; i < a; ++i) {
        B += ('0' + b);
    }
    cout << min(A , B) << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = 2e5+50;
const int M = 1e6;
const ll oo = 1e18;
const int mod = 1e9+7;

ll dp[N][2];
vector<int> g[N];

void dfs(int u,int p){
	dp[u][0] = dp[u][1] = 1;
	for(int v : g[u]){
		if(v == p)continue;
		dfs(v,u);
		dp[u][0] = (dp[u][0] * dp[v][1] + dp[u][0] * dp[v][0])%mod;
		dp[u][1] = (dp[u][1] * dp[v][0])%mod;
	}
	return;
}

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int u,v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,0);
	cout << (dp[1][0] + dp[1][1])%mod << endl;
}

Measured memory_bytes: 16512
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	string s;
	long long k;
	while(cin>>s>>k)
	{
		if(s.size()==1)
		{
			cout<<s[0]<<endl;
		}
		else
		{
			int i;
			for(i=0;i<s.size()-1;i++)
			{
				if(s[i]!='1')
					break;
			}
			if(k<=i)
				cout<<1<<endl;
			else
				cout<<s[i]<<endl;
			
		}
	
	}
	return 0;
}


Measured memory_bytes: 256
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var a,b,t int
    fmt.Scan(&a,&b,&t)
    ans := t/a*b
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> answer(N+1, 0);
    for (int x=1; x<=100; x++)
    {
        for (int y=1; y<=100; y++)
        {
            for (int z=1; z<=100; z++)
            {
                if (x*x + y*y + z*z + x*y + y*z + z*x <= N) answer[x*x + y*y + z*z + x*y + y*z + z*x]++;
            }
        }
    }
    for (int i=1; i<=N; i++) cout << answer[i] << endl;
}

Measured memory_bytes: 3628
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1;
	int dy = y2 - y1;
	cout << x2 - dy << ' ' << y2 + dx << ' ' << x2 - dy - dx << ' ' << y2 + dx - dy << endl;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		Set<Integer> s = new HashSet<>();
		for (int i = 0; i < n; i++) {
			s.add(Integer.parseInt(scanner.nextLine()));
		}
		System.out.println(s.size());
	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A_K,A_B,T_K,T_B;
  cin>>A_K>>A_B>>T_K>>T_B;
  int kaisuT=A_K/T_B;
  int kaisuA=T_K/A_B;
  if(A_K%T_B!=0)kaisuT++;
  if(T_K%A_B!=0)kaisuA++;
  if((kaisuT)>=(kaisuA)){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) cout << (x) << endl;
#define outs(x) for(auto i : x) cout << i << " ";
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;

int main() {
  str line;getline(cin,line);
  if(line[0] == line[line.length() - 1]) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int m;
    cin >> m;
    cout << 24 + (24 - m) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
int main() {
  int M, N, P[10000], C[500], E[500];

  cin >> M >> N;
  for(int i = 0; i < M; i++) {
    cin >> P[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> C[i] >> E[i];
  }

  int dp[10001];
  fill_n( dp, 10001, INF);
  dp[0] = 0;
  for(int i = 0; i < N; i++) {
    for(int j = M; j >= 0; j--) {
      if(dp[j] != INF){
        dp[min( j + C[i], M)] = min( dp[min( j + C[i], M)], dp[j] + E[i]);
      }
    }
  }

  sort(P, P + M, greater< int >());
  int ret = 0, sum = 0;
  for(int i = 0; i < M; i++){
    sum += P[i];
    ret = max( ret, sum - dp[i + 1]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 1260
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

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

  set<int> s;
  int now   = 0;
  int count = 0;
  int target = 0;
  s.insert(now);
  rep (i, n) {
    now = a[now];
    count++;
    auto itr = s.find(now);
    if (itr != s.end()) {
      target = a[now];
      break;
    }
    s.insert(now);
  }

  now = 0;
  int loopCount = 0;
  int loopPlace = 0;
  rep (i, n) {
    now = a[now];
    if (now == target) {
      break;
    }
    loopPlace = now;
    loopCount++;
  }
  // P(count);
  // P(loopCount);
  // P(loopPlace);
  // P(target);

  ll doCount = 0;
  if (k <= count) {
    doCount = k;
    now = 0;
  } else {
    if (target == a[target]) {
      doCount = (k - count) % 1;
      now = a[loopPlace];
    } else {
      doCount = (k - count) % (count - loopCount);
      now = loopPlace;
    }

  }

  rep (i, doCount) {
    now = a[now];
  }
  P(now + 1);
  return 0;
}

Measured memory_bytes: 13128
h,w=map(int,input().split())
n=int(input())
b=list(map(int,input().split()))
a=[]
for i in range(n):
  for j in range(b[i]):
    a.append(i+1)
g=[[0 for i in range(w)] for j in range(h)]
for i in range(h):
  if i%2==0:
    for j in range(w):
      g[i][j]=a[0]
      a.remove(a[0])
  else:  
    for j in range(w):
      g[i][w-j-1]=a[0]
      a.remove(a[0])
for i in range(h):
  print(*g[i])


Measured memory_bytes: 3956
#include<iostream>
using namespace std;
int main(){
  string s;
  while(cin >>s){
    int ans = 0,a,b=100000;
    for(int i=0; i<s.size(); i++){
      if(s[i] == 'I') a = 1;
      if(s[i] == 'V') a = 5;
      if(s[i] == 'X') a = 10;
      if(s[i] == 'L') a = 50;
      if(s[i] == 'C') a = 100;
      if(s[i] == 'D') a = 500;
      if(s[i] == 'M') a = 1000;
      ans+=a;
      if(b<a) ans-=b*2;
      b = a;
    }
    cout <<ans<<endl;
  }
  return 0;
}

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


int main(){
  vector<int> an(5);
  for (int i = 0; i < 5; i++){
    cin >> an.at(i);
  }
  int k;
  cin >> k;

  sort(an.begin(), an.end());
  int sa = an.at(4) - an.at(0);
  if (sa <= k){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
}


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

using namespace std;

#define ll long long

int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    ll arr[300009];
    for(ll i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    ll a[300009];
    ll b[300009];
    a[0]=arr[0];
    b[0]=sum-a[0];
    for(ll i=1;i<n-1;i++){
        a[i]=a[i-1]+arr[i];
        b[i]=sum-a[i];
    }
    ll min= abs(a[0]-b[0]);
    for(ll i=0;i<n-1;i++){
        if(min>abs(a[i]-b[i])){
            min=abs(a[i]-b[i]);
        }
    }
    cout<<min;
    return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int H, W, D, Q;
  cin >> H >> W >> D;

  vec< pair< int, int > > a(H * W);
  vec< vec< int > > sumM(D, vec< int >());

  REP(i, H) {
    REP(j, W) {
      int p;
      cin >> p;
      p--;
      a[p] = mp(j, i);
    }
  }
  cin >> Q;
  vec< int > l(Q);
  vec< int > r(Q);
  REP(i, Q) {
    cin >> l[i] >> r[i];
    l[i]--, r[i]--;
  }

  REP(i, D) {
    sumM[i].pb(0);
    int prevPos[2] = {a[i].first, a[i].second};
    for (int j = i + D; j < W * H; j += D) {
      int currentPos[2] = {a[j].first, a[j].second};

      // DEBUG(j);
      // PRINTALL(currentPos);
      int val = sumM[i].back() + (abs(currentPos[0] - prevPos[0]) +
                                  abs(currentPos[1] - prevPos[1]));
      prevPos[0] = currentPos[0];
      prevPos[1] = currentPos[1];
      sumM[i].pb(val);
    }
  }
  // PRINTALL(sumM[0]);
  // PRINTALL(sumM[1]);

  REP(i, Q) {
    int l0 = l[i] / D;
    int l1 = l[i] % D;
    int r0 = r[i] / D;
    print(sumM[l1][r0] - sumM[l1][l0]);
  }
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    string s;
    cin >> s;
    if(s == "ARC"){
        cout << "ABC";
    }
    else{
        cout << "ARC";
    }


    return 0;
}


Measured memory_bytes: 3652
import java.util.*;

public class Main{
  static int H, W, K;
  static char[][] cake;
  static int[][] ans;
  static boolean[] check;
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    H = Integer.parseInt(S[0]);
    W = Integer.parseInt(S[1]);
    K = Integer.parseInt(S[2]);
    cake = new char[H][W];
    ans = new int[H][W];
    int count = 1;
    for(int i = 0; i < H; i++){
      String T = sc.nextLine();
      for(int j = 0; j < W; j++){
        cake[i][j] = T.charAt(j);
        if(cake[i][j] == '#'){
          ans[i][j] = count;
          count++;
        }
      }
    }
    
    check = new boolean[H];
    for(int i = 0; i < H; i++){
      boolean flag = false;
      for(int j = 0; j < W; j++){
        if(cake[i][j] == '#'){
          func(i, j-1, ans[i][j]);
          func(i, j+1, ans[i][j]);
          flag = true;
        }
      }
      if(!flag){
        check[i] = true;
      }
    }
    
    for(int i = 0; i < H; i++){
      if(check[i]){
        ans[i] = func2(i-1, 0);
        if(ans[i] == null){
          ans[i] = func2(i+1, 1);
        }
      }
    }
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(j == W-1){
          System.out.println(ans[i][j]);
        }else{
          System.out.print(ans[i][j]+" ");
        }
      }
    }
  }
  public static void func(int h, int w, int num){
    if(w < 0 || w >= W){
      return;
    }
    if(ans[h][w] > 0){
      return;
    }
    ans[h][w] = num;
    
    func(h, w-1, num);
    func(h, w+1, num);
  }
  public static int[] func2(int i, int a){
    if(i < 0 || i >= H){
      return null;
    }
    
    if(!check[i]){
      return ans[i];
    }else{
      if(a == 0){
        return func2(i-1, 0);
      }else{
        return func2(i+1, 1);
      }
    }
  }
}

Measured memory_bytes: 45128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder str = new StringBuilder();
		
		String line;
		String[] imperative;
		int a;
		int b;
		
		str.append(scan.nextLine());
		int turns = Integer.parseInt(scan.nextLine());
		
		for (int i = 0; i < turns; i++) {
			line = scan.nextLine();
			imperative = line.split(" ");
			//imperative[1] => a?????????
			a = Integer.parseInt(imperative[1]);
			//imperative[2] => b?????????
			b = Integer.parseInt(imperative[2]) + 1;
			
			if(imperative[0].equals("print")){
				//??????=>print ??§????????°??¨???
				System.out.println(str.substring(a, b));
			}else if(imperative[0].equals("reverse")){
				//??????=>reverse ??§????????°
				//str??§?????¢?????????????±?????????????reverse??????????????????????????¢?????????str???????????????
				StringBuilder reverse = new StringBuilder();
				reverse.append((str.substring(a, b)));
				str.replace(a, b, (reverse.reverse()).toString());
			}else{
				//?????????print???reverse ??§???????????????????????????
				str.replace(a, b, imperative[3]);
			}
			
		}
		
	}
}

Measured memory_bytes: 21608
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,a[100];
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	int ans=0;
	rep(i,n){
		cin>>a[i];
		if(i%2==0&&a[i]%2)
		ans++;
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> odp(n, 0);
    for (int i = 1; i < n; ++i)
    {
        int x;
        cin >> x;
        --x;
        ++odp[x];
    }
    for (int i = 0; i < n; ++i)
        cout << odp[i] << endl;
    return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    ll A, B;
    cin >> A >> B;
    ll ans = 0;
    if(A%2)
    {
        ans = A;
        A++;
    }
    ll num1 = (B - A + 1) / 2;
    bool t = num1 % 2;
    bool p = (B-A+1)%2;
    ans = ans xor t;
    if(p)
    {
        ans = ans xor B;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
def main():
    import numpy as np

    N, K = map(int, input().split())
    section = [list(map(int, input().split())) for _ in range(K)]
    MOD = 998244353

    dp = np.zeros(N + 1, dtype=np.int64)
    dp[1] = 1
    cumsum = np.zeros(N + 1, dtype=np.int64)
    cumsum[1] = 1
    for i in range(2, N + 1):
        for left_section, right_section in section:
            left = max(i - right_section - 1, 0)
            right = i - left_section
            if right < 0:
                continue
            dp[i] += cumsum[right] - cumsum[left]
        cumsum[i] = cumsum[i - 1] + dp[i]
        dp[i] %= MOD
        cumsum[i] %= MOD
    print(dp[N] % MOD)
    # print(dp)
    # print(cumsum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 29796
s = input()
len_s = len(s)
x = "abcdefghijklmnopqrstuvwxyz"
ls = {i : j for j, i in enumerate(x)}
if len_s < 26:
    set_s = set(s)
    candidate = list(set(x).difference(set_s))
    candidate.sort()
    print(s + candidate[0])
else:
    if s == x[::-1]:
        print(-1)
    else:
        res = ""
        inv_s = s[::-1]
        _max = -1
        for i, j in enumerate(inv_s):
            if _max > ls[j]:
                break
            _max = max(_max, ls[j])
        res = s[:-1-i]
        candidate = [k for k in inv_s[:i] if k > j]
        print(res + candidate[0])

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

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
bool dp[2][8001];

int main() {
    string s;
    cin >> s;
    int x[2];
    cin >> x[0] >> x[1];
    int n = s.size();
    vector<int> v[2];
    bool dir = 0;
    int len = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'F') {
            len++;
        } else {
            v[dir].push_back(len);
            len = 0;
            dir ^= 1;
        }
    }
    v[dir].push_back(len);
    x[0] -= v[0][0];
    v[0].erase(v[0].begin());
    x[0] = abs(x[0]);
    x[1] = abs(x[1]);
    for (int k = 0; k < 2; k++) {
        int sum = 0;
        for (int i = 0; i < v[k].size(); i++) {
            sum += v[k][i];
        }
        if (sum < x[k] || (sum - x[k]) % 2) {
            cout << "No" << endl;
            return 0;
        }
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        for (int i = 0; i < v[k].size(); i++) {
            for (int j = 0; j <= 8000; j++) {
                dp[(i + 1) & 1][j] |= dp[i & 1][j];
                if (j + v[k][i] <= 8000) dp[(i + 1) & 1][j + v[k][i]] |= dp[i & 1][j];
            }
            for (int j = 0; j <= 8000; j++) dp[i & 1][j] = 0;
        }
        if (!dp[v[k].size() & 1][(sum - x[k]) / 2]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N; int x;
	while(~scanf("%d%d", &N, &x)) {
		if(x == 1 || x == N * 2 - 1) {
			puts("No");
		} else {
			puts("Yes");
			vector<int> a(N * 2 - 1);
			rep(i, a.size()) a[i] = i + 1;
			int b[2] = { x - 1, x };
			if(x >= N) ++ b[0], ++ b[1];
			a.erase(a.begin() + b[0] - 1, a.begin() + b[1]);
			a.insert(a.begin() + (N - 1), b, b + 2);
			for(int i = 0; i < N * 2 - 1; ++ i)
				printf("%d\n", a[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 2304
n, d = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
  res = xy[i][0]**2 + xy[i][1]**2
  
  if res <= d**2:
    ans += 1
    
print(ans)

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  string S;

  while(cin >> S){
    int N = S.size();
    vector<i64> a(2019), b(2019), ans(2019);

    REP(i,N){
      REP(j,2019) b[j] = 0;
      
      REP(j,2019){
        b[(10*j+S[i]-'0')%2019] += a[j];
      }
      
      b[S[i]-'0'] += 1;

      swap(a, b);

      REP(j,2019){
        ans[j] += a[j];
      }
    }

    
    
    pout(ans[0]);
  }

  return 0;
}


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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;
    for (int i=0; i<K; i++)
    {
        if (A>=B)
        {
            B *= 2;
            continue;
        }
        else if (B>=C)
        {
            C *= 2;
            continue;
        }
        else break;
    }
    string ans;
    if (A<B && B<C) ans = "Yes";
    else ans = "No";

    cout << ans << endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll n;
ll a[1000005];
ll factt[1234567];
ll ff[1000000];

ll calc(ll a,ll b,ll p){
  if(b==0){
    return 1;
  }else if(b%2==0){
    ll d=calc(a,b/2,p);
    return (d*d)%p;
  }else if(b%2==1){
    return (a*calc(a,b-1,p))%p;
  }
}
ll inv(ll y){
  return calc(y, MOD-2, MOD);
}

ll comb(ll a,ll b){
  if(a<b)return 0;
  ll ans=(factt[a]*inv(factt[b]))%MOD;
  ans*=inv(factt[a-b])%MOD;
  return ans%MOD;
}

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>n;
  if(n==2){
    P(1);
    return 0;
  }else if(n==3){
    P(4);
    return 0;
  }
  REP(i,1000000){
    if(i==0)factt[i]=1;
    else factt[i]=(i*factt[i-1])%MOD;
  }
  // REP(i,100)P(factt[i]);
  REP(i,1000000){
    ff[i]=(comb(i-1,n-i-1)*factt[i])%MOD;
    ff[i]*=factt[n-i-1];
    ff[i]%=MOD;
  }
  ll ans=0;
  for(int i=(n+1)/2;i<=n-1;i++){
    ans+=(ff[i]-ff[i-1]+MOD)*i;
    ans%=MOD;
  }
  // REP(i,n)P(ff[i]);
  P(ans%MOD);
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main() {
    cout<<fixed<<setprecision(10);


    ll N; cin>>N;
    vint X(N),Y(N),P(N);
    rep(i,N) cin>>X[i]>>Y[i]>>P[i];


    ll m = 1; rep(i,N) m*=3;

    vvint D[2];
    rep(i,2) D[i].resize(N, vint(1ll<<N, LLONG_MAX));
    // 前計算
    rep(i,1ll<<N){
        set<ll> s[2];
        // s[0].insert(-100000); s[1].insert(-100000);
        // s[0].insert(100000); s[1].insert(100000);
        s[0].insert(0); s[1].insert(0);
        rep(j,N){
            if((i>>j)&1){
                s[0].insert(X[j]);
                s[1].insert(Y[j]);
            }
        }
        rep(j,N){
            ll d = LLONG_MAX;
            for(auto e:s[0]){
                chmin(d, abs(e-X[j]));
            }
            D[0][j][i] = d;
            d = LLONG_MAX;
            for(auto e:s[1]){
                chmin(d, abs(e-Y[j]));
            }
            D[1][j][i]= d;
        }
    }

    vint ans(N+1, LLONG_MAX);

    rep(i,m){
        ll tate,yoko;
        tate = yoko = 0;
        ll cnt = 0;
        ll fac = 1;
        ll j = i;
        rep(k,N){
            if(j%3==1){
                cnt++;
                tate += fac;
            }else if(j%3==2){
                cnt++;
                yoko += fac;
            }
            fac *= 2;
            j /= 3;
        }
        vint dist(N, LLONG_MAX);
        ll tmp = 0;
        rep(k,N){
            chmin(dist[k], P[k]*min(D[0][k][tate], D[1][k][yoko]));
            tmp += dist[k];
        }
        chmin(ans[cnt], tmp);
    }

    for(auto e:ans)cout<<e<<endl;



    return 0;

}

Measured memory_bytes: 11272
from fractions import gcd


def main(input_1, input_2):
    left = [0] * (input_1+1)
    for i in range(input_1):
        left[i+1] = gcd(left[i], input_2[i])

    right = [0] * (input_1 + 1)
    i = input_1 - 1
    while i >= 0:
        right[i] = gcd(right[i+1], input_2[i])
        i -= 1

    while i >= 0:
        right[i] = gcd(right[i+1], input_2[i])

    res = 0
    for i in range(input_1):
        l = left[i]
        r = right[i+1]
        gcd_val = gcd(l, r)
        if gcd_val > res:
            res = gcd_val

    return res


if __name__ == "__main__":
    input_1 = int(input())
    input_2 = list(map(int, input().split()))
    print(main(input_1, input_2))


Measured memory_bytes: 89580
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#define MAX 1000000000000000000LL
long long inf=1000000007;
using namespace std;

int main(){
    string str;
    cin>>str;
    int sta=0;
    int end=0;
    bool jud=true;;
    for(int i=0; i<str.length(); i++){
        if(str[i]=='A'&&jud){
            sta=i;
            jud=false;
        }
        else if(str[i]=='Z'){
            end=i;
        }
    }
    int ans=end-sta+1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	rdr := NewReader()

	happiness := make([][]int, n)
	for i := range happiness {
		happiness[i] = rdr.ReadInts()
	}

	m := make([][]int, n)
	for i := range m {
		m[i] = make([]int, 3)
	}
	m[0][0] = happiness[0][0]
	m[0][1] = happiness[0][1]
	m[0][2] = happiness[0][2]

	for i := range happiness[1:] {
		m[i+1][0] = Max(m[i][1], m[i][2]) + happiness[i+1][0]
		m[i+1][1] = Max(m[i][0], m[i][2]) + happiness[i+1][1]
		m[i+1][2] = Max(m[i][0], m[i][1]) + happiness[i+1][2]
	}

	fmt.Println(MaxInts(m[n-1]...))
}

// generated by https://github.com/murosan/gollect

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func MaxInts(n ...int) int {
	max := n[0]
	for _, v := range n[1:] {
		if v > max {
			max = v
		}
	}
	return max
}

type Reader struct {
	r    *bufio.Reader
	size int
	sep  string
}

func NewReader() *Reader {
	size := 4096
	return &Reader{
		r:    bufio.NewReaderSize(os.Stdin, size),
		size: size,
		sep:  " ",
	}
}

func (rdr *Reader) ReadLine() string {
	buf := make([]byte, 0, rdr.size)
	for {
		line, isPrefix, err := rdr.r.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func (rdr *Reader) ReadStrs() []string {
	return strings.Split(rdr.ReadLine(), rdr.sep)
}

func (rdr *Reader) ReadInts() []int {
	a := rdr.ReadStrs()
	b := make([]int, len(a))
	for i, v := range a {
		b[i], _ = strconv.Atoi(v)
	}
	return b
}


Measured memory_bytes: 14592
#include <stdio.h>

int n, a[101][101], sum=0;

void MST(void){
  int i, j, u, min;
  int T[101], v[101], c[101];

  for(i=0; i<n; i++){
    T[i]=100000;
    v[i]=-1;
    c[i]=0;
  }
  T[0]=0;

  while(1){
    min=100000;
    u=-1;
    for(i=0; i<n; i++){
      if(min>T[i] && c[i]!=2){
	u=i;
	min=T[i];
      }
    }
    if(u==-1)break;
    c[u]=2;
    for(j=0; j<n; j++){
      if(c[j]!=2 && a[u][j]!=100000){
	if(T[j]>a[u][j]){
	  T[j]=a[u][j];
	  v[j]=u;
	  c[j]=1;
	}
      }
    }
  }

  for(i=0; i<n; i++){
    if(v[i]!=-1){
      sum+=a[i][v[i]];
    }
  }
}

int main(){
  int i, j, e;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      scanf("%d", &e);
      if(e==-1)a[i][j]=100000;
      else a[i][j]=e;
    }
  }
  MST();
  printf("%d\n", sum);

  return 0;
}
      

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  int N;
  int A[100000];
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
    A[i]--;
  }
  int cnt=0;
  FOR(i,0,N){
    if(A[A[i]]==i){
      cnt++;
    }
  }
  cout<<cnt/2<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    vs32 a(n);
    map<s64, s64> m;
    rep (i, n)
    {
        cin >> a[i];
        ++m[a[i]];
    }

    s64 sum = 0;
    for (auto x : m)
    {
        sum += x.second * (x.second - 1) / 2;
    }

    s64 ans;
    rep (i, n)
    {
        s64 cnt = m[a[i]];
        ans = sum - cnt * (cnt - 1) / 2 + (cnt - 1) * (cnt - 2) / 2;
        cout << ans << "\n";
    }

    return 0;
}



Measured memory_bytes: 10368
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
#x = int(input())
a, b, c = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

k = int(input())

d = 0
while (True):
    if b > a:
        break
    else:
        b *= 2
        d += 1

while (True):
    if c > b:
        break
    else:
        c *= 2
        d += 1

if d <= k:
    print("Yes")
else:
    print("No")
    


        


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

int main()
{
	int a[4] = { 1, 0, 0, -1};
	char x, y;
	char d;

	auto swap = [](int* x, int* y){
		int z = *x;
		*x = *y;
		*y = z;
	};

	auto getNum = [x,y](char z){
		switch (z){
			case 'A':	return 0;
			case 'B':	return 1;
			case 'C':	return 2;
		}				return 3;
	};

	while (cin >> x >> d >> y){
		swap(&a[getNum(x)], &a[getNum(y)]);
	}


	for (int i = 0; i < 3; ++i)
		if (a[i] == 1)
			cout << static_cast<char>('A' + i) << endl;

	return 0;
}

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


/*  
    
*/

void test_case(){
    int n; cin >> n;
    int a[n][n];
    
    for(int i = 0; i < n ; i++ ){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
        
    int mex = (1 << n ) - 1;
    int dp[n+1][mex+1];
    
    for(int i = 1; i <= mex; i++)
        dp[0][i] = 0;
    
    int mod = 1e9 + 7;
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++ ){
        for(int j = 0; j <= mex; j++){
            dp[i][j] = 0;
            if( __builtin_popcount(j) != i)
                continue;
            
            for(int k = 0; k < n; k++){
                if(a[i-1][k] && (j & (1 << k ))){
                    dp[i][j] += dp[i-1][ j - (1 << k ) ];
                    dp[i][j] %= mod;
                }
            }
        
        }
    }
    
    cout << dp[n][mex] << endl;
    
}

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

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


Measured memory_bytes: 183836
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

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

uint64_t mygcd(uint64_t lhs, uint64_t rhs) {
  if (lhs % rhs == 0) {
    return rhs;
  } else {
    return mygcd(rhs, lhs % rhs);
  }
}

int main() {
  int N;
  cin >> N;
  P s[200000];
  for (int i = 0; i < N; i++) {
    uint64_t a, b;
    cin >> a >> b;
    s[i] = P(b, a);
  }
  sort(s, s + N);
  uint64_t now = 0;
  bool flag = true;
  for (int i = 0; i < N; i++) {
    auto time = s[i].first;
    auto cost = s[i].second;
    if (now + cost > time) {
      flag = false;
      break;
    } else {
      now += cost;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int cnt=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='7')
            cnt=1;
    }
    if(cnt==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";

}


Measured memory_bytes: 3596
N = int(input())
S = list(map(int,input().split()))
B= list()
X = list()
for i in S:
    if i % 2== 0:
        B.append(i)
for n in B:
    if n % 3 == 0 or n % 5 == 0:
        X.append(n)
if len(B) == len(X):
    print('APPROVED')
else:
    print('DENIED')




Measured memory_bytes: 9112
/*
By Tianyi Chen. All rights reserved.
Date: 2017-04-29
*/
#include<bits/stdc++.h>
using namespace std;
int T,n,t,pend,ans;
int main(){
 scanf("%d%d",&n,&T);
 while(n--){
  scanf("%d",&t);
  ans+=min(T,t+T-pend);
  pend=t+T;
 }
 printf("%d\n",ans);
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

ll mm[1000001];
vector<ll> a(200001);

bool enum_divisors(long long N) {
    bool flag = false;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            if((i != N && mm[i] >= 1) || mm[i] > 1){
                flag = true;
                break;
            }
            if (mm[N/i] > 1 || (i != 1 && mm[N/i] >= 1)) {
                flag = true;
                break;
            }
        }
    }
    return flag;
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < 1000001; i++){
        mm[i] = 0;
    }

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

    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(enum_divisors(a[i]) == false){
            ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 12732
#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(){
    ll n;
    cin >> n;

    vector<pair<ll, int> > fs;
    for(ll i=2; i*i<=n; ++i){
        int x = 0;
        while(n%i == 0){
            n/=i;
            ++x;
        }
        if(x!=0) fs.emplace_back(i,x);
    }
    if(n!=1) fs.emplace_back(n,1);

    int ans = 0;
    for(auto p : fs){
        int x = p.second;
        int b= 1;
        while(b<=x){
            x -= b;
            b++;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
	int A,B,C;
	cin>>A>>B>>C;
	if(A==5&&B==5&&C==7)
	{
		cout<<"YES"<<endl;
	}
	else if(A==5&&B==7&&C==5)
	{
		cout<<"YES"<<endl;
	}
	else if(A==7&&B==5&&C==5)
	{
		cout<<"YES"<<endl;
	}
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
N,K = [int(i) for i in input().split()]
S = input()
memo = S[0]
count = 0
total = 0
cntDict= dict.fromkeys([int(i) for i in range(1,N+1)],0)


for s in S:
    if s == memo:
        count +=1
    else:
        cntDict[count] += 1
        count = 1
    memo = s
cntDict[count] += 1
changeCnt = sum(cntDict.values())

for k,v in cntDict.items():
    if v == 0 and k == 1:
        continue
    
    total += (k-1)*v
        
if changeCnt//2 <= K:
    total = N-1
else:
    total += 2*K
        

print(total)

Measured memory_bytes: 16368
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void){

    ll N,M; cin>>N>>M;
    ll ans = N*M;
    if(N==1 && M==1) cout<<ans<<endl;
    else if(N==1 || M==1) cout<<ans-2<<endl;
    else{
        cout<<(N-2)*(M-2)<<endl;
    }


}

Measured memory_bytes: 256
A,B,K=map(int,input().split())
count=0
while count!=K:
         if  A%2!=0:
                 A-=1
         A,B=A/2,A/2+B
         count+=1
         A,B=B,A
if count%2==0:
           print(int(A),int(B))
else:
            print(int(B),int(A))

Measured memory_bytes: 3060
import Data.Char

rep 0 _ x = x
rep n a ((f,d):ds) =
  if f == 0 && a /= d
  then (1,a):(rep (n-1) a ds)
  else (0,d):(rep n a ds)

ans b d =
  let zd = zip (repeat 0) b
      nz = length $ filter (== 0) b
      no = length $ filter (== 1) b
      rz = if nz > d then d else nz
      ro = if (d-rz) == 0 then 0 else d-rz
      sq = reverse $ rep ro 0 $ reverse $ rep rz 1 zd
  in
    map (intToDigit . snd) sq

main = do
  _ <- getLine
  b <- getLine
  d <- getLine
  let b' = map digitToInt b :: [Int]
      d' = read d :: Int
      o  = ans b' d'
  putStrLn o



Measured memory_bytes: 4256
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	static ArrayList<Integer> list = new ArrayList<Integer>();
	static ArrayList<Integer> listX = new ArrayList<Integer>();
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		makePrimeList(104730);
		makeSumList();
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) break;
			
			System.out.println(listX.get(n-1));
		}
	}
	public static void makeSumList() {
		int sum = 0;
		for(int i = 0; i < 10000; i++) {
			sum += list.get(i);
			listX.add(sum);
		}
	}
	public static void makePrimeList(int n) {
		boolean[] isntPrime = new boolean[n];
		isntPrime[0] = isntPrime[1] = true;
		list.add(2);
		for(int i = 3; i < n; i+= 2) {
			if(!isntPrime[i]) {
				list.add(i);
				for(int j = i + i; j < n; j+= i) {
					isntPrime[j] = true;
				}
			}
		}
	}

	
	
}

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

char S[110],T[110],tmp[110];
int k;
bool flag;
int main()
{
//	freopen("B - String Rotation.txt","r",stdin);
	
	scanf("%s",&S);
	scanf("%s",&T);
		
	
	flag=false;
	
	for(int i=0; i<strlen(S); i++)
	{
		for(int j=0; j<strlen(S); j++)
		{
			k=i+j;
			if (k>=strlen(S)) k-=strlen(S);
			tmp[j]=S[k];
		}
	//	printf("%s\n",tmp);
		if (strcmp(tmp,T)==0) flag=true;
	}
	
	if (flag==true) printf("Yes");
	else printf("No");
	
//	fclose(stdin);
}

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

const int64_t MOD = 1000000007;

int N, L;
int64_t x[5050], a[5050];

int main() {
    scanf("%d%d", &N, &L);
    for (int j = 0; j < N; ++j) { scanf("%lld", x+j); }
    for (int j = 0; j < N; ++j) { scanf("%lld", a+j); }

    int64_t memo[5050];

    fill(memo, memo+L, 0);
    if (a[N-1] == 0) { memo[x[N-1]] = 1; }
    else { for (int j = x[N-1]; j < L; j += a[N-1]) { memo[j] = 1; } }

    for (int j = N-2; j >= 0; --j) {
        int64_t acc = 0;
        for (int k = L-1; k >= x[j]; --k) {
            int temp = memo[k];
            if ( (a[j] == 0 && k == x[j]) || (a[j] != 0 && (k - x[j]) % a[j] == 0) ) {
                memo[k] = acc % MOD;
            } else {
                memo[k] = 0;
            }

            acc = (acc + temp) % MOD;
        }
    }

    int64_t ans = 0;
    for (int j = 0; j < L; ++j) {
        ans = (ans + memo[j]) % MOD;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3324