akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int co = 0;
    int ans = n;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == 'R' && s[i + 1] == 'L') {
            co++;
        }
    }
    int c2 = 0;
    if (s[0] == 'L') {
        c2++;
    }
    if (s[n - 1] == 'R') {
        c2++;
    }
    ans -= co * 2;
    ans -= c2;
    if (c2 > 0) {
        if (k >= co) {
            k -= co;
            ans += co * 2;
        } else {
            ans += k * 2;
            k = 0;
        }
        if (k >= c2 - 1) {
            ans += c2 - 1;
        }
    } else {
        if (k >= co - 1) {
            k -= co - 1;
            ans += (co - 1) * 2;
        } else {
            ans += k * 2;
            k = 0;
        }
        if (k > 0) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>


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

	int NUM;

	scanf("%d", &NUM);

	int *data = (int*)malloc(sizeof(int) * NUM);

	for (int i = 0; i < NUM; i++){
		scanf("%d", &data[i]);
	}

	//?????????????????????????????????NUM-1??¨??????
	for (int j = 0; j < NUM - 1; j++){
		printf("%d ", data[j]);
	}
	printf("%d\n", data[NUM - 1]);

	for (int i = 1; i < NUM; i++){
		int min = i;

		for (int j = i; j > 0; j--){
			//??\???????????????
			if (data[j - 1] > data[j]){
				int temp = data[j - 1];
				data[j - 1] = data[j];
				data[j] = temp;
			}
			else
				break;
		}

		//?????????????????????????????????NUM-1??¨??????
		for (int j = 0; j < NUM-1; j++){
			printf("%d ",data[j]);
		}
		printf("%d\n",data[NUM-1]);
	}


	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bs binary_search
#define pb push_back
#define pp pair<ll,ll>
#define all(v) v.begin(),v.end()
#define F first 
#define S second 
#define lc "\n"
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
int main() 
{
    fastio
    ll n,i; cin>>n; ll a[n],b[n]={0};
    for(i=0;i<n;i++) cin>>a[i];
    b[0]=0; b[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
    cout<<b[n-1];
    return 0;
}

Measured memory_bytes: 5196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int gcd(int x, int y);
int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	long long int N, X;
	cin >> N >> X;

	// Xからの距離を保存する
	vector<int> xl;
	for(int i=0; i<N; i++) {
		int x;
		cin >> x;
		xl.push_back(abs(X - x));
	}
	
	int ans = xl.at(0);

	for(int i=1; i<N; i++) {
		ans = gcd(ans, xl.at(i));
	}


	cout << ans;

	return 0;
}

int gcd(int x, int y) {
	
	if(x < y) {
		int tmp = y;
		y = x;
		x = tmp;
	}
	while(x%y) {
		int tmp = x%y;
		x = y;
		y = tmp;
	}
	return y;
}

Measured memory_bytes: 892
#include<stdio.h>
  
#define AMAX 20
#define MMAX 200
 
int A[AMAX+1];
int n, q;
 
int solve( int p, int t )
{
	if( 0 == t ) { return 1; }
	return  ( p < n ) ? solve( p+1, t-A[p] ) || solve( p+1, t ): 0 ;
}
 
int main( void ) 
{
    int i;
    int num;
     
    scanf( "%d", &n );  
    for( i=0; i<n; i++ ) {
        scanf( "%d", &A[i] );
    }   
    scanf( "%d", &q );
    for( i=0; i<q; i++ ) {
        scanf( "%d", &num );
        if( solve( 0, num ) ) {
            printf( "yes\n" );      
        } else {
            printf( "no\n" );
        }
    }
  
    return 0;
}

Measured memory_bytes: 580
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    int sum = 0;
    int[] num = new int[N+1];
    for(int i = 1; i <= N; i++){
      num[i] = Integer.parseInt(S[i-1]);
      sum += Math.abs(num[i]-num[i-1]);
    }
    sum += Math.abs(num[N]);
    for(int i = 1; i <= N; i++){
      int ans = sum;
      if(i != N){
        ans -= Math.abs(num[i]-num[i-1]);
        ans -= Math.abs(num[i]-num[i+1]);
        ans += Math.abs(num[i-1]-num[i+1]);
      }else{
        ans -= Math.abs(num[i]-num[i-1]);
        ans -= Math.abs(num[N]);
        ans += Math.abs(num[N-1]);
      }
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 62796
import fractions
import collections


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

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

g = fractions.gcd(a,b)
c = collections.Counter(prime_factorize(g))
print(len(c)+1)

Measured memory_bytes: 64236
#include<iostream>
using namespace std;
int main()
{
    int a[100];
    int n,i,j,temp,count=0;cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n-1;i++)
    {
        for(j=0;j<n-i-1;j++)
        {
            if(a[j]>a[j+1])
            {
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
                count++;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        if(i>0&&i!=n)
        cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<count<<endl;
    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define endl '\n'
#define szfor(i,x) for(size_t i=0;i<x.size();i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
ll MAX=1e17;

int main(){
    fast_io;
    ll n,m;
    cin>>n>>m;
    ll a=1900,b=100;
    ll t=a*(m) + b*(n-m);
    for (int i = 0; i < m; ++i)
       {
            t*=2;
       }   
    show(t);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Queue;
import java.util.ArrayDeque;



public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		long sum = 0;
		for(int i = 0; i < n - 1; ++i) {
			sum+=a[i+1];
		}
		long ans = 0;
		for(int i = 0; i < n - 1; ++i) {
			ans+=(a[i]%(long)(Math.pow(10, 9)+7))*(sum%(long)(Math.pow(10, 9)+7));
			ans%=(long)(Math.pow(10, 9)+7);
			sum-=a[i+1];
		}
		System.out.println(ans);
	}
}



Measured memory_bytes: 51240
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

class bipartite_matching {
public:
    int n;
    std::vector<std::vector<int>> g;
    std::vector<int> match;

    bipartite_matching(int n_) : n(n_), g(n_), match(n_), used(n_) {}

    void add_edge(int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int maximum_matching(void) {
        int res = 0;
        fill(begin(match), end(match), -1);
        for (int v = 0; v < n; ++v) {
            if (match[v] == -1) {
                fill(begin(used), end(used), false);
                if (dfs(v)) res++;
            }
        }
        return res;
    }

private:
    std::vector<int> used;
    bool dfs(int v) {
        used[v] = true;
        for (int u : g[v]) {
            int w = match[u];
            if (w == -1 || (!used[w] && dfs(w))) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }
};

struct edge{
  ll to, num, use;
  edge(ll t, ll n, ll u):to(t), num(n), use(u){};
};

typedef pair<ll, ll> pl;
int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  vvl d = VV(n, m, 0, ll);
  re(i, n) re(j, m) scanf("%lld", &d[i][j]);

  vector<vector<edge>> G(n+1);

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      ll r = i;
      ll ar = (d[i][j]-1)/m;
      G[r].push_back(edge(ar, d[i][j], 0));
    }
  }

  map<ll, ll> num_col;
  for(int c=0;c<m;c++){
    multiset<pl> st;
    bipartite_matching bp(2*n);
    //使われていない辺を張る
    re(i,n) for(auto e:G[i]) if(!e.use) bp.add_edge(i, n+e.to);
    bp.maximum_matching();
    //s -> t := 元の行 -> 最終的な行
    for(int i=0;i<n;i++) st.insert(pl(i, bp.match[i]-n));

    re(i, n) {
      for(int j=0;j<G[i].size();j++){
        if(G[i][j].use) continue;
        auto itr = st.find(pl(i, G[i][j].to));
        if(itr==st.end()) continue;
        st.erase(itr);
        G[i][j].use = 1;
        num_col.emplace(G[i][j].num, c);
      }
    }

  }
  /*
  std::cout << "---" << '\n';
  for(auto itr:num_col){
    std::cout << itr.first << " " << itr.second << '\n';
  }
  */
  vvl x = VV(n, m, 0, ll);
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      ll to = num_col.at(d[i][j]);
      x[i][to] = d[i][j];
    }
  }
  d = x;
  re(i, n) re(j, m) std::cout << d[i][j] << (j==m-1?"\n":" ");
  for(int j=0;j<m;j++){
    vll tmp(n);
    for(int i=0;i<n;i++) tmp[i] = d[i][j];
    sort(all(tmp));
    for(int i=0;i<n;i++) d[i][j] = tmp[i];
  }
  re(i, n) re(j, m) std::cout << d[i][j] << (j==m-1?"\n":" ");
  return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int n = sc.nextInt();
		int ans = 1;

		for(int i = 0; i < d; i++) {
			ans = ans * 100;
		}
		if(n == 100) {
			ans = ans * n + ans;
		}else  {
			ans = ans * n;
		}

		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] array = new int[3];
		int count = 0;
		for(int i = 0; i < 3;i++) array[i] = sc.nextInt();
		while(array[0] != array[1] || array[0] != array[2]){
			int minNum = 0;
			int maxNum = 0;
			for(int i = 1; i <3;i++){
				if(array[minNum] > array[i]) minNum = i;
				else if(array[maxNum] < array[i]) maxNum = i;
			}
			if(array[maxNum] - array[minNum] > 1){
				array[minNum] += 2;
				count++;
				continue;
			}
			for(int i = 0; i <3; i++) if(i != maxNum) array[i]++;
			count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21972
package main

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

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

var comb [][]int

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i], _ = strconv.Atoi(stringLineScan())
	}
	ans := 0
	for i := 0; i < n-1; i++ {
		if p[i] == i+1 {
			p[i], p[i+1] = p[i+1], p[i]
			ans++
		}
	}
	if p[n-1] == n {
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1920
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}
        static String getStr(){return sc.next();}
        static int getInt(){return sc.nextInt();}
        static Long getLong(){return sc.nextLong();}
        static boolean isNext(){return sc.hasNext();}
        public static void main(String[] args){
          int N = getInt();
          long[] list = new long[N];
          long max = 0;
          for(int i = 0; i < N; i++){
            list[i] = getLong();
            max += list[i];
          }
          
          long output1 = 0;//左から
          long output2 = 0;//右から
          long[] test = new long[N];
          long[] test2 = new long[N];
          //累積和やってみる？
          //myout(test[0]);
          for(int i = 0; i < N; i++){
            if(i > 0){
            	test[i] = test[i-1] + list[i];
            }else{
                test[i] = list[i];
            }
            if(max / 2 <= test[i]){
              if(max / 2 == test[i]){
                //コスト0円のケース
			  	//累積和を求める過程で合計/2が見つかる場合
              	myout("0");
                return;
              }else{
                //半分超えたら、それまでの累積和と残り分の差(max-test[i])の絶対値だけお金要る
                output1 = Math.abs(test[i]-(max-test[i]));
                break;
              }
            }
          }
          
          for(int i = N-1; 0 <= i; i--){
            if(i != N-1){
            	test2[i] = test2[i+1] + list[i];
            }else{
                test2[i] = list[i];
            }
            if(max / 2 <= test2[i]){
              if(max / 2 == test2[i]){
                //コスト0円のケース
			  	//累積和を求める過程で合計/2が見つかる場合
              	myout("0");
                return;
              }else{
                //半分超えたら、それまでの累積和と残り分の差(max-test[i])の絶対値だけお金要る
                output2 = Math.abs(test2[i]-(max-test2[i]));
                break;
              }
            }
          }
          myout(Math.min(output1,output2));
        }
        //便利メソッド追加枠ここから

        //便利メソッド追加枠ここまで
}


Measured memory_bytes: 96156
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
vector<int> l(n);
for(int& i:l) cin>>i;
sort(l.begin(),l.end()); 
int ans=0;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){ 
int s1=l[i]+l[j],s2=max(l[i]-l[j],l[j]-l[i]); 
auto itr1=lower_bound(l.begin()+(j+1),l.end(),s1);
auto itr2=upper_bound(l.begin()+(j+1),itr1,s2); 
ans+=(itr1-itr2); 
}
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 2e5 + 7;

vi G[N];
int vis[N];

signed main()
{
	IO_OP;
	
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		G[u].PB(v);
		G[v].PB(u);

	}	
	
	queue<int> q({1});
	while(q.size()) {
		int u = q.front(); q.pop();
		for(int v:G[u]) {
			if(!vis[v]) {
				vis[v] = u;
				q.push(v);
			}
		}
	}

	cout << "Yes" << endl;
	for(int i = 2; i <= n; i++) cout << vis[i] << endl;
}





Measured memory_bytes: 12856
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>

using namespace std;

int main(){
   int n;
   string a,b,c;
   cin>>n>>a>>b>>c;
   int ans=0;
   for(int i=0;i<n;i++){
      if(a.at(i)==b.at(i) && b.at(i)==c.at(i) && c.at(i)==a.at(i))ans+=0;
      else if(a.at(i)!=b.at(i) && b.at(i)!=c.at(i) && c.at(i)!=a.at(i))ans+=2;
      else ans++;
   }
   cout<<ans<<endl;
   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F            first
#define S            second
#define PB           push_back
#define MP           make_pair
#define Fin          freopen("input.txt","r",stdin)
#define Fout         freopen("output.txt","w",stdout)
#define Precision(a) cout << fixed << setprecision(a)
#define FasterIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF9 2147483647
#define INF18 9223372036854775806
#define ll long long
#define ull unsigned long long
#define nn printf("\n")
#define no printf("NO\n")
#define yes printf("YES\n")
#define pp pair<int,int>
#define ppp pair<int,pp >
#define mapii map<int,int>
#define mapll map<ll,ll>
#define mapsi map<string,int>
#define mapss map<string,string>

char Uplowch(char ch)
{
    if(ch >= 'A' &&  ch <= 'Z')
        ch += 32;
    return ch;
}
char Lowupch(char ch)
{
    if(ch >= 'a' &&  ch <= 'z')
        ch -= 32;
    return ch;
}


int main()
{
    int t,n,m,a,b,i,j,x,y,mx,mn,sum,k=0,flag;

    string s;
    while(cin>>n)
    {
        a = 0;
        b = 0;
        x = 0;
        y = 0;
        while(n--)
        {
            cin>>s;

            if(s=="AC")a++;
            else if(s=="WA")b++;
            else if(s=="TLE")x++;
            else if(s=="RE")y++;
        }

        printf("AC x %d\n",a);
        printf("WA x %d\n",b);
        printf("TLE x %d\n",x);
        printf("RE x %d\n",y);


    }

    return 0;
}


Measured memory_bytes: 3720
// inputに入力データ全体が入る
	// 2
	// testString
	// => 2文字よりも入力の文字の方が多いのでte...
    function Main(inputString: string) {
        // 1行目がinput[0], 2行目がinput[1], …に入る
        const arrInputString = inputString.trim().split("\n");
    	//文字列から10進数に変換するときはparseIntを使います
		const DISPLAY_LENGTH = parseInt(arrInputString[0], 10);
		const DISPLAY_STRING = arrInputString[1]
    	if(DISPLAY_STRING.length > DISPLAY_LENGTH){
			console.log('%s', DISPLAY_STRING.substring(0, DISPLAY_LENGTH) + '...')
		} else {
			console.log(DISPLAY_STRING)
		}
    	//出力
    }
    //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
	Main(require("fs").readFileSync("/dev/stdin", "utf8"));
	// Main("1\ntest")
	// Main("40\nferelibenterhominesidquodvoluntcredunt")
	

Measured memory_bytes: 29604
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())
    al = list(map(int, input().split()))
    bl = list(map(int, input().split()))

    total = 0
    for i in range(n):
        if al[i] < bl[i]:
            total += al[i]
            if al[i+1] <= bl[i] - al[i]:
                total += al[i+1]
                al[i+1] = 0
            else:
                total += bl[i] - al[i]
                al[i+1] -= bl[i] - al[i]
        else:
            total += bl[i]

    print(total)


Measured memory_bytes: 18752
#include <iostream>
using namespace std;
int main(void){
    int x1,x2;
    cin>>x1>>x2;
    if(x1>x2){
    cout<<x1-x2<<endl;
    }
    if(x1<x2){
    cout<<x2-x1<<endl;
    }
    if(x1==x2){
    cout<<x2-x1<<endl;
    }
}


Measured memory_bytes: 3100
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    dic = collections.defaultdict(list)
    for i in range(n):
        s, p = LS()
        p = int(p)

        dic[s].append((p,i+1))
    
    key = list(dic.keys())
    key.sort()
    for k in key:
        lst = dic[k]
        lst.sort(reverse=True)
        lst = list(zip(*lst))[1]
        for s in lst:
            print(s)

    
    
main()


Measured memory_bytes: 68516
#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);
    string s; cin>>s;
    int ans=s.size();
    rep(i,s.size()-1){
        if(s.at(i)!=s.at(i+1)){
            chmin(ans,max<int>(i+1,s.size()-i-1));
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  for (int i=0 ; i<W+2 ; i++) cout << '#' ;
  cout << endl;
  for (int i=0 ; i<H ; i++){
    vector<char> vec(W+2);
    vec.at(0)='#';
    vec.at(W+1)='#';
    for (int i=1 ; i<W+1 ; i++) cin >> vec.at(i);
    for (int i = 0; i < vec.size(); i++) cout << vec.at(i) ;
    cout << endl;
  }
  for (int i=0 ; i<W+2 ; i++) cout << '#' ;
  cout << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define LL long long
 
int main()
{
  string s;
  cin>>s;
  for(int i=0;i<s.size();i+=2){
      if(s[i]!='h' or s[i+1]!='i'){
           cout<<"No"<<"\n";
           return 0;
      }
  }
  cout<<"Yes"<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <limits.h>
using namespace std;
 
 
int main(){
 
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    for(int i=0;i<101;i++){
        C -= B;
        
        if(C <=0){

        cout <<"Yes";
        break;
        }
        
        A -= D;
        if(A <= 0) {
            cout <<"No";
            break;
        }
        
    }
}

Measured memory_bytes: 3640
n,k = map(int,input().split())
li=list(range(n))
for i in range(n):
    li[i]=int(input())
li.sort()
ans=100000000000
for i in range(n-k+1):
    if ans>(li[i+k-1]-li[i]):
        ans=li[i+k-1]-li[i]
print(ans)
        
    


Measured memory_bytes: 7472
#pragma region header
#include <bits/stdc++.h>
using namespace std;

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

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

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

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

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

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

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

int main()
{
	i64 H, W;
	cin >> H >> W;
	vector<string> a;
	REP(i, H)
	{
		string str;
		cin >> str;
		REP(j, W)
		{
			if (str[j] == '#')
			{
				a.push_back(str);
				break;
			}
		}
	}

	vector<int> output;
	REP(i, W)
	{
		REP(j, SIZE(a))
		{
			if (a[j][i] == '#')
			{
				output.push_back(i);
				break;
			}
		}
	}

	REP(i, SIZE(a))
	{
		string ans;
		REP(j, SIZE(output))
		{
			ans += a[i].substr(output[j], 1);
		}
		cout << ans << endl;
	}
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int k, x;
    cin >> k >> x;
    cout << (500 * k >= x ? "Yes" : "No") << endl;
    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);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int M = sc.nextInt();

        int[] a = new int[A + 1];
        int[] b = new int[B + 1];

        int mina = Integer.MAX_VALUE / 2;
        int minb = Integer.MAX_VALUE / 2;

        for (int i = 1; i <= A; i++) {
            a[i] = sc.nextInt();
            mina = Math.min(a[i], mina);
        }
        for (int i = 1; i <= B; i++) {
            b[i] = sc.nextInt();
            minb = Math.min(b[i], minb);
        }

        int minSum = mina + minb;

        for(int i=0;i <M; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int c = sc.nextInt();
            
            minSum = Math.min(a[x] + b[y] - c, minSum);
        }
        sc.close();

        System.out.println(minSum);
    }

}


Measured memory_bytes: 132228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n;
	cin >> n;
	double res;
	if(n%2!=0) {
		res = (n/2+1)/(double)n;
	} else {
		res = (n/2)/(double)n;
	}
	cout << fixed << setprecision(7) << res << endl;
	
	return 0;
}



Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define pb push_back
#define Int int64_t
using namespace std;

int N,M,A,B,C,K;
int main()
{
    cin>>N;
    vector<Int> A(N);
    for(auto &x:A) cin>>x;
    int largest=*max_element(A.begin(),A.end());
    Int sum=accumulate(A.begin(),A.end(),0);
    sum-=largest;
    cout<<(largest<sum ? "Yes\n":"No\n");
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int solve(int  n,int arr[],int dp[])
{
    if(n==0)
    return 0;
    if(dp[n]!=-1)
    {
        return dp[n];
    }
    int ans=INT_MAX;
    int op1,op2;
     op1=abs(arr[n-1]-arr[n])+solve(n-1,arr,dp);
     op2=abs(arr[n-2]-arr[n])+solve(n-2,arr,dp);
    return dp[n]=min(op1,op2);
}
int main() {
    int n;
    int i;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int dp[n];
    memset(dp,-1,sizeof(dp));
    cout<<solve(n-1,arr,dp);
}


Measured memory_bytes: 12216
S=list(input())
p=0;q=0
for i in range(len(S)):
  for j in range(i,len(S)):
    if S[j]=="A" or S[j]=="C" or  S[j]=="G" or S[j]=="T":
      q=q+1
      p=max(p,q)
      #print(p,q)
    else:
      q=0
      break
  q=0
print(p)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public final class Main {
	public static void main(String[] args) throws java.lang.Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder a = new StringBuilder(br.readLine());
		StringBuilder b = new StringBuilder(br.readLine());
		StringBuilder c = new StringBuilder(br.readLine());
		Solver s = new Solver();
		System.out.println(s.solve(a, b, c));
	}

}

class Solver {

	String solve(StringBuilder a, StringBuilder b, StringBuilder c) {
		char t = 'a';
		while (true) {
			if (t == 'a') {
				if (a.length() == 0) {
					return "A";
				}
				t = a.charAt(0);
				a.deleteCharAt(0);
			} else if (t == 'b') {

				if (b.length() == 0) {
					return "B";
				}
				t = b.charAt(0);
				b.deleteCharAt(0);
			} else if (t == 'c') {

				if (c.length() == 0) {
					return "C";
				}
				t = c.charAt(0);
				c.deleteCharAt(0);
			}
		}

	}

}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    Graph G(n);
    for(int i = 0; i < n; i++){
        int u, k; cin >> u >> k;
        for(int j = 0; j < k; j++){
            int a; cin >> a;
            G.at(u - 1).push_back(a);
        }
    }
    vector<int> dist(n, -1);
    dist[0] = 0;
    queue<int> que;
    que.push(1);
    while(!(que.empty())){
        int v = que.front();
        que.pop();
        for(auto nv : G.at(v - 1)){
            if(dist[nv - 1] != -1){
                continue;
            }
            else{
                que.push(nv);
                dist[nv - 1] = dist[v - 1] + 1;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        cout << i << " " << dist[i - 1] << endl;
    }
}


Measured memory_bytes: 3160
s = list(input())
n = len(s)

a = []
b = []
counta = 0
countb = 0
for i in range(n):
    if i % 2 == 0:
        a.append("0")
        b.append("1")
    else:
        a.append("1")
        b.append("0")
    if s[i] != a[i]:
        counta += 1
    if s[i] != b[i]:
        countb += 1
print(min(counta,countb))


Measured memory_bytes: 5512
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int n, a[105], ans=0;
double avg = 0, diff = INF;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        avg += a[i];
    }
    avg /= n;
    for (int i = 0; i < n; i++) {
        if (diff > abs(avg - a[i])) {
            ans = i;
            diff = abs(avg - a[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define int long long 
#define dou double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int N,x;
	cin >> N;
	int count=0;
	if(N>1000){
		int t=N/100;
		//cout << t << endl;
		if(N%1000!=0){
			x=N%1000;
		//cout << x << endl;
			int y=(N-x)/1000;
		//cout << y << endl;
			count=1000*(y+1)-N;
		}
		else{
			count=0;
		}
	}
	else{
		count=1000-N;
	}
	cout << count << endl;
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979323846;

int main() {
  int N;
  cin >> N;
  vector<int> X(N), L(N);
  for (int i=0; i<N; i++) cin >> X[i] >> L[i];
  vector<pair<int, int>> V(N);
  for (int i=0; i<N; i++) {
    V[i].first = X[i]+L[i];
    V[i].second = X[i]-L[i];
  }
  sort(V.begin(), V.end());
  // cur:現在選んでいる区間のうち、最も右にあるやつの右端
  int res = 0, cur = -INT_MAX;
  for (int i=0; i<N; i++) {
    if (cur>V[i].second) continue; // 被るやつは飛ばす
    res++;
    cur = V[i].first;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
int R,C,s[10000][10],f[10],N,i,j,n,m;void rec(int k){if(k==R){for(n=i=0;i<C;i++,n+=m>R-m?m:R-m,N=N>n?N:n)for(m=j=0;j<R;j++)m+=s[i][j]^f[j];return;}f[k]=0;rec(k+1);f[k]=1;rec(k+1);}main(){for(;std::cin>>R>>C,R;rec(0),printf("%d\n",N))for(j=R;j-->0;)for(i=C;i-->0;)std::cin>>s[i][j];}

Measured memory_bytes: 1256
import itertools
N=int(input())
l=[[] for i in range(N)]
for i in range(N):
  a=int(input())
  for j in range(a):
    x,y=map(int,input().split())
    l[i].append((x-1,y))
ans=0
for t in itertools.product(range(2),repeat=N):
  miss=False
  for i in range(N):
    if t[i]==0:continue
    for x,y in l[i]:
      if not t[x]==y:break
    else:continue
    break
  else:ans=max(ans,sum(t))
print(ans)

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long double w,h,x,y,a,b,c;
	int f=0;
	cin>>w>>h>>x>>y;
	if(w/2==x && h/2==y){
		f=1;
	}
	else if(w/2==h/2 || w/h==x/y){
		f=2;
	}
	a=min(w-x,x)*h;
	b=w*min(h-y,y);
	c=max(a,b);
	if(f==0){
		cout<<std::fixed<<std::setprecision(10)<<c<<" "<<0<<endl;
	}else if(f==1){
		cout<<std::fixed<<std::setprecision(10)<<c<<" "<<1<<endl;
	}else if(f==2){
		cout<<std::fixed<<std::setprecision(10)<<w*h/2<<" "<<0<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

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

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

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

u64 N, M;
s64 a;
u64 *ans;

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

    cin >> N >> M;
    ans = new u64[N + 1]();
    ans[0] = 1;
    ans[1] = 1;
    bool *ng = new bool[N + 1];
    rep (i, M)
    {
        cin >> a;
        ans[N - a] = 0;
        ng[N - a] = true;
    }

    for (int i = 2; i < N + 1; ++i)
    {
        if (ng[i])
        {
            // ans[i] = 0;
        }
        else
        {
            // ans[i] += ans[i - 2] % MOD;
            // ans[i] += ans[i - 1] % MOD;
            ans[i] = (ans[i - 2] + ans[i - 1]) % MOD;
        }
    }

    cout << ans[N] << "\n";
    return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

typedef long long int ll;
typedef long double ld;

int main(){
    while(true){
        ll h,w;
        cin >> h >> w;
        if(h==0 && w==0){
            break;
        }
        for (int i=0;i<h;++i){
            for (int j=0;j<w;++j){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define REP(i, s, n) for (signed i = (s); i < signed(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c).begin(), (c).end()

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

signed main() {
	int r, n;
	while (cin >> r >> n && r) {
		V height(r * 2);
		rep(i, n) {
			int lx, rx, h; cin >> lx >> rx >> h;
			lx += r;
			rx += r;
			REP(i, max(0, lx), min(r * 2, rx)) {
				height[i] = max(height[i], h);
			}
		}

		double ans = 1 << 27;
		rep(x, r * 2) {
			int h = height[x];
			double a = sqrt(r * r - pow(abs(r - x) - (r - x > 0), 2));
			double sun = (double)(h + r) - a;
			ans = min(ans, sun);
		}
		printf("%.8f\n", ans);
	}
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair

ll power(ll k ,ll n){
  ll prod=1;
  while(n){
    if(n%2) prod=prod*k;
    k=k*k;
    n/=2;
  }
  return prod;
}

void solve(){
 	
  string s; cin>>s;
  ll n=s.size();
  ll p,sum=0;
  vector<ll>v;
  for(ll j=0;j<n;j++){
    v.clear();
    v.pb(s[j]-'0');
    for(ll i=j;i<n;i++){
      p=v.back();
      ll f=n-i-2;
      ll b=j-1;
      if(f<0) f=0;
      if(b<0) b=0;
      sum+=p*pow(2,f)*pow(2,b);
      if(i+1<n)
      v.pb(p*10+s[i+1]-'0');
    }
  }
  cout<<sum<<endl;
 	
}



int main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  fast
  ll t=1;
 
  while(t--){
  	solve();
  }

return 0;
  
}

Measured memory_bytes: 4028
n, d = gets.split(' ').map(&:to_i)
arr = []
n.times do
  arr.push(gets.split(' ').map(&:to_i))
end

count = 0
for i in 0...n do
  line1 = arr[i]
  for j in (i + 1)...n do
    line2 = arr[j]
    sum = 0
    for k in 0...d do
      sum += (line1[k] - line2[k]) ** 2
    end
    count += 1 if (sum ** 0.5) == (sum ** 0.5).to_i
  end
end

puts count

Measured memory_bytes: 1788
#include <iostream>
int main()
{
    int n;
    std::cin >> n;

    long double a;
    long long ans=1;
    long double b=1;
    for(int i=0;i<n;i++){
        std::cin >> a;
        ans=ans*a;
        b = b*a;
    }

    if(b>1000000000000000000){
        std::cout << "-1" << std::endl;
        return 0;
    }

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

Measured memory_bytes: 3700
#include <stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    
    int bus,train;
    
    if(a>=b){
        bus = b;
    }
    else{
        bus = a;
    }
    
    if(c>=d){
        train = d;
    }
    else{
        train = c;
    }
    
    printf("%d",bus + train);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	int pt=1,cnt=0;
	while(pt<b){
		pt += a-1;
		cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
/*input
1
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    ll ans=mypow(10,n);
    ans-=mult(2,mypow(9,n));
    ans+=mypow(8,n);
    ans%=MOD;
    ans+=MOD;
    ans%=MOD;
    cout<<ans;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<" L-B-W-- "<<x<<" --N-B\n"
#define pb push_back
//#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const double pai = acos(-1.0);
const double eps = 1e-8;
//const int mod=998244353;
const int mod=2019;
//const int mod=1e9+7;
const int inf=1e9+7;
//const ll inf=0x7f7f7f7f1234abcd;
const int maxn=2e5+10;
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;x=x*x%mod; y>>=1;} return res; }
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}
ll lcm(ll a, ll b) { return a * b / __gcd(a, b); }

int t,n,m,k;
char a[maxn];
int dp[2100];
int d[maxn];
int main(){
    d[1]=1;
    rep(i,2,maxn) d[i]=d[i-1]*10%2019;
    scanf("%s",a+1);
    int s=strlen(a+1),ss=0;
    dp[0]++;
    ll sum=0;
    per(i,s,1){
        ss=d[s-i+1]*(a[i]-'0')+ss;
        ss%=2019;
        sum+=dp[ss];
        dp[ss]++;
    }
    printf("%lld\n",sum);









    return 0;
}


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

using namespace std;

int main()
{
	char a[100010];
	scanf("%s",a+1);
	for(int i=1;i<=strlen(a+1);i++){
		if(a[i]=='9'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int T1,T2;
	int A1,A2;
	int B1,B2;
	cin>>T1>>T2>>A1>>A2>>B1>>B2;
	int P=(A1-B1)*T1,Q=(A2-B2)*T2;
	if(P>0)P=-P,Q=-Q;
	A1*=T1,A2*=T2,B1*=T1,B2*=T2;

	if(P+Q==0)
	{
		cout<<"infinity"<<endl;
		return 0;
	}
	if(P>0)
	{
		swap(A1,B1);
		swap(A2,B2);
	}
	if(P+Q<0)cout<<"0"<<endl;
	else
	{
		/*int T=(-P)/(P+Q);
		T*=2;
		if((-P)%(P+Q)!=0)T++;
		cout<<T<<endl;*/
		int D=A1+A2-B1-B2;
		int T=(B1-A1)/D+1;
		T*=2;
		T--;
		if((B1-A1)%D==0)T--;
		cout<<T<<endl;
	}
	

	return 0;
}


Measured memory_bytes: 256
import java.util.*;



class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int n;

        int m;

        int q;

        

        n = scanner.nextInt();

        int[] a = new int[n];

        for (int i = 0; i < n; i++) {

            a[i] = scanner.nextInt();

        }

        

        q = scanner.nextInt();

        for (int i = 0; i < q; i++) {

            m = scanner .nextInt();

            if (exhaustive(a, m, 0)) {

                System.out.println("yes");

            } else {

                System.out.println("no");

            }

        }

    }

    

    static boolean exhaustive(int[] a, int m, int current) {

        if (m == 0) {

            return true;

        }

        if (m < 0 || current == a.length) {

            return false;

        }

        

        if (exhaustive(a, m, current+1) || exhaustive(a, m - a[current], current+1)) {

            return true;

        }

        return false;

    }

}


Measured memory_bytes: 26792
use std::io;
use std::str::FromStr;
fn main() {
    let stdin = io::stdin();
    let mut s = String::new();
    stdin.read_line(&mut s).ok();
    s.trim();
    s.pop();
    let n : u32 = u32::from_str(&s).expect("e");
    let m : u32 = n / 7;
    let mut f : bool = false;
    for x in 0..(m + 1) {
        f = f || (n - 7 * x) % 4 == 0;
    }
    if f {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e18 + 1e18;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll N, K;
	cin >> N >> K;
	vll A(N + 1);
	repn(i, N)cin >> A[i];
	for (ll j = K + 1; j <= N; j++) {
		if (A[j] > A[j - K]) { cout << "Yes" << endl; }
		else { cout << "No" << endl; }
	}
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

int K,S;

int main(){
	cin>>K>>S;
	int ans=0;
	REP(x,K+1){
		REP(y,K+1){
			int z=S-x-y;
			if (z>=0 && z<=K){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

int main()
{
  int a, p;
  cin >> a >> p;
  int b = a*3+p;
  int ans = b/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256