akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main() {

  while( true ) {

    long long int t, p, r;
    cin >> t >> p >> r;
    if ( t == 0 ) break;

    long long int w[51][11] = {0};
    vector< pair< long long int, pair< long long int, long long int > > > score;
    for ( long long int i = 0; i < t; i++ ) {

      score.push_back( make_pair( 0, make_pair( 0, i+1 ) ) );

    }

    for ( long long int i = 0; i < r; i++ ) {

      long long int t_in, p_in, time;
      string m;
      cin >> t_in >> p_in >> time >> m;
      t_in--;
      p_in--;

      if ( m == "WRONG" ) {
	w[t_in][p_in]++;
      }else {
	score[t_in].first--;
	score[t_in].second.first += w[t_in][p_in] * 1200 + time;
      }

    }

    sort( score.begin(), score.end() );

    for ( long long int i = 0; i < t; i++ ) {

      cout << score[i].second.second << " " << -score[i].first << " " << score[i].second.first << endl;

    }

  }

}

Measured memory_bytes: 1220
s=input()
for i in range(2**3):
  op=format(i,'03b')
  op=op.replace('1','+').replace('0','-')
  st=s[0]+op[0]+s[1]+op[1]+s[2]+op[2]+s[3]
  if eval(st)==7:
    print(st+"=7")
    break

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

int main ()
{
    int a, b, c;
    while (cin >> a >> b >> c, a || b || c) {
        int res = 0;
        for (int x = 1; x < 1000; x++) {
            for (int y = 1; y < 1000; y++) {
                if ((x * (100 + a) / 100) + (y * (100 + a) / 100) == c) {
                    res = max(res, (x * (100 + b) / 100) + (y * (100 + b) / 100)) ;
                }
            }
        }
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void){
	int n,i;
	int a[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n-1;i>=0;i--){
		if(i==0){
			printf("%d",a[i]);
		}else{
			printf("%d ",a[i]);
		}
	}
	printf("\n");
	return 0;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  int a[100][100], b[100], c[100];
  for (int i=0; i<n; i++)
    for (int j=0; j<m; j++) cin >> a[i][j];
  for (int i=0; i<m; i++) cin >> b[i];
  for (int i=0; i<n; i++) {
    c[i] = 0;
    for (int j=0; j<m; j++) c[i] += a[i][j] * b[j];
  }
  for (int i=0; i<n; i++) cout << c[i] << endl;
  return 0;
}



Measured memory_bytes: 3136
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector< int > a(N), b(N);

    for (int i = 0; i < N; i++) cin >> a[i];
    for (int i = 0; i < N; i++) cin >> b[i];

    int ans = 0;
    for (int i = 0; i < 29; i++) {
        vector< int > a_mod(N), b_mod(N);
        for (int j = 0; j < N; j++) {
            a_mod[j] = a[j] % (1 << (i + 1));
            b_mod[j] = b[j] % (1 << (i + 1));
        }

        sort(b_mod.begin(), b_mod.end());

        int cnt = 0;
        for (int j = 0; j < N; j++) {
            // int low = 0, high = N - 1;
            // while (high - low > 1) {
            //     int mid = (high + low) / 2;

            //     if (a_mod[j] + b_mod[mid] > (1 << i)) {
            //         high = mid;
            //     } else {
            //         low = mid;
            //     }
            // }
            int add = 0;
            if ((1 << i) - a_mod[j] >= 0) {
                add += lower_bound(b_mod.begin(), b_mod.end(),
                                   (1 << (i + 1)) - a_mod[j]) -
                       lower_bound(b_mod.begin(), b_mod.end(),
                                   (1 << i) - a_mod[j]);
            } else {
                add += lower_bound(b_mod.begin(), b_mod.end(),
                                   (1 << (i + 1)) - a_mod[j]) -
                       b.begin();
                add += lower_bound(b_mod.begin(), b_mod.end(), 1 << (i + 1)) -
                       lower_bound(b_mod.begin(), b_mod.end(),
                                   (1 << (i + 1)) + (1 << i) - a_mod[j]);
            }
            cnt += add;
        }

        // cout << i << ": " << cnt << endl;
        if (cnt & 1) {
            ans += (1 << i);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3432
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.io.*;
//import java.util.stream.IntStream;
import java.nio.charset.Charset;


public class Main {

    static int INFTY = Integer.MAX_VALUE;
    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
      //  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


     //   try{

            int n = sc.nextInt();
            int[] a = new int[n];
            // 長さiの最長増加部分列の最後尾の値、(同じ長さの場合は最小値)
            int[] l = new int[n+1];
            Arrays.fill(l, -1);
            int length = 0;

            for (int i = 0; i < n; i++) {
                a[i] = sc.nextInt();
            }

            for (int i = 0; i < n; i++) {
                //最大値より大きい場合は入れ替えだけ
                if(a[i]>l[length]){
                    l[length + 1] = a[i];
                    length++;
                    continue;
                }

                int index = Arrays.binarySearch(l, 0, length, a[i]);
                // 見つからなかった場合の戻り値はマイナスの変な数になっている
                if(index < 0){
                    l[-index - 1] = a[i];
                } else {
                    l[index] = a[i];
                }
                
            }
            
            System.out.println(length);

    }

}




Measured memory_bytes: 71148
/*
  AOJ 1305
  Title:Membership Management
  @kankichi573
*/
#include <stdio.h>
#include <string.h>

int n,mem,parent,child;
char name[1001][16];
char descendant[1001];
char mark[1001];
int member[1001][10];
char member_cnt[1001];


void mark_descendant(int n)
{
  int i;

  if(mark[n])
    return;
  mark[n]=1;
  if(member_cnt[n]==0)
    descendant[n]=1;
  else
    for(i=0;i<member_cnt[n];i++)
      mark_descendant(member[n][i]);
}

int register_name(char *s)
{
  int i;
  for(i=1;i<=mem;i++)
    if(0==strcmp(s,&name[i][0]))
      return(i);
  mem++;
  strcpy(&name[mem][0],s);
  member_cnt[mem]=0;
  return(mem);
}
void dump()
{
  int i,j,m;

  for(i=1;i<=mem;i++)
    {
      m=member_cnt[i];
      if(m>0)
	{
	  printf("%s [%d]:",&name[i][0],m);
	  /*
	  for(j=0;j<m;j++)
	    if(member_cnt[member[i][j]]==0)
	      printf("\x1b[32m%4s\x1b[37m|",&name[member[i][j]][0]);
	    else
	      printf("\x1b[37m%4s\x1b[37m|",&name[member[i][j]][0]);
	  */
	  printf("\n");
	}
    }
}
main()
{
  int i,count;
  char buf[200],*p;

  while(scanf("%d ",&n) && n)
    {
      memset(descendant,0,sizeof(descendant));
      memset(member_cnt,0,sizeof(member_cnt));
      memset(mark,0,sizeof(mark));
      mem=0;
      for(i=0;i<n;i++)
	{
	  fgets(buf,200,stdin);
	  p=strtok(buf,":");
	  parent=register_name(p);

	  while(1)
	    {
	      if((p=strtok(NULL,",.\n")))
		{
		  child=register_name(p);
		  member[parent][member_cnt[parent]]=child;
		  member_cnt[parent]++;
		}
	      else
		break;
	    }
	}
#ifdef DEBUG
      dump();
#endif      
      mark_descendant(1);
      for(i=1,count=0;i<=mem;i++)
	count += descendant[i];
      printf("%d\n",count);
      
    }
  return(0);
}

Measured memory_bytes: 688
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    vector<int> ans(4);
    rep(i, n){
        string t = s[i];
        if (t == "AC"){
            ans[0]++;
        } else if (t == "WA") {
            ans[1]++;
        } else if (t == "TLE") {
            ans[2]++;
        } else {
            ans[3]++;
        }
    }

    printf("AC x %d\n", ans[0]);
    printf("WA x %d\n", ans[1]);
    printf("TLE x %d\n", ans[2]);
    printf("RE x %d\n", ans[3]);

}



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

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

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

  for(int i=0; i<n; i++){
    int v = a[i];
    int j = i-1;
    while(j>=0 && a[j]>v){
      a[j+1] = a[j];
      j--;
    }
  a[j+1] = v;
  for(int i=0; i<n; i++){
     cout << a[i];
     if(i!=n-1){
       cout << " ";
     } 
   } 
   cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
using namespace std;

int main() {
    for(string s; cin >> s, s != "0"; ) {
        int ans = 0;
        for(int i = 0; i < (int)s.length(); i++) ans += s[i] - '0';
        cout << ans << endl;
    }
}

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

#define MyREP(i, n) for (long long i = 0; i < (long long)(n); i++)

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}


struct UnionFind {
    vector<int> par;
    vector<int> siz;

    UnionFind(int N) : par(N), siz(N,1) { 
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x){
        return siz[root(x)];
    }
};

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

    UnionFind uf(n);
    MyREP(i,m){
        int a,b;
        cin>>a>>b;
        uf.unite(a-1,b-1);
    }
    vector<bool> rt(n,false);
    int cnt = 0;
    MyREP(i,n){
        if(!rt[uf.root(i)]){
            cnt++;
            rt[uf.root(i)]=true;
        }
    }
    cout<<cnt-1<<endl;
    return 0;
}

Measured memory_bytes: 3984
#[allow(unused_macros)]
macro_rules! read_i {
    ( $($args:expr ; $t:ty),* ) => {{
        let line = read_string();
        let mut line = line.split_whitespace();
        $(
            let tmp:$t = line.next().unwrap().parse().unwrap();
            *$args = tmp;
        )*
    }};
}
pub fn read_string() -> String{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned().to_string()
}
pub fn read_vec_i(n:usize) -> Vec<i32> {
    let mut v:Vec<i32> = Vec::new();
    let line = read_string();
    let mut line = line.split_whitespace();
    for _i in 0..n {
        let x = line.next().unwrap().parse().unwrap();
        v.push(x);
    }
    v
}
pub fn read_vec2_i(n:usize, m:usize) -> Vec<Vec<i32>> {
    let mut v:Vec<Vec<i32>> = Vec::new();
    for i in 0..n {
        let v1:Vec<i32> = Vec::new();
        v.push(v1);
        let line = read_string();
        println!("> {}", line);
        let mut line = line.split_whitespace();
        for _j in 0..m {
            let x = line.next().unwrap().parse().unwrap();
            v[i].push(x);
        }
    }
    v
}
fn main(){
    let mut n = 0;
    let mut a = 0;
    let mut b = 0;
    read_i!(
        &mut n;usize, 
        &mut a;i32, 
        &mut b;i32
    );
    let mut s:Vec<char> = read_string().chars().collect();
    let mut cnt_a:i32 = 0;
    let mut cnt_b:i32 = 0;
    let mut cnt:i32 = 0;
    for (i, x) in s.iter().enumerate() {
        if *x == 'a' {
            cnt_a+=1;
            if cnt < a + b {
                cnt+=1;
                println!("Yes");
            } else {
                println!("No");
            }
        } else if *x == 'b' {
            cnt_b+=1;
            if cnt < a + b && cnt_b <= b {
                cnt += 1;
                println!("Yes");
            } else{
                println!("No");
            }
        } else {
            println!("No");
        }
    }

}

Measured memory_bytes: 4732
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int k, s;
    cin >> k >> s;

    int ans = 0;
    for(int x = 0; x <= k; ++x){
        for(int y = 0; y <= k; ++y){
            int z = s - x - y;
            if(0 <= z and z <= k) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include <cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include <bits/stdc++.h>
using namespace std;

int main()
{ 
    int n, k;
    
    cin >> n >> k;
    
    int a[n];
    double b[n-k+1];
    
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    double prod = 0;
    for(int i=0; i<k; i++){
        prod += log(a[i]);
    }
    b[0] = prod;
    
    for(int i=1; i<n-k+1; i++){
        prod = prod + log(a[k+i-1]) - log(a[i-1]);
        b[i] = prod;
    }
    
    // compare
    for(int i=1; i<n-k+1; i++){
        if(b[i] > b[i-1]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        
    }
}


Measured memory_bytes: 6136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if ((a.equals(b) && a.equals("H")) || (a.equals("D") && b.equals("D")))
			System.out.println("H");
		else
			System.out.println("D");
		sc.close();
	}
}

Measured memory_bytes: 20560
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#define ll long long
#define vi vector<ll>
#define vs vector<string>
#define fr(i, k, n) for (ll i = k; i < n; i++)
#define rep(i, n) fr(i, 0, n)
#define alll(v) v.begin(), v.end()
#define mp(a, b) make_pair(a, b)
#define rdd(a) ll a; cin >> a
#define rrd rdd(a); rep(i, a)
//min({a,b,c,d})などの記法
using namespace std;
template <class X> void pr(X x) { cout << x << endl; }
template <class X> void prr(X x) { for (auto it : x) { cout << it<<" ";}cout<<endl; }

ll gcd(ll a,ll b){
    while(b!=0){
        ll tmp =b;
        b=a%b;
        a=tmp;
    }
    return a;
}

int main(int argc, const char * argv[]) {
    ll n;
    cin>>n;
    vi v(n);
    rep(i, n){
        cin>>v[i];
    }
    ll tmp=1;
    rep(i, n){
        ll xx=tmp*(v[i]/gcd(tmp, v[i]));
        tmp=xx;
    }
    pr(tmp);
    
    return 0;
}


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

int main()
{
  int64_t a, b, k ;
  cin >> a >> b >> k ;
  if(a + b <= k)
  {
    cout << 0 << " " << 0 << endl ;
  }
  else
  {
    if(a >= k)
    {
      a -= k ;
      k = 0 ;
    }
    else
    {
      k -= a ;
      a = 0 ;
    }
    b -= k ;
    cout << a << " " << b << endl ;
  }
  
}


Measured memory_bytes: 256
use std::io::*;

fn main() {
    let stdin = stdin();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let (n, _m) = to_pair(&buf);

    let mut conflicts: Vec<(i32, i32)> =
        stdin.lock().lines().map(|l| to_pair(&l.unwrap())).collect();
    conflicts.sort_by_key(|t| t.1);
    let mut bridges = vec![false; (n - 1) as usize];
    let mut last_broken: usize = std::usize::MAX;

    for t in conflicts {
        let w = (t.0 - 1) as usize;
        let e = (t.1 - 1) as usize;
        if !(last_broken >= w && last_broken < e) {
            bridges[e - 1] = true;
            last_broken = e - 1;
        }
    }

    println!("{}", bridges.into_iter().filter(|&b| b).count());
}

fn to_pair(s: &str) -> (i32, i32) {
    let v: Vec<_> = s.split_whitespace().map(|w| w.parse().unwrap()).collect();
    let (l, r) = (v[0], v[1]);
    (l, r)
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(int argc, char const *argv[])
{
    ll n,x;cin>>n>>x;
    vector<int> l(n);
    ll ret=0;
    ll cnt=1;
    for(int i=0;i<n;i++){
        ll l;cin>>l;
        ret +=l;
        if(ret>x)break;
        cnt++;
    }
    cout<< cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    string ans;
    rep(i,s.size()){
      if(s[i] == '0') ans += '0';
      else if (s[i] == '1') ans += '1';
      else{
        if(ans.size() == 0) ans = ans;
        else ans.erase(ans.size()-1);
      }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <tuple>
#include <iomanip>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M;
  cin>>N>>M;
  vector<int> P(M);
  vector<vector<int> > S(M,vector<int>(N,0));
  for(int i=0;i<M;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int s;
      cin>>s;
      s--;
      S[i][s]=1;
    }
  }
  for(int i=0;i<M;i++){
    cin>>P[i];
  }
  int ans=0;

  for(int bit=0; bit<(1<<N);bit++){
    vector<int> now(M,0);
    for (int i=0; i<N; i++) {
      if (bit & (1<<i)) { 
        for(int j=0;j<M;j++){
          if(S[j][i]==1)now[j]++;
        }
      }
    }
    bool flag=true;
    for(int j=0;j<M;j++){
      if(now[j]%2!=P[j])flag=false;
    }
    ans+=flag;
  }
  cout<<ans<<endl;
}


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

/*
// ordered_set 
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
 
using namespace std;
 
typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ld, ld>                                    pll;
 
# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define Sort(x)                                         sort(all(x))
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
 
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}

//const ll md = 1e9 + 7;//998244353;
const int xn = 1e5 + 10;
const int xm = -20 + 10;
const int SQ = 320;
const int sq = 320 + 10;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int Md = 1e9 + 7;
const int TM = 3;
const int Base = 257;

ll n, ans = 1, cnt;
string a, b;
bool flag[xn];

int main(){
    InTheNameOfGod;
    
    cin >> n >> a >> b;
    for (int i = 0; i < n; ++ i){
    	if (a[i] == b[i]) flag[i] = true;
	}
	for (int i = 0; i < n; ++ i){
		if (!flag[i]) ++ cnt;
		if (cnt % 2 == 0 && !flag[i]) continue;
		if (!i){
			if (flag[i]) ans = ans * 3 % Md;
			else ans = ans * 6 % Md;
			continue;
		}
		if (flag[i] && flag[i - 1]) ans = ans * 2 % Md;
		else{
			if (flag[i] && !flag[i - 1]) continue;
			if (!flag[i] && flag[i - 1]) ans = ans * 2 % Md;
			else ans = ans * 3 % Md;
		}
	}
	cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int N=0;
    int a[30000]={0};
    int ans[30000]={0};
    int count=0;
    while(1){
        int count2=0;
        long sum=0;
        long ave=0;
        scanf("%d",&N);
        if(N==0) break;
        for(int i=0;i<N;i++){
            scanf("%d",&a[i]);
            sum+=a[i];
        }
        ave=sum/N;
        for(int i=0;i<N;i++){
            if(a[i]<=ave) count2++;
        }
        ans[count]=count2;
        count++;
    }
    for(int i=0;i<count;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
    
}


Measured memory_bytes: 2048
n = input()

flag = True
for i in range(len(n)):
  if i%2 == 0:
    if n[i] == 'R' or n[i] == 'U' or n[i] == 'D':
      pass
    else:
      flag = False
      
  else:
    if n[i] == 'L' or n[i] == 'U' or n[i] == 'D':
      pass
    else:
      flag = False
      
if flag:
  print('Yes')
else:
  print('No')
      

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        bool debugFlg = false;
        if (debugFlg)
        {
            var exStdIn = new System.IO.StreamReader("stdin.txt");
            System.Console.SetIn(exStdIn);
        }
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    void calc()
    {
        int[] s = cin.ArrayInt(3);
        int A = s[0]; // Aまで入れられる
        int B = s[1]; // B入ってる
        int left = A - B; //残り
        int C = s[2];

        int ans = C > left ? C - left : 0 ;
        Console.WriteLine($"{ans}");
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13268
a,b,k = list(map(int, input().split()))

temp_a = a
if (k >= a):
  a = 0
else :
  a = (a - k)
k = k - temp_a

if k < 0 :
  k = 0
if (k >= b):
  b = 0
else :
  b = (b - k)


print("%s %s" % (a,b))

Measured memory_bytes: 3064
h,w = gets.chomp.split(" ").map!(&:to_i)
retsu = []
h.times {|i|
  retsu[i] = gets.chomp.split(" ")
}
h.times{|i|
  w.times{|j|  
    puts ("A".ord + j).chr + (i+1).to_s if(retsu[i][j] == "snuke")
  }
}

Measured memory_bytes: 1788
x, y = list(map(int, input().split()))

crain = (4*x - y) / 2
kame = x - crain

if crain < 0 or kame < 0:
    print('No')
    exit()

if crain.is_integer() and crain > 0:
    print('Yes')
    exit()

if kame.is_integer() and kame > 0:
    print('Yes')
    exit()

print('No')

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<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);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

int main() {
  int n, z, w;
  cin >> n >> z >> w;

  int a1 = 0, a2 = 0;
  REP(i, n) {
    a1 = a2;
    cin >> a2;
  }

  if(n == 1){
    pl(abs(a2 - w));
  } else {
    pl(max(abs(a1-a2),abs(a2 - w)));
  }

  return 0;
}


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

using namespace std;

const long long int INF = 1LL<<60;
const long long int mod = 1e9 + 7;

bool is_prime(int n) {
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2 == 0) return false;

  double sqrt_n = sqrt(n);
  for(int i=3; i<=sqrt_n; i+=2) {
    if(n%i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int Q;
  cin >> Q;
  vector<int> l(Q);
  vector<int> r(Q);
  int max_r = 0;
  for(int i=0; i<Q; i++) {
    cin >> l.at(i) >> r.at(i);
    max_r = max(max_r, r[i]);
  }

  // prime[k]: the number of x when li=1 and ri = k
  vector<int> prime(max_r+1, 0);
  prime[0] = 0;
  for(int i=1; i<=max_r; i++) {
    if(i%2 == 1) {
      if (is_prime(i)) {
        int j = (i + 1) / 2;
        if(is_prime(j)) {
          prime[i] = prime[i-1] + 1;
        } else {
          prime[i] = prime[i-1];
        }
      } else {
        prime[i] = prime[i-1];
      }
    } else {
      prime[i] = prime[i-1];
    }
  }

  for(int i=0; i<Q; i++) {
    int res = prime[r[i]] - prime[l[i]-1];
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            string[] s0 = Console.ReadLine().Split(' ');
            string[] s1 = Console.ReadLine().Split(' ');

            long ans = 0;
            for (int i = 0; i < N; i++)
            {
                ans += Math.Max(0, long.Parse(s0[i]) - long.Parse(s1[i]));
            }

            Console.WriteLine(ans);
        }
    }
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int h, w, n, sr, sc, ub, db, lb, rb;
  string s, t;
  Solver2(LL h, LL w) : h(h), w(w){};

  void solve() {
    cin >> n >> sr >> sc;
    cin >> s >> t;
    ub = lb = 0;
    rb = w + 1;
    db = h + 1;
    vector<pair<int, int>> aoki, takahashi;
    for (int i = n - 1; i >= 0; --i) {
      //aoki
      if (t[i] == 'L') {
        rb = min(rb + 1, w + 1);
      } else if (t[i] == 'R') {
        lb = max(lb - 1, 0);
      } else if (t[i] == 'U') {
        db = min(db + 1, h + 1);
      } else {
        ub = max(ub - 1, 0);
      }

      //takahashi
      if (s[i] == 'L') {
        lb++;
      } else if (s[i] == 'R') {
        rb--;
      } else if (s[i] == 'U') {
        ub++;
      } else {
        db--;
      }
      DBG(lb, rb, ub, db)
      if (rb == lb + 1 || db == ub + 1) {
        cout << "NO" << endl;
        return;
      }
    }
    if (ub < sr && sr < db && lb < sc && sc < rb) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, m;
  std::cin >> n >> m;

  Problem::Solver2 sol(n, m);
  sol.solve();
  return 0;
}


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

struct node{
  int key;
  struct node *next;
  struct node *prev;
};
typedef struct node *nodePointer;
nodePointer head;
nodePointer tail;


nodePointer listSearch(int key){
  nodePointer n;
  for(n=head->next; n->next!=NULL; n=n->next){
    if(n->key==key)return n;
  }
  return NULL;
}


void insert(int key){
  nodePointer n;
  n=malloc(sizeof(struct node));
  n->key=key;
  n->prev=head;
  n->next=head->next;
  head->next->prev=n;
  head->next=n;
}

void delete(int key){
  nodePointer n;
  n=listSearch(key);
  if(n != NULL){
    n->prev->next=n->next;
    n->next->prev=n->prev;
    free(n);
  }
}

void deleteFirst(int key){
  nodePointer n;
  n=head->next;
  head->next=n->next;
  n->next->prev=head;
  free(n);
}

void deleteLast(int key){
  nodePointer n;
  n=tail->prev;
  n->prev->next=tail;
  tail->prev=n->prev;
  free(n);
}


int main(){
  int key,n,i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  nodePointer P;
  head=malloc(sizeof(struct node));
  tail=malloc(sizeof(struct node));
  head->next=tail;
  head->prev=NULL;
  tail->next=NULL;
  tail->prev=head;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst(key);
	else if ( com[6] == 'L' ) deleteLast(key);
      } else {
	delete(key); nd++;
      }
      size--;
    }
  }
  for(P=head->next; P->next!=NULL; P=P->next){
    if(P != head->next) printf(" ");
    printf("%d", P->key);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 33016
while True:
	import math
	n=int(input())
	if n==0:
		break
	st=list(map(int,input().split()))
	hei=sum(st)/n
	hensa=[]
	for a in range(n):
		hensa.append(((st[a]-hei)**2)/n)
	print(math.sqrt(sum(hensa)))


Measured memory_bytes: 5708
N = int(input())
card_list = list(map(int, input().split()))

ali_sum = 0
bob_sum = 0

for index, card in enumerate(sorted(card_list)):
    if index % 2 == 1:
        ali_sum +=  card
    else:
        bob_sum += card

print(abs(ali_sum - bob_sum))

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;

inline int in() {int x; scanf("%d",&x); return x;}
inline ll lin() {ll x; scanf("%lld",&x); return x;}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

int inp[N];

int main(){
    int n = in(), c = in(), k = in();

    for(int i = 1; i <= n; i++){
        inp[i] = in();
    }

    sort(inp + 1, inp + n + 1);

    int ans = 0, start = 1;

    while(start <= n){
        int low = start, high = min(start + c - 1, n), mid, ok = start;
        while(low <= high){
            mid = (low + high) >> 1;
            if(inp[start] + k >= inp[mid]){
                low = mid + 1;
                ok = mid;
            }else {
                high = mid - 1;
            }
        }
        ans++;
        start = ok + 1;
    }

    printf("%d\n",ans);
}


Measured memory_bytes: 640
from sys import stdin, stdout
from collections import deque, defaultdict
import math as m

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n = int(rl())
	_, dig = divmod(n, 10)
	if dig in {2,4,5,7,9}:
		print("hon")
	elif dig in {0,1,6,8}:
		print("pon")
	else:
		print("bon")
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 83148
#include<bits/stdc++.h>
using namespace std;
 
typedef unsigned long long ull;
 
ull b=1e9+7;
int n,m,r=1,l=0;
ull h[300001],p[300001];
string s,q;
set<ull> rh;
int main(){
  cin>>n>>m;
  cin>>s;
  p[0]=h[0]=1;
  for(int i=0;i<n;i++){
    p[i+1]=p[i]*b;
    h[i+1]=h[i]*b+s[i];
    //cout<<p[i]<<" "<<h[i]<<endl;
  }
  for(int k=0;k<m;k++){
    cin>>q;
    if(q=="L++")l++;
    else if(q=="L--")l--;
    else if(q=="R++")r++;
    else r--;
    rh.insert(h[r]-h[l]*p[r-l]);
    //cout<<h[r]-h[l]*p[r-l]<<endl;
  }
  cout<<rh.size()<<endl;
}


Measured memory_bytes: 21904
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_variables)]

use std::io::stdin;
use std::str::FromStr;
use std::cmp::min;

fn read<T: FromStr>() -> T {
    let mut str = String::new();
    stdin().read_line(&mut str).ok();
    str.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut str = String::new();
    stdin().read_line(&mut str).ok();
    str.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_n_vec<T: FromStr>(n: u32) -> Vec<Vec<T>> {
    let mut v_outer = Vec::new();
    for _ in 0..n {
        let v_inner = read_vec();
        v_outer.push(v_inner);
    }
    v_outer
}

fn main() {
    let line: Vec<u64> = read_vec();
    let n = line[0];
    let k = line[1];

    let rem = n % k;
    println!("{}", min(rem, k - rem));
}

Measured memory_bytes: 4352
#!/usr/bin/env python3
from collections import deque

S_a = deque(list(input()))
S_b = deque(list(input()))
S_c = deque(list(input()))

turn = "a"

while True:
    if turn == "a":
        if not S_a:
            print("A")
            exit()
        turn = S_a.popleft()
    elif turn == "b":
        if not S_b:
            print("B")
            exit()
        turn = S_b.popleft()
    else:
        if not S_c:
            print("C")
            exit()
        turn = S_c.popleft()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define endl '\n'
#define pb push_back
const int N=1e5+1;
const int INF=1e9+7;

int32_t main()
{
 ios_base::sync_with_stdio(0);
 cin.tie(0); cout.tie(0);
 int d,t,s; cin>>d>>t>>s;
 if(d<=(s*t)){cout<<"Yes"<<endl;}
 else{cout<<"No"<<endl;}
}


Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main()
{
    int k,x;
    cin >> k >> x;
    
    int mn=x-k+1;
    int mx=x+k-1;


    mx = std::min(mx,1000000);
    mn = std::max(mn,-1000000);

    cout << mn;
    for(int i=mn+1;i<mx+1;i++)
    {
        cout << " " << i ;
    }
    cout << endl;


    return 0;
}

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

t_cunt = a_cunt = 1

for _ in range(N):
    T,A = map(int,input().split())
    if T < t_cunt or A < a_cunt:
        nt = t_cunt//T + 1 if t_cunt%T else t_cunt//T
        na = a_cunt//A + 1 if a_cunt%A else a_cunt//A
        n = max(nt, na)
        t_cunt = n*T
        a_cunt = n*A
    else:
        t_cunt = T
        a_cunt = A
    #print(t_cunt, a_cunt)
print(t_cunt+a_cunt)

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(std::string b) {
  string x = "ATCG";
  string y = "TAGC";
  cout << y[x.find(b[0])] << endl;
}

int main() {
  std::string b;
  std::cin >> b;
  solve(b);
  return 0;
}


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

int main() {

    while (1) {
        int n;
        cin >> n;
        if (n == 0)
            break;
        vector<int> a(n);

        int sum = 0;
        double ave = 0;
        rep(i, n) {
            cin >> a[i];
            sum += a[i];
        }

        ave = (double)sum / n;

        double ans = 0;
        rep(i, n) {
            ans += (a[i] - ave) * (a[i] - ave);
        }

        printf("%.6f\n", sqrt(ans / n));
    }

    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(60001);
  for (int i = 1; i <= 100; i++) {
    for (int j = 1; j <= 100; j++) {
      for (int k = 1; k <= 100; k++) {
        a[i * i + j * j + k * k + i * j + j * k + k * i]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << a[i] << '\n';
  }
  return 0;
}

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

using namespace std;

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

const double PI=3.14159265358979323846;

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

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

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

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


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

    int n;
    cin >> n;

    s64 a[n + 2];
    rep (i, n + 1) cin >> a[i];
    a[n + 1] = 0;

    s64 l[n + 1];
    s64 r[n + 1];
    rep (i, n + 1) l[i] = CEIL(a[i + 1], 2);

    r[n] = l[n];
    for (int i = n - 1; i >= 0; --i)
    {
        r[i] = r[i + 1] + a[i + 1];
    }
    r[0] = 1 - a[0];
    rep (i, n)
    {
        r[i + 1] = min(r[i + 1], 2 * r[i] - a[i + 1]);
    }

    rep (i, n + 1)
    {
        if (l[i] > r[i])
        {
            cout << "-1\n";
            return 0;
        }
    }

    s64 ans = 0;
    rep (i, n + 1)
    {
        ans += r[i] + a[i];
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 5984
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int[] d = new int[3];
        d[0] = scan.nextInt();
        d[1] = scan.nextInt();
        d[2] = scan.nextInt();
        Arrays.sort(d);
        int answer = d[2] * 10 + (d[1] + d[0]);
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int vis[100001];
long long int dp[100001];
vector<int>v[100001];
long long int dfs(int x)
{
    if(vis[x])
    return dp[x];
    
    vis[x]=1;
    
    for(auto i=v[x].begin();i<v[x].end();i++)
    {
        if(vis[*i])
        dp[x]=max(dp[x],1+dp[*i]);
        else
        dp[x]=max(dp[x],1+dfs(*i));
    }
    return dp[x];
}
int main()
{
    
    long long int n,m;
    cin>>n>>m;
    
    
    for(long long int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
    }
    for(long long int i=1;i<=n;i++)
    vis[i]=0;
    
    for(long long int i=1;i<=n;i++)
    if(!vis[i])
    dp[i]=dfs(i);
    
    long long int mx=dp[1];
    for(long long int i=2;i<=n;i++)
    mx=max(dp[i],mx);
    
    cout<<mx;
    
    
    
    
    
    
    
}

Measured memory_bytes: 8192
import java.util.Scanner;
import java.math.BigInteger;

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

	int n = in.nextInt();
	int [] o = new int [n];
	int [] y = new int [n];

	BigInteger x = new BigInteger("0");
	BigInteger p = new BigInteger("4294967311");
	// BigInteger p = new BigInteger("1000000007");
	BigInteger d = new BigInteger("2147483648");

	for(int i = 0; i < n; ++i){
	    o[i] = in.nextInt();
	    y[i] = in.nextInt();
	}

	for(int i = 0; i < n; ++i){
	    int oo = o[i];
	    BigInteger yy = new BigInteger(String.valueOf(y[i]));

	    if(oo == 1){ // +
		x = x.add(yy);
	    }else if(oo == 2){ // -
		x = x.subtract(yy);
	    }else if(oo == 3){ // *
		x = x.multiply(yy);
	    }else if(oo == 4){ // /
		// x = x.multiply(yy.modPow(p.subtract(new BigInteger("2")), p));
		x = x.multiply(yy.modInverse(p));
	    }
	    x = x.mod(p);
	}

	if(x.compareTo(d) == -1)
	    System.out.println(x);
	else
	    System.out.println(x.subtract(p));
    }
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define inf 9e18
#define pii pair<int,int>
#define fastio ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
using namespace std;
int32_t main()
{
    
    fastio
   
    
    int n;
    cin>>n;
    int dp[n+2],a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    dp[n-1] = 0;
    if(n-2>=0)
        dp[n-2] = abs(a[n-1]-a[n-2]);
    for(int i=n-3;i>=0;i--)
        dp[i] = min(abs(a[i]-a[i+1])+dp[i+1],abs(a[i]-a[i+2])+dp[i+2]);
    cout<<dp[0];
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
   
typedef struct{
    int key;
    int left;
    int right;
} Node;
   
void insert(Node*, int, int);
void print1(Node*, int);
void print2(Node*, int);
   
int main()
{
    char s[10];
    Node *t;
    int m;
    int a;
    int i;
    int cnt=0;   

    scanf("%d", &m);

    t=(Node*)malloc(sizeof(Node)*m);
   
    for(i=0; i<m; i++)
    {
        scanf("%s", &s);

        if(s[0]=='i'){scanf("%d", &a);insert(t, cnt, a);cnt++;}
        if(s[0]=='p')
        {
            if(cnt>0) print1(t, 0);
            printf("\n");
            if(cnt>0) print2(t, 0);
            printf("\n");
        }
    }
       
    return 0;
   
}
   
void print1(Node *t, int p)
{
    if(t[p].left>=0)print1(t, t[p].left);
    printf(" %d", t[p].key);
    if(t[p].right>=0)print1(t, t[p].right);
}
   
void print2(Node *t, int p)
{
    printf(" %d",t[p].key);
    if(t[p].left>=0)print2(t,t[p].left);
    if(t[p].right>=0)print2(t,t[p].right);
}
   
void insert(Node *t, int cnt, int z)
{
    int x=0, y;
    if(cnt<1) x=-1;
   
    t[cnt].key = z;
    t[cnt].left = -1;
    t[cnt].right= -1;
   
    while(x>=0){
        y = x; 
        if(z < t[x].key)
            x = t[x].left; 
        else
            x = t[x].right; 
    }
   
    if(cnt<1){}
    else if(z < t[y].key)
    {
        t[y].left = cnt; 
    }
    else {
        t[y].right = cnt;
    }
}


Measured memory_bytes: 7596
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(long long i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	string s, t;
	cin >> s;
	t = s;
	reverse(all(t));
	int ans = s.size() / 2;
	char hoge = s[s.size() / 2];
	if (s.size() % 2 == 1) {
		ans++;
	}
	else {
		if (hoge == t[t.size() / 2]) {
			ans++;
		}
		else {
			cout << ans << endl;
			return 0;
		}
	}
	int foo = s.size() / 2 + 1;
	while (s[foo] == hoge&&t[foo] == hoge) {
		ans++;
		if (foo == 0) {
			break;
		}
		foo++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
from sys import exit, stdin

input = stdin.readline
import copy

# from collections import deque,Counter
# import numpy as np


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

mod = 10 ** 9 + 7
a, b, c = 1, 1, 2
for i in range(N):
    a = a * 10 % mod
    b = b * 8 % mod
    c = c * 9 % mod

ans = (a + b - c) % mod

print(ans)


Measured memory_bytes: 9340
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    
    int ans=0;
    for(int i=0;i<N;i++){
        if(S[i] != S[i+1]) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include<algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
using namespace std;


int main()
{
    long long a,b,c,d;
    long long e ,f, g, h;
    long long max = -1000000000;
    scanf("%lld %lld %lld %lld", &a,&b,&c,&d);
    max = a * c;
    e = a * c;
    f = a * d;
    g = b * c;
    h = b * d;
    if (e <= f && g <= f && h <= f)
        max = f;
    else if (e <= g && f <= g && h <= g)
        max = g;
    else if (e <= h && f <= h && g <= h)
        max = h;
    printf("%lld", max);

        

    
    

    
    
   

}

Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll N, K;
    cin >> N >> K;
    int ans = 1;
    ll cur = 1;
    while(true){
        if(cur > N) break;
        cur *= K;
        ans++;
    }
    cout << ans-1 << endl;
}

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

int main()
{
    int N; cin >> N;
    vector<ll> a(N), b(N);
    ll sum = 0;
    int zero = 0;
    int minus = 0;
    ll MIN = INFINITY;
    for(int i=0;i<N;i++) {
        cin >> a[i];
        sum += abs(a[i]);
        if(MIN > abs(a[i])) MIN = abs(a[i]);

        if(a[i] == 0) zero++;
        else if(a[i] < 0) minus++;
    }
    if((minus+zero)&1){
        sum -= 2*MIN;
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
  int H,W;
  while(1){
    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;
  }

  return 0;
}



Measured memory_bytes: 3104