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

int main()
{	
	int n;
	double s = 100000;
		
	cin >> n;
	
	while(n--)
		s = ceil(s * 1.05 * 0.001) * 1000;
	cout << (int)s << endl;
		
	return 0;
}

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

int main(){

    int N,M;
    cin>>N>>M;
    long long int ans=1;
    if(N==M+1){
        for(int i=1;i<=N;i++){
            ans=(ans*i)%1000000007;
        }
        for(int i=1;i<=M;i++){
            ans=(ans*i)%1000000007;
        }
    }
    else if(N==M){
        for(int i=1;i<=N;i++){
            ans=(ans*i)%1000000007;
        }
        ans=(ans*ans*2)%1000000007;
    }
    else if(N+1==M){
        for(int i=1;i<=N;i++){
            ans=(ans*i)%1000000007;
        }
        for(int i=1;i<=M;i++){
            ans=(ans*i)%1000000007;
        }
    }
    else ans=0;
    cout<<ans<<endl;
}


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

using namespace std;

int main()
{
    int n, k;
    ios_base::sync_with_stdio(0);

    cin >> n >> k;
    vector<int> v(10);

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

    while (true) {
        int f = 1;
        int temp = n;
        while (temp) {
            if (v[temp%10] == 1) {
                f = 0;
                break;
            }
            temp /= 10;
        }

        if (f) {
            cout << n;
            break;
        }

        ++n;
    }
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;

long long M;
int N;
Graph G;

// dp[v][to] := 有効辺 (v, to) について to 側の木についての解
vector<vector<long long>> dp;
vector<long long> res;

long long rec(int v, int p = -1) {
    long long res = 1;
    dp[v].assign(G[v].size(), 1);
    for (int i = 0; i < G[v].size(); ++i) {
        int to = G[v][i];
        if (to == p) continue;
        dp[v][i] = (rec(to, v) + 1) % M;
        res = res * dp[v][i] % M;
    }
    return res;
}

void rerec(int v, long long pval = 0, int p = -1) {
    int s = G[v].size();
    for (int i = 0; i < s; ++i) {
        int to = G[v][i];
        if (to == p) dp[v][i] = (pval + 1) % M;
    }

    // 累積積
    vector<long long> left(s+1, 1), right(s+1, 1);
    for (int i = 0; i < s; ++i) {
        left[i+1] = (left[i] * dp[v][i]) % M;
        right[i+1] = (right[i] * dp[v][s-i-1]) % M;

        //cout << v << ", " << G[v][i] << ": " << dp[v][i] << endl;
    }
    res[v] = left[s];

    // それぞれ
    for (int i = 0; i < s; ++i) {
        int to = G[v][i];
        if (to == p) continue;
        long long toval = left[i] * right[s-i-1] % M;
        rerec(to, toval, v);
    }
}

void solve() {
    res.assign(N, 1);
    dp.assign(N, vector<long long>());
    rec(0);
    rerec(0);
    for (int v = 0; v < N; ++v) cout << res[v] << endl;
        
}

int main() {
    while (cin >> N >> M) {
        G.assign(N, vector<int>());
        for (int i = 0; i < N-1; ++i) {
            int x, y; cin >> x >> y; --x, --y;
            G[x].push_back(y); G[y].push_back(x);
        }
        solve();
    }
}


Measured memory_bytes: 24320
//#include <fstream>

#include <iostream>
#include <algorithm>

using namespace std;

const int MOD = 1000000007;
const int NMAX = 1005;
int n, m;
char s[NMAX][NMAX];
int dp[NMAX][NMAX];

int main()
{
	//ifstream cin("test.in");
	//ofstream cout("test.out");
	cin >> n >> m;
	for (int i = 1;i <= n;++i)
		cin >> (s[i] + 1);
	for (int i = 1;i <= n;++i)
	{
		s[i][0] = s[i][m + 1] = '#';
		s[i][m + 2] = 0;
	}
	for (int j = 1;j <= m;++j)
	{
		s[0][j] = s[n + 1][j] = '#';
	}
	dp[1][1] = 1;
	for (int i = 1;i <= n;++i)
	{
		for (int j = 1;j <= m;++j)
		{
			if (i == 1 && j == 1)
				continue;
			if (s[i][j] == '#')
				continue;
			int x = 0, y = 0;
			if (s[i - 1][j] == '.')
				x = dp[i - 1][j];
			if (s[i][j - 1] == '.')
				y = dp[i][j - 1];
			dp[i][j] = (1LL * x + y) % MOD;
		}
	}
	cout << dp[n][m] << "\n";
	return 0;
}

Measured memory_bytes: 5120
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;

class _Class
{
  void _Do()
  {
    var s = Split.strings()[0];
    int z = 0;
    for (int i = 0; i < s.Length; i++)
      if (s[i] == '0')
        z += 1;
    for (int i = 0; i < s.Length; i++)
      if (s[i] == '1')
        z -= 1;
    z = Math.Abs(z);
    Console.WriteLine(s.Length-z);

  }

  static void Main(string[] args)
  {
    new _Class()._Do();
  }
}

static class Split
{ 

  // 1
  public static string[] strings()
  {
    return Console.ReadLine().Split();
  }


  // [2.1] -2,147,483,648 ~ +2,147,483,647
  public static int[] ints()
  {
    var _s = Console.ReadLine().Split();

    var x = new int[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = int.Parse(_s[i]);

    return x;
  }

  // [2.2] 
  // -9,223,372,036,854,775,808 ~ 
  // +9,223,372,036,854,775,807
  public static long[] longs()
  {
    var _s = Console.ReadLine().Split();

    var x = new long[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = long.Parse(_s[i]);

    return x;
  }

  public static double[] doubles()
  {
    var _s = Console.ReadLine().Split();

    var x = new double[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = double.Parse(_s[i]);

    return x;
  }

  public static BigInteger[] bigs()
  {
    var _s = Console.ReadLine().Split();

    var x = new BigInteger[_s.Length];
    for (var i = 0; i < _s.Length; i++)
      x[i] = BigInteger.Parse(_s[i]);

    return x;
  }
}







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

int main(){
	int N;
	cin>>N;
	
	int A[N]={};
	for(int i=0;i<N;i++)
		cin>>A[i];
	
	int Alice=0,Bob=0;
	sort(A,A+N,greater<int>());
	
	for(int i=0;i<N;i++){
		if(i%2==0)
			Alice+=A[i];
		else
			Bob+=A[i];
	}
	
	cout<<Alice-Bob<<endl;
	return 0;
	
}

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

int main()
{
   int a,b,c,i,j,k,s,t=0;
   scanf("%d",&a);
   scanf("%d",&b);
   scanf("%d",&c);
   scanf("%d",&s);
   for(i=0;i<=a;i++)
   {
       for(j=0;j<=b;j++)
       {
           for(k=0;k<=c;k++)
           {
               if(i*500+j*100+k*50==s)
                  t++;
           }
       }
   }
    printf("%d\n",t);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn=100004;
int s[maxn];
char step[maxn];
int n;
int flag=0;
void dfs(int a,int b,int c,int id){
	if(!flag){
		if(id==n+1) {
			printf("Yes\n");
			for(int i=1;i<=n;i++) printf("%c\n",step[i]);
			flag=1;
			return ;
		}
		if(s[id]==1) {
			for(int i=1;i<=2;i++){
				if(i==1) {
					a++;b--;
					if(a>=0&&b>=0){
						step[id]='A';
						dfs(a,b,c,id+1);
					}
					a--;b++;
				}
				else{
					b++;a--;
					if(a>=0&&b>=0){
						step[id]='B';
						dfs(a,b,c,id+1);
					}
					a++;b--;
				}
			}
		}
		if(s[id]==2) {
			for(int i=1;i<=2;i++){
				if(i==1) {
					c++;b--;
					if(c>=0&&b>=0){
						step[id]='C';
						dfs(a,b,c,id+1);
					}
					c--;b++;
				}
				else{
					b++;c--;
					if(c>=0&&b>=0){
						step[id]='B';
						dfs(a,b,c,id+1);
					}
					c++;b--;
				}
			}
		}
		if(s[id]==3) {
			for(int i=1;i<=2;i++){
				if(i==1) {
					a++;c--;
					if(a>=0&&c>=0){
						step[id]='A';
						dfs(a,b,c,id+1);
					}
					a--;c++;
				}
				else{
					c++;a--;
					if(a>=0&&c>=0){
						step[id]='C';
						dfs(a,b,c,id+1);
					}
					a++;c--;
				}
			}
		}
	}
}
int main(){
	int a,b,c;
	scanf("%d%d%d%d",&n,&a,&b,&c);
	getchar();
	for(int i=1;i<=n;i++){
		char ch1=getchar();
		char ch2=getchar();
		if(ch1=='A'&&ch2=='B') s[i]=1;
		if(ch1=='A'&&ch2=='C') s[i]=3;
		if(ch1=='B'&&ch2=='C') s[i]=2;
		if(ch2=='A'&&ch1=='B') s[i]=1;
		if(ch2=='A'&&ch1=='C') s[i]=3;
		if(ch2=='B'&&ch1=='C') s[i]=2;
		getchar();
	}
	dfs(a,b,c,1);
	if(flag==0) printf("No\n");
}

Measured memory_bytes: 13688
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
    int n,q;
    cin>>n;
    for(int i=9;i>=1;i--)
    {
       if(n%i==0)
       {
           q=n/i;
           if(q<=9)
           {
               cout<<"Yes";
               return 0;
           }
       }
    }
    cout<<"No";
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int q; cin >> q;
  ll sum_b = 0;
  ll min_val = 0;
  ll left, right;
  multiset<ll> set_left, set_right;
  REP(i,q){
    int x; cin >> x;
    auto itr = set_left.begin();
    switch(x){
      case 1: ll a,b; cin >> a >> b;
      if(i!=0){
        itr = set_left.end(); itr--;
        left = *itr;
        right = *set_right.begin();
      }
      if(i==0||*itr>=a){
        set_left.insert(a);
        set_left.insert(a);
        itr = set_left.end(); itr--;
        set_right.insert(*itr);
        set_left.erase(itr);
      }else{
        set_right.insert(a);
        set_right.insert(a);
        set_left.insert(*set_right.begin());
        set_right.erase(set_right.begin());
      }
      sum_b += b;
      if(i!=0){
        if(left>a||a>right) min_val += min(abs(left-a),abs(right-a));
      }
      break;
      case 2:
      itr = set_left.end(); itr--;
      cout << *itr << " " << min_val+sum_b << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 18944
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

char s[200010];
int szS;

char lastS[200010];
int szLast;

int check(int p)
{
	int count = 0;
//	ip = 0;
	while (p < szS)
	{
		if (szLast == 1)
		{
			if (lastS[0] == s[p])
			{
				if ((p + 1) < szS)
				{
					lastS[0] = s[p];
					lastS[1] = s[p + 1];
					lastS[2] = '\0';
					szLast = 2;
					p += 2;
					count++;
				}
				else
				{
					lastS[1] = s[p];
					szLast = 2;
					p++;
				}
			}
			else
			{
				lastS[0] = s[p];
				lastS[1] = '\0';
				szLast = 1;
				p++;
				count++;
			}
		}
		else
		{
			lastS[0] = s[p];
			lastS[1] = '\0';
			szLast = 1;
			p++;
			count++;
		}
	}
	
	return count;
}

int main()
{
	scanf("%s", s);
	szS = strlen(s);
	
	strcpy(lastS, "");
	szLast = 0;
	int countA = check(0);
	
	
	int countB = 0;
	
	if (szS >= 2)
	{
		lastS[0] = s[0];
		lastS[1] = s[1];
		lastS[2] = '\0';
		countB = check(2) + 1;
	}
	
	
	if (countA < countB)
		printf("%d\n", countB);
	else
		printf("%d\n", countA);
		
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<P, int> PP;
int main(){
	ll x, a, b; cin >> x >> a >> b;
	if (a >= b)cout << "delicious" << endl;
	else if (x >= b-a)cout << "safe" << endl;
	else cout << "dangerous" << endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};

fn main() {
    input! {
        s: String,
    }
    let sc = s.chars().collect::<Vec<char>>();
    if sc[sc.len() - 1] == 's' {
        println!("{}{}", s, "es");
    } else {
        println!("{}{}", s, "s");
    }
}


Measured memory_bytes: 2192
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  string sa, sb, sc;
  cin >> sa >> sb >> sc;
  sa += "x"; sb += "y"; sc += "z";
  ll a = 0; ll b = 0; ll c = 0;
  string ns = "a";
  while (1) {
    if (ns == "x") {
      cout << "A" << '\n';
      return 0;
    }
    if (ns == "y") {
      cout << "B" << '\n';
      return 0;
    }
    if (ns == "z") {
      cout << "C" << '\n';
      return 0;
    }
    else if (ns == "a") {
      ns = sa[a];
      ++a;
    }
    else if (ns == "b") {
      ns = sb[b];
      ++b;
    }
    else if (ns == "c") {
      ns = sc[c];
      ++c;
    }
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3616
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var h = new HashSet<char>();
		for(int i=0;i<N;i++) h.Add(S[i]);
		if(h.Count == N){
			Console.WriteLine(0);
			return;
		}
		
		var RH = new RollingHash(S, 2525, (long)1e9 + 7);
		
		int l = 0, r = N;
		while(r - l > 1){
			int c = (r + l) / 2;
			
			var di1 = new Dictionary<long, int>();
			var di2 = new Dictionary<long, int>();
			for(int i=0;i+c-1<N;i++){
				var h1 = RH.GetHash(i, c);
				if(di1.ContainsKey(h1) == false){
					di1.Add(h1, i);
					di2.Add(h1, i);
				}
				di1[h1] = Math.Min(di1[h1], i);
				di2[h1] = Math.Max(di2[h1], i);
			}
			bool chk = false;
			var ks = di1.Keys;
			foreach(var k in ks){
				if(di2[k] - di1[k] >= c) chk = true;
			}
			
			if(chk){
				l = c;
			} else {
				r = c;
			}
		}
		Console.WriteLine(l);
		
	}
	int N;
	String S;
	public Sol(){
		N = ri();
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

class RollingHash{
	
	long[] Hash;
	long[] Base;
	String S;
	long mod;
	int N;
	
	public RollingHash(String s_,long base_=2525,long mod_=(long)1e9+7){
		mod=mod_;
		S=s_;
		N=S.Length;
		Hash=new long[N+1];
		
		Base=new long[N+1];
		Base[0]=1;
		Base[1]=base_;
	
		for(int i=1;i<N;i++){
			Base[i+1]=Base[i]*Base[1];
			if(Base[i+1]>=mod)Base[i+1]%=mod;
		}
		
		Hash[0]=0;
		Hash[1]=(long)S[0];
		for(int i=1;i<N;i++){
			Hash[i+1]=Hash[i]*Base[1]+(long)S[i];
			if(Hash[i+1]>=mod)Hash[i+1]%=mod;
		}
	}
	
	public long GetHash(int strt,int len){
		//return hash of S.Substring(strt,len);
		if(len==0)return 0;
		if(strt+len>=N)len=N-strt;
		long ret=Hash[strt+len]+mod-(Hash[strt]*Base[len]>=mod?Hash[strt]*Base[len]%mod:Hash[strt]*Base[len]);
		return ret>=mod?ret%mod:ret;
	}
	

}

Measured memory_bytes: 23008
module Memoizable
	def memoize(name)
		original = "__original_#{name}__"
		([Class, Module].include?(self.class) ? self : self.class).class_eval {
			alias_method(original, name)
			private(original)
			cache = {}
			define_method(name){|*args|
				cache[args] ||= send(original, *args)
			}
		}
	end 
end

def addition(s1, s2)
	match_len = s2.size-1
	match_len -= 1 until match_len == 0 || s1 =~ /#{s2[0..match_len-1]}$/
	s2.size - match_len
end

include Memoizable
memoize :addition

loop {
	n = gets.to_i
	break if n == 0
	names = (1..n).map{gets.chomp}
	trivial = []
	names.combination(2){|a, b|
		trivial << b if a =~ /#{b}/
		trivial << a if b =~ /#{a}/
	}
	trivial.uniq!
	n -= trivial.size
	names -= trivial
	names << ""
	a = {}
	(0..n).to_a.permutation(2){|i, j|
		a[[i, j]] = addition(names[i], names[j])
	}
	
	table = [{n => 0}]		
	(1..(1<<n)-1).each{|x|
		table[x] = Hash.new(Float::INFINITY)
		t = table[x]
		is = (0..n-1).select{|i| x[i] == 1}
		is.each{|i|
			y = x - (1 << i)
			last_name = names[i]
			table[y].each{|k, len|
				l = len + a[[k, i]]
				t[i] = l if l < t[i]
			}
		}
	}
	p table[(1<<n)-1].values.min
}

Measured memory_bytes: 26240
#include<stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", s);
    char pc = s[0];
    int ans = 1;
    int x = 1;
    while(s[x] != '\0'){
        if(s[x] != pc){
            ans++;
            pc = s[x];
        }
        x++;
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double LD;
typedef long long ll;
#define int ll
#define pb push_back
#define mp make_pair
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
#define forn(i, n) for (int i = 0; i < n; i++)
void solve()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < (n); i++)
    {
        int t = n / i;
        if (t * i < n)
            ans += t;
        else
            ans += t - 1;
    }
    cout << ans;
}
int32_t main()
{
    // int t;
    // cin >> t;
    // while(t--)
    solve();

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define hell  1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb   push_back


int main()
{
	ios;
	ll n;
	string s="";
	cin>>n;
	while(n>0)
	{
		if(n%26==0)
		{
			s+='z';
			n/=26;
			n--;
		}
		else
		{
			s+=char(97+((n-1)%26));
			n/=26;
		}
	}
	for(ll i=s.size()-1;i>=0;i--)
	{
		cout<<s[i];
	}
}

Measured memory_bytes: 3656
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int cnt[30], l[100010], r[100010];
signed main() {
    string s; cin >> s;
    int len = s.length();
    rep(i,0,s.length()) cnt[ s[i] - 'a' ]++;
    rep(i,0,len)    l[i+1] = l[i  ] + (s[i] != 'x');
    repr(i,len-1,0) r[i+1] = r[i+2] + (s[i] != 'x');
    
    int odd = 0;
    rep(i,0,26) {
        if(cnt[i] % 2 && (i != 'x' - 'a')) {
            odd++;
        }
    }

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

    string notx = "";
    rep(i,0,len) if(s[i] != 'x') notx += s[i];
    string rev_notx = notx;
    reverse(rev_notx.begin(), rev_notx.end());
    if(notx != rev_notx) {
        cout << -1 << endl;
        return 0;
    }

    string rev = s;
    reverse(rev.begin(), rev.end());

    int a = 0, b = 0, ans = 0;
    while(a < len || b < len) {
        if(a == len) ans++, b++;
        else if(b == len) ans++, a++;
        else if(s[a] == rev[b]) a++, b++;
        else if(s[a] == 'x') ans++, a++;
        else if(rev[b] == 'x') ans++, b++;
    }
    cout << ans / 2 << endl;
    return 0;
}

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

typedef long long Int;
typedef pair<Int,Int> PII;
typedef vector<int> VInt;
 
#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define EACH(it, a) for(auto it = (a).begin(); it != (a).end(); ++it)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair

char A[128][128];
int R[128][128];

int main()
{
	int H, W;
	cin >> H >> W;
	int i, j;
	FOR(i, 0, H) cin >> A[i];
	FOR(i, 0, H)
	FOR(j, 0, W)
	{
		R[i][j] = H*W;
		if(i == 0 && j == 0) R[i][j] = 0;
		if(i != 0) R[i][j] = min(R[i][j], R[i - 1][j] + (A[i][j] == A[i - 1][j] ? 0 : 1));
		if(j != 0) R[i][j] = min(R[i][j], R[i][j - 1] + (A[i][j] == A[i][j - 1] ? 0 : 1));
	}

	int res = R[H - 1][W - 1];
	if(res % 2 == 0)
	{
		res = res / 2;
		if(A[0][0] != '.') ++res;
	}
	else res = (res + 1)/2;

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll Q = 1000000007;

int main(){
  ll N,M;
  cin >> N >> M;
  string S,T;
  cin >> S >> T;
  ll g=1,l;
  while(true){
    l=N*g;
    if(l%M==0){
      break;
    }
    g ++;
  }
  g=N*M/l;
  for(ll i=0;i<g;i++){
    //cout << S[i*l/M] << " " << T[i*l/N] << endl;
    if(S[i*l/M]!=T[i*l/N]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << l << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  for (int i=0; i<N; i++) cin >> P[i];
  for (int i=0; i<N; i++) cin >> Q[i];
  
  if(P>Q) swap(P,Q);
  int ans = 0;
  
  while(P<Q){
    next_permutation(P.begin(), P.end());
    ans += 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
const long long int mod=1e9+7;
typedef long long ll;
int N,A,B,C;
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int dfs(vector<int> HowUse,vector<int> L){
    //cout<<"howuselen : "<< HowUse.size()<<endl;
    if(HowUse.size()==N){
        int lenA,lenB,lenC;
        int cost=0;
        lenA=lenB=lenC=0;
        
        FOR(i,N){
            if(HowUse[i]==1){
                lenA+=L[i];
                if(lenA!=L[i]){
                    cost+=10;
                }
            }else if(HowUse[i]==2){
                lenB+=L[i];
                if(lenB!=L[i]){
                    cost+=10;
                }
            }else if(HowUse[i]==3){
                lenC+=L[i];
                if(lenC!=L[i]){
                    cost+=10;
                }
            }
        }
        if(lenA==0 || lenB==0 || lenC==0){
            return INT32_MAX;
        }
        cost+=abs(lenA-A);
        cost+=abs(lenB-B);
        cost+=abs(lenC-C);    
        return cost;
    }
    vector<int> tmpA=HowUse;
    vector<int> tmpB=HowUse;
    vector<int> tmpC=HowUse;
    vector<int> tmpD=HowUse;
    tmpA.push_back(1);
    tmpB.push_back(2);
    tmpC.push_back(3);
    tmpD.push_back(0);
    int a=dfs(tmpA,L);
    int b=dfs(tmpB,L);
    int c=dfs(tmpC,L);
    int d=dfs(tmpD,L);
    vector<int> re;
    if(a>=0){
        re.push_back(a);
    }
    if(b>=0){
        re.push_back(b);
    }
    if(c>=0){
        re.push_back(c);
    }
    if(d>=0){
        re.push_back(d);
    }
    //i->A
    //B
    //C
    //unse
    int min=INT32_MAX;
    for(auto x : re){
        if(min>x){
            min=x;
        }
    }
    return min;
    
}
bool vecfind(vector<string> v,string in){
    for(auto x:v){
        if(x==in){
            return false;
        }
    }
    return true;
}
int main(){
    int N,M;
    cin>>N;
    string s[N];
    vector<string> S;
    FOR(i,N){
        cin>>s[i];
        //string tmp=s[i];
        
    }
    cin>>M;
    string t[M];
    FOR(i,M){
        cin>>t[i];
    }

    int ans[N]={0};
    int max=0;
    FOR(i,N){
        FOR(j,N){
            
            if(s[i]==s[j]){
                ans[i]++;
            }
            
            
        } 
        FOR(k,M){
                if(s[i]==t[k]){
                    ans[i]--;
                }
            }  
    }
    FOR(i,N){
        if(max<ans[i]){
            max=ans[i];
        }
    }

    cout<<max<<endl;
    return 0;
}




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

int main(){
    int n;
    cin >> n;
    int a[n+1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int ans[n+1];
    vector<int> b;
    int mid = n / 2;
    for(int i = n; i > mid; i--){
        if(a[i] == 1){
            ans[i] = 1;
            b.push_back(i);
        } else {
            ans[i] = 0;
        }
    }
    for(int i = mid; i >= 2; i--){
        int t = 0;
        for(int j = 2*i; j <= n; j+=i){
            if(ans[j] == 1){
                t++;
            }
        }
        if(t % 2 == a[i]){
            ans[i] = 0;
        } else {
            ans[i] = 1;
            b.push_back(i);
        }
    }    
    if(a[1] == (b.size() % 2)){
        ans[1] = 0;
    } else {
        ans[1] = 1;
        b.push_back(1);
    }
    int m = b.size();
    cout << m << endl;
    sort(b.begin(), b.end());
    for(int i = 0; i < m; i++){
        if(i == m -1){
            cout << b[i] << endl;
        } else {
            cout << b[i] << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+10;
const int mo_num=1e6+3;
int n,m,a[maxn],b[maxn],ans;
int jc[maxn];
int ext_gcd(int a,int b,int &x,int &y){ if(b==0){x=1;y=0;return a;}int q=a/b, g=ext_gcd(b,a-q*b,x,y), z=x-q*y;x=y; y=z;return g; }
int inv(int a){ int x,y;ext_gcd(a,mo_num,x,y);return (x+mo_num)%mo_num; }
void init(int *x, int len){ x[0]=1;for(int i=1;i<len;i++)x[i]=(x[i-1]*i)%mo_num; }
int C(int r,int n){ if(n<0 or n<r or r<0)return 0;return (jc[n]*inv(jc[r])%mo_num)*inv(jc[n-r])%mo_num; }
int Pow(int a,int b){//快速幂
    a%=mo_num;
    int ans = 1;
    while(b)
    {
        if(b&1)
            ans = (ans*a)%mo_num;
        a = (a*a)%mo_num;
        b/=2;
    }
    return ans%mo_num;
}
int32_t main()
{
    IOS
    int t;
    init(jc,maxn);
    cin>>t;
    fut(i)
    {
        int x,d;
        cin>>x>>d>>n;
        if(!d){
            out(mod(Pow(x,n)))
            continue;
        }
        x=mod(x*inv(d));
        if(x+n-1>=mo_num){
            out(0)
            continue;
        }
        out(mod(jc[x+n-1]*mod(inv(jc[x-1])*Pow(d,n))))
    }
    return 0;
}


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

#define MOD		1000000007
#define ll		long long int
#define pll		pair<ll, ll>
#define pb		push_back
#define endl	"\n"
#define f 		first
#define s 		second
#define fastio 	ios_base::sync_with_stdio(false);cin.tie(NULL)

ll power(ll x, ll y) { ll ans = 1; x %= MOD; while (y) {if (y & 1)ans = (x * ans) % MOD; x = (x * x) % MOD; y >>= 1;} return ans;}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)


int main() {
	string str;
	cin >> str;
	ll mod = 0;
	for(char c : str) {
        int curr = c - '0';
        mod += (curr % 9);
        mod %= 9;
	}

	if(mod) {
        cout << "No\n";
	} else {
        cout << "Yes\n";
	}

}


Measured memory_bytes: 3712
#include<iostream>

int dp[101][4][2];

int main(void){
    std::string s;
    int nzc;
    std::cin >> s >> nzc;
    int mk = s.size();
    dp[0][0][0] = 1;
    for(int i = 0; i < mk; i++){
	for(int j = 0; j < 4; j++){
	    for(int k = 0; k < 2; k++){
		int d = s[i] - '0';
		for(int l = 0; l < 10; l++){
		    int ni = i + 1, nj = j, nk = k;
		    if(l != 0){
			nj++;
		    }
		    if(nj > nzc){
			continue;
		    }
		    if(k == 0){
			if(l > d) continue;
			if(l < d) nk = 1;
		    }
		    // std::cout << ni << " " << nj << " " << nk << " " << dp[ni][nj][nk] << std::endl;
		    dp[ni][nj][nk] += dp[i][j][k];
		}
	    }
	}
    }
    std::cout << dp[mk][nzc][1] + dp[mk][nzc][0] << std::endl;
    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[110000],b[110000];
int main(){
    ll n,c=0,d=0;
    cin>>n;
    rep(i,0,n)cin>>a[i];
    rep(i,0,n)cin>>b[i];
    rep(i,0,n){
        if(a[i]>=b[i])c+=a[i]-b[i];
        else {
            if((b[i]-a[i])%2==0){d+=(b[i]-a[i])/2;}
            else {d+=(b[i]-a[i])/2+(ll)1;c++;}
        }
    }
    if(d>=c)cout<<"Yes";
    else cout<<"No";
}

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

int main(){
  long long int a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  int x=abs(b-a);
  if(v*t<w*t+x){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  } 
}

Measured memory_bytes: 3620
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
#define MAXN 100000
int lon[MAXN+5],jie=0;
int main(){
    int n,l;
    scanf("%d%d",&n,&l);
    for(int i=1;i<=n;i++)
        scanf("%d",&lon[i]);
    for(int i=1;i<n;i++)
        if(lon[i]+lon[i+1]>=l){
            jie=i;
            printf("Possible\n");
            break;
        }
    if(jie==0){
        printf("Impossible");
        return 0;
    }
    for(int i=1;i<jie;i++)
        printf("%d\n",i);
    for(int i=n-1;i>=jie+1;i--)
        printf("%d\n",i);
    printf("%d",jie);
    return 0;
}


Measured memory_bytes: 1152
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=2,mini=INF,sum=0;
    string str,str2;
    ll x;
    cin>>x;
    set<ll> s;
    while(1){
        if(f>=x){
            a=1;
            for(ll i=2;i<f;i++){
                if(f%i==0) a=0;
            }
            if(a==1){
                cout<<f<<endl;
                return 0;
            }
        }
                f++;

    }

    return 0;
}

Measured memory_bytes: 256
n, a, b, md = gets.split.map(&:to_i)

def getlen(a)
  res = 0
  while a > 0
    res += 1
    a /= 10
  end
  res
end

def modpow(a, b, md)
  res = 1
  while b > 0 
    if b.odd? 
      res = res * a % md
    end
    a = a * a % md
    b /= 2
  end
  res
end

def modpowsum(r, n, md)
  return 0 if n == 0
  if n.odd?
    return (1 + modpowsum(r, n - 1, md) * r) % md
  end
  x = modpowsum(r, n / 2, md)
  return x * (1 + modpow(r, n / 2, md)) % md
end

def modpowsum2(r, n, md)
  if n == 0
    return 0
  end
  if n.odd?
    return (n - 1 + modpowsum2(r, n - 1, md) * r) % md
  end
  x = modpowsum2(r, n / 2, md)
  return (x * modpow(r, n / 2, md) + x + modpowsum(r, n / 2, md) * n / 2) % md
end

k = 0
ans = 0

while k < n
  l = k
  r = n
  while r - l > 1
    m = (l + r) / 2
    if getlen(a + m * b) == getlen(a + k * b)
      l = m
    else
      r = m
    end
  end
  len = getlen(a + k * b) * (r - k)
  ans = ans * modpow(10, len, md) % md

  x = modpow(10, getlen(a + k * b), md)
  ans += (a + b * k) * modpowsum(x, r - k, md)
  ans += b * modpowsum2(x, r - k, md)
# a * modpowsum(x, r - k, md) + b * modpowsum2(x, r - k
  ans %= md
  k = r
end

puts ans



Measured memory_bytes: 1788
import java.util.*;
import java.util.Scanner;

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

        String S = sc.nextLine();
        String T = sc.nextLine();

        int[] R = new int[26];
        int[] RDash = new int[26];

        for (int i = 0; i < 26; i++) {
            R[i] = -1;
            RDash[i] = -1;
        }

        boolean canConvert = true;
        for (int i = 0; i < S.length(); i++) {
            int S_i = S.charAt(i) - 97;
            int T_i = T.charAt(i) - 97;
            if (R[S_i] >= 0) {
                if (R[S_i] != T_i) {
                    canConvert = false;
                    break;
                }
            }
            if (RDash[T_i] >= 0) {
                if (RDash[T_i] != S_i) {
                    canConvert = false;
                    break;
                }
            }
            if (R[S_i] < 0) {
                R[S_i] = T_i;
            }
            if (RDash[T_i] < 0) {
                RDash[T_i] = S_i;
            }
        }

        if (canConvert) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 30428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int n, m;
void solve() {
	cin >> n >> m;
	map<int, bool> ok;
	pair<int, int> a[m];
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		if (u > v) swap(u, v);
		if (u == 1) {
			ok[v] = true;
		}
		a[i].first = u;
		a[i].second = v;
	}
	for (int i = 0; i < m; i++) {
		if (a[i].second == n && ok[a[i].first]) {
			cout << "POSSIBLE";
			return;
		}
	}
	cout << "IMPOSSIBLE";
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1; 
    //cin >> T;
    while(T--) solve();
}

Measured memory_bytes: 11264
#include<stdio.h>
int main(void)
{
  int a,b,c,i,n=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i = a;i <= b; i++)
    if(c%i==0)n++;
    printf("%d\n",n);
    return 0;
}



Measured memory_bytes: 2140
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var s = cin.Read;

            var max = 0;
            for (int i = 1; i < n; ++i)
            {
                var x = s.Substring(0, i).ToCharArray().Distinct();
                var y = s.Substring(i).ToCharArray().Distinct();
                max = Math.Max(x.Intersect(y).Count(), max);
            }
            Console.WriteLine(max);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; }}
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main()
{
    Hello
    int healthTak, strengthTak, healthAok, strengthAok;
    cin >> healthTak >> strengthTak >> healthAok >> strengthAok;
    int cntr = 0;
    while(true){
        if(cntr % 2 == 0){
            if(healthTak <= 0)
                return cout << "No", 0;
            healthAok -= strengthTak;
        }
        else {
            if(healthAok <= 0)
                return cout << "Yes", 0;
            healthTak -= strengthAok;
        }
        cntr++;
    }
    return 0;
}

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

int N,M;
struct edge{ ll from,to,cost;};
vector<edge> E;
vector<ll> d;
vector<bool> negative;

void f(int s){
    rep(i,N+10) {d[i] = INF; negative[i] = false;}

    d[s] = 0;
    ll cnt=0;
    rep(i,N){
        rep(j,M){
            edge e = E[j];
            if(d[e.from] != INF && d[e.to] > d[e.from]+e.cost){
                d[e.to] = d[e.from] + e.cost;
                if(i==N-1) negative[e.to] = true;
            }
        }
    }
    rep(i,N){
        rep(j,M){
            edge e = E[j];
            if(negative[e.from]){
                negative[e.to] = true;
            }
        }
    }
    return ;
}

int main(){
    cin >> N >> M;
    d.resize(N+10); negative.resize(N+10);
    rep(i,M){
        int s,t,c; cin >> s >> t >> c;
        s--;t--;c=-c;
        edge e = {s,t,c};
        E.push_back(e);
    }
    f(0);
    if(negative[N-1]) cout << "inf" << endl;
    else cout << -d[N-1] << endl;
}

Measured memory_bytes: 3652
//ABC 048-A
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;


int main() {
	string str1, str2, str3;
	cin >> str1 >> str2 >> str3;
	cout << str1[0] << str2[0] << str3[0];
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
int main(void)
{
  int h, w;
  char map[52][52] = {};
  bool ok = true;
  std::cin >> h >> w;
  for(int i = 0; i != h; i++){
    for(int j = 0; j != w; j++){
      std::cin >> map[i + 1][j + 1];
    }
  }
  for(int i = 0; i != h; i++){
    for(int j = 0; j != w; j++){
      if(map[i + 1][j + 1] == '#'){
        if(map[i][j + 1] != '#' && map[i + 1][j] != '#' && 
           map[i + 2][j + 1] != '#' && map[i + 1][j + 2] != '#'){
          ok = false;
          goto end;
        }
      }
    }
  }
  end:
  std::cout << (ok ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

N, W = [int(x) for x in input().split()]
items = [tuple(map(int, input().split())) for _ in range(N)]

#topdown
memo = np.zeros(shape = W+1, dtype = np.int64)

for w,v in items:
    memo[w:] = np.maximum( memo[w:], memo[:-w] + v)

print(memo[-1])

Measured memory_bytes: 29752
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll A, B;
    cin >> A >> B;

    if (A % B == 0) {
        cout << "-1" << endl;
    } else {
        reps(i, 2, MAX_N) {
            if ((A * i) % B != 0) {
                cout << A * i << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
int n,m,q,k;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int len=s1.length();
	string ans=s2.substr(0,len);
	if(ans==s1) cout<<"Yes";
	else cout<<"No";
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,k,r,s,p; cin >> n >> k >> r >> s >> p;
    string t; cin >> t;
    vector<char> kiroku(n);
    int ans = 0;
    REP(i,n){
        if(i<k){
            if(t[i]=='r') ans += p;
            if(t[i]=='s') ans += r;
            if(t[i]=='p') ans += s;
            kiroku[i] = t[i];
        }
        if(i>=k && kiroku[i-k]!=t[i]){
            if(t[i]=='r') ans += p;
            if(t[i]=='s') ans += r;
            if(t[i]=='p') ans += s;
            kiroku[i] = t[i];
        }
    }
    out(ans);

    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <string>
#include <stack>
#include <utility>
#include <vector>
#include <math.h>

#define rep(i, n) for (auto i = 0; i < (n); i++)
#define MOD 1e9 + 7
typedef long long ll;

using namespace std;

int main() {
  int n, d;
  cin >> n >> d;
  int c = 0;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    if (sqrt(x*x + y*y) <= d)
      c++;
  }
  cout << c << endl;

  return 0;
}



Measured memory_bytes: 3180
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  int min;

  int ab, ac, bc;
  ab = a+b;
  ac = a+c;
  bc = b+c;
  if (ab > ac) {
    if (ac > bc) {
      min = bc;
    }
    else {
      min = ac;
    }
  }
  else {
    if (ab > bc) {
      min = bc;
    }
    else {
      min = ab;
    }
  }
  printf("%d\n", min);
  return 0;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

int euclid(int a, int b)
{
    if (a < b)
        euclid(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

int sum_digit(int x)
{
    int sum = 0;
    while (x)
    {
        // cout << x << " ";
        sum += x % 10;
        x /= 10;
    }
    // cout << " + " << sum << endl;
    return sum;
}

signed main()
{
    int n, a, b;
    cin >> n >> a >> b;

    int sum = 0;
    for (int i = 0; i <= n; i++)
    {
        int tmp = sum_digit(i);
        if (tmp >= a && tmp <= b)
        {
            sum += i;
            // cout << i << " =" << endl;
        }
    }
    // cout << endl;
    cout << sum << endl;
}


Measured memory_bytes: 384