akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

//---------------------------------------------------------------
//---------------------------------------------------------------

int N, CN;

map<int, int> mp[30];

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

	cin >> N >> CN;
//	cout << N << " " << CN << endl;
	int s, t, c;
	map<int, int> *m;
	REP(i, 0, N) {
		cin >> s >> t >> c;
//		cout << s << " " << t << " " << c << endl;
		mp[c - 1][s]++;
		mp[c - 1][t]--;
//		cout << "mp[" << (c - 1) << "][" << s << "] = " << mp[c - 1][s] << endl;
//		cout << "mp[" << (c - 1) << "][" << t << "] = " << mp[c - 1][t] << endl;
	}
	
	map<int, int> wk;
	REP(i, 0, CN) {
//	    cout << endl << "i = " << i << endl;
//	    cout << "mp.size(" << i << ") = " << mp[i].size() << endl;
    	for(auto x : mp[i]) {
//		    cout << "  key = " << x.first					// キーを表示
//			    << ", val = " << x.second << endl;		// 値を表示
    	    if(x.second == 1) {
    	        wk[x.first - 1]++;
//    	        cout << "  wk[" << (x.first - 1) << "] + 1" << endl;
    	    } else if(x.second == -1) {
    	        wk[x.first]--;
//    	        cout << "  wk[" << x.first << "] - 1" << endl;
    	    }
    	}
	}
	
	int ans = 0;
	int l = 0;
	for(auto x : wk) {
//	    cout << "key = " << x.first					// キーを表示
//		    << ", val = " << x.second << endl;		// 値を表示
	    l += x.second;
	    if(ans < l)     ans = l;
//	    cout << " l = " << l << "  ans = " << ans << endl;
	}
	cout << ans << endl;

	return 0;
}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
ll k;
ll w[100000], d[100000];

int main(){
    cin >> n >> k;
    rep(i,n) cin >> w[i] >> d[i];
    ll st = 0, en = 2000000000000000001, mid;
    while (en-st > 1) {
        mid = (st+en) / 2;
        ll sum = 0;
        rep(i,n) {
            if (w[i] > mid) continue;
            sum++;
            sum += (mid-w[i])/d[i];
            if (sum >= k) break;
        }
        if (sum >= k) en = mid;
        else st = mid;
    }
    cout << en << endl;
}
































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

typedef long long int lli;

const lli maxn = 52, maxk = 52, maxv = 52;

lli n, A[maxn], B[maxn];
vector<pair<lli, lli>> graph[maxv];

bool dfs0(lli node, lli looker, lli mask)
{
	if(node == looker) return true;
	for(auto it: graph[node])
	{
		if((mask&(1ll<<it.second)) && it.first < node && dfs0(it.first, looker, mask)) return true;
	}
	return false;
}

bool cando(lli mask)
{
	for(lli i = 0;i < n;i++)
	{
		if(!dfs0(A[i], B[i], mask))
		{
			//cout << A[i] << " " << B[i] << "\n";
			return false;
		}
	}
	return true;
}

int main(void)
{
	scanf("%lld", &n);
	for(lli i = 0;i < n;i++) scanf("%lld", &A[i]);
	for(lli i = 0;i < n;i++) scanf("%lld", &B[i]);

	for(lli i = 1;i < maxk;i++)
	{
		for(lli v = 0;v < maxv;v++)
		{
			graph[v].push_back({v%i, i-1ll});
		}
	}
	//cout << "here\n";

	lli mask = lli(1ll<<(maxk-1ll))-1ll;
	if(!cando(mask))
	{
		printf("-1\n");
		exit(0);
	}

	for(lli i = maxk-2;i >= 0;i--)
	{
		mask ^= lli(1ll<<i);
		if(!cando(mask)) mask ^= lli(1ll<<i);
	}
	printf("%lld\n", lli(mask<<1ll));

	//lli mask = (1<<6)+(1<<4);
	//cout << cando(mask) << "\n";
}

Measured memory_bytes: 256
from collections import defaultdict
def main():
    N = int(input())
    c = defaultdict(int)

    for i in range(N):
        c[input()] += 1

    print("AC x {}".format(c["AC"]))
    print("WA x {}".format(c["WA"]))
    print("TLE x {}".format(c["TLE"]))
    print("RE x {}".format(c["RE"]))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9448
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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; }

vector< vector<int> > Graph;
vector< int > value;






int f(int x) {
    int ans = 0;
    while(x>0){
        ans += x%10;
        x /= 10;
    }
    return ans;
}


int main(int argc, const char * argv[]) {
  
    
    
    int n; cin >> n;
    if(n%f(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  
    


    
    

    
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF=1e18;
#define PI 3.14159265358979323846
const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    COMinit();

    int S, W;
    cin >> S >> W;

    string result = W >= S ? "unsafe" : "safe";
    cout << result  << '\n';


    return 0;
}

Measured memory_bytes: 15604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

#define INF LLONG_MAX/5
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define enld endl

signed main() {
	string S;
	cin >> S;
	if (S.back() == 's') {
		cout << S << 'e' << 's' << endl;
	}
	else {
		cout << S << 's' << endl;
	}
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define sz(x) int (x.size());
using namespace std;
const int MOD=1000000007;

int main(){
  string s,t;
  cin>>s>>t;
  vector<vector<int>> c(26);
  ll ns,nt;
  ns=sz(s);nt=sz(t);
  rep(i,ns){
    ll now=s[i]-'a';
    c[now].push_back(i);

  }
  rep(i,ns){
    ll now=s[i]-'a';
    c[now].push_back(i+ns);

  }
  ll ans=0;
  ll pos=0;
  rep(i,nt){
    ll temp=t[i]-'a';
    if (c[temp].size()==0) {
      puts("-1");return 0;}
    pos=*lower_bound(c[temp].begin(),c[temp].end(),pos)+1;
    if (pos>=ns){
      pos-=ns;ans+=ns;
    }

  }
  ans+=pos;

  cout<<ans;
return 0;
}


Measured memory_bytes: 1724
#include<iostream>
#include<cmath>
#include<vector>
#include<cstdlib>
#include<algorithm>
#define INF 1000000000

using namespace std;

void init(int);
int find(int);
void unite(int,int);
bool same(int,int);
void dijkstra(int);
vector<int>get_path(int);

int par[1001],rank[1001];
int V,prev[1001];
double cost[1001][1001],d[1001];
bool used[1001];

int main(void){

  int b[1001],m,s,g;
  double x[1001],y[1001];
  while(cin >> V,V){
    for(int i=0;i<V;i++){
      cin >> b[i] >> x[i] >> y[i];
    }

    init(V);

    for(int i=0;i<=V;i++)
      for(int j=0;j<=V;j++)
	cost[i][j]=INF;

    for(int i=0;i<V;i++){
      for(int j=0;j<V;j++){
	if(i!=j){
	  double a=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
	  if(50.-a>=0){
	    cost[b[i]][b[j]]=cost[b[j]][b[i]]=a;
	    unite(b[i],b[j]);
	  }
	}
      }
    }

    cin >> m;
    for(int i=0;i<m;i++){
      cin>> s >> g;
      if(!same(s,g)){
	cout << "NA" << endl;
      }
      else {
	dijkstra(s);
	vector<int>p=get_path(g);
	for(int j=0;j<p.size();j++){
	  cout << p[j];
	  if(j!=p.size()-1)cout <<" ";
	  else cout << endl;
	}
      }
      
    }

  }

  return 0;
}

void init(int n){
  for(int i=0;i<=n;i++){
    par[i]=i;
    rank[i]=0;
  }
}

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

void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;

  if(rank[x]<rank[y])par[x]=y;
  else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}

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

void dijkstra(int s){
  fill(d,d+V+1,INF);
  fill(used,used+V+1,false);
  fill(prev,prev+V+1,-1);
  d[s]=0;

  while(true){
    int v=-1;
    for(int u=1;u<=V;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }

    if(v==-1)break;
    used[v]=true;

    for(int u=1;u<=V;u++){
      if(d[u]>d[v]+cost[v][u]){
	d[u]=d[v]+cost[v][u];
	prev[u]=v;
      }
    }
  }
}

vector<int>get_path(int t){
  vector<int>path;
  for(;t!=-1;t=prev[t])path.push_back(t);
  reverse(path.begin(),path.end());
  return path;
}

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

int main(){
	char a;
	vector <char> b;
	while (cin >> a){
		if (a == '0')b.push_back('0');
		if (a == '1')b.push_back('1');
		if (a == 'B' && !b.empty())b.pop_back();
	}
	for (int i = 0; i < b.size(); i++)cout << b[i];
	cout << endl;
	return 0;
}

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

using namespace std;

const int NS = (int)1e6 + 4;

int N;
int arr[NS];
multiset < int > st;
vector < int > vc;

int main(){
    scanf("%d", &N);
    for(int i = 1; i <= (1 << N); ++i){
        scanf("%d", arr + i); arr[i] = (int)1e9 - arr[i];
        st.insert(arr[i]);
    }
    sort(arr + 1, arr + (1 << N) + 1);
    vc.push_back(*st.begin()), st.erase(st.begin());
    for(int k = 1; k <= N; ++k){
        sort(vc.begin(), vc.end()); int vcd = (int)vc.size();
        for(int i = 0; i < vcd; ++i){
            multiset < int >::iterator p = st.lower_bound(vc[i] + 1);
            if(p == st.end()){
                puts("No"); return 0;
            }
            vc.push_back(*p); st.erase(p);
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 14716
#![allow(unused_mut)]
#![allow(non_snake_case)]

#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        p: [i64; n],
    }
    let mut cnt = 0;
    for i in 1..p.len() - 1 {
        let mut d = Vec::new();
        d.push(p[(i as i64 -1) as usize]);
        d.push(p[i+1]);
        d.push(p[i]);
        d.sort();
        if d[1] == p[i] {
            cnt+=1;
        }
    }
    println!("{}", cnt);
}

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

using namespace std;

int n, m, ans;
vector<int> edge[8];
bool done[8];

int dfs(int u) {
  done[u] = true;
  for (int v: edge[u]) {
    if (done[v]) continue;
    dfs(v);
  }
  
  bool f = true;
  for (int i = 0; i < n; i++) {
    if (not done[i]) {
      f = false;
    }
  }
  if (f) ans++;
  
  done[u] = false;
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  
  dfs(0);
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, i;
    cin >> n;
    string s1, s2;
    int t=0, h=0;
    
    for(i=0; i<n; i++){
        cin >> s1 >> s2;
        if(s1.compare(s2)==0){
            t++; h++;
        }
        else if(s1.compare(s2)>0) t+=3;
        else h+=3;
    }
    cout << t << " " << h << endl;
}



Measured memory_bytes: 3164
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	// 入力
	long h = sca.nextLong();
	int n = sca.nextInt();
	int[] ai = new int[n];
	for(int i = 0; i < n; i++) {
		ai[i] = sca.nextInt();
	}

	int ans_hint = 0;
	for(int i = 0; i < n; i++) {
		ans_hint += ai[i];
	}
	if((long)ans_hint < h) {
		System.out.println("No");
	}
	else {
		System.out.println("Yes");
	}

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 49392
N, M = gets.split.map &:to_i
query = $<.map{|s|
  a, b = s.split
  [a.to_i, !!b["AC"]]
}
was = [0] * (N + 1)
acs = [false] * (N + 1)
query.each{|no, ac|
  if ac
    acs[no] = true
  else
    was[no] += 1 if !acs[no]
  end
}
# wa = was.select.with_index{|n, no| acs[no] }.inject:+
wa = 0
was.each_with_index{|n, no|
  wa += n if acs[no]
}

puts [acs.count(true), wa] * " "

Measured memory_bytes: 11516
def myAnswer(S:list) -> int:
   C0 = 0
   C1 = 0
   for s in S:
      if(s =="0"):
         C0+=1
      else:
         C1 += 1
   return 2*min(C0,C1)

def modelAnswer():
   tmp=1
def main():
   S = list(input())
   print(myAnswer(S[:]))
if __name__ == '__main__':
   main()

Measured memory_bytes: 4652
import java.util.*;

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

        int n = sc.nextInt();
        int k = sc.nextInt();

        int[] p = new int [n];
        double[] q = new double [n];

        dp[0] = 0;
        dp[1] = 1;

        for(int i = 0; i < n; i++){
            p[i] = sc.nextInt();
            q[i] = sum(p[i]);
            q[i] /= p[i];
        }

        double sum = 0;
        for(int i = 0; i < k; i++){
            sum += q[i];
        }
        double max = sum;


        for(int i = k; i < n; i++){
            sum += q[i];
            sum -= q[i - k];
            max = Math.max(sum, max);
        }

        System.out.println(max);
    }

    static int[] dp = new int[1001];
    static int sum(int n){
        if(dp[n] == 0){
            dp[n] = sum(n - 1) + n;
        }
        return dp[n];
    }

}


Measured memory_bytes: 84584
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, k, s;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k >> s;
    for(int i = 0 ; i < k ; i++){
        cout << s << " ";
    }
    for(int i = 0 ; i < n - k ; i++){
        if(s == (int)1e9) cout << 1 << " ";
        else cout << (int)1e9 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a+b==c) puts("Yes");
	else if(b+c==a) puts("Yes");
	else if(c+a==b) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
S = sum(B[A[i]-1] for i in range(N))
for i in range(N-1):
  if A[i+1]-1==A[i]:
    S += C[A[i]-1]
print(S)

Measured memory_bytes: 8836
N = int(input())
S = sorted([int(input()) for _ in range(N)])

ans = sum(S)

if ans % 10 == 0:
  # find numbers that are not multiples of 10 in order of decreasing.
  for s in S:
    if s % 10 != 0:
      ans -= s
      break
  # if all the numbers in the list are multiples of 10, the ans is 0.
  if ans == sum(S):
    ans = 0

print(ans)


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

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

    public static void main(String[] args) {
        int N = in.i();
        int M = in.i();
        int[] a = new int[M + 1];
        for (int i = 0; i < M; i++) {
            a[i] = in.i();
        }
        int[] d = new int[N + 2];
        d[1] = 1;
        for (int i = 1, j = 0; i <= N; i++) {
            if (i == a[j]) {
                d[i + 1] = 0;
                j++;
            } else {
                d[i + 1] = (d[i] + d[i - 1]) % 1000000007;
            }
        }
        out.println(d[N + 1]);
    }
}

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

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

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

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                back();
                break;
            }
        }
    }

    char[] s(final int N) {
        skip();
        char[] s = new char[N];
        for (int i = 0; i < s.length; i++) {
            s[i] = next();
        }
        return s;
    }

    String s() {
        try {
            return readLine();
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

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

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

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


Measured memory_bytes: 36220
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int time[] = new int[5];
		for (int i = 0; i < 5; i++) {
			time[i] = scan.nextInt();
		}
		
		int last = 0;
		for (int i = 1; i < 5; i++) {
			if (time[i] % 10 == 0) {
				continue;
			}
			if (time[0] % 10 > time[i] % 10) {
				last = i;
			}
		}
		
		int sum = 0;
		for (int i = 0; i < 5; i++) {
			
			if (time[i] % 10 == 0 || i == last) {
				sum += time[i];
			} else {
				sum += time[i] + (10 - (time[i] % 10));
			}
			
		}
		
		System.out.println(sum);
		scan.close();
	}
}

Measured memory_bytes: 22612
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        
        ArrayList<Integer> result =new ArrayList<Integer>();
        
        while (true) {
            
            String numLine = scanner.next();
            
            if ("0".equals(numLine)) {
                break;
            }
            
            int size = numLine.length();
            int sum = 0;
            for (int i=size; i>=1; i--) {
                int num = Integer.parseInt(numLine.substring(i-1, i));
                sum += num;
            }
            result.add(sum);
        }
        
        // display
        for (Integer i : result) {
            System.out.println(i);
        }
        
    }
}


Measured memory_bytes: 26640
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define MAX ((ll)(1e17+100))
#define MX ((ll)(1e6+100))
#define ARRS ((ll)(2e6+100))
#define HS ((ll)(233))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define LG 21
#define mul(a,b) a=((a)*(b))%MOD
using namespace std;

ll fw[ARRS+100];
ll n;
ll add(ll i,ll x){
	i+=n+10;
	while(i<ARRS){
	//cout<<i<<" "<<x<<" "<<endl;
		fw[i]+=x;
		i+=i&-i;
	}
}

ll quer(ll i){
	i+=n+10;
	ll p=0;
	while(i){
		p+=fw[i];
		i-=i&-i;
	}
	return p;
}
ll a[ARRS];
ll f[ARRS];

int main(){
	vector<ll> v;
	cin>>n;
	for(int i=0; i<n; i++)
		cin>>a[i],v.pb(a[i]);
	
	sort(v.begin(),v.end());
	ll l=0,r=v.size()-1;
	while(l<r){
		ll m=v[l+r+1>>1];
		
		for(int i=0; i<n; i++){
			if(a[i]>=m)
				f[i]=1;
			else f[i]=-1;
		}

		for(int i=0; i<=2*n+100; i++)fw[i]=0;
		ll s=0,ps=0;
		add(0,1);
		for(int i=0; i<n; i++){
			//cout<<s<<" ";
			s+=f[i];
			ps+=quer(s);
			add(s,1);
		}
		//cout<<ps<<endl;
		ps=n*(n+1)/2-ps;
		//cout<<endl;
		//cout<<"->"<<m<<endl;
		//cout<<n*(n+1)/2<<endl;
		//cout<<ps<<" "<<(n*(n+1)/2)/2+1<<endl;
		if(ps>(n*(n+1)/2)/2+1)
			r=(l+r+1>>1)-1;
		else l=(l+r+1>>1);
	}
	cout<<v[l];
}


Measured memory_bytes: 14196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int N;
ll w[100100];
ll v[100100];
ll memo[110][100100];
ll knapSack(int W, int at){
    if(at == 0 || W == 0){
        return 0;
    }
    if(memo[at][W] != -1) return memo[at][W];
    if(w[at-1] > W) return knapSack(W, at-1);
    return memo[at][W] = max(v[at-1]+knapSack(W-w[at-1], at-1), knapSack(W, at-1));
}


int main()
{
    cin.sync_with_stdio(false);
    int W;
    cin >> N >> W;
    memset(memo, -1, sizeof(memo));
    rep(i,0,N) cin >> w[i] >> v[i];
    cout << knapSack(W, N) << endl;
    return 0;
}


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

#define int long long

using namespace std;

const int N = 5005;
const int mod = 1e9 + 7;

void add (int &x, int y) {
    x += y;
    x %= mod;
}

int dp[N], f[N];

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

    int n;
    string s;
    cin >> n >> s;

    dp[0] = 1;
    for (int i = 0; i < n; i++) {
        memset(f, 0, sizeof(f));
        for (int j = 0; j <= i; j++) {
            add(f[j + 1], dp[j]);
            if (j) add(f[j - 1], 2 * dp[j]);
            else add(f[j], dp[j]);
        }

        for (int j = 0; j < N; j++) dp[j] = f[j];
    }

    cout << dp[s.length()];
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';


using namespace boost::multiprecision;
using namespace std;

/* MOD演算ライブラリ(暫定)*/
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(void){

    COMinit();
    ll S;
    cin>>S;
    ll cho=S/3;
    ll cou=0;
    rep1(i, cho){
        cou+=COM(S-2*i-1, i-1);
        cou%=MOD;
        //cout<<cou<<endl;
    }
    cout<<cou<<endl;
    return 0;
}


Measured memory_bytes: 15584
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		long N = int.Parse(Console.ReadLine());
		long[]S = new long[N];
		string[]str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			S[i] = long.Parse(str[i]);
		}
		long ans = 0;
		for(long i=1;i<=N;i++){
			long a = 0;
			for(long k=1;k<=N;k++){
              	if(k*i>=N-1 || (N-1-k*i<=k*i && (N-1)%i == 0) || N-1-k*i <= i){
                  break;
                }
				a += S[N-1-k*i];
				a += S[k*i];
				ans = Math.Max(ans,a);
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 29280
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    string s; cin >> s;
    int ans;
    if (s == "RRR") {
        ans = 3;
    } else if (s[0] == 'R' && s[1] == 'R') {
        ans = 2;
    } else if (s[1] == 'R' && s[2] == 'R') {
        ans = 2;
    } else if (s == "SSS") {
        ans = 0;
    } else {
        ans = 1;
    }

    cout << ans << endl;

    return 0;
}






Measured memory_bytes: 3592
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main()
{
    large a,b,c,d;
    cin >> a >> b >> c >> d;

    cout << max({
        a * c,
        a * d,
        b * c,
        b * d,
    });
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

const int MAX_N = 3e6;
ll fac[MAX_N+1], ifac[MAX_N+1];

//comb(n, k)でnCk
ll comb(int n, int k){
    ll c = fac[n];
    c *= ifac[n-k], c %= MOD;
    c *= ifac[k], c %= MOD;
    return c;
}

//perm(n, k)でnPk
ll perm(int n, int k){
    return(fac[n]*ifac[n-k])%MOD;
}

//mpow(x,n)で(x^n)%MODをO(log(n))で計算
ll mpow(ll x, ll n){
    ll res = 1, now = x;
    while(n > 0){
        if(n%2 == 1) res *= now, res %= MOD;
        now *= now, now %= MOD;
        n /= 2;
    }
    return res;
}


int main(){
  	ll r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    //1〜nまでのmod(MOD)における逆元
    ll inv[MAX_N+1];
    rep2(i, 1, MAX_N){
        inv[i] = mpow(i, MOD-2);
    }
    //i!とi!の逆元
    fac[0] = 1, ifac[0] = 1;
    rep2(i, 1, MAX_N){
        fac[i] = (fac[i-1]*i) % MOD;
        ifac[i] = (ifac[i-1]*inv[i]) % MOD;
    }
    ll ans = 0;
    ans += comb(r2+c2+2, c2+1);
    ans += MOD-comb(c2+r1+1, r1);
    ans += MOD-comb(r2+c1+1, c1);
    ans += comb(r1+c1, r1);
    cout << ans%MOD << endl;
}

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

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

            List<int> a = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            List<int> b = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            List<int> c = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            int result = b.Sum();

            for (int index = 0; index < n - 1; index++)
            {
                int diff = a[index + 1] - a[index];

                if (diff == 1)
                {
                    result += c[a[index] - 1];
                }

            }


            Console.WriteLine(result);
        }
    }
}


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

int main (){
    
    int a, b;
    cin >> a >> b;
    
    int x = (a + b);
    
    if (x % 2 == 0){
        cout << x / 2 << endl;
    }
    else {
        cout << (x + 1) / 2 << endl;
    }
    
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nq = IO.RSInt;

            var s = ReadLine();
            // "AC"の数の累積和
            var cnt = new int[s.Length];
            cnt[0] = 0;
            for (int i = 1; i < s.Length; i++)
            {
                if (s[i - 1] == 'A' && s[i] == 'C')
                {
                    cnt[i] = cnt[i - 1] + 1;
                }
                else
                {
                    cnt[i] = cnt[i - 1];
                }
            }

            var list = new List<int>();
            for (int i = 0; i < nq[1]; i++)
            {
                var lr = IO.RSInt;
                var l = lr[0] - 1;
                var r = lr[1] - 1;

                var ans = 0;
                if (l == 0)
                {
                    ans = cnt[r];
                    list.Add(ans);
                    continue;
                }
                ans = cnt[r] - cnt[l - 1];
                if (s[l - 1] == 'A' && s[l] == 'C') ans--;
                list.Add(ans);
            }
            foreach (var ans in list)
            {
                WriteLine(ans);
            }
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 17596
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;

int N,M = 0,res = 0;
vector <pair<int,int> > e[123];
bool C[1000123];

void addEd(int u,int v,int x){
    e[u].push_back(make_pair(v,x));
    ++M;
}
void find(int u,int s = 0){
    if(u >= N){
        if(C[s]) cout << "FAIL AT s = " << s << endl;
        else ++res;
        C[s] = 1;
        return ;
    }
    for(int i = 0; i < e[u].size();++i){
        find(e[u][i].first,s + e[u][i].second);
    }
}
int main(){

    int L;
    cin >> L;

    if(L == 2){
        cout << "2 2" << endl;
        cout << "1 2 0" << endl;
        cout << "1 2 1" << endl;

        return 0;
    }
    --L;
    int r = 0;
    while((1 << (r + 1)) <= L) ++r;
    N = r + 1;

    //for(int i = 19; i >= 0; --i) cout << ((L >> i) & 1);
    //cout << endl;

    //cout << "N = " << N << endl;

        for(int i = 1; i < N; ++i){
            addEd(i,i + 1,0);
            addEd(i,i + 1,1 << (i - 1));
        }

    for(int i = r - 1; i >= 0; --i)
        if((L >> i) & 1){
            //cout << "L("<<i<<") = " << 1 << endl;
            int L2 = L^(1 << i);
            int lo = L2 & ( ((1 << (r + 1)) - 1) - ((1 << (i + 1)) - 1) );
            addEd(i + 1,N,lo);
        }
    
    addEd(1,N,L);

    //find(1);
    //cout << "res = " << res << endl;

    cout << N << " " << M << endl;
    for(int i = 1; i <= N; ++i){
        for(int j = 0; j < e[i].size(); ++j) cout << i << " " << e[i][j].first << " " << e[i][j].second << endl;
    }

    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int A=in(),B=in(),C=in(),D=in();
	
	while(true){
		C -= B;
		if(C<=0){
			out("Yes");
			return 0;
		}
		A -= D;
		if(A<=0){
			out("No");
			return 0;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

// int main(void)
// {
//     int N;
//     cin >> N;

//     vector<int> a(N);
//     int four = 0;
//     int two = 0;
//     int other = 0;
//     for (int i = 0; i < N; i++)
//     {
//         int num;
//         cin >> num;
//         if (num % 4 == 0)
//         {
//             four++;
//         }
//         else if (num % 2 == 0)
//         {
//             two++;
//         }
//         else
//         {
//             other++;
//         }
//     }

//     string ans;
//     if (two == 0)
//     {
//         if (other <= four + 1)
//         {
//             ans = "Yes";
//         }
//         else
//         {
//             ans = "No";
//         }
//     }
//     else
//     {
//         if (other <= four)
//         {
//             ans = "Yes";
//         }
//         else
//         {
//             ans = "No";
//         }
//     }
//     cout << ans << endl;
// }

int main(void)
{
    int N;
    cin >> N;
    vector<int> a(N);
    int four = 0;
    int two = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        // 4の倍数
        if (a[i] % 4 == 0)
        {
            four++;
        }
        else if (a[i] % 2 == 0)
        {
            two++;
        }
    }
    // printf("four = %d, two = %d\n", four, two);

    string ans;
    int sum;
    if (two % 2 == 0)
    {
        sum = four * 4 + two * 2;
    }
    else
    {
        sum = four * 4 + (two - 1) * 2;
    }
    // printf("left = %d, sum = %d\n", (N / 2) * 4, sum);
    if ((N / 2) * 4 <= sum)
    {
        ans = "Yes";
    }
    else
    {
        ans = "No";
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3740
//#define _GLIBCXX_DEBUG
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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; }



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,Q; cin>>N>>Q;
  fenwick_tree<ll> ft(N);
  rep(i,N) {ll a; cin>>a; ft.add(i,a);}
  
  rep(i,Q){
    int t; cin>>t;
    if(t){
      ll l,r; cin>>l>>r;
      cout<<ft.sum(l,r)<<'\n';
    }
    else{
      ll p,x; cin>>p>>x;
      ft.add(p,x);
    }
  }
  
  return 0;
}

Measured memory_bytes: 8252
def maxHeapify(heap, i):
    left = (i + 1) * 2 - 1
    right = (i + 1) * 2
    largest = left if left < len(heap) and heap[left] > heap[i] else i
    largest = right if right < len(heap) and heap[right] > heap[largest] else largest
    if largest != i:
        heap[i], heap[largest] = heap[largest], heap[i]
        maxHeapify(heap, largest)

def buildMaxHeap(heap):
    for i in range(len(heap) // 2, -1, -1):
        maxHeapify(heap, i)

n = int(input())
heap = list(map(int, input().split()))
buildMaxHeap(heap)

out = ''
for key in heap:
    out += (' {}'.format(str(key)))
print(out)

Measured memory_bytes: 65484
#include <stdio.h>
 
int main()
{
    int a[100], n, i, j, x;
    int c = 0;
 
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
 
    for (i = 0; i < n; i++) {
        for (j = n - 1; j >= i + 1; j--) {
            if (a[j] < a[j-1]) {
                x = a[j];
                a[j] = a[j-1];
                a[j-1] = x;
                c += 1;
            }
        }
    }

    for (i = 0; i < n; i++) {
        if (i == n - 1) {
            printf("%d\n", a[i]);
        } else {
            printf("%d ", a[i]);
        }
    }
    printf("%d\n", c);
 
    return 0;
}

Measured memory_bytes: 600
import sys
import math
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, M = map(int, readline().split())
    S = readline().rstrip().decode('utf-8')
    T = readline().rstrip().decode('utf-8')

    G = math.gcd(N, M)

    A = ''.join(S[::N // G])
    B = ''.join(T[::M // G])

    if A == B:
        answer = N * M // G
    else:
        answer = -1
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9448
using System;

namespace abc132
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var input2 = Console.ReadLine().Split(' ');
            
            var n = int.Parse(input[0]);
            var p = Array.ConvertAll(input2, int.Parse);

            var count = 0;
            for(int i=0; i<n-2; i++)
            {
                if((p[i]<p[i+1] && p[i+1]<p[i+2]) || (p[i+2]<p[i+1] && p[i+1]<p[i]))
                    count++;
            }

            Console.WriteLine(count.ToString());
        }
    }
}

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

public class NoGood
{
    public List<int> L { get; set; }
}
public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var buhin = Array.ConvertAll(line, int.Parse);
            if (buhin[0] == 0 && buhin[1] == 0 && buhin[2] == 0) break;
            var good = new List<int>();
            var nogoods = new List<NoGood>();
            var n = int.Parse(Console.ReadLine().Trim());
            for (int i = 0; i < n; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                var test = Array.ConvertAll(line2, int.Parse);
                if (test[3] == 0)
                {
                    var a = new NoGood();
                    a.L = new List<int>();
                    for (int j = 0; j < 3; j++) a.L.Add(test[j]);
                    nogoods.Add(a);
                }
                else
                    for (int j = 0; j < 3; j++) good.Add(test[j]);
            }
            var good2 = good.Distinct().ToArray();
            for (int i = 0; i < good2.Length; i++)
            {
                for (int j = 0; j < nogoods.Count() ; j++)
                {
                    nogoods[j].L.Remove(good2[i]);
                }
            }
            var answer = Enumerable.Repeat(2, buhin.Sum()+1).ToArray();
            foreach (var x in good2) answer[x] = 1;
            var one = nogoods.Where(x => x.L.Count() == 1);
            foreach (var x in one) answer[x.L[0]] = 0;
            for (int i = 1; i < answer.Length; i++)
                Console.WriteLine(answer[i]);
        }
    }
}

Measured memory_bytes: 10336
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

int main(){
	int a, b;

	cin >> a;
	cin >> b;
	
	int ret = max(a+b, max(a-b, a*b));

	cout << ret << endl;
	
	return 0;
}

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

int main (){
  long long N,A,B;
  cin >> N>>A>>B;
  long long x,y;
  x=N/(A+B);
  y=N-x*(A+B);
  if (y <= A){
  cout << A*x+y << endl;
  }
  else{
    cout << A*x+A << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define exit return 0;
#define is(x) cout << #x << " = " << x << endl;
using namespace std;
const int N=500000;
bool prime[N];
void sieve(){
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<100000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<100000; i += p)
                prime[i] = false;
        }
    }
}
int nxt(){int x;cin >> x;return x;}
int32_t main(){
    base
    string a,b,c;
    cin>>a>>b>>c;
    int turn=0;
    vector<string>v;
    int anhy[5];
    memset(anhy,0,sizeof anhy);
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    while(1){
        if(anhy[turn]==v[turn].size())break;
        int ba3do=v[turn][anhy[turn]]-'a';
        anhy[turn]++;
        turn=ba3do;
    }
    cout<<(char)(turn+'A');
    exit
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    string s;
    cin >> s;
    int n = s.size();
    map<int,int> m;
    int sum = 0;
    m[0]++;
    ll ans = 0;
    ll pow10 = 1;
    rrep(i,n) {
        sum += (s[i]-'0')*pow10;
        sum %= 2019;
        pow10 = pow10*10%2019;
        ans += m[sum];
        m[sum]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3772
#include<cstdio>

bool search(int n,int d[],int k){
  while(n!=0){
    int m = n%10;
    for(int i=0;i<k;i++){
      if(d[i]==m) return false;
    }
    n/=10;
  }

  return true;
}


int main(void){
  int n,k;
  int d[10];

  scanf("%d %d",&n,&k);
  
  for(int i=0;i<k;i++)
    scanf("%d",&d[i]);

  while(!search(n,d,k)){
    n++;
  }

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

  return 0;
}


Measured memory_bytes: 128