akhauriyash/Code-Regression huggingface dataset:
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

uint32_t nextpint(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }
void printint(uint32_t x){ if(x<0){x=-x; putchar_unlocked('-');}else if(x==0){putchar_unlocked('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar_unlocked(s[i]); putchar_unlocked('\n'); }

char s[4002];

int main(void){
	uint32_t n=nextpint();
	nextstr(s+1);
	uint32_t dr=0, dg=0, db=0;
	for(uint32_t i=1; i<=n; i++){
		if(s[i]=='R'){
			dr++;
		}else if(s[i]=='G'){
			dg++;
		}else{
			db++;
		}
	}
	uint32_t ans=dr*dg*db;
	for(uint32_t i=1; i<=n/2; i++){
		for(uint32_t j=i-1; j>0; j--){
			if(s[i-j]!=s[i] && s[i+j]!=s[i] && s[i-j]!=s[i+j]){
				ans--;
			}
		}
	}
	for(uint32_t i=n/2+1; i<=n; i++){
		for(uint32_t j=n-i; j>0; j--){
			if(s[i-j]!=s[i] && s[i+j]!=s[i] && s[i-j]!=s[i+j]){
				ans--;
			}
		}
	}
	printf("%"PRIu32"\n", ans);
}


Measured memory_bytes: 1604
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n, m = get_li()
    K2S = defaultdict(set)
    S2K = defaultdict(set)
    for i in range(m):
        ks = get_li()
        S = ks[1:]
        for s in S:
            K2S[i+1].add(s)
            S2K[s].add(i+1)
    P = get_li()
    ans = 0
    for x in its.product([0, 1], repeat=n):
        valid = True
        for i in range(m):
            on = 0
            for j in K2S[i+1]:
                on += x[j-1]
            if on % 2 != P[i]:
                valid = False
                break
        if valid:
            ans += 1
    print(ans)
    return


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


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


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


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


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


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


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


if __name__ == '__main__':
    main()


Measured memory_bytes: 67180
h,w,k=map(int,input().split())
board=[list(input()) for _ in range(h)]
ans=0
for paint_h in range(2**h): #すべての行の塗りつぶし方を2進数で列挙する
    #print(paint_h)    
    for paint_w in range(2**w): #すべての列の塗りつぶし方を2進数で列挙する
        cnt=0
        for i in range(h): #すべてのi行目j列目の要素についてみる
            for j in range(w):
                if (paint_h>>i)&1==0 and (paint_w>>j)&1==0: #各行のi番目のビットと各列のj番目のビットがともに0であればそのマスは塗りつぶされない
                    if board[i][j]=='#': #塗りつぶされないマスが黒マスであれば個数を+1する
                        cnt+=1
        if cnt==k: #塗りつぶされない黒マスの個数がKに等しければ答えを+1する
            ans+=1
print(ans)


Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (int)1e9
#define OO (ll)1e18
#define EPS 1e-7
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=10005;
int f(int n){
    int cnt=0;
    while(n)
        cnt+=(n%10),n/=10;
    re cnt;
}
int main()
{
    IO;
    int n;
    cin >> n;
    int Min=100;
    for(int i=1;i<n;++i)
        Min=min(Min,f(i)+f(n-i));
    cout<<Min<<endl;
    re 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef unsigned long long ll;
//最大公約数
ll gcd(ll a,ll b){
    
    if(a==0 || b==0)return 0;
    if(a<b){
        ll sw;
        sw=a;
        a=b;
        b=sw;
    }
    
    ll r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }
    return b;
}
//最小公倍数
ll lcm(ll a,ll b){


    if(a==0 || b==0)return 0;

    return a/gcd(a,b)*b;

}

int main(void){
    
    int n;
    cin>>n;
    ll t[111];
    //cout<<lcm(122342,963223)<<endl;
    for(int i=0;i<n;i++)cin>>t[i];
    ll ans=1;
    for(int i=0;i<n;i++){
        ans=lcm(ans,t[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

const long INF = LLONG_MAX / 3;

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

  vector<long> dp(n, INF);
  dp[0] = 0;
  rep(i,n){
    rep(j,1,3){
      if(i+j < n){
        dp[i+j] = min<long>(dp[i+j], dp[i] + abs<long>(h[i+j] - h[i]));
      }
    }
  }

  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
char s[2005][2005];
int a[2005][2005];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int i,j,k,l;
    for(i=0;i<n;i++)
        scanf("%s",s[i]);
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(s[i][j]=='.')
            {
                k=j;
                while(1)
                {
                    j++;
                    if(s[i][j]=='#'||j>=m)break;
                }
                for(l=k;l<j;l++)
                {
                    a[i][l]+=(j-k);
                }
            }
        }
    }
    int maxx=-1;
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
        {
            if(s[j][i]=='.')
            {
                k=j;
                while(1)
                {
                    j++;
                    if(s[j][i]=='#'||j>=n)break;
                }
                for(l=k;l<j;l++)
                {
                    a[l][i]+=(j-k);
                    maxx=max(maxx,a[l][i]);
                }
            }
        }
    }
    printf("%d\n",maxx-1);
    return 0;
}


Measured memory_bytes: 19840
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>

#define mod 1000000007

using namespace std;

char S[1001];

int main()
{
    int len;

    scanf("%s", &S);

    printf("%s", S);
    len = strlen(S);
    if(S[len - 1] == 's')
        printf("e");
    printf("s");

    return 0;
}


Measured memory_bytes: 1732
#include <stdio.h>

int main(void){
  int a,b,c;
  int n;
  int i;

  scanf("%d" ,&n);
  for(i = 0;i < n;i++){
    scanf("%d %d %d" ,&a ,&b ,&c);
    if(c*c == a*a + b*b || b*b == a*a + c*c || a*a == b*b + c*c)
      printf("YES\n");

    else printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#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++)
#define _GLIBCXX_DEBUG

int main(){
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int count=0;
    rep(i,n){
        if(t[i]!=s[i]) count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3836
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        char alphabet[] = "abcdefghijklmnopqrstuvwxyz".toCharArray();
        char s[] = sc.next().toCharArray();
        int k = sc.nextInt();
        int n = s.length;

        for (int i = 0; i < n; i++) {
            if (s[i] != 'a') {
                int cnt = 26 - s[i] + 'a';
                if (k >= cnt) {
                    s[i] = 'a';
                    k -= cnt;
                }
            }
        }
        s[n - 1] = alphabet[(s[n - 1] - 'a' + k) % 26];

        System.out.println(new String(s));
    }

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


Measured memory_bytes: 28092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	string s1,s2;
	while(cin>>s1>>s2,s1!="0"){
		int a=0,b=0;
		rep(i,4){
			if(s1[i]==s2[i]){
				a++;
			}
		}
		rep(i,4){
			rep(j,4){
				if(s1[i]==s2[j]){
					b++;
				}
			}
		}
		cout<<a<<" "<<b-a<<endl;
	}
}

Measured memory_bytes: 1184
import fractions
a,b,c,d = map(int, input().split())

c_cnt = b//c - (a-1)//c
d_cnt = b//d - (a-1)//d
cd = (c * d) // fractions.gcd(c, d)
cd_cnt= b//cd - (a-1)//cd

ans = b-(a-1) - (c_cnt + d_cnt - cd_cnt)
print(ans)

Measured memory_bytes: 5048
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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 long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}



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

    if(A*C <=B)cout << C << endl;
    else cout <<  B/A  << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // AGC009A - Multiple Array
  int N; cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  REP(i, N){
    cin >> A[i] >> B[i];
  }

  ll ans = 0;
  for(int i = N-1; i >= 0; i--){
    if((A[i] + ans) % B[i] != 0){
      ans += B[i] - ((A[i] + ans) % B[i]);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;
//const ll mod=998244353;
int main(void){
  ll a,b;
  cin>>a>>b;
  if(b-a+1>=2019) cout<<0<<endl;
  else{
    ll ans=INF;
    for(ll i=a;i<=b-1;i++){
      for(ll j=i+1;j<=b;j++){
        ll L=i%2019,R=j%2019;
        ll a=(L*R)%2019;
        ans=min(a,ans);
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(void)
{
	int a,b,c,d,e,f,g,h;
	cin>>a>>b>>c>>d>>e;
	f=a*e;
	if (e<c)
	{
		g=b;
	}
	else if(e>c)
	{
		g=b+(e-c)*d;
	}
	if (g<f)
	{
		cout<<g<<endl;
	}
	else if (g>f)
	{
		cout<<f<<endl;
	}
	return 0;
}

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

typedef double db;
typedef int in;
typedef long int li;
typedef long long int lli;
typedef long ld;
typedef long lld;

#define pi M_PI
#define in scanf
#define out printf
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<n;++i)
#define debugd(d) printf("%d\n",d)
#define debugs(s) printf("%s\n",s)
#define debugc(c) printf("%c\n",c)
#define debugf(f) printf("%f\n",f)


int main (void)
{
  int x,a,b;
  in("%d %d %d \n",&x,&a,&b);
  if(abs(x-a)<abs(x-b)){
    puts("A");
  }else puts("B");
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int n = sc1.nextInt();
		int k = sc1.nextInt();
		String s = sc1.next();
		String str;

		if (k == 1) {
			str = s.toLowerCase().charAt(k-1) + s.substring(k, n);
		}
		else if ( k == n ) {
			str = s.substring(0, k-1) + s.toLowerCase().charAt(k-1);
		}
		else {
			str = s.substring(0, k-1) + s.toLowerCase().charAt(k-1) + s.substring(k, n);
		}

		System.out.println(str);

		sc1.close();

	}

}

Measured memory_bytes: 22868
#include <iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>

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

using namespace std;

vector<int> enum_div(int n)//nの約数を列挙
{
	vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> res;
    vector<int> hel(1000000, 0);
    REP(i,n) cin >> a[i];
    
    int cal=0;

    for(int i=n-1;i>=0;i--) {
        if (a[i] != hel[i+1]%2) {
            res.push_back(i+1);
            vector<int> dum = enum_div(i+1);
            for(auto i:dum) hel[i]++;
        }
    }

    cout << res.size() <<endl;
    REP(i,res.size()) cout << res[i] <<endl;
}

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

int main() {
  string a ,b;
  cin >> a >> b;
  if ( a.size() == b.size()){
  cout << (a<b ?"LESS" : a==b ?"EQUAL" : "GREATER")
    << endl;
  }else if(a.size() > b.size()){
    cout << "GREATER" << endl;
  }else if(a.size() < b.size()){
    cout <<  "LESS"  << endl;
  }      
}

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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;

    vector<int> sum(n+1);
    sum[0] = 0;
    for(int i = 0; i < n-1; ++i){
        if(s[i] == 'A' and s[i+1] == 'C'){
            sum[i+1] = sum[i] + 1;
        }
        else{
            sum[i+1] = sum[i];
        }
    }



    for(int i = 0; i < q; ++i){
        int l, r;
        cin >> l >> r;
        --l; --r;
        cout << sum[r]-sum[l] << endl;
    }

    return 0;
}


Measured memory_bytes: 1488
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    long[] X = aryread();
    long[] I = iota(N).array;
    zip(X, I).sort();
    // writeln(X);
    // writeln(I);
    long[] ans = new long[](N);

    foreach (i; 0 .. N / 2)
    {
        ans[I[i]] = X[N / 2];
    }
    foreach (i; N / 2 .. N)
    {
        ans[I[i]] = X[N / 2 - 1];
    }
    foreach (a; ans)
        writeln(a);
}


Measured memory_bytes: 13068
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, k;

llong pow(llong n, llong m) {
    llong res = 1;
    while (m--) res *= n;

    return res;
}

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

    cout << k * (pow(k - 1, n - 1)) << endl;

    return 0;
}


Measured memory_bytes: 256
#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;
ll const INF = 1LL << 60;

int main() {
  ll n, m;
  cin >> n >> m;
  cout << (n - 1) * (m - 1) << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
  int K,X; cin>>K>>X;

  int l=max(X-K+1,-1000000LL);
  int r=min(X+K-1, 1000000LL);
  for(int i=l;i<=r;i++){
    cout<<i<<' ';
  }
  cout<<endl;

  return 0;
}


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

int main(){
    int N,K; cin>>N>>K;
    int h[N];
    rep(i, N) cin>>h[i];

    ll dp[N];
    rep(i, N) dp[i] = 10e9;
    dp[0] = 0;
    for(int i=1; i<N; i++){
        for(int j=1; j<=min(i,K); j++){
            dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
        }
    }

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 4748
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        a: i64, b: i64, n: i64,
    }

    if b <= n {
        println!("{}", (a * (b - 1)) / b - a * ((b - 1) / b));
    } else {
        println!("{}", (a * n) / b - a * (n / b));
    }
}


Measured memory_bytes: 2176
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);


using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
const int M = 1e6 + 500;

lli dp[N];

void solve()
{
    lli n, k;
    cin>>n>>k;
    lli a[n];
    for(int i = 1; i <= n; i ++)
        cin>>a[i];
    for(int i = 1; i < n + 500; i ++)
        dp[i] = 1e9;
    dp[1] = 0;
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= k; j ++)
        {
            if(i + j <= n)
                dp[i + j] = min(dp[i + j], dp[i] + abs(a[i] - a[i + j]));
        }
    }
    cout<<dp[n]<<endl;
    return ;
}
/*
10
6
10 3 2 5 7 8
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    lli t;
    t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;


int main() {

	
	int N;
	cin >> N;
	string str;
	cin >> str;

	int cnt = 0;
	int ans = 0;
	for(int i = 2; i < N; i++) {
		if (str.at(i - 2) == 'A' && str.at(i - 1) == 'B' && str.at(i) == 'C') {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		String T = scan.next();
		int[] transArrayS = new int[26];
		for (int i = 0; i < transArrayS.length; i++) {
			transArrayS[i] = -1;
		}
		int[] transArrayT = new int[26];
		for (int i = 0; i < transArrayS.length; i++) {
			transArrayT[i] = -1;
		}
		for (int i = 0; i < S.length(); i++) {
			if (transArrayS[S.charAt(i) - 'a'] == -1) {
				transArrayS[S.charAt(i) - 'a'] = T.charAt(i) - 'a';
			} else if (transArrayS[S.charAt(i) - 'a'] != T.charAt(i) - 'a') {
				System.out.println("No");
				return;
			}
			if (transArrayT[T.charAt(i) - 'a'] == -1) {
				transArrayT[T.charAt(i) - 'a'] = S.charAt(i) - 'a';
			} else if (transArrayT[T.charAt(i) - 'a'] != S.charAt(i) - 'a') {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 26680
#include <iostream>
using namespace std;
int main()
{
	int N,K,a,b,ci,ti;
	while(~scanf("%d%d",&N,&K))
	{
		int sum=0;
		ci=ti=-1;
		for(int i=0;i<N;i++)
		 {
		 	scanf("%d%d",&a,&b);
		 	if(b>K) continue;
		 	if(ci==-1&&ti==-1) {ci=a;ti=b;sum++;}
		 	if(ci>=a)
		 	 {
		 	 	if(ci>a) {ci=a;ti=b;sum++;}
		 	 	if(ci==a&&ti>b) {ci=a;ti=b;sum++;}
			 }
		 }
		 if(sum==0) cout<<"TLE"<<endl;
		 else cout<<ci<<endl;
		   
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
int gcd(int a,int b){
  if(a%b==0){
    return b;
  }
  else{
    return gcd(b,a%b);
  }
}
int main(){
int n,x;
cin>>n>>x;
int c[n];
  int d[n];
  for(int i=0;i<n;i++){
    cin>>c[i];
  }
for(int i=0;i<n;i++){
  d[i]=abs(c[i]-x);
}
  int ans=d[0];
  for(int i=1;i<n;i++){
    ans=gcd(ans,d[i]);
  }
cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

template <typename T>
pair<vector<int>,vector<int>> dijkstra(const vector<vector<pair<int,T>>> &G,int s,T inf) {
  vector<int> d(G.size(),inf),c(G.size(),0);
  d[s] = 0;
  c[s] = 1;
  using P = pair<T,int>;
  priority_queue<P,vector<P>,greater<P>> que;
  que.emplace(0,s);
  while (!que.empty()) {
    T dd; int v;
    tie(dd,v) = que.top(); que.pop();
    if (d[v] < dd) continue;
    for (auto e : G[v]) {
      // cout << d[v] << " " << e.first << " " << d[v]+e.second << endl;
      if (d[e.first] > d[v]+e.second) {
        d[e.first] = d[v]+e.second;
        c[e.first] = c[v];
        que.emplace(d[e.first],e.first);
      } else if (d[e.first] == d[v]+e.second) {
        (c[e.first] += c[v]) %= MOD;
      }
    }
  }
  return make_pair(d,c);
}

int N,M,S,T;
int U[200010],V[200010],D[200010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> M >> S >> T;
  S--; T--;
  vector<vector<pair<int,int>>> G(N);
  REP(i,M) {
    cin >> U[i] >> V[i] >> D[i];
    U[i]--; V[i]--;
    G[U[i]].emplace_back(V[i],D[i]);
    G[V[i]].emplace_back(U[i],D[i]);
  }
  vector<int> ds,cs,dt,ct;
  tie(ds,cs) = dijkstra(G,S,INF);
  tie(dt,ct) = dijkstra(G,T,INF);
  int ans = cs[T]*cs[T];
  for (int i = 0; i < N; i++) {
    if (ds[i]*2 == ds[T]) {
      (ans += MOD-cs[i]*cs[i]%MOD*ct[i]%MOD*ct[i]%MOD) %= MOD;
    }
  }
  for (int i = 0; i < M; i++) {
    
    if (ds[U[i]]+D[i]+dt[V[i]] == ds[T]) {
      if (ds[U[i]]*2 < ds[T] && ds[V[i]]*2 > ds[T]) {
        (ans += MOD-cs[U[i]]*cs[U[i]]%MOD*ct[V[i]]%MOD*ct[V[i]]%MOD) %= MOD;
      }
    }
    if (ds[V[i]]+D[i]+dt[U[i]] == ds[T]) {
      if (ds[V[i]]*2 < ds[T] && ds[U[i]]*2 > ds[T]) {
        (ans += MOD-cs[V[i]]*cs[V[i]]%MOD*ct[U[i]]%MOD*ct[U[i]]%MOD) %= MOD;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main() {
  string s; cin>>s;
  int n=s.size(),hug=0;
  
  rep(i,n/2){
    if(s.at(i)!=s.at(n-i-1)){hug++;}
  }
  cout<<hug;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll big = 1000000007;
const ll mod = 998244353;

ll n,m,q;
ll T;


vi P;
ll pek[100001] = {0};
ll deg[100001] = {0};

ll par(int i){
    int i2 = i;
    while(i2 != pek[i2])i2 = pek[i2];
    return i2;
}

void merg(int i, int j){
    int i2 = par(i);
    int j2 = par(j);
    if(i2 != j2){
        if(deg[j2]> deg[i2]){
            int temp = i2;
            i2 = j2;
            j2 = temp;
        }
        deg[i2] += deg[j2];
        pek[j2] = i2;
    }
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);
    ll a,b,c,e;
    cin >> n >> m;
    for(int c1 = 0; c1 < n; c1++){
        cin >> a;
        a--;
        P.push_back(a);
        pek[c1] = c1;
        deg[c1] = 1;
    }
    for(int c1 = 0; c1 < m; c1++){
        cin >> a >> b;
        a--;
        b--;
        merg(a,b);
    }
    int ans = 0;
    for(int c1 = 0; c1 < n; c1++){
        ans += (par(P[c1]) == par(c1));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 2296
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define answer(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    string S, T;
    cin >> S >> T;

    for (int i = 0; i < n; i++) {
        cout << S[i] << T[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int r,c,i,j,xy[101][101];
 
    scanf("%d %d",&r,&c);
    for(i=0;i<r+1;i++)
    {
        for(j=0;j<c+1;j++)
        {
            xy[i][j] = 0;
        }
    }
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            scanf("%d",&xy[i][j]);
        }
    }
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            xy[i][c] += xy[i][j];
        }
    }
    for(i=0;i<r;i++)
    {
        for(j=0;j<c+1;j++)
        {
            xy[r][j] += xy[i][j];
        }
    }
    for(i=0;i<r+1;i++)
    {
        for(j=0;j<c+1;j++)
        {
            printf("%d",xy[i][j]);
            if(j!=c)
            {
                printf(" ");
            }
        }
            printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>  
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(int i = a; i <=b; i++)
#define rep2(i,a,b) for(int i = a; i>=b; i--)
#define PB push_back 
#define MP make_pair
#define db long double
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define cases int testcases;cin>>testcases; while(testcases--)
#define INF 2000000000
const double PI = acos(-1);
const int N = 100005;
#define eps 1e-6
#define MOD 1000000007
  int32_t main() 
  {
    IOS



        char ch;
        cin >> ch;
        ch++;
        cout << ch;




    return 0;
      }
        

Measured memory_bytes: 256
package main

import (
	"fmt"
)

// bit全探索

func main(){
	var h, w, k int
	fmt.Scan(&h, &w, &k )
	js := make([][]byte, h)
	for i := range js {
		fmt.Scan(&js[i])
	}

	var ans int

	for i := 0; i < 1 <<uint(h+w); i++ {
		cnt := 0
		for s := 0; s < h; s++ {
			for t := 0; t < w; t++ {
				if i&(1<<uint(s)) > 0 {
						continue
				}
				if i&(1<<uint(h+t)) > 0 {
					continue
				}
				if js[s][t] == '#' {
					cnt++
				}
			}
		}
		if cnt == k {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
import sys
input=sys.stdin.readline
from random import seed, randint

def calc(d,C,S,T):
    Last=[0]*26
    score=0
    for day,t in enumerate(T):
        t-=1
        Last[t]=day+1
        score+=S[day][t]
        for i,c in enumerate(C):
            score-=c*(day+1-Last[i])
    return score

def main():
    d=int(input())
    C=tuple(map(int,input().split()))
    S=[tuple(map(int,input().split())) for _ in range(d)]
    Ans=[0]*d
    Last=[0]*26
    for day in range(d):
        ans=0
        score=-float('inf')
        for t in range(26):
            TmpList=Last[:]
            tmp_score=0
            TmpList[t]=day+1
            for i,c in enumerate(C):
                tmp_score-=c*(day+1-TmpList[i])
            if tmp_score>score:
                score=tmp_score
                ans=t+1
        Ans[day]=ans
        Last[ans-1]=day
    print(*Ans,sep='\n')
    
if __name__=='__main__':
    main()

Measured memory_bytes: 78408
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args){
		solve();
	}

	public static void solve(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int d = sc.nextInt();
			int e = sc.nextInt();
			if(d==0 && e==0){
				break;
			}
			double ans = 100000.0;
			for(int i=0;i<=d/2;i++){
				ans = Math.min(ans, Math.abs(Math.sqrt(i*i+(d-i)*(d-i))-(double)e));
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 26288
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    System.out.print(s.charAt(0));
    System.out.print(s.length() - 2);
    System.out.println(s.charAt(s.length() - 1));
  }
}

Measured memory_bytes: 23252
N,T = map(int,input().split())
c = [] 
t = []
min = 1001
for i in range(N):
    c,t = map(int,input().split())
    if t <= T :
        if c < min :
            min = c

if min != 1001:
    print(min)
else:
    print('TLE')

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int x = Integer.parseInt(chr[0]);
			int y = Integer.parseInt(chr[1]);
			int ans =x+y;
			System.out.println(ans<10 ? ans:"error" );
		}
	}
}


Measured memory_bytes: 25336
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

int NOD[(int)1e7];

void generateNOD(ll int n)
{
    for (ll int i = 1; i <= n; i++)
    {
        for (ll int j = i; j <= n; j += i)
        {
            ++NOD[j];
        }
    }
}

int findNOD(ll int n)
{
    int cnt = 0;
    for (ll int i = 1; (i * i) <= n; i++)
    {
        if (n % i == 0)
        {
            ++cnt;
            if ((n / i) != i)
                ++cnt;
        }
    }
    return cnt;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    ll int n, sum = 0;
    cin >> n;
    generateNOD(n);
    for (ll int i = 1; i <= n; i++)
    {
        //cout << i << " * " << NOD[i] << " = " << i * NOD[i] << endl;
        sum += (i * NOD[i]);
    }
    cout << sum;
    
    return 0;
}

Measured memory_bytes: 42664
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


signed main() {
    ll n;
    cin >> n;
    
    ll r = 0;
    
    map <ll, ll> mp;
    
    const auto &res = prime_factorize(n);
    for(auto p: res) {
        mp[p.first] += p.second;
    }
    
    ll tmp = 1;
    for (auto i: mp) {
        while(i.second >= 0) {
            i.second -= tmp;
            tmp++;
            if (i.second >= 0) r++;
        }
        
        tmp = 1;
    }
    
    mes(r);
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 3556
N, M= map(int, input().split())

WAlist = [0]*N
ACflag = [0]*N

for i in range(M):
    p, s = input().split()
    p=int(p)
    if ACflag[p-1] == 0:
        if   s == "WA":
            WAlist[p-1] += 1
        elif s == "AC":
            ACflag[p-1] = 1
            
WA = 0
for i in range(N):
    if ACflag[i]==1:
        WA += WAlist[i]
    
print(sum(ACflag), WA)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    REP(i, n-1){
        ans += ((n-1)/i);
    }
    cout << ans << endl;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    
    if (b == 1) {
        cout << 0 << '\n';
    } else {
        for (int i = 1; ; ++i) {
            if (i * a - (i - 1) >= b) {
                cout << i << '\n';
                exit(0);
            }
        } 
    }
}

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

bool from[200005];
bool to[200005];

int main()
{
    int n,m;

    scanf("%d%d",&n,&m);

    for (int i = 0;i < m;i++)
    {
        int a,b;

        scanf("%d%d",&a,&b);

        if (a == 1) from[b] = 1;
        if (b == n) to[a] = 1;
    }

    bool ans = 0;

    for (int i = 2;i < n;i++)
    {
        if (from[i] && to[i])
        {
            ans = 1;
            break;
        }
    }

    if (ans) printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	ll n;
	string s;
	cin >> n >> s;
	if(n%2){
		cout << "No" << endl;
		return 0;
	}

	string t = s.substr(0,n/2);
	t = t+t;
	if(t==s){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		char[] a = line.toCharArray();
		int count = 0;
		for (int i = 0; i < a.length; i++) {
			if (a[i] == '1') {
				count++;
			}
		}
		System.out.println(count);
	}
}

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

int n;
vector<P> v(55);


double dist(P a, P b){
	double dx=a.first-b.first;
	double dy=a.second-b.second;
	return sqrt(dx*dx+dy*dy);
}


//(x,y)を中心とする円で全ての頂点を含む時の半径
double f(double x,double y){
	double res=0;
	rep(i,n){
		res=max(res,dist(make_pair(x,y),v[i]));
	}
	return res;
}


//三分探索、x座標固定
double g(double x){
	double l=0, r=1005;
	rep(i,85){
		double c1=(l*2+r)/3;
		double c2=(l+r*2)/3;
		if (f(x,c1)>f(x,c2)) l=c1;else r=c2;
	}
	return f(x,l);

}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
cin>>n;
rep(i,n){
	double t1,t2;
	cin>>t1>>t2;
	v[i]=make_pair(t1,t2);
}
double l=0,r=1005;
rep(i,85){
	double c1=(l*2+r)/3;
	double c2=(l+r*2)/3;
	if (g(c1)>g(c2)) l=c1;else r=c2;

}
double ans=g(l);
cout<<setprecision(10)<<ans;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr int dx[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
constexpr int dy[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
int main() {
    int H, W, N;
    map<int,map<int,int>>mp;
    long long cnt[10] = {};
    cin >> H >> W >> N;
    cnt[0] = (long long)(H - 2) * (W - 2);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        for (int j = 0; j < 9; j++) mp[a+dy[j]][b+dx[j]]++;
    }
    for (auto &rows : mp) {
        int y = rows.first;
        if (y < 2 || H - 1 < y) continue;
        for (auto &col : rows.second) {
            int x = col.first;
            if (x < 2 || W - 1 < x) continue;
            cnt[col.second]++;
            cnt[0]--;
        }
    }
    for (int i = 0; i < 10; i++) cout << cnt[i] << endl;
    return (0);
}


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

int main(int argc, char* argv[]) {
    int nA, nB, nM;
    cin >> nA >> nB >> nM;
    int* a = new int[nA];
    int amin = 100000;
    for (int n = 0; n < nA; ++n) {
        cin >> a[n];
        if (amin > a[n]) amin = a[n];
    }
    int* b = new int[nB];
    int bmin = 100000;
    for (int n = 0; n < nB; ++n) {
        cin >> b[n];
        if (bmin > b[n]) bmin = b[n];
    }
    int* c = new int[nM];
    int* x = new int[nM];
    int* y = new int[nM];
    int cmin = 200000;
    for (int n = 0; n < nM; ++n) {
        cin >> x[n] >> y[n] >> c[n];
        int cache = a[x[n]-1] + b[y[n]-1] - c[n];
        if (cmin > cache) cmin = cache;
    }

    if (cmin > amin + bmin) cmin = amin + bmin;
    printf("%d\n", cmin);

    return 0;
}


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

int main(){
	int n;
	cin >> n;
	map<int,int> cnt;
	rep(i,n){
		int d;
		cin >> d;
		cnt[d]++;
	}
	cout << cnt.size() << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    int a, ans = 0;
    rep(i, n) {
        cin >> a;
        ans = __gcd(ans, a);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n,a[100005],b[100005];
int main()
{
	SPEED;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i],b[i]=a[i];
	sort(b+1,b+n+1);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ll j=lower_bound(b+1,b+n+1,a[i])-b;
		if(j%2!=i%2)ans++;
	}
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] XYZ = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            int cnt = 0;
            Console.WriteLine((XYZ[0] - XYZ[2]) / (XYZ[1] + XYZ[2]));
        }
        
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(ans);

Measured memory_bytes: 28196
N,M=map(int, input().split())
ab= [
  list(map(int, input().split()))
  for _ in range(N)
]

ab = sorted(ab, key=lambda  x: x[0])

d=0
ans =0
for a,b in ab:
  if d+b <= M:
    ans += a*b
    d += b
  else:
    ans += (M-d)*a
    break
print(ans)

Measured memory_bytes: 29792
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
#define h first
#define p second

int H, W;
vector<string> field;
vector< vector<int> > cnt;

void init(){
  cnt = vector< vector<int> >(H, vector<int>(W, 0));
  REP(i, W) cnt[0][i] = (field[0][i] == '.' ? 1 : 0);
  FOR(y, 1, H) REP(x, W) cnt[y][x] = (field[y][x] == '*' ? 0 : cnt[y - 1][x] + 1);
}

int solve(vector<int> cnt){
  cnt.push_back(0);
  vector<P> v;
  int res = 0;
  //for(int n : cnt) cout <<n <<", "; cout <<endl;
  REP(i, cnt.size()){
    if(v.empty() || v.back().h < cnt[i]) v.push_back(P(cnt[i], i));
    else if(v.back().h > cnt[i]){
      int next_p = i;
      while(!v.empty() && v.back().h >= cnt[i]){
        P now = v.back(); v.pop_back();
        //cout <<"!  h = " <<now.h <<", w = " <<(i - now.p) <<endl;
        res = max(res, now.h * (i - now.p));
        next_p = now.p;
      }
      v.push_back(P(cnt[i], next_p));
    }
  }
  return res;
}

int main() {
  while(cin >>H >>W && H && W){
    field = vector<string>(H);
    REP(i, H) cin >>field[i];
    init();
    int res = 0;
    REP(i, H) res = max(res, solve(cnt[i]));
    cout <<res <<endl;
  }
  return 0;
}

Measured memory_bytes: 3384