akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

#define ll long long
#define endl long long
using namespace std;

double arr[6];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int m=9;
    int j=0;
    ll ans=0;
    for(int i=0; i<5; i++)
    {
        cin >> arr[i];
        if(m > (int)arr[i]%10 && (int)arr[i]%10 != 0)
        {
            m = (int)arr[i]%10;
            j = i;
        }
    }
    for(int i=0; i<5; i++) if(i!=j)
    {
        ans += ceil(arr[i]/10)*10;
    }
    ans += arr[j];
    cout << ans;
}


Measured memory_bytes: 256
/*
**    Success is most often achieved by those who don't know that failure is inevitable.
**    -- Coco Chanel
**
**    Author : Dhiraj Govindvira
**      Date : 05-Sep-2020 ~ Saturday
**      Time : 06:19:15 PM
*/

#ifdef Dhiraj
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define FOR(i, a, b, s)     for(ll i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define FOR1(b)             FOR(i, 0, b, 1)
#define FOR2(i, b)          FOR(i, 0, b, 1)
#define FOR3(i, a, b)       FOR(i, a, b, (a) <= (b) ? 1 :-1)
#define FOR4(i, a, b, s)    FOR(i, a, b, s)
#define GET5(a, b, c, d, e, ...) e
#define FORC(...)           GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)
#define loop(...)           FORC(__VA_ARGS__)(__VA_ARGS__)
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename... T> 
inline void inp(T&... args) {
    ((cin >> args), ...);
}
// scan vector
template <typename T> 
inline istream& operator >>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream& operator >>(istream &in, pair<T, U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(int &T)
{
    ll n;
    cin >> n;
    
    vector<ll> a(n);
    cin >> a;

    ll xr = 0;
    for(ll x : a) {
        xr ^= x;
    }

    loop(i, n) {
        cout << (xr ^ a[i]) << " ";
    }
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
        freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
        // freopen("D:/dhiraj/Programming/e1.txt", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    for(int i = 1; i <= t; i++) {
        cerr << "Case #" << i << "\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 4740
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

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

    string s;
    cin >> s;

    ll n = s.size();

    rep(i,0,n/2)
    {
        //cout << s[i] <<  ' ' << s[n/2-1-i] << endl;
        if (s[i]!=s[n/2-1-i])
        {
            cout << "No" << endl;
            return 0;
        }
    }


    rep(i,(n+3)/2-1,n)
    {
        //cout << s[i] <<  ' ' << s[n-1-i] << endl;
        if (s[i]!=s[n-1-i])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
#define pb emplace_back
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}

ll power(ll x, ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2,m)%m; 
    p = (p * p)%m; 
  
    return (y%2 == 0)? p : (x * p)%m ; 
} 

ll modInverse(ll a, ll m) 
{ 
        // If a and m are relatively prime, then modulo inverse 
        // is a^(m-2) mode m 
    return power(a, m-2,m); 
} 
  
// To compute x^y under modulo m 


int main()
{
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll a[n+1] = {0};
    for(int i=0;i<n;i++)
    {
      int di;
      cin>>di;
      for(int j=0;j<di;j++)
      {
        int gh;
        cin>>gh;
        a[gh] = 1;
      }
    }int g = n;
    for(int i=1;i<=g;i++)
    {
      if(a[i]==1)
      {
        n--;
      }
    }
    cout<<n;
    
    
    return 0;
}

Measured memory_bytes: 3576
N, M = [int(a) for a in input().split()]
a_list = [int(a) for a in input().split()]
b_list = [int(a) for a in input().split()]

# N, M = 14, 13
# a1 = "158 167 181 147 178 151 179 182 176 169 180 129 175 168"
# b1 = "181 150 178 179 167 180 176 169 182 177 175 159 173"
# a_list = [int(a) for a in a1.split()]
# b_list = [int(a) for a in b1.split()]

ans = 1
in_sign = False
a_list.sort()
b_list.sort()
a_num, b_num = 0, 0

for i in range(N * M):
    in_sign = False
    this_num = N * M - i
    while len(a_list) > 0 and a_list[-1] > this_num:
        a_num += 1
        a_list.pop()
    if len(a_list) > 0 and this_num == a_list[-1]:
        if len(a_list) > 1 and a_list[-1] == a_list[-2]:
            ans = 0
            break
        this_a = 1
        in_sign = True
    else:
        this_a = a_num

    while len(b_list) > 0 and b_list[-1] > this_num:
        b_num += 1
        b_list.pop()
    if len(b_list) > 0 and this_num == b_list[-1]:
        if len(b_list) > 1 and b_list[-1] == b_list[-2]:
            ans = 0
            break
        this_b = 1
        in_sign = True
    else:
        this_b = b_num

    if in_sign:
        ans *= this_a * this_b
    else:
        ans *= this_a * this_b - i
    ans = ans % (10 ** 9 + 7)
    if ans == 0:
        break
print(str(ans))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll n;
  cin>>n;
  set <string> ss;
  fo(i,n)
  {
    string s;
    cin>>s;
    ss.insert(s);
   }
  cout<<ss.size();
 

    



  return 0;
}


Measured memory_bytes: 19204
n,m,X,Y = gets.chomp.split(" ").map(&:to_i)
x = gets.chomp.split(" ").map(&:to_i)
y = gets.chomp.split(" ").map(&:to_i)
war = false
if X < Y
  n.times do |i|
    m.times do |j|
      if x[i] >= y[j]
        war = true
      end
    end
  end
  if x.max >= Y || y.min <= X
    war = true
  end
else
  war = true
end
if war
  puts "War"
else
  puts "No War"
end


Measured memory_bytes: 14264
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m=0,l=0,sum=0;

        cin>>n;
        while(l<n){
            l++;
            if(l%3!=0&&l%5!=0){
                m+=l;}


        }sum=sum+m;
       cout << sum<<endl;



}


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

typedef long long LL;

const int N=100000,INF=1000000000;

int n,m,sum;

void into(){
  scanf("%d%d%d",&n,&m,&sum);
}

int ans[N+9];

void Get_ans(){
  for (int i=1;i<=n;++i) ans[i]=i<=m?sum:sum==INF?1:sum+1;
}

void work(){
  Get_ans();
}

void outo(){
  for (int i=1;i<=n;++i)
	printf("%d ",ans[i]);
  puts("");
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 4156
ary = Array.new(4).map{Array.new(3).map{Array.new(10,0)}}
n = gets.to_i
for i in 1..n
  b,f,r,v = gets.split.map {|n| n.to_i}
  ary[b-1][f-1][r-1] += v
end
for b in 1..4
  for f in 1..3
    for r in 1..10
      print " " + ary[b-1][f-1][r-1].to_s
    end
    print "\n"
  end
  puts "####################" unless b == 4
end

Measured memory_bytes: 6112
#include <iostream>
#include <cstdlib>

const int MAX_SIZE = 1000000;
const int MAX_M = 100 + 1;

void insertionSort(int A[], int n, int g, int &count) {
  for (int i = g; i < n; i++) {
     int v = A[i];

     int j = i -g;
    
     while ((j >= 0) && (A[j] > v)) {
       A[j + g] = A[j];
       j -= g;
       count = count + 1;
     }

     A[j + g] = v;
  }
}

int main() {
  int n = 0;

  std::cin >> n;

  int A[MAX_SIZE] = {0};

  for (int i = 0; i < n; i++) {
    std::cin >> A[i];
  }

  int m = 0;
  int G[MAX_M] = {0};

  G[0] = 1;
  m++;

  while (G[m] < n) {
    int g = 3 * G[m - 1] + 1;

    if (g >= n) {
      break;
    } else {
      G[m] = g;
    }

    m++;
  }

  std::cout << m << std::endl;
    
  int count = 0;

  for (int i = m - 1; i >= 0; i--) {
    std::cout << G[i];

    if (i > 0) {
      std::cout << " ";
    } else {
      std::cout << std::endl;
    }    
    
    insertionSort(A, n, G[i], count);
  }
  
  std::cout << count << std::endl;
  
  for (int i = 0; i < n; i++) {
    std::cout << A[i] << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 5076
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
using namespace std;

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

#define MAX_N 53
#define MAX_R 53

int p[MAX_R], c[MAX_R];
int card [MAX_N][2];
int n,r;

bool input(){
  cin>>n>>r;
  REP(i, r)cin>>p[i]>>c[i];
  return (n!=0);
}

void solve(){
    REP(i, n+1)card[i][0] = i;
    REP(i, n+1)card[i][1] = i;

    REP(i, r) {
      //REP(j, n)cout<<card[n-j][0]<<' ';
      //cout<<endl;
      REP(j, c[i]) {
        card[n-j][1] = card[n-p[i]+1-j][0];
      }

      REP(j, p[i]-1) {
        card[n-c[i]-j][1] = card[n-j][0];
      }

     // REP(j, n-c[i]-p[i])card[j+1][1] = card[j+1][0];

      REP(i, n)card[i+1][0] = card[i+1][1];
    }

    //REP(i, n)cout<<card[n-i][0]<<' ';
    cout<<card[n][0]<<endl;
}

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

Measured memory_bytes: 3044
import java.util.*;
import java.util.Scanner;
import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
 
public class Main
{
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    public static void main (String[] args) 
	{
        //code by sushant kumar
        FastReader in=new FastReader();
        String S1=in.nextLine();
        String S2=in.nextLine();
        int count=0;
        for(int i=0;i<S1.length();i++)
        {
            if(S1.charAt(i)!=S2.charAt(i))
                count++;
        }
        System.out.println(count);
        
       
    }
}

Measured memory_bytes: 30364
package main

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

func main() {
	sc := NewScanner()
	s := sc.NextLine()
	k := sc.NextInt()

	// s := "atcoderandatcodeer"
	// k := 5
	// s := "aba"
	// k := 4

	mp := map[string]struct{}{}
	for i := 0; i < len(s)+1; i++ {
		for j := i + 1; j < len(s)+1 && j <= i+k; j++ {
			//			fmt.Printf("..%+v\n", s[i:j]) // output for debug
			mp[s[i:j]] = struct{}{}
		}
	}

	sarr := []string{}
	for k, _ := range mp {
		sarr = append(sarr, k)
	}
	sort.Strings(sarr)

	fmt.Printf("%+v\n", sarr[k-1]) // output for debug
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 3200
#include <iostream>
#include <cstdint>

using namespace std;

int main(int argc, char const* argv[]) {
	uint64_t N, K;

	cin >> N;
	cin >> K;

	uint64_t cnt = 0;
	for (uint64_t L = K; L <= N + 1; L++) {
		cnt += (L * (2 * N - L + 1)) / 2 - ((L - 1) * L) / 2 + 1;
		cnt = cnt % (1000000007);
	}

	cout << cnt;

	return 0;
}


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

int main() {
	cin.tie(nullptr); ios_base::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	fenwick_tree<ll> fw(n);
	for (int i = 0; i < n; ++i) {
		int x; cin >> x;
		fw.add(i, x);
	}
	for (int i = 0; i < q; ++i) {
		int a, b, c; cin >> a >> b >> c;
		if (a == 0) fw.add(b, c);
		else cout << fw.sum(b, c) << endl;
	}
	return 0;
}

Measured memory_bytes: 8240
n = int(input())

a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))

c = 0
for i in range(n):
    ai = a[i]
    bi = b[i]
    if ai < bi:
        c += (bi-ai)//2
    else:
        c -= (ai-bi)
print('Yes' if c >= 0 else 'No')


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

using namespace std;

#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
    #define _CRT_SECURE_NO_WARNINGS
    #pragma warning(disable:4996)
#endif

#define ll long long
#define vi vector<ll>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

ll INF = 1e9 + 7;



int main()
{
    string s, t;
    cin >> s >> t;
    int n = s.size(); int k = t.size();
    vector<vi> dp(n + 1, vi(k + 1, 0));
    for(int i = 1; i <= n; i++)
        for (int j = 1; j <= k; j++)
        {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (s[i - 1] == t[j - 1]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
        }
    string ans = "";
    int i = n, j = k;
    while (i > 0 && j > 0)
    {
        if (s[i - 1] == t[j - 1] && dp[i - 1][j - 1] == dp[i][j] - 1)
        {
            ans += s[i - 1];
            i--;
            j--;
        }
        else if (dp[i - 1][j] == dp[i][j]) i--;
        else j--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}

Measured memory_bytes: 73756
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#include<math.h>
#define scani(x) scanf("%d",&x)
#define scanc(x) scanf("%s",x)

#define printi(x) printf("%d",x)
#define printin(x) printf("%d\n",x)
#define printc(x) printf("%s",x)
#define repd(i,n,m) for(int i = n; i > m; i--)
#define repu(i,n,m) for(int i = 0; i < m; i++)
#define allprintu(i,n,m,a) for(int i = 0; i < m; i++){if(i != m-1){printf("%d ",a[i]);}else{printf("%d\n",a[i]);}}
#define allprintd(i,n,m,a) for(int i = n; i > m; i--){if(i != 0){printf("%d ",a[i]);}else{printf("%d\n",a[i]);}}
int cnt;

void insertionsort(int a[], int n, int g){
	int v;
	int j;
	repu(i,g,n){
		v = a[i];
		j = i - g;
		while(j>=0 && a[j]>v){
			a[j+g] = a[j];
			j = j - g;
			cnt++;
		}
		a[j+g] = v;
	}
}

void shellsort(int a[], int n){
	cnt = 0;
	int j;
	int g[100];
	int box = 1;
	for(j = 0;box <= n; j++){
		g[j] = box;
		box = box*3 + 1;
	}
	int m = j;
	repd(i,m-1,-1){
		insertionsort(a,n,g[i]);
	}
	printin(m);
	allprintd(i,m-1,-1,g);
	printin(cnt);
	repu(i,0,n){
		printin(a[i]);
	}
	
}

int main(void){
	int n;
	scani(n);
	int a[n];
	repu(i,0,n){
		scani(a[i]);
	}
	shellsort(a,n);
	return 0;
}


Measured memory_bytes: 5672
# frozen_string_literal: true

n, y = gets.split.map(&:to_i)

ary_p = []

0.upto(n) do |i_10000|
  0.upto(n - i_10000) do |i_5000|
    i_1000 = n - (i_10000 + i_5000)
    ary_p.push([i_10000, i_5000, i_1000])
  end
end

ans = ary_p.find { |ary| ary[0] * 10000 + ary[1] * 5000 + ary[2] * 1000 == y }
puts ans.nil? ? '-1 -1 -1' : ans.join(' ')


Measured memory_bytes: 112416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    vi a(n);
    for(int i=0;i<n;++i) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    int mi = INF;
    for(int i=0;i<n-1;++i) {
      mi = min(mi, a[i+1] - a[i]);
    }
    cout << mi << endl;
  }
}



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

namespace Vertial
{
    class Program
    {
        static int[][] D;
        static int[][] map;
        static int N;
        static int[,] dist;
        static int C;
        static void Main(string[] args)
        {
            var NC = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            N = NC[0];
            C = NC[1];

            D = new int[C][];
            for (int i = 0; i < C; i++)
            {
                D[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            }

            map = new int[N][];
            for (int i = 0; i < N; i++)
            {
                map[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            }
            dist = new int[3,C+1];
            for (int i = 1; i <= N; i++)
            {
                for (int j = 1; j <= N; j++)
                {
                    if ((i + j) % 3 == 0)
                    {
                        dist[0, map[i - 1][j - 1]]++;
                    }
                    else if ((i + j) % 3 == 1)
                    {
                        dist[1, map[i - 1][j - 1]]++;
                    }
                    else
                    {
                        dist[2, map[i - 1][j - 1]]++;
                    }
                }
            }
            var min = long.MaxValue;
            
            for (int i = 1; i <= C; i++)
            {
                for (int j = 1; j <= C; j++)
                {
                    for (int k = 1; k <= C; k++)
                    {
                        if(!(i == j || j == k || i== k))
                        {
                            //3割って0余るものをi,1あまるものをj,2余るものをに変換する
                            min = Min(min, Calculation(i, j, k));
                        }
                    }
                }
            }
            Console.WriteLine(min);
        }

        static long Calculation(int a,int b,int c)
        {
            long ans = 0;
            for (int i = 0; i < 3; i++)
            {
                for (int j = 1; j <= C; j++)
                {
                    if(i == 0)
                    {
                        ans += dist[i, j] * D[j - 1][a-1];
                    }else if(i == 1)
                    {
                        ans += dist[i, j] * D[j - 1][b-1];
                    }
                    else
                    {
                        ans += dist[i, j] * D[j - 1][c-1];
                    }
                    
                }
            }
            
            return ans;
        }


    }
}


Measured memory_bytes: 18632
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<ll, pii>pi3;
set<pi3>se;
void add(ll s, ll t, ll x)
{
	//printf(" %lld %lld %lld\n", s, t, x);
	set<pi3>::iterator it = se.lower_bound(make_pair(s, make_pair(-1, -1)));
	ll las = -1;
	vector<pi3>zz;
	for (;;)
	{
		if (it == se.end())break;
		pi3 z = *it;
		it++;
		ll q = z.first, p = z.first - z.second.second + z.second.first;
		if (t < p)break;
		if (s <= p&&q <= t)se.erase(z), las = z.second.second;
		else if (s <= p)
		{
			se.erase(z);
			zz.push_back(make_pair(q, make_pair(t + 1, q)));
			las = t;
		}
		else if (q <= t)
		{
			se.erase(z);
			zz.push_back(make_pair(s - 1, make_pair(p, s - 1)));
			las = q;
		}
		else
		{
			se.erase(z);
			zz.push_back(make_pair(s - 1, make_pair(p, s - 1)));
			zz.push_back(make_pair(q, make_pair(t + 1, q)));
			las = t;
		}
	}
	if (las != -1)se.insert(make_pair(x, make_pair(las, las)));
	for (int i = 0; i < zz.size(); i++)se.insert(zz[i]);
}
int main()
{
	int num;
	ll mod;
	scanf("%d%lld", &num, &mod);
	se.insert(make_pair(mod - 1, make_pair(0, mod - 1)));
	ll sum = 0;
	for (int p = 0; p < num; p++)
	{
		ll len;
		int mode;
		scanf("%lld%d", &len, &mode);
		len *= 2;
		if (mode == 1)
		{
			if (len > mod)
			{
				printf("-1\n");
				return 0;
			}
			set<pi3>::iterator it = se.begin();
			ll z = (*it).first - ((*it).second.second - (*it).second.first) + sum;
			if (z%mod <= mod - len)add(z / mod*mod + mod - len - sum + 1, z / mod*mod + mod - sum - 1, z / mod*mod + mod - sum);
			else
			{
				add(z - sum, z / mod*mod + mod - sum - 1, z / mod*mod + mod - sum);
				add(z / mod*mod + mod + mod - len - sum + 1, z + mod - sum, z / mod*mod + mod + mod - sum);
			}
		}
		sum += len;
		/*set<pi3>::iterator it = se.begin();
		for (;;)
		{
			if (it == se.end())break;
			pi3 z = *it;
			it++;
			printf("%lld %lld %lld\n", z.first + sum, z.second.first, z.second.second);
		}
		printf("-----\n");*/
	}
	ll mini = 5000000000000000000LL;
	set<pi3>::iterator it = se.begin();
	for (;;)
	{
		if (it == se.end())break;
		pi3 z = *it;
		it++;
		mini = min(mini, sum + z.first - z.second.second);
	}
	printf("%lld\n", mini);
}

Measured memory_bytes: 12544
import java.util.Scanner;

class Solver{
	Scanner sc =new Scanner(System.in);
	
	
	void run(){
		int n = sc.nextInt();
		
		solve(n);
	}
	void solve(int n){
		int[] ans = new int[n];
		int count = 64;
		ans[0] = 2;
		ans[1] = 5;
		ans[2] = 63;
		
		int sum = 70;
		if(n == 3){
			System.out.println("2 5 63");
			return;
		}
		if(n==4){
			System.out.println("2 5 63 80");
			return;
		}
		if(n == 5){
			System.out.println("2 5 63 64 76");
			return;
		}
		
		for(int i = 3;i < n-2; i++){
			for(;count % 2 != 0 && count % 5 != 0 && count % 3 != 0;count++){}
			ans[i] = count;
			sum += count;
			sum %= 30;
			count++;
		}

//		System.out.println("   "+count+" "+sum);

		for(;count % 2 != sum%2 || count % 5 != 0 && count % 3 != 0;count++){}
		ans[n-2] = count;
		sum += count;
		sum %= 30;
		count++;
		
//		System.out.println("   "+count+" "+sum);
		
//		for(;(count % 2 != 0 && count % 5 != 0 && count % 3 != 0) || (count+sum)%30 != 0;count++);
		ans[n-1] = count + 30 - ((count+sum)%30);
		
		long mysum = 0;
		for(int i = 0;i < n-1; i++){
			System.out.print(ans[i]);
			System.out.print(" ");
			mysum += ans[i];
//			System.out.println();
		}
		System.out.println(ans[n-1]);
//		System.out.println(ans[n-1]);
		
	}
}

public class Main {
	public static void main(String[] args){
		Solver s  = new Solver();
		s.run();
		}
}

Measured memory_bytes: 27588
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;

int main(){
  int n; cin >> n;
  int k; cin >> k;
  long long ans = 1;
  rep(i,n){
    ans = (ans*k)%MOD;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3116
def count_num(num,dic):
    if num in dic.keys():
        dic[num] += 1
    else:
        dic[num] = 1
    return dic


# input
NKQ = input().split()
A = [int(input()) for i in range(int(NKQ[2]))]
dic = {}
for i in A:
    dic = count_num(i,dic)

X = int(NKQ[1])-int(NKQ[2])
for j in range(1,int(NKQ[0])+1):
    if j in dic.keys():
        a = dic[j]
    else:
        a = 0
    if X+a > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 11680
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

pair<ll,ll> A[90010];
ll ans[90010];
ll dis(pair<ll,ll> a, pair<ll,ll> b){
  return abs(a.first-b.first)+abs(a.second-b.second);
}


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

  ll h, w, d;
  cin >> h >> w >> d;

  rep(i,h)rep(j,w){
    ll inp; cin >> inp;
    A[inp] = mp(i,j);
  }

  ll q; cin >> q;
  vector<pair<ll,ll> >lr;
  rep(i,q){
    ll l,r;
    cin >> l >> r;
    lr.pb(mp(l,r));
  }

  rep(i,d+1){
    ans[i]=0;
    if(i==0) continue;
    ll s = i;
    while(s<=(h*w-d)){
      s+=d;
      ans[s] = ans[s-d]+dis(A[s-d],A[s]);
    }
    
  }
  
  rep(i,q){
    cout << ans[lr[i].second] - ans[lr[i].first] << endl;
  }
  

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

ll gcd (ll a,ll b){
  if(a%b==0){
    return b;
  }
  else{
    return gcd(b,a%b);
  }
}
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x=b/c-(a-1)/c;
    ll y=b/d-(a-1)/d;
    ll z=gcd(c,d);
    ll zz=c*d/z;
    ll zzz=b/zz-(a-1)/zz;
    ll www =(b-a+1)-(x+y-zzz);
    cout<<www<<endl;
    return 0;
}




Measured memory_bytes: 3520
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N = int(input())
A = list(map(int, input().split()))
a = [0] * len(A)

# bの値は中央値
# https://qiita.com/Noiri/items/291ae9bf4a2eacab6f5f
for i in range(N):
    a[i] = A[i]-i-1

a.sort()
b = a[N // 2 - 1] if (N % 2 == 0) else a[(N + 1) // 2 - 1]

ans = 0
for i in range(N):
    ans += abs(a[i] - b)

print(ans)

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

int main() {
    int N, Q;
    cin >> N;
    long long sum = 0;
    vector<long long> num(110000, 0);
    for (int i = 0; i < N; ++i) {
        long long A; cin >> A;
        sum += A;
        num[A]++;
    }
        
    cin >> Q;
    for (int i = 0; i < Q; ++i) {
        long long B, C; cin >> B >> C;
        sum += (C - B) * num[B];
        num[C] += num[B];
        num[B] = 0;
        cout << sum << endl;
     }
}

Measured memory_bytes: 4064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BGuidebook solver = new BGuidebook();
        solver.solve(1, in, out);
        out.close();
    }

    static class BGuidebook {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            BGuidebook.R[] r = new BGuidebook.R[n];
            for (int i = 0; i < n; i++) {
                String name = in.next();
                int score = in.nextInt();
                r[i] = new BGuidebook.R(score, name, i + 1);
            }

            Arrays.sort(r);

            for (BGuidebook.R x : r) {
                out.println(x.i);
            }
        }

        static class R implements Comparable<BGuidebook.R> {
            final int score;
            final String name;
            final int i;

            R(int score, String name, int i) {
                this.score = score;
                this.name = name;
                this.i = i;
            }

            public int compareTo(BGuidebook.R o) {
                if (!name.equals(o.name)) {
                    return name.compareTo(o.name);
                }
                return -Integer.compare(score, o.score);
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21204
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

ll fastpow(ll a, ll pw) {
	ll res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}

int main() {
    cin>>N;
    vec num(N,0);
    ll mini = INF;
    rep(i,N) {
        cin>>A;
        if(i == 0 && A != 0){
            cout<<0<<endl;
            return 0;
        }
        ++num[A];
    }
    if(num[0] != 1){
        cout<<0<<endl;
        return 0;
    }
    ll last = 1, ans = 1;
    reps(i,1,N){
        if(num[i] == 0){
            ll che = 0;
            rep(j,i) che += num[j];
            if(che != N) ans = 0;
            break;
        }
        (ans *= fastpow(last, num[i]))%=MOD;
        last = num[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
a,b,c=map(int,input().split())
if(a>b):
    n=b
    #print(str(a)+" "+str(b)+" "+str(c))
    b=a
    #print(str(a)+" "+str(b)+" "+str(c))
    a=n
    #print(str(a)+" "+str(b)+" "+str(c))
if(b>c):
    n=b
    b=c
    c=n
    #print(str(a)+" "+str(b)+" "+str(c))
    #print(str(a)+" "+str(b)+" "+str(c))
if(a>b):
    n=a
    a=b
    b=n
print(str(a)+" "+str(b)+" "+str(c))


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define END(x) cout << x << endl; exit(0);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, minimum, maximum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> s;
    if (s == "Sunny") MSG("Cloudy")
    else if (s == "Cloudy") MSG("Rainy")
    else MSG("Sunny")
}


Measured memory_bytes: 256
n = int(input())

num = list ( map(int, input().split()) )

j = 0
k = 0

while j == 0:
  #print(num)
  for i in range(len(num)):
    if num[i] % 2 == 0:
      num[i] = num[i] / 2
    else:
      j = 1;
      break;
  
  if j == 0:
    k += 1
      
print( k )


Measured memory_bytes: 2940
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

class question {
public:
	int N;
	int K;
	vector<int> h;
	int dp() {
		static vector<int> memo(100000);
		for (int i = 1;i < N;i++) {
			int tmp = INT_MAX;
			for (int j = max(0, i - K);j < i;j++) {
				tmp = min(tmp, memo[j] + abs(h[i] - h[j]));
			}
			memo[i] = tmp;
		}
		return memo[N - 1];
	}
	void ans() {
		cin >> N >> K;
		h.resize(N);
		REP(i, N) cin >> h[i];
		cout << dp() << "\n";
	}
};

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

	question q;
	q.ans();

	return 0;
}

Measured memory_bytes: 1024
s=input()
k=int(input())
m=0
j=0
if len(set(list(s)))==1:print((len(s)*k)//2);exit()
for i in range(len(s)):
 if len(s)<=j+1:
  a=m*k
  if s[0]==s[-1]==s[1]==s[len(s)//3]:print(a+k-1)
  else:print(a)
  break;
 if s[j]==s[j+1]:
  m+=1
  j+=1
 j+=1

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
	int a,b,c,d=0;
	cin>>a>>b;
	c=b;
	if(b==0)
	{
		c=0;
		a*=10;
	}
	while(c>0)
	{
		c/=10;
		d++;
	}
	for(int i=1;i<=d;i++)
	a*=10;
	a+=b;
	for(int i=1;a>0;i+=2)
	{
		a-=i;
		if(a==0)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<functional>
#include<cstring>
#include<cstdlib>
#include<complex>
using namespace std;
typedef long long ll;
typedef complex < double > Point;

typedef vector < Point > Polygon;
namespace std {
    bool operator < (Point a,Point b) {
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
    }
    bool operator < (complex<long long> a,complex<long long> b) {
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
    }
}
const double EPS = 1e-10;
const double INF = 1e12;



struct Line : Polygon{
    Line(){};
    Line(Point p,Point q){ push_back(p);push_back(q); }
};
double cross(Point p,Point q){
    return imag(conj(p)*q);
}
double dot(Point p,Point q){
    return real(conj(p)*q);
}
bool crosspoint(Line l, Line m, Point *p) { //exist => true
    double A = cross(l[1] - l[0], m[1] - m[0]);
    double B = cross(l[1] - l[0], l[1] - m[0]);
    if (abs(A) < EPS && abs(B) < EPS){
        *p = m[0]; // same line
        return false;
    }
    if (abs(A) < EPS)return false;
    *p =  m[0] + B / A * (m[1] - m[0]);
    return true;
}
bool EQ(Point P,Point Q){
    return abs(P - Q) < EPS;
}
int main(){

    int n;
    while(cin>>n,n){
        Line L[120];
        for(int i = 0;i < n;i++){
            int x,y;
            cin>>x>>y;
            L[i].push_back(Point(x,y));
            cin>>x>>y;
            L[i].push_back(Point(x,y));
        }

        int ans = 1;
        for(int i = 0;i < n;i++){
            vector<Point> points;
            for(int j = 0;j < i;j++){
                Point P;
                if(!crosspoint(L[i],L[j],&P))continue;
                //cout<<P<<endl;
                if(EQ(P,L[i][0]) || EQ(P,L[i][1]) || EQ(P,L[j][0]) || EQ(P,L[j][1]))continue;
                if(abs(P.real()) - 100.0 > EPS || abs(P.imag()) - 100.0 > EPS)continue;
                bool flg = false;
                for(int k = 0;k < points.size();k++){
                    if(abs(P - points[k]) < EPS){
                        flg = true;
                        break;
                    }
                }
                if(!flg){
                    points.push_back(P);
                    //cout<<P<<endl;
                }
            }
            //cout<<points.size()<<endl;
            ans += points.size() + 1;
        }

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

Measured memory_bytes: 1224
O=list(input())
E=list(input())
ans=""
if len(O)-len(E) > 0:
    ans+=O[0]
    O.pop(0)
    for i in range(len(O)):
        ans+=E[i]
        ans+=O[i]
else:
    for i in range(len(O)):
        ans+=O[i]
        ans+=E[i]
print(ans)

Measured memory_bytes: 3064
INF = 1000000000

N, M = list(map(int, input().split()))
a_list = []
c_list = []
for i in range(M):
    a, _ = list(map(int, input().split()))
    a_list.append(a)
    c = 0
    for one in list(map(int, input().split())):
        c |= 1<<(one-1)
    c_list.append(c)

dp = [INF]*(1<<N)
dp[0] = 0
for s in range(1<<N):
    for i in range(M):
        t = c_list[i] | s
        cost = a_list[i]+dp[s]
        dp[t] = min(dp[t], cost)

if dp[-1]==INF:
    print(-1)
else:
    print(int(dp[-1]))


Measured memory_bytes: 46040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll extgcd(ll a,ll b,ll& x,ll& y){
    ll d=a;
    if(b!=0){
        d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
    }else{
        x=1;y=0;
    }
    return d;
}

int main(){fastio
    ll a,b;cin>>a>>b;
    ll x,y;
    extgcd(a, b, x, y);
    cout<<x<<' '<<y<<endl;
    
    return 0;
}





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

int main() {
    string s;
    cin >> s;
    int count = 0;
    for(int i = 0; i < s.size()-1; i++){
        if(s.at(i) == 'A' && s.at(i+1) == 'C'){
            count++;
        }
    }
    if(count == 0){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

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

bool ok(int val, vector<int> arr, int k) {
    for(int i : arr) {
        k -= (i + val - 1) / val - 1;
    }
    return k >= 0;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    int L = 1, R = 1e9 + 10;
    int mid = L + (R - L) / 2;
    while(L < R) {
        int mid = L + (R - L) / 2;
        if(ok(mid, arr, k)) {
            R = mid;
        } else {
            L = mid + 1;
        }
    }
    cout << L << endl;
}

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

int main(){
  int n;
  cin >> n;
  
  string u[257];
  for(int i=0;i<n;i++)cin >> u[i];

  int m;
  cin >> m;
  
  string t;
  int sta = 1;
  for(int i=0;i<m;i++){
    cin >> t;
    
    int flg = 0;
    for(int i=0;i<n;i++){
      if(t == u[i]) {
	flg = 1;
	sta++;
	break;
      }
    }

    if(flg == 1){
      if(sta%2 == 1) cout << "Closed by ";
      else cout << "Opened by ";
      cout << t << endl;
    }
    else cout << "Unknown "<<t<<endl;
    
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
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;
}
const long long INF = 1LL << 60;

// input
int N;
long long W, weight[110], value[110]; //品物の個数は100個なので少し余裕をもたせてサイズ110に

// DP table
long long dp[110][100100] = {};

int main()
{
    cin >> N >> W;
    for (int i = 0; i < N; ++i) {
        cin >> weight[i] >> value[i];
    }

    //DP Loop
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {
            // i番目の品物を選ぶ場合
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i + 1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            // i番目の品物を選ばない場合
            chmax(dp[i + 1][sum_w], dp[i][sum_w]);
        }
    }

    // 最適値の出力
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 79360
Q = int(input())
N = 10**5 + 1000

def getPrimes():
    isPrime = [True] * N
    isPrime[1] = False
    for i in range(2, N):
        if not isPrime[i]:
            continue
        for p in range(i + i, N, i):
            isPrime[p] = False
    return isPrime

isPrime = getPrimes()

A = [0] * (N)
for i in range(2, N):
    if i % 2 == 1 and isPrime[i] and isPrime[(i + 1) // 2]:
        A[i] = 1
accA = [0] * (N + 1)
for i, a in enumerate(A, start=0):
    accA[i] += accA[i - 1] + a

for _ in range(Q):
    l, r = map(int, input().split())
    print(accA[r] - accA[l - 1])



Measured memory_bytes: 9716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int t = 0;
			if(x == 0 && y == 0) {
				break;
			}
			if(x > y) {
				t = x;
				x = y;
				y = t;
			}
			System.out.printf("%d ",x);
			System.out.printf("%d\n",y);
		}

	}
}


Measured memory_bytes: 40900
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int[] L = in.ii(N);
        Arrays.sort(L);

        long ans = 0;
        for (int i = 2; i < N; i++) {
            for (int j = 0, k = i - 1; j < i - 1; j++) {
                while (j < k && L[j] + L[k] > L[i]) {
                    k--;
                }
                ans += i - Math.max(k, j) - 1;
            }
        }

        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string str;
  cin >> str;
  int k[30] = {0};
  k[str[0] - 'A'] ++;
  k[str[1] - 'A'] ++;
  k[str[2] - 'A'] ++;
  k[str[3] - 'A'] ++;
  if (k[str[0]-'A'] != 2 || k[str[1]-'A'] != 2 || k[str[2]-'A'] != 2 || k[str[3]-'A'] != 2) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def calc_sum_of_digit(k):
    _sum = 0

    for i in k:
        _sum += int(i)

    return _sum

def main():
    N, A, B = list(map(int, input().split()))

    result = 0
    for i in range(1, N+1):
        sum_of_digit = calc_sum_of_digit(str(i))

        if A <= sum_of_digit <= B:
            result += i

    print(result)


main()


Measured memory_bytes: 2940