akhauriyash/Code-Regression huggingface dataset:
/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___ 
           __|__|
          |  |___       */
#include <bits/stdc++.h>
using namespace std;
 
 
//---------------------------------------------------MACROS----------------------------------------------------------
#define ll long long
#define ld long double
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back 
#define mp make_pair
#define nl "\n" 
#define vec(v , n) vector<ll> v(n)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pll pair<ll , ll>
#define mii map<int , int>
#define mll map<ll , ll>
#define msi map<string , int>
#define mci map<char , int>
#define f1 first
#define f2 second
#define inf 1e18 + 10

//---------------------------------------------------GLOBAL----------------------------------------------------------
const ll MOD = 1e9 + 7 ;
const ll MAX = 1e5 + 7 ;

//---------------------------------------------------FUNCTIONS-------------------------------------------------------

const ll nax = 2e5+5 ;
ll n , length , dp[nax] , height[nax] , values[nax] ;
vector<ll> tree ;

void solve(){
    scanf("%lld" , &n) ;
    beg(i , n) scanf("%lld" , height+i) ;
    beg(i , n) scanf("%lld" , values+i) ;
    ll p , len=1 , m_size=1 , best=0 ;
    while(m_size <= n){
    	m_size*=2 ;
    }
    tree.resize(2*m_size) ;
    beg(i , n){
    	best = 0 ;
    	for(ll j = height[i]+m_size ; j>1 ; j/=2){
    		if(j&1)
    			best = max(best , tree[j-1]) ;
    	}
    	dp[height[i]] = best + values[i] ;
    	for(ll j = height[i]+m_size ; j>=1 ; j/=2){
    		tree[j] = max(tree[j] , dp[height[i]]) ;
    	}
    }
    ll ans=0; 
    beg(i , n){
    	ans = max(ans , dp[height[i]]) ;
    }
    printf("%lld" , ans) ;
}

//---------------------------------------------------DRIVER----------------------------------------------------------
int main()
{
    fast ;
    int t=1 ;
    //scanf("%lld" , &t) ;
    while(t--){
        solve() ;
        //cout << "A" << nl ;
    }
    return 0;
}   

Measured memory_bytes: 9088
import Data.List
  
main = do
 [_,_,x,y] <- map read . words <$> getLine  :: IO [Int]
 xs <- sort . (x:).map read .words <$> getLine
 ys <- sort . (y:).map read .words <$> getLine
 putStrLn $ if ((xs++ys)) == (sort (xs++ys)) && ((xs++ys))==(nub(xs++ys)) then "No War" else "War"

Measured memory_bytes: 1020
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int N, M;
    cin >> N >> M;
    int A[M];
    REP(i, M) cin >> A[i];

    ll s = 0;
    REP(i, M) s += A[i];

    if (s <= N) cout << N - s << endl;
    else cout << -1 << endl;


    return 0;
}


Measured memory_bytes: 3636
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    count = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            k = x - i - j
            if j < k <= n:
                count += 1
    print(count)



Measured memory_bytes: 5596
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
    string N;

    cin >> N;

    if(N.find("9") != string::npos){
      cout << "Yes";
    }else{
      cout << "No";
    }
    cout  << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int P, Q, A, N;

int dfs(int p, int q, int n, int t){
	if(P * q == p * Q)return 1;
	if(P * q < p * Q)return 0;
	if(N == n)return 0;

	int ret=0;
	for(int i=t; q * i <= A; i++){
		ret+=dfs(p * i + q, q * i, n + 1, i);
	}

	return ret;
}

int main(){
	while(1){
		cin >> P >> Q >> A >> N;
		if(!P && !Q && !A && !N) break;
		cout << dfs(0, 1, 0, 1) << endl;
	}
	return 0;
}


Measured memory_bytes: 3012
#include <stdio.h>
#include <string.h>
int insert(char *);
int find(char *);
int getChar(char);
long long getKey(char *);
int h1(int);
int h2(int);
#define M 1046527
#define L 14

char H[M][L]; /* Hash Table */

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);

	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key)
{
  return key % M;
}
int h2(int key)
{
  return 1 + (key % (M - 1));
}

int find(char str[])
{
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++)
    {
      h = (h1(key) + i * h2(key)) % M;
      if(strcmp(H[h],str)==0)
        return 1;
      else if(strlen(H[h])==0)
        return 0;
    }
    return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++)
    {
      h = (h1(key) + i * h2(key)) % M;
      if(strcmp(H[h],str)==0)
        return 1;
      else if(strlen(H[h])==0)
      {
        strcpy(H[h],str);
        return 0;
      }
   }
   return 0;
}



Measured memory_bytes: 16052
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {
	ll n, k, q,a;
	in(n);
	in(k);
	in(q);

	vll score(n, 0);
	rep(i, 0, q) {
		in(a);
		score[a - 1]++;
	}

	rep(i, 0, n) {
		if (q - score[i] < k) {
			outn("Yes");
		}
		else {
			outn("No");
		}
	}
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> v, P, Q;
  rep(i, N) {
    v.push_back(i + 1);
    int x;
    cin >> x;
    P.push_back(x);
  }
  rep(i, N) {
    int x;
    cin >> x;
    Q.push_back(x);
  }
  int a = 0, b = 0, c = 0;
  do {
    c++;
    if (v == P) {
      a = c;
    };
    if (v == Q) {
      b = c;
    }
  } while (next_permutation(v.begin(), v.end()));
  int ans = a - b;
  if (ans < 0) ans = -1 * ans;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const int N = 102;

int b[N];

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i < n; ++i)
        cin >> b[i];
    int ans(0);
    ans += b[1] + b[n - 1];
    for (int i = 2; i < n; ++i)
        ans += min(b[i], b[i - 1]);
    cout << ans;
    return 0;
}


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

void fnInput(vector<string>& rvsStrX, vector<string>& rvsStrY)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvsStrX.resize(nMaxSiz);
  rvsStrY.resize(nMaxSiz);

  for (int i = 0; i < nMaxSiz; ++i)
  {
    cin >> rvsStrX[i] >> rvsStrY[i];
    rvsStrX[i] = ' ' + rvsStrX[i];
    rvsStrY[i] = ' ' + rvsStrY[i];
  }
}

int fnLngCmnSubseq(const vector<string>& cnrvsStrX, const vector<string>& cnrvsStrY)
{
  for (int i = 0; i < cnrvsStrX.size(); ++i)
  {
    const int nMAXNX = cnrvsStrX[i].size();
    const int nMAXNY = cnrvsStrY[i].size();
    vector<vector<int>> vvnLcsDP(nMAXNX, vector<int>(nMAXNY, 0));

    for (int nx = 1; nx < nMAXNX; ++nx)
      for (int ny = 1; ny < nMAXNY; ++ny)
        if (cnrvsStrX[i][nx] == cnrvsStrY[i][ny])
          vvnLcsDP[nx][ny] = vvnLcsDP[nx - 1][ny - 1] + 1;
        else
          vvnLcsDP[nx][ny] = max(vvnLcsDP[nx - 1][ny], vvnLcsDP[nx][ny - 1]);

    cout << vvnLcsDP[nMAXNX - 1][nMAXNY - 1] << endl;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> vsStrX, vsStrY;

  fnInput(vsStrX, vsStrY);
  fnLngCmnSubseq(vsStrX, vsStrY);
  return 0;
}

Measured memory_bytes: 6868
def main():
    cards = {
        'S': [0] * 13,
        'H': [0] * 13,
        'C': [0] * 13,
        'D': [0] * 13
    }

    n = int(input())
    for _ in range(n):
        a, b = input().split()
        cards[a][int(b) - 1] = 1

    for a, b in cards.items():
        for i in range(13):
            if b[i] == 0:
                print(a, i + 1)


main()



Measured memory_bytes: 5600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    long long int i, j, n, x, ans=0, po=0;
    scanf("%lld", &x);
    if(x>=30) printf("Yes");
    else printf("No");
    
}

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

using namespace std;

int main(){
    int sum = 0, N, max = 0;
    cin>>N;
    int A[N][2];
    for(int i=0 ; i<2 ; i++){
        for(int j=0 ; j<N ; j++)
            cin>>A[j][i];
    }
    for(int i=0 ; i<N; i++){
        for(int j=0 ; j<=i ; j++)
            sum += A[j][0];
        for(int k=i ; k<N ; k++)
            sum += A[k][1];
        if(sum > max)
            max = sum;
        sum = 0;
    }
    cout<<max<<'\n';
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}
vector<string> ans;
void dfs(string s,int depth,char back){
  if(depth == 0){
    ans.push_back(s);
    return;
  }
  for(int i = 'a'; i <= back+1; ++i)dfs(s+char(i),depth-1,max((int)back,i));
}
int main(){
  int n; cin >> n;
  string s = "a";
  dfs(s,n-1,'a');
  sort(ans.begin(), ans.end());
  for(string&e:ans)cout << e << endl;
  return 0;
}


Measured memory_bytes: 7796
N, K = map(int, input().split())
A = list(map(lambda x: x - 1, map(int, input().split())))
current = 0
memo = {
    0: 0
}
for i in range(1, K + 1):
    current = A[current]
    if current in memo:
        # loop length
        length = i - memo[current]
        tmp = (K - memo[current]) % length
        for j in range(tmp):
            current = A[current]
        break
    else:
        memo[current] = i
print(current + 1)

Measured memory_bytes: 32368
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;
int main(){
    ll n, y;
    cin >> n >> y;
    ll sum;
    rep(i,n+1){
        for(int j = 0; j < n+1-i;j++){
            int thou = n - j - i;
            sum = y - i*10000 - j*5000;
            if(sum == thou*1000){
                cout << i << " " << j 
                << " " << thou << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " <<-1 << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    char n[11];
    scanf("%s", n);
    int sum = 0;
    int len = strlen(n);
    for (int i=0; i<len; i++)
    {
        sum += n[i] - '0';
    }
    if (atoi(n)%sum == 0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a>b?b:a;}


ll f(ll a, ll b) {
  if(a==b) return 0;
  if(a-b==1) return 1;
  if(a-b==2) return -1;
  if(a-b==-1) return -1;
  if(a-b==-2) return 1;
  return 999;
}

int main(void) {
  string s, t;
  cin >> s >> t;
  ll Q;
  cin >> Q;
  ll i;
  ll sa[MAX]={}, sb[MAX]={};
  ll ta[MAX]={}, tb[MAX]={};
  
  for(i=0; i<s.size(); i++) {
    if(s[i]=='A') {
      sa[i+1]=sa[i]+1;
      sb[i+1]=sb[i];
    }else {
      sa[i+1]=sa[i];
      sb[i+1]=sb[i]+1;
    }
  }
  
  for(i=0; i<t.size(); i++) {
    if(t[i]=='A') {
      ta[i+1]=ta[i]+1;
      tb[i+1]=tb[i];
    }else {
      ta[i+1]=ta[i];
      tb[i+1]=tb[i]+1;
    }
  }
  
  for(i=0; i<Q; i++) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    
    ll SA=(sa[b]-sa[a-1])%3;
    ll SB=(sb[b]-sb[a-1])%3;
    ll TA=(ta[d]-ta[c-1])%3;
    ll TB=(tb[d]-tb[c-1])%3;
    
    if(f(SA, SB)==f(TA, TB)) pt("YES");
    else pt("NO");
    
  }
  
  
}






Measured memory_bytes: 3968
#include<cstdio>
#include<cstring> 
#include<iostream>
#include<algorithm>
using namespace std;
const int M=1200000;
unsigned long long ans,d,c,sum;int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%llu%llu",&d,&c) ,sum+=c,ans+=d*c;
	
	printf("%llu",sum+(ans-1)/9-1);
		
}

Measured memory_bytes: 256
#include <string.h>
int main()
{
    char s[100000],a[50000];
    int i,j=0;
    gets(s);
    for(i=0;s[i];i++)
        if(i%2==0)
            a[j++]=s[i];
    a[j]='\0';
    puts(a);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

void DispArr(int32_t arr[], int32_t len) {
	printf("%d", arr[0]);
	for (int32_t i = 1; i < len; i++) {
		printf(" %d", arr[i]);
	}
	putchar('\n');
}

void Swap(int32_t *a, int32_t *b) {
	int32_t tmp = *a;
	*a = *b;
	*b = tmp;
}

void SelectionSort(int32_t arr[], int32_t len) {
	int32_t swapCnt = 0;
	for (int32_t i = 0; i < len; i++) {
		int32_t minPos = i;
		for (int32_t j = i+1; j < len; j++) {
			minPos = (arr[minPos] > arr[j]) ? j : minPos;
		}
		if (minPos != i) {
			Swap(&arr[i], &arr[minPos]);
			swapCnt++;
		}
	}
	DispArr(arr, len);
	printf("%d\n", swapCnt);
}

int main() {
	int32_t dataNum;
	scanf("%d", &dataNum);

	int32_t *data = (int32_t *)calloc(dataNum, sizeof(int32_t));
	if (!data) return 1;

	for (int32_t i = 0; i < dataNum; i++) {
		scanf("%d", &data[i]);
	}
	
	SelectionSort(data, dataNum);
	return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#include<vector>
 
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007struct $
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define arraysize(ar)  (sizeof(ar) / sizeof(ar[0]))

using namespace std;

int a,b,c;
string s;



signed main(){

     
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int X,A;
 		cin>>X>>A;
 		if(X<A) cout<<0;
  		else cout<<10;

    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

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

		long n = Long.parseLong(sc.next());
		long m = Long.parseLong(sc.next());

		long ans = Math.min(n, m / 2);
		m -= ans * 2;
		ans += Math.max(0, m / 4);

		System.out.println(ans);
		sc.close();
	}
}

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


int main(){
    int a;
    cin >>a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>

using namespace std;

int main(void){

    int a;

    int b;

    cin >> a >> b;

    if(a < b){

        cout << "a" << " < " << "b" << endl;

    }
    
    if(a > b){

       cout <<  "a" << " > " << "b" << endl;

    }

    if(a == b){

        cout << "a" << " == " << "b" << endl;

    }

    return 0;
    
} 

Measured memory_bytes: 1156
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
#include <vector>

//UnionFind
class UnionFind
{
  public:
    UnionFind(int size_) : parent(size_, -1), __size(size_) {}
    void unite(int x, int y)
    {
        if ((x = find(x)) != (y = find(y)))
        {
            if (parent[y] < parent[x])
                std::swap(x, y);
            parent[x] += parent[y];
            parent[y] = x;
            __size--;
        }
    }
    bool is_parent(int x) { return find(x) == x; }
    bool is_same(int x, int y) { return find(x) == find(y); }
    int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
    int size(int x) { return -parent[find(x)]; }
    int size() const { return __size; }

  private:
    std::vector<int> parent;
    int __size;
};
//UnionFind
int N, M;
vector<pii> XY;
vector<int> P;
int main()
{
    cin >> N >> M;
    P.resize(N);
    for (auto &val : P)
    {
        cin >> val;
        val--;
    }
    XY.resize(M);
    UnionFind ut(N);
    for (auto &val : XY)
    {
        cin >> val.first >> val.second;
        val.first--;
        val.second--;
        ut.unite(val.first, val.second);
    }
    int res = 0;
    for (int i = 0; i < N; i++)
    {
        int a = P[i];
        int b = i;
        if (ut.is_same(a, b))
        {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int H,W;
vector<string> S;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> H >> W;
    for (int i = 0; i < H; i++)
    {
        string s; cin >> s;
        S.push_back(s);
    }
}

bool isIN(int x, int y){
    return (0<=x && x<H && 0<=y && y<W);
}

bool chk(int i, int j){
    bool ret=false;
    for (int k = 0; k < 4; k++)
    {
        int x=i+dx[k];
        int y=j+dy[k];
        if(!isIN(x,y)) continue;
        ret |= (S[x][y]=='#');
    }
    return ret;    
}

bool solve(){
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if(S[i][j]=='.') continue;
            if(chk(i,j)) continue;
            return false;
        }        
    }
    return true;
}   

int main()
{
    input();
    cout << (solve()?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
const long long mod = 1000000007;
const long long inf = 1145141919810;
typedef pair<int, int> P;
typedef pair<P, P> PP;
struct edge {int to, cost;};
vector<edge>G[10007];
int t[10007],d[3][10007][201];

void dijk(int s, int x) {
	rep(i, 3)
		rep(j, 10005)
		rep(k,201)d[i][j][k] = inf;
	d[0][s][0] = 0;
	priority_queue<PP, vector<PP>, greater<PP>>Q;
	Q.push(PP(P(0, s), P(0, t[s])));
	while (Q.size()) {
		PP p = Q.top();
		int v = p.first.second;
		Q.pop();
		if (d[p.second.second][v][p.second.first] < p.F.F)continue;
		rep(i, G[v].size()) {
			edge e = G[v][i];
			if (p.second.second == 0) {
				if (t[e.to] == 0) {
					if (d[0][e.to][0] > d[0][v][p.second.first] + e.cost) {
						d[0][e.to][0] = d[0][v][p.second.first] + e.cost;
						Q.push(PP(P(d[0][e.to][0], e.to), P(0, 0)));
					}
				}
				else if (t[e.to] == 1) {
					int ld = min(x, e.cost + p.second.first);
					if (d[0][e.to][ld] > d[0][v][p.second.first] + e.cost) {
						d[0][e.to][ld] = d[0][v][p.second.first] + e.cost;
						Q.push(PP(P(d[0][e.to][ld], e.to), P(ld, 0)));
					}
				}
				else {
					int ld =min(x, p.second.first + e.cost);
					if (d[2][e.to][0] > d[0][v][p.second.first] + e.cost&&ld == x) {
						d[2][e.to][0] = d[0][v][p.second.first] + e.cost;
						Q.push(PP(P(d[2][e.to][0], e.to), P(0, 2)));
					}
				}
			}

			else {
				if (t[e.to] == 2) {
					if (d[2][e.to][0] > d[2][v][p.second.first] + e.cost) {
						d[2][e.to][0] = d[2][v][p.second.first] + e.cost;
						Q.push(PP(P(d[2][e.to][0], e.to), P(0, 2)));
					}
				}
				else if (t[e.to] == 1) {
					int ld = min(x, e.cost + p.second.first);
					if (d[2][e.to][ld] > d[2][v][p.second.first] + e.cost) {
						d[2][e.to][ld] = d[2][v][p.second.first] + e.cost;
						Q.push(PP(P(d[2][e.to][ld], e.to), P(ld, 2)));
					}
				}
				else {
					int ld = min(x,p.second.first + e.cost);
					if (d[0][e.to][0] > d[2][v][p.second.first] + e.cost&&ld == x) {
						d[0][e.to][0] = d[2][v][p.second.first] + e.cost;
						Q.push(PP(P(d[0][e.to][0], e.to), P(0, 0)));
					}
				}
			}
		}
	}
}
signed main() {
	int n, m, x; cin >> n >> m >> x;
	rep(i, n)cin >> t[i];
	rep(j, m) {
		int a, b, c; cin >> a >> b >> c;
		a--, b--;
		G[a].push_back({ b,c });
		G[b].push_back({ a,c });
	}
	dijk(0, x); 
	int ans = inf;
	rep(i, 3)
		rep(j, 201)ans = min(ans, d[i][n-1][j]);
	cout << ans << endl;
}


Measured memory_bytes: 51564
// abc050_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N;
    cin >> N;
    vector<ll> T(N);
    REP(i, N) cin >> T[i];

    ll sm = accumulate(ALL(T), 0);

    int M;
    cin >> M;
    REP(i, M){
        ll p, x;
        cin >> p >> x;
        print(sm + x - T[p-1]);
    }

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

int main(){
    int n,W;
    std::cin >> n>>W;
    //std::cout << n << std::endl;
    vvector(dp,int,n+1,12000,0);
    rep(i,n+1)dp[i][0]=0;
    std::vector<int> v(n),w(n);
    rep(i,n)std::cin >> v[i]>>w[i];
    rep(i,n){
        rep(j,10001){
            dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
            dp[i+1][j+w[i]]=max(dp[i][j+w[i]],dp[i][j]+v[i]);
        }
    }
    int ans=-INF;
    rep(i,W+1){
    //    std::cout << dp[n][i] << std::endl;
        ans=max(ans,dp[n][i]);
    }
    std::cout << ans << std::endl;
}


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

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

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

void enqueue(P x){
  Q[tail]= x;
  tail = (tail + 1 ) % LEN;
}

P dequeue(){
  P x;
  x= Q[head];
  head = (head+ 1)% LEN;
  return x;
}

int min(int a, int b){
  if(a< b){
    return a;
  }
  else return b;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  head=1;

 cin >> n;
 cin >> q;
  tail = n+1;
  for ( i = 1; i <= n; i++){
  cin>> Q[i].name ;
  cin>> Q[i].t ;

  }

while(head != tail){
  u=dequeue();
  c = min(q, u.t);
  u.t -= c;
  elaps += c;
  if(u.t > 0){
    enqueue(u);
  }
  else{
    cout<< u.name << " " <<elaps <<endl;
  }
}

  return 0;
}



Measured memory_bytes: 13212
import math

N,M=map(int,input().split())
MR=math.ceil(math.sqrt(M))

LISTM=[]
for i in range(1,MR+1):
    if M%i==0:
        LISTM.append(i)
        LISTM.append(M//i)
    
LISTM.sort()
LISTM.reverse()

for j in LISTM:
    if j<=M//N:
        print(j)
        break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
	int n,k,i,j;
	cin>>n>>k;
	vector<char> d(k);
	loop(i,0,k){
		cin>>d[i];
	}
	while(1){
		bool flag=false;
		string s=to_string(n);
		loop(i,0,s.size()){
			loop(j,0,d.size()){
				if(s[i]==d[j]){
					flag=true;
					break;
				}
			}
		}
		if(flag){
			n++;
		}else{
			cout<<n<<endl;
			break;
		}
	}
}

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

long long int answ(long long int x){
  if(x==1) return 1;
  if(x>1) return 2*answ(x/2)+1;
}
int main() {
    char b;
    cin>>b;
    if(b=='A') cout<<"T"<<endl;
    if(b=='T') cout<<"A"<<endl;
    if(b=='G') cout<<"C"<<endl;
    if(b=='C') cout<<"G"<<endl;



}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stack>

using namespace std;

int main(int argc, char const *argv[]) {

	int n, m, x, y, c = 1;
	
	scanf("%d %d", &n, &m);

	vector<pair<int, bool> > cajas(n, pair<int, bool>(1, false));
	cajas[0].second = true;

	while(m--) {
		scanf("%d %d", &x, &y);
		cajas[x-1].first--;
		cajas[y-1].first++;
		if(cajas[x-1].second) {
			if(!cajas[y-1].second) {
				cajas[y-1].second = true;
				c++;
			}
		}
		if(cajas[x-1].first == 0 && cajas[x-1].second) {
			cajas[x-1].second = false;
			c--;
		}
	}
	printf("%d\n", c);

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;
    return 0;
}


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

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define ZERO(a) memset(a,0,sizeof(a))

const int M = 1500;
ll h[M+5], w[M+5];

void solve(int H, int W) {
    ZERO(h); ZERO(w);
    FOR(i,1,H+1) scanf("%lld", &h[i]);
    FOR(i,1,W+1) scanf("%lld", &w[i]);

    rep(i,H) h[i+1] += h[i];
    rep(i,W) w[i+1] += w[i];

    map<ll,ll> nums;
    FOR(i,1,W+1) rep(j,i) nums[w[i]-w[j]]++;

    ll ans = 0;
    FOR(i,1,H+1) {
        rep(j,i) {
            ll height = h[i] - h[j];
            ans += nums[height];
        }
    }

    cout << ans << endl;
}

int main() {
    int H, W;
    while(cin>>H>>W, H) solve(H,W);
    return 0;
}

Measured memory_bytes: 26824
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<set<pair<int,int> > >tree(n);
    int a[n-1];
    int b[n-1];
    for(int i=0;i<n-1;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        tree[a[i]].insert(make_pair(b[i],i));
    }
    int maxx = 0;
    vector<int>colors(n);
    queue<pair<int,int> >que;
    que.push(make_pair(0,0));
    while(!que.empty()){
        int next = que.front().first;
        int hen = que.front().second;
        que.pop();
        if(hen > maxx)maxx = hen;
        int tmp=0;
        for(auto j: tree[next]){
            tmp++;
            if(tmp == hen)tmp++;

            que.push(make_pair(j.first,tmp));
            colors[j.second] = tmp;
        }
    }

    cout << maxx << endl;
    for(int i=0;i<n-1;i++)cout<<colors[i] << endl;
    
    
}


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

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S.at(i);
    }
    for (int i = 0; i < N; i++)
    {
        if (S[i] == "Y")
        {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}


Measured memory_bytes: 256
'use strict'

/////////////////////////////////////
//コピペスペース//////////////////////

//定数
const INF  =  900719925474099 // Math.floor(Number.MAX_SAFE_INTEGER / 10);

//スペース区切りの数字列を数字の配列にして返す
function mapint(line){return line.split(' ').map((v)=>parseInt(v));}

function lower_bound(d,a,b,e){
    for(var c;1<b-a;)
        d[c=0|(a+b)/2]<e ? a=c : b=c;
    return d[a]<e?b:a
};

const MOD = 1000000007;

//コピペスペース//////////////////////
/////////////////////////////////////

function Main(input){
	let temp = input.trim().split('\n');
	let n = parseInt(temp[0]);
	let a = mapint(temp[1]);

	let x = new Array(n);
	let hugo = 1;
	x[0] = 0;
	for(let i=0;i<n;i++){
		x[0] += hugo * a[i];
		hugo *= -1;
	}
	a[n-1] -= x[0]/2;
	for(let i=1;i<n;i++){
		x[i] = 2 * a[i-1] - x[i-1];
	}
	console.log(x.join(' '));

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main()
{
    int k;
    cin >> k;
    ll x = 7%k;
    for(int i=1; i<=k;i++){
        if(x==0) {
            cout << i << endl;
            return 0;
        }
        x = (10*x+7)%k;
    }
    cout << -1 << endl;
    return 0;
}

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

int A[3];

int main()
{
	for(int i=0; i<3; i++) cin>>A[i];
	
	sort(A, A+3);
	
	cout<<10*A[2]+A[1]+A[0]<<'\n';
	
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    w, h, x, y = get_li()
    area = w * h / 2
    multiple = 1 if w // 2 == x and w % 2 == 0 and h // 2 == y and h % 2 == 0 else 0
    print(area, multiple)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()


Measured memory_bytes: 65388
A, B, C = map(int,input().split())

if A == 1 and B == 1 and C == 1:
    print(0)
    exit()

elif A == B == C:
    print(-1)
    exit()

LA = []
LB = []
LC = []
LA.append(A)
LB.append(B)
LC.append(C)
i = 0
cnt = 0

while LA[i] % 2 == 0 and LB[i] % 2 == 0 and LC[i] % 2 == 0:
    LA.append((LB[i]+LC[i])/2)
    LB.append((LC[i]+LA[i])/2)
    LC.append((LA[i]+LB[i])/2)
    i += 1
    cnt += 1

print(cnt)

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

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

int main()
{
  int m, n;
  bool a[1000010];
  int b[1000010];

  for(int i = 0; i < 1000010; i++) a[i] = false;

  for(int i = 1; i < 1000010; i *= 5) {
    for(int j = 1; i * j < 1000010; j *= 3) {
      for(int k = 1; i * j * k < 1000010; k *= 2) {
        a[i * j * k] = true;
      }
    }
  }

  b[0] = 0;
  for(int i = 1; i < 1000010; i++) {
    b[i] = b[i - 1] + (a[i] ? 1 : 0);
  }
  while(cin >> m, m){
    cin >> n;
    cout << b[n] - b[m - 1] << endl;
  }
}

Measured memory_bytes: 6040
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    map<long long, int> ma;
    for(int i=0; i<n; i++){
        long long t;
        cin >> t;
        ma[t]++;
    }
    for(int i=0; i<m; i++){
        long long b,c;
        cin >> b >> c;
        ma[c] += b;
    }
    long long sum = 0;
    int c = 0;
    for(auto e = ma.rbegin(); e != ma.rend(); e++){
        if(e->second <= n){
            sum += e->first * e->second;
            n -= e->second;
        }else{
            sum += e->first * n;
            break;
        }
    }
    
    cout << sum << endl;
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
typedef long long ll;

const int MAX_N=2e5;	
const ll INF=1e12;
int N;
ll A[MAX_N];

int main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	ll lb=-INF,ub=INF;
	while(ub-lb>1){
		ll mid=(lb+ub)/2;
		int c1,c2;
		c1=c2=0;
		REP(i,N){
			if (A[i]>mid+i+1){
				c1++;
			}else{
				c2++;
			}
		}
		if (c1<=c2){
			ub=mid;
		}else{
			lb=mid;
		}
	}
	ll ans=0;
	REP(i,N){
		ans+=llabs(A[i]-(ub+i+1));
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    ll x, y;
    cin >> x >> y;

    ll tmp_x = x;
    ll cnt = 0;
    while ( 1 ) {
        if ( tmp_x > y ) {
            break;
        }
        cnt++;
        tmp_x *= 2;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read(){
	int sum = 0, t = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') t = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ sum = sum * 10 + ch - '0'; ch = getchar(); }
	return sum * t;
}

int n;
int f[10], g[10];

int main(){
	n = read();
	for(int i = 0; i < 10; i++) f[i] = -0x3f3f3f3f;
	f[0] = 0;
	for(; n ; n--){
		int x = read();
		swap(f, g);
		for(int i = 0; i < 10; i++)
			f[(i + x) % 10] = max(g[(i + x) % 10], g[i] + x);
	}
	int ans = 0;
	for(int i = 1; i < 10; i++) ans = max(ans, f[i]);
	printf("%d\n", ans);
}


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

int main(){
    ll a;
    char b_[8];
    long double c;
    cin >> a >> c;
    int b=0;
    if(b_[0] != '.') b+=(b_[0]-'0')*100;
    if(b_[1] != '\0'){
        if(b_[2] != '\0'){
            b+=(b_[2]-'0')*10;
            if(b_[3] != '\0'){
                b+=(b_[3]-'0');
            }
        }
    }
    ll ans;
    ans = a*b;
    ans /=100;
    ans = a*c;
    cout << ans << endl;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int INF = 0x3f3f3f3f;
const ll  LINF = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

// sqrt(x^2 + y^2) <= d
// x^2 + y^2 <= d^2

void solve(){
    int n,ans=0;
    ll d;
    cin>>n>>d;
    for(int i=0;i<n;++i){
        ll x,y;
        cin>>x>>y;
        if(x*x + y*y <= d*d)
            ++ans;
    }
    cout<<ans<<endl;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

char f[102][102];

void DFS(int x,int y,char c){
    if(f[x][y]!=c)  return;

    f[x][y]='.';

    DFS(x+1,y,c);
    DFS(x-1,y,c);
    DFS(x,y-1,c);
    DFS(x,y+1,c);
}

int main(){
    int H,W;
    while(1){
        cin>>H>>W;
        if(H+W==0)  break;
        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                cin>>f[i][j];
            }
        }

        int cnt=0;
        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                if(f[i][j]!='.'){
                    cnt++;
                    DFS(i,j,f[i][j]);
                }
            }
        }
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 3376
q=int(input())
max=100001
is_prime =[1]*max
is_prime[0] = 0
is_prime[1] = 0
for i in range(2,max):
    if not is_prime[i]:
        continue
    for j in range(i*2,max,i):
        is_prime[j] = 0

a=[0]*(max+1)
for i in range(max):
    if i%2==0:
        continue
    if is_prime[i]==1 and is_prime[(i+1)//2]:
        a[i]=1

s=[0]*(max+1)
for i in range(max):
    s[i+1]=s[i]+a[i]

for i in range(q):
    l,r=map(int,input().split())
    print(s[r+1]-s[l])

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

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    cout << max(0LL, C - (A - B)) << endl;
    return 0;
}


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


typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vtype; ///for typecasting array into a vector
#define all(x) x.begin(),x.end()
#define alls(x) begin(x), end(x)
#define read(x) freopen(#x, "r", stdin);
#define write(y) freopen(#y, "w", stdout);
#define faster() {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define pb push_back
#define pf push_front
#define forn(n) for(int i=0; i<n; i++)
#define fori(xxx,xxy) for(int i=xxx; i<=xxy; i++)
#define forj(yyy,yyx) for(int j=yyy; j<=yyx; j++)
#define sc(frt) scanf("%d", &frt)
#define newline cout<<'\n';
#define test cout<<"came here\n";
#define PI 3.1415926535
#define bset(a,x) ((a)(1<<(x)))
#define bclr(a,x) ((a)&(~(1<<(x))))
#define bchk(a,x) ((a)>>(x))&(1)

int mod(int& x, int& m)
{
    int r = x%m;
    return r<0 ? r+m : r;
}

#ifdef sony

///-----------debugger starts here-----------

vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}

#define debug(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}

inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }

template<typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __evars_out_var(a);
    cerr << "; ";
    __evars(++it, args...);
}


///----------debugger ends here----------------


#endif // sony




int main()
{
    #ifdef sony
    read(in.txt)
    //write(out.txt)
    #endif

    faster()

    ll n,a,b;

    cin >> n >> a >> b;

    ll tot = a+b;

    ll rem = n%tot;

    ll ans = rem>=a? a : rem;

    ans += n/tot*a;

    cout << ans;



    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    if (right < v.size() && v[right] == target)
    {
        return right;
    }
    return -1;
}

int main(int argc, const char *argv[])
{
    int n;
    cin >> n;
    cout << (n - 2) * 180 << endl;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		HashMap<String, Integer> hashMap = new HashMap<>();

		String st = br.readLine();
		String[] st2 = st.split("");

		for (int i = 0; i < st.length(); i++) {
			if (hashMap.containsKey(st2[i])) {
				System.out.println("no");
				System.exit(0);
			} else {
				hashMap.put(st2[i], i);
			}
		}
		System.out.println("yes");
	}
}


Measured memory_bytes: 23252
N = int(input())

ans = [0] * (N-1)
to = [[] for i in range(N-1)]
used = [0] * N

for i in range(N-1):
    a, b = map(int, input().split())
    to[a-1].append([b-1, i])

for i in range(N-1):
    unable = used[i]
    c = 1
    for j, id in to[i]:
        if c == unable:
            c += 1
        ans[id] = c
        used[j] = c
        c += 1

print(max(used))
for i in range(N-1):
    print(ans[i])

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

using namespace std;

int main(void) {
	int N;
	long long ans=0;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  string s;cin>>s;
  int n=s.size();
  ll ans=0;
  rep(bit,1<<(n-1)){
    ll a=s[0]-'0';
    rep(i,n-1){
      if(bit&(1<<i)){
        ans+=a;
        a=0;
      }
      a=a*10+s[i+1]-'0';
    }
    ans+=a;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632