akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
  char s[200];
  int c, n, i;

  scanf("%s", s);

  c = 0;
  for (i = 0; s[i] != 0; i++) {
    c++;
  }

  n = c - 2;

  printf("%c%d%c\n", s[0], n, s[c-1]);

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail++;
  if(LEN < tail) tail = 0;
}

P dequeue(){
  P x;
  x = Q[head];
  head++;
  if(LEN < head) head = 0;

  return x;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1;
  tail = n + 1;

  while(head != tail){
    u = dequeue();
    if(u.t > q){
      elaps += q;
      u.t -= q;
      enqueue(u);
    }else if(u.t <= q){
      elaps += u.t;
     printf("%s %d\n", u.name, elaps);
    }
  }
  
  return 0;
}

Measured memory_bytes: 10752
import java.util.Scanner;

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

		long a = sc.nextInt();
		long b = sc.nextInt();

		if (a == 2 || b == 2) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		sc.close();

	}

}


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

using namespace std;

int N, K, D, R;
vector< int > g[50000];
vector< int > F[24][50000];
int in[50000];

int main()
{
  scanf("%d %d", &N, &K);
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < 24; j++) {
      F[j][i].resize(K);
    }
    for(int j = 0; j < K; j++) {
      scanf("%d", &F[0][i][j]);
    }
  }
  scanf("%d", &D);
  while(D--) {
    int a, b;
    scanf("%d %d", &a, &b);
    --a, --b;
    g[a].emplace_back(b);
    ++in[b];
  }

  map< vector< int >, int > latte;
  vector< int > bb(K);
  iota(begin(bb), end(bb), 0);
  do {
    latte[bb] = (int) latte.size() - 1;
    int id = latte[bb];
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < K; j++) {
        F[id][i][j] = F[0][i][bb[j]];
      }
    }
  } while(next_permutation(begin(bb), end(bb)));
  int sz = (int) latte.size();

  priority_queue< pair< vector< int >, int > > que[24];
  for(int i = 0; i < N; i++) {
    if(in[i]) continue;
    for(int j = 0; j < sz; j++) {
      que[j].emplace(F[j][i], i);
    }
  }

  vector< int > E(K);
  bool v[50000] = {};
  auto evaluation = [&]()
  {
    auto &q = que[latte[E]];
    while(v[q.top().second]) q.pop();
    auto p = q.top();
    printf("%d\n", p.second + 1);
    v[p.second] = true;
    for(auto &to : g[p.second]) {
      if(--in[to] == 0) {
        for(int j = 0; j < sz; j++) que[j].emplace(F[j][to], to);
      }
    }
  };

  for(int i = 0; i < K; i++) scanf("%d", &E[i]), --E[i];
  scanf("%d", &R);
  int sum = 0;
  for(int i = 0; i <= R; i++) {
    int M = N;
    if(i < R) scanf("%d", &M);
    while(sum < M) evaluation(), ++sum;
    if(i < R) for(int j = 0; j < K; j++) scanf("%d", &E[j]), --E[j];
  }
}

Measured memory_bytes: 145144
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;
ll isPal(string s,ll l,ll h) 
{ 
    while(h>l) 
    { 
        if(s[l++]!=s[h--]) 
        { 
            return 0;
        } 
    } 
    return 1;
}
int main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string s;
	in(s);
	ll c1=0,c2=0,c3=0;
	ll n=s.size();
	if(isPal(s,0,n-1)){
	    //cout<<isPal(s,(n+3)/2 - 1,n-1)<<endl;
	    
		if(isPal(s,0,(n-1)/2 - 1)&&isPal(s,(n+3)/2 - 1,n-1))cout<<"Yes\n";
		else cout<<"No\n";
	}else cout<<"No\n";
	return 0;
}


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

using namespace std;

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

	int L = S.size();
	string ans = "AC";

	if (S[0] != 'A') {
		ans = "WA";
	}
	int cnt = 0;
	for (int i = 1; i < L; i++) {
		if (isupper(S[i])) {
			if (i == 1 || i == L - 1 || S[i] != 'C') {
				ans = "WA";
			}
			++cnt;
		}
	}
	if (cnt != 1) {
		ans = "WA";
	}
	cout << ans << endl;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int x = Integer.parseInt(br.readLine());

		if (x == 0)
			System.out.println(1);
		else if (x == 1)
			System.out.println(0);
	}
}

Measured memory_bytes: 32480
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int N, sumA, sumB;
		sumA = 0; sumB = 0;
		Scanner input = new Scanner(System.in);
		N = input.nextInt();
		int[] a = new int[N];
		
		for(int i=0; i < N; i++) {
			a[i] = input.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			for(int t = 0; t < N; t++) {
				if(a[i]>a[t]) {
					int temp = a[i];
					a[i] = a[t];
					a[t] = temp;
				}
			}
		}
		
		for(int i = 0; i < N; i+=2) {
			sumA += a[i];
		}
		for(int i = 1; i < N; i+=2) {
			sumB += a[i];
		}
		
		System.out.println(sumA - sumB);
		
	}

}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

ll solve1(vector<ll> &a) {
  ll sum = 0ll;
  ll res = 0ll;
  for (int i = 0; i < a.size(); i++) {
    sum += a[i];
    if (i % 2 == 0) {
      if (sum <= 0) {
        res += 1 - sum;
        sum = 1;
      }
    } else {
      if (sum >= 0) {
        res += sum + 1;
        sum = -1;
      }
    }
  }
  return res;
}

ll solve2(vector<ll> &a) {
  ll sum = 0ll;
  ll res = 0ll;
  for (int i = 0; i < a.size(); i++) {
    sum += a[i];
    if (i % 2 == 1) {
      if (sum <= 0) {
        res += 1 - sum;
        sum = 1;
      }
    } else {
      if (sum >= 0) {
        res += sum + 1;
        sum = -1;
      }
    }
  }
  return res;
}

void solve() {
  int N;
  cin >> N;
  vector<ll> t(N);
  cin >> t;
  cout << min(solve1(t), solve2(t)) << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


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

using ll = long long;

int n;
ll a[123456];

int main()
{
	memset(a, 0, sizeof(a));
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%lld",a + i);
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		if (a[i] > 1)
		{
			//pair with self
			ans += (a[i] / 2);
			a[i] = a[i] % 2;
		}
		if (a[i] == 1)
		{
			if (a[i + 1] > 0)
			{
				--a[i]; --a[i + 1];
				++ans;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1152
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        HashSet<Integer> A=new HashSet<>();

        for (int i = 0; i < N; i++) {
            A.add(sc.nextInt());
        }
        if (A.size()==N) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

int main(){
    int A[26] = {0};
	string s;
	cin>>s;
	for(size_t i=0;i<s.length();i++){
		A[s[i]-97]++;
	}
	for(size_t i=0;i<26;i++){
		if(A[i]%2!=0){ 
		printf("No"); 
		return 0;
		}
	}
	printf("Yes");
    return 0;
}

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

int main()
{
    int n;
    ll a[200001];
    ll sum_a[200001];
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
        a[i]*=2;
        if(i!=0){
            sum_a[i]=sum_a[i-1]+a[i];
        }else{
            sum_a[i]=a[i];
        }
        //cout<<i<<" "<<a[i]<<" "<<sum_a[i]<<endl;
    }

    ll sum_all=sum_a[n-1];
    ll harf=sum_all/2;
    //bool odd = sum_all%2==0 ? false : true;
    ll ans=20202020202;


    
    for (int i = 0; i < n; i++)
    {
        ans = min( ans, abs(sum_a[i]-harf));
        //cout<<ans<<endl;
    }

    std::cout<<ans;

    return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int cnt[1000005];
const int mod = 1e9+7;
void add(int &a, int b){
    a += b;
    if(a >= mod)a -= mod;
}
void mul(int &a, int b){
    a = (ll)a * b % mod;
}
int pow(int a, int b){
    int res = 1;
    while(b){
        if(b&1)mul(res, a);
        mul(a, a);
        b >>= 1;
    }
    return res;
}
int inv(int a){
    return pow(a, mod - 2);
}
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        int b = a[i];
        for(int j = 2; j * j <= b; j++){
            int t = 0;
            while(b % j == 0){
                t++;
                b /= j;
            }
            cnt[j] = max(cnt[j], t);
        }
        cnt[b] = max(cnt[b], 1);
    }
    int k = 1;
    for(int i = 2; i <= 1000000; i++){
        mul(k, pow(i, cnt[i]));
    }
    int res = 0;
    for(auto x : a){
        add(res, inv(x));
    }
    mul(res, k);
    cout << res << endl;
}


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

int main() {
  string str;
  string kekka = "";
  
  cin >> str;
   
  // 操作  
  for(int i = 0; i < str.size(); i++){
    switch(str.at(i)){
      case '0':
        kekka += "0";
        break;
      case '1':
        kekka += "1";
        break;
      default:
        if(kekka.size() > 0) kekka.erase(--kekka.end());
        break;
    }
  }
  cout << kekka;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>	
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

string itos (int n )
{
	string b = "";
	while (n > 0 ){
		b += (n % 2 == 0 ? '0': '1' );
		n /= 2;
	} // end while
	while (b.length() < 5 ){
		b += '0';
	} // end while
	reverse (ALL(b ) );

	return b;
} 

int main()
{
	const string code[] = { "101", "010001", "000011", "10010001", "000000", "000001" };	
	const char extra[] = { ' ', '.', ',', '-', '\'', '?' };

	const char m[] = { 'E', 'P', 'D', 'C', 'K', 'I',
						  'R', 'L', 'O', 'S', 'T', 'F',
						  'W', 'H', 'A', 'Z', 'X',
						  'Y', 'J', 'M', 'B', 'G',
						  'U', 'V', 'N', 'Q' }; 	

	const string code2[] = { "110", "111", "0001", "0101", "0110", "0111",
								"1000", "00100", "00101", "00110", "00111", "01001",
								"000010", "010000", "100101", "10010000", "10010010",
								"10010011", "10011000", "10011001", "10011010","10011011",
								 "10011100", "10011101", "10011110", "10011111"};
	map<char,string> en1;
	int i = 0;
	for (char c = 'A'; c <= 'Z'; c++,i++ ){
		en1[c] = itos (i );  
	} // end for
	for (int j = 0; j < sizeof (extra)/sizeof (extra[0] ); i++, j++ ){
		en1[extra[j]] = itos (i );
	} // end for

	map<string, char> en2;
	for (int i = 0; i < sizeof(extra )/sizeof (extra[0] ); i++ ){
		en2[code[i]] = extra[i];
	} // end for
	for (int i = 0; i < sizeof (m )/sizeof(m[0] ); i++ ){
		en2[code2[i]] = m[i];
	} // end for

	string str;
	while (getline (cin, str ) ){
		int n = str.length();
		string ans = "";
		for (int i = 0; i < n; i++ ){
			ans += en1[str[i]];
		} // end for
		int size = ans.length();

		int i = 0;
		string res = "";
		while (i < size ){
			bool found = false;
			for (int j = 3; j <= 8; j++ ){
				string curr = ans.substr(i, j );
				if (en2.find (curr ) != en2.end() ){
					res += en2[curr];
					i += j;
					found = true;
					break;
				} // end if
			} // end for
			if (!found )
				break;
		} // end while

		cout << res << endl;
	} // end while

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define HASHSIZE 5000

typedef struct word{
  char *str;
  struct word *next;
}Word;

Word *hashtable[HASHSIZE]={0};

int hash(char *key){
  unsigned int hash=0;
  int length = strlen(key);
  int i;
  for(i=0; i< length; i++){
    hash += key[i] * pow(7, i);
  }
  return hash%HASHSIZE;
}

void put_word(char *str){
  Word *a;
  int l=strlen(str);
  a=(Word*)malloc(sizeof(Word));
  a->str = (char*)malloc(sizeof(char)*(l+1));
  strcpy(a->str, str);
  int h=hash(a->str);
  a->next=hashtable[h];
  hashtable[h]=a;
}

void aaaaa(int aaa){
  int i, count =0;
  for(i=0; i<aaa; i++){
    count++;
  }
}

int main(){
  long n, i;
  int aaa=10;
  scanf("%ld", &n);

  for(i=0; i<n; i++){
    char command[7];
    scanf("%s", command);
    if(strcmp(command, "insert") == 0){
      char str1[13];
      scanf("%s", str1);
      put_word(str1);
    }
    if(strcmp(command, "find") == 0){
      char str2[13];
      scanf("%s", str2);
      Word *a = hashtable[hash(str2)];
      while(a !=NULL){
	if(strcmp(a->str, str2) == 0)break;
	a=a->next;
      }
      if(a != NULL){
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
  }
  aaaaa(aaa);
  return 0;
}



Measured memory_bytes: 37604
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input
 
def insertionSort(a,g):
    global cnt
    for i in range(g,len(a)):
        v = a[i]
        j = i - g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j = j - g
            cnt+=1
            a[j+g] = v
 
def shellSort(a):
    global cnt
    cnt = 0
    g = []
    h = 1
    while h <= len(a):
        g.append(h)
        h = 3*h+1
    g.reverse()
    m = len(g)
    print(m)
    print(' '.join(map(str,g)))
    for i in range(m):
        insertionSort(a,g[i])
 
a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)


Measured memory_bytes: 45524
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(0);
    int n; cin >> n;
    cout << (10000-n)%1000 << endl;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program2
    {

        static void Main(string[] args)
        {
            var linea = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
            int N = linea[0];
            int K = linea[1];
            int[] cuantostienen = new int[N];

            for(int i=1; i<=K; i++)
            {
                var contador = Int32.Parse(Console.ReadLine());
                var lineaquienes = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
                for(int j=0;j<contador; j++)
                {
                    int index = lineaquienes[j] - 1;
                    cuantostienen[index]++;
                }
            }

            int respuesta = cuantostienen.Select(x => x).Where(x => x == 0).Count();
            Console.WriteLine(respuesta);
        }
    }
}

Measured memory_bytes: 28492
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false)
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <int, int> PLL;
typedef pair <PLL, int> PLLI;
typedef pair <PLL, PLL> PP;
typedef pair <PII, int> PPI;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
const int inf =1e9+9;
const ll mod = 1e9+7;
const ll MOD = 1e9+696969;
int n, m,w, k, a, b,maks, DL = 0, CC = 0, T;
#define maxn 201000
int ile[maxn];

int main() {
	boost;
	cin >> n;
	FOR(i, 1, n) {
		cin >> a;
		ile[a]++;
	}
	if (n == 1 && a == 0) OUT(1);
	if (n == 1) OUT(1);
	int val = n - 1;
	ll wyn = 1;
	while (val >= 0) {
		if (val == 0 && n % 2 == 1) {
			if (ile[val] != 1) OUT(0);
		}
		else {
			if (ile[val] == 2) wyn = (wyn * 2) %mod;
			else OUT(0);
		}
		val -= 2;
	}
	cout << wyn;
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {

	popular()
}

func popular(){

	var N,K int

	fmt.Scan(&N,&K)

	var a,b int

	a = N%K

	b= (N%K)-K

	if b < 0{

		b= b*-1
	}

	if a < b {

		fmt.Println(a)

	}else{

		fmt.Println(b)
	}

}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    int a, b, t; cin >> a >> b >> t;

    cout << (t/a) * b << endl;
    return 0;
}




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

typedef long long ll;

ll strToNum(std::string S) {
	ll ret = 0;
	for(char c : S) {
		ret = 10 * ret + (ll)(c - '0');
	}
	return ret;
}

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

	int N = S.length();
	ll ans = 0;
	for(int i = 0; i < (1 << (N - 1)); ++i) {
		ll sum = 0;
		int first = 0;
		for(int j = 0; j < N - 1; ++j) {
			if((i >> j) & 1) {
				sum += strToNum(S.substr(first, j - first + 1));
				first = j + 1;
			}
		}
		sum += strToNum(S.substr(first, N - first));
		ans += sum;
	}

	std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<cstdio>
const int vx[4]={-1,0,0,1},vy[4]={0,-1,1,0};
int H,W,K;
char A[810][810];
struct Point{int x,y,d;}Q[810*810];
int min(int a,int b){return a<b?a:b;} 
int main(){
	scanf("%d%d%d",&H,&W,&K);
	for(int i=0;i<H;i++){
		scanf("%s",A[i]);
		for(int j=0;j<W;j++)if(A[i][j]=='S')*Q=(Point){i,j,0};
	}
	Point*h=Q,*t=Q+1;
	int ans=1<<30;
	for(;h<t;h++){
		ans=min(ans,1+(min(min(h->x,H-h->x-1),min(h->y,W-h->y-1))+K-1)/K);
		if(ans<2)break;
		if(h->d<K)for(int d=0,dx,dy;d<4;d++)if(A[dx=h->x+vx[d]][dy=h->y+vy[d]]=='.'){
			*t++=(Point){dx,dy,h->d+1};
			A[dx][dy]=1; 
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 2944
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[110000];
int l[110000];
int r[110000];
pair<long long,int>ev[110000];

int main(){
	int a,b;scanf("%d%d",&a,&b);
	long long cur=0;
	for(int i=0;i<a;i++){
		scanf("%d%d%d",p+i,l+i,r+i);
		ev[i]=make_pair((long long)l[i]*p[i]+(long long)r[i]*(b-p[i]),i);
		cur+=(long long)l[i]*p[i];
	}
	std::sort(ev,ev+a);
	reverse(ev,ev+a);
	long long left=-1;
	long long right=(long long)b*a;
	while(left+1<right){
		long long M=(left+right)/2;
		long long req=M/b;
		long long val=0;
		for(int i=0;i<req;i++){
			val+=ev[i].first;
		}
		bool ok=false;
		for(int i=0;i<a;i++){
			long long tmp=val;
			if(i<req){
				tmp-=ev[i].first;
				tmp+=ev[req].first;
			}
			tmp+=min((long long)p[ev[i].second],M%b)*l[ev[i].second]+max(0LL,M%b-p[ev[i].second])*r[ev[i].second];
			if(tmp>=cur){
				ok=true;
			}
		}
		if(ok)right=M;
		else left=M;
	}
	printf("%lld\n",right);
}

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

int main() {
  int n;
  cin >> n;

  bool flag = false;
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 15; j++) {
      if (i * 4 + j * 7 == n) {
        flag = true;
        break;
      }
    }
    if (flag) {
      break;
    }
  }

  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (a, b) = input_tuple();
    if b % a == 0 {
        println!("{}", a + b);
    } else {
        println!("{}", b - a);
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  long long N, X, M;
  cin >> N >> X >> M;

  long long sum = 0;

  long long a = X;

  vector<long long> times_(M);
  vector<long long> sum_(M);
  vector<long long> num_(M);

  for (int i = 2; i < M; i++)
  {
    long long t = 1;
    long long s = 0;
    long long b = i;
    while (b * b < M)
    {
      s += b;
      b = b * b;
      t++;
    }
    s += (b % M);
    sum_[i] = s;
    num_[i] = b * b % M;
    times_[i] = t;
  }

  vector<long long> before_s(M, -1);
  vector<long long> before_i(M, -1);
  vector<long long> loop_s(M, -1);
  vector<long long> loop_i(M, -1);

  for (long long i = 0; i < N;)
  {
    if (loop_i[a] > 0)
    {
      if (N - i > loop_i[a])
      {
        long long nn = (N - i) / loop_i[a];
        i += loop_i[a] * nn;
        sum += loop_s[a] * nn;
        continue;
      }
    }
    else
    {
      if (before_i[a] >= 0)
      {
        loop_i[a] = i - before_i[a];
        loop_s[a] = sum - before_s[a];
      }
      else
      {
        before_i[a] = i;
        before_s[a] = sum;
      }
    }

    if (a == 0)
      break;
    else if (a == 1)
    {
      sum += (N - i);
      break;
    }

    if (N - i >= times_[a])
    {
      sum += sum_[a];
      i += times_[a];
      a = num_[a];
    }
    else
    {
      long long b = a * a % M;
      sum += b;
      a = b;
      i++;
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 8708
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        int plus[5002] = {0}, max = -100001, input;
        range(i,1,n+1){
            cin >> input;
            plus[i]+= input;
            plus[i+1] = plus[i];
        }
        rep(i,n+1){
            rep(j,i){
                if(max < plus[i] - plus[j]){
                    max = plus[i] - plus[j];
                }
            }
        }
        cout << max << endl;
    }
}

Measured memory_bytes: 1188
#include <stdio.h>

int main(void) {
  unsigned long long int n;
  char name[1024] = {0};
  int offset = 1023;
  scanf("%llu", &n);

  n--;

  name[offset--] = "abcdefghijklmnopqrstuvwxyz"[n % 26];
  n /= 26;

  for (; n; n /= 26) {
    n--;
    name[offset--] = "abcdefghijklmnopqrstuvwxyz"[n % 26];
  }
  puts(name + offset + 1);
  return 0;
}

Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VL vector<LL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double ang1, ang2;
    ang1 = (2*PI*(h+(m/(double)60)))/(double)12;
    ang2 = (2*PI*m)/(double)60;
    double ang = fabs(ang1 - ang2);
    double ans = (a*a) + (b*b) - (2*a*b*cos(ang));
    ans = sqrt(ans);
    cout<<fixed<<setprecision(9)<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
#define inf 0x7fffffff
/*------------------------------------------------------------*/

int main(){
	int n;
	in(n);
	int ans=inf;
	FOR(i,1,n){
		int c;
		in(c);
		int k=0;
		while(c%2==0)c/=2,k++; 
		ans=min(ans,k);
	}
	out(ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

int n,m;
char sq[105][105];
int sx,sy;
int answer;

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

int visited[25][25];

void dfs(int x,int y,char c){
    for(int i=0;i<4;i++){
        int nx = x+dx[i], ny = y+dy[i];
        if(1<=nx&&nx<=n&&1<=ny&&ny<=m&&sq[nx][ny]==c){
            sq[nx][ny]='.';
            dfs(nx,ny,c);
        }
    }
}

void solve(){
    while(1){
        scanf("%d%d",&n,&m);
        if(m==0&&n==0) break;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                cin >> sq[i][j];
            }
        }
        answer=0;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                if(sq[i][j]!='.'){
                    answer++;
                    dfs(i,j,sq[i][j]);
                }
            }
        }
        printf("%d\n",answer);
    }
}


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



Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    int res = 0;
    for (int i = 1; i < n; i++) {
      int sum = 0, j = 0;
      while (sum < n) {
	sum += i+j;
	j++;
      }
      if (sum == n) res++;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1160
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IO std::ios::sync_with_stdio(false)
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)
#define INF 0x3f3f3f3f
inline int read() {
    int x = 0, neg = 1; char op = getchar();
    while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
    while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
    return neg * x;
}
inline void print(int x) {
    if (x < 0) { putchar('-'); x = -x; }
    if (x >= 10) print(x / 10);
    putchar(x % 10 + '0');
}
string str;
signed main() {
    IO;
    cin >> str;
    if(str.size() < 6){
        cout << "No" <<endl;
        return 0;
    }
    str = " " + str;
    if(str[3] == str[4] && str[5] == str[6]) cout << "Yes" <<endl;
    else cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>

using namespace std;
using ll = long long;

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

	sort(argS.begin(), argS.end());
	set<char> truncS;
	for (ll i = 0; i < argS.size(); ++i) {
		truncS.insert(argS.at(i));
	}

	char base = 'a';
	for (int i = 0; i < 26; i++) {
		char target = base + i;
		if(truncS.find(target) != truncS.end()) {
			continue;
		}
		else {
			cout << target << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define loopj(n) for(int j=0;j<n;j++)
#define loopi(a,b,k) for(int i=a;i<b;i=i+k)
#define  deb(x) cout<<#x<<"  "<<x<<endl
#define sync std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int main()
{
	string s;
	string t;
	cin>>s>>t;
	int s_len=s.size();
	int t_len=t.size();
	int mini=INT_MAX;
	for(int i=0;i<s_len-t_len+1;i++)
		{
			int count=0;
			for(int j=0;j<t_len;j++)
			{
				if(s[i+j]!=t[j])
				count++;
			}
			mini=min(mini,count);			
		}
		cout<<mini<<endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

int hoge[256][256];
int r,c;
int i,j;

main(){
	scanf("%d %d",&r,&c);
	for(i=0; i<r; i++){
		for(j=0 ; j <c; j++){
			scanf("%d",&hoge[i][j]);
		}
	}
	for(i=0; i<=r; i++){
		hoge[i][c]=0;
	}
	for(j=0; j<=c; j++){
		hoge[r][j]=0;
	}
	for(i=0; i<r; i++){
		for(j=0 ; j <c; j++){
			hoge[i][c] += hoge[i][j];
			hoge[r][j] += hoge[i][j];
			hoge[r][c] += hoge[i][j];
		}
	}
	for(i=0; i<=r; i++){
		for(j=0 ; j <=c; j++){
			if(j){
			printf(" ");
			}
			printf("%d",hoge[i][j]);
		}
		printf("\n");
	}
	return 0;
}
	
	
	
	
	

Measured memory_bytes: 704
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int m,a[7],b[7],g,n;

int f(int r,int c){
	if(r<0)return 0;
	if(c==m)return r==0;
	int res=0;
	rep(i,b[c]+1)res+=f(r-a[c]*i,c+1);
	return res;
}

int main(){
	while(cin>>m&&m){
		rep(i,m)cin>>a[i]>>b[i];
		cin>>g;
		rep(i,g){
			cin>>n;
			cout<<f(n,0)<<endl;
		}
	}
}

Measured memory_bytes: 868
#include <stdio.h>
#define MAX(x,y) ((x) < (y) ? (y) : (x))
#define MIN(x,y) ((x) > (y) ? (y) : (x))
int dp[5001][5001];

int main() {
    int N, ans = 0;
    char S[5001];
    scanf("%d %s", &N, S);
    for (int i = N - 1; i >= 0; --i) {
        for (int j = N - 1; j >= 0; --j) {
            if (S[i] == S[j])
                dp[i][j] = MAX(dp[i][j], dp[i+1][j+1] + 1);
            ans = MAX(ans, MIN(dp[i][j], j-i));
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 97792
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
int main() {
  int H,W,M;
  cin >> H >> W >> M;
  vector<int> h(H,0),w(W,0);
  vector<pair<int,int>> B;
  int i,j;
  int _h,_w;
  for(i=0;i<M;i++) {
    cin >> _h >> _w;
    h[_h-1]++;
    w[_w-1]++;
    B.push_back(pair<int,int>(_h-1,_w-1));
  }
  sort(B.begin(),B.end());
  int mh = 0,mw = 0;
  vector<int> Mh,Mw;
  for(i=0;i<H;i++)mh = max(mh,h[i]);
  for(i=0;i<W;i++)mw = max(mw,w[i]);
  for(i=0;i<H;i++)if(h[i] == mh)Mh.push_back(i);
  for(i=0;i<W;i++)if(w[i] == mw)Mw.push_back(i);
  int l,r,m;
  for(i=0;i<Mh.size();i++) {
    for(j=0;j<Mw.size();j++) {
      l = 0;
      r = B.size();
      while(r-l>1) {
        m = (l+r)/2;
        if(B[m] > pair<int,int>(Mh[i],Mw[j]))r = m;
        else l = m;
      }
      if(B[l].first != Mh[i] || B[l].second != Mw[j]) {
        cout << mh+mw << endl;
        return 0;
      }
    }
  }
  cout << mh+mw-1 << endl;
}

Measured memory_bytes: 12300
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<iostream>
#include<algorithm>
#include<ctime>
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1)
#define LL long long
#define inf (1<<30)
#define modn 1000000007
#define maxn 20+10
#define Mod 2
#define type 1
#define rep(a,b) for(i=a;i<=b;i++)
#define eps 1e-7
#define zero(x) fabs(x)<eps
#define equal(x,y) zero(x-y)
#define shift(x) (1<<x)
#define lowbit(x) (x&(-x))
#define del(S,i,j) (S^(1<<i)^(1<<j))
#define jiao(S,i) (S&(1<<i))
#define bing(S,i) (S|(1<<i))
#define bu(S,i) (S^(1<<i))
#define ALL_BITS (1<<n)-1
#define BuJi(A) ALL_BITS^A
#define wei_del(A,bit) (A|=(1<<bit))
#define rep_all for(s=1;s<=ALL_BITS;s++)
#define rep_zi for(s0=s;s0;s0=(s0-1)&s)
using namespace std;
vector<int> G[110];
int ans,n,m,u;
int vis[110],deg[110],val[110][110],he[110],rp[110],tmp[110];
int fun(int cur)
{
    int v,i,j;
    for(i=0;i<cur;i++)
    rp[i]=G[u][tmp[i]];
    rp[cur]=u;
    v=0;
    for(i=0;i<=cur;i++)
    {
        int t=inf;
        for(j=0;j<=cur;j++)
        {
            if(i==j)continue;
            t=min(t,val[rp[i]][rp[j]]);
        }
        v+=t;
    }
    if(v!=inf)
    ans=max(v,ans);
}
void dfs(int cur,int _n,int s)
{
    int i,j;
    fun(cur);
    for(i=s;i<_n;i++)
    {
        tmp[cur]=i;
        dfs(cur+1,_n,i+1);
    }
}
int main()
{
    int i,j;
    scanf("%d%d",&n,&m);
    memset(val,0,sizeof(val));
    for(i=1;i<=m;i++)
    {
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        val[x][y]=z;
        val[y][x]=z;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    ans=0;
    for(i=1;i<=n;i++)
    if(G[i].size())
    {
        u=i;
        memset(vis,0,sizeof(vis));
        dfs(0,G[u].size(),0);
    }
    printf("%d\n",ans);
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ll mod = 1000000007;

int main(void)
{
	ll n, k;
	cin >> n >> k;
	vector<ll> vs(n);
	rep(i, n)cin >> vs[i];
	vector<ll> sum(n + 1, 0);
	rep(i, n) {
		sum[i + 1] = sum[i] + vs[i];
	}
	rep(i, n + 1) {
		sum[i] = ((sum[i] - i) % k + k) % k;
	}
	ll s = 0;
	unordered_map<ll, ll> c;
	for (int i = 0; i <= n; i++) {
		if (i - k >= 0) {
			c[sum[i - k]]--;
		}
		s += c[sum[i]];
		c[sum[i]]++;
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 11592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

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

    int n,sum; cin>>n;
    vector<int> a(n),b(n),dif(n);
    rep(i,n)cin>>a.at(i);
    rep(i,n)cin>>b.at(i);
    rep(i,n){
        dif.at(i)=a.at(i)-b.at(i);
        sum+=dif.at(i);
    }

    if(sum<0){
        cout<<-1<<endl;
        return 0;
    }

    sort(all(dif));
    int l=0,r=n-1,num=0,ans=0;
    while(dif.at(l)<0){
        ans++;
        while(num<abs(dif.at(l))){
            ans++; num+=dif.at(r); r--;
        }
        num-=abs(dif.at(l));
        l++;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 2560
def c_guess_the_number():
    N, M = [int(i) for i in input().split()]
    Conds = [[int(i) for i in input().split()] for j in range(M)]

    digit = [-1] * N
    # 同じ桁に異なる数字を指定した場合と、
    # 2 桁以上なのに左から 1 桁目に 0 を指定した場合を検出
    for s, c in Conds:
        if digit[s - 1] not in (-1, c):
            return -1
        if N >= 2 and s == 1 and c == 0:
            return -1
        digit[s - 1] = c

    # 指定されなかった桁は基本的に 0 とすればよいが、
    # 左から 1 桁目は 0 にできない。N = 1, M = 0 だと例外的に 0 にできる。
    for d, value in enumerate(digit):
        if value == -1:
            digit[d] = 1 if (N >= 2 and d == 0) else 0
    return ''.join(map(str, digit))

print(c_guess_the_number())

Measured memory_bytes: 3064
#include <stdio.h>

int findsumdigits(int n){
	int sum = 0;
	while(n > 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}
int main(void){
	int n, a, b;
	int i, res,ans=0;
	scanf("%d%d%d", &n, &a, &b);

	for (i = 1; i <= n; i++){
		res= findsumdigits(i);
		if (a<=res && res <= b){
			ans += i;
		}
	}
	printf("%d\n", ans);
	return 0;
}

/*
int main(void){
	int n, i, j, a[110], b[110], c[110],d[110];
	int count = 0;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d%d", &a[i], &b[i]);
	}
	for (i = 0; i < n; i++){
		scanf("%d%d", &c[i], &d[i]);
	}
	
	for (i = 0; i < n;i++){
		for (j = i; j < n; j++){
			if (a[i] < c[j] && b[i] < d[j]){
				count++;
				break;
			}
		}
	}
	printf("%d\n", count);
	return 0;
}*/



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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

ll gcd(ll a , ll b){
    while(a > 0 && b > 0){
        if(a > b)   a %= b;
        else    b %= a;
    }
    return a + b;
}

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

ll a , b , c , d;

int main()
{
    _FastIO;
    cin >> a >> b >> c >> d;
    ll x = a / c;
    if(a % c) x++;
    ll y = b / c;
    ll ans = y - x + 1;
    x = a / d;
    if(a % d) x++;
    y = b / d;
    ans += (y - x + 1);
    ll k = lcm(c , d);
    x = a / k;
    if(a % k) x++;
    y = b / k;
    ans -= (y - x + 1);
    ans = b - a + 1 - ans;
    cout << ans << endl;
    return 0;
}


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

#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
#define PI                      3.14159265358979323846
#define int                     long long
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  map<int, int>              mii;
typedef  long double                 ld;


clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

int32_t main()
{
  FIO
 
 
  int a,b;
cin>>a>>b;
if(a==2 or b==2)
cout<<"No";
else 
cout<<"Yes";

  timer();
  return 0;
}  

Measured memory_bytes: 256
n, m = map(int, input().split())
edges = [None] * m

for i in range(m):
    a, b, c = map(int, input().split())
    edges[i] = (a-1, b-1, -c)

INF = float("inf")
d = [INF] * n
d[0] = 0

for i in range(n-1):
    for f, t, c in edges:
        if d[f] == INF: continue
        d[t] = min(d[t], d[f] + c)

inf_flag = [False] * n

for i in range(n):
    for f, t, c in edges:
        if d[f] == INF: continue
        if inf_flag[f] == True:
            inf_flag[t] = True
        if d[t] > d[f] + c:
            d[t] = d[f] + c
            inf_flag[t] = True

print("inf" if inf_flag[n-1] else -d[n-1])


Measured memory_bytes: 48748
#include <iostream>
#include <vector>
constexpr int MOD = 1e9 + 7;
int main()
{
    int N;
    std::cin >> N;
    std::string S;
    std::cin >> S;
    S = "<" + S;
    std::vector<int> dp(N + 1, 0), sum(N + 1, 0);
    dp[0] = 1, std::fill(sum.begin(), sum.end(), 1);
    for (int i = 0; i < N; i++) {
        if (S[i] == '<') {
            for (int j = 0; j < N - i; j++) { dp[j] = sum[j]; }
        } else {
            for (int j = 0; j < N - i; j++) { dp[j] = (sum[N - i] + MOD - sum[j]) % MOD; }
        }
        for (int j = 0; j <= N; j++) { sum[j] = (dp[j] + (j == 0 ? 0 : sum[j - 1])) % MOD; }
        std::fill(dp.begin(), dp.end(), 0);
    }
    std::cout << sum[N] << std::endl;
    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i, N)
    {
        cin >> D.at(i);
    }
    sort(D.begin(), D.end());
    reverse(D.begin(), D.end());
    int msize = D.at(0) + 1, cnt = 0;
    rep(i, N)
    {
        if (msize == D.at(i))
        {
            continue;
        }
        cnt++;
        msize = D.at(i);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	int sum = 0;
	for(int i=0;i<s.size();++i)
		sum += (int)(s[i]-'0');
	if(sum%9==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*
ll dx[8]={-1,-1,-1,0,0,1,1,1};
ll dy[8]={-1,0,1,-1,1,-1,0,1};
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
*/
int main()
{
     ll t,arr[15],a;
     for(int i=0;i<15;i++)
        arr[i]=0;
     cin>>t;
     for(int i=0;i<t;i++)
     {
         cin>>a;
         if(a<3200)
         arr[a/400]++;
         else
            arr[8]++;
     }
     int mn=0,mx=0,sum;
     for(int i=0;i<=7;i++)
     {
         mx+=(arr[i]>0);
     }
     mn=mx;
     mn=max(mn,1);
     cout<<mn<<" "<<mx+arr[8]<<endl;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

int ceil(int a, int b) {
	return (a + b - 1) / b;
}

void solve() {
	int d, g;
	cin >> d >> g;
	
	vi p(d), c(d);
	for(int i = 0; i < d; i++) cin >> p[i] >> c[i];
	
	int ans = inf;
	for(int msk = 0; msk < (1 << d); msk++) {
		int num = 0, score = 0;
		for(int i = 0; i < d; i++) if(msk & (1 << i)) num += p[i], score += c[i] + (i + 1) * 100 * p[i];
		for(int i = d - 1; i >= 0 && score < g; i--) {
			if(msk & (1 << i)) continue;
			num += min(p[i], ceil(g - score, 100 * (i + 1)));
			score += 100 * (i + 1) * min(p[i], ceil(g - score, 100 * (i + 1)));
		}
		
		if(score >= g) ans = min(ans, num);
	} 
	
	cout << ans << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<iostream>
using namespace std;
/*
int i_max(int data[],int size){
	int m=d[0];
	for(int i=1;i<size;i++) if(m<d[i]) m=d[i];
	return m;
}
int i_min(){
	int m=d[0];
	for(int i=1;i<size;i++) if(m>d[i]) m=d[i];
	return m;
}*/

int i_max(int p,int q){
	if(p>q) return p;
	return q;
}
int i_min(int p,int q){
	if(p<q) return p;
	return q;
}

int main(){
	int data;
	int max,min;
	int p,n;
	while(cin>>n){
		if(n==0) break;
		data=0;
		max=0;
		min=10000;
		for(int i=0;i<n;i++){
			cin>>p;
			data+=p;
			max=i_max(max,p);
			min=i_min(min,p);
		}
		data-=(max+min);
		data/=(n-2);
		cout<<data<<endl;
	}
	return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int64_t> A(N);
  vector<pair<int64_t,int>> B(M);
  
  for(int i=0;i<N;++i) cin>>A[i];
  for(int i=0;i<M;++i){
    int b;
    int64_t c;
    cin>>b>>c;
    B[i]=make_pair(c,b);
  }

  sort(A.begin(),A.end());
  sort(B.begin(),B.end(),greater<pair<int64_t,int>>());

  vector<int64_t> rewrite(N);
  int sz=0;
  for(int i=0;i<M;++i){
    for(int j=0;j<B[i].second;++j){
      if(sz<N){
      rewrite[sz]=B[i].first;
      ++sz;
      }
    }
    if(sz==N) break;
  }

  int64_t ans=0;
  for(int i=0;i<N;++i){
    ans += max(A[i],rewrite[i]);
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 3328