akhauriyash/Code-Regression huggingface dataset:
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define Yy cout<<"Yes"
#define Nn cout<<"No"
#define yy cout<<"yes"
#define nn cout<<"no"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vc vector<char> 
#define vll vector< pair<ll,ll> > 
#define mps map<string ,ll>
#define mpc map<char ,ll>
#define mpl map<ll, ll>
#define pr pair<ll,ll>
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x%MOD*x%MOD)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll tt=1;

//	   cin>>tt;
	      while(tt--)
{
	
	ll ans=0;
	/*
	3
1 2 3*/
ll n,m,j,k,l,i;
cin>>n;
ll a[n],s=0;
fo(i,n)
{
	cin>>a[i];
s+=a[i];
}
fo(i,n)
{
	ans+=(a[i]*((s-a[i])%MOD))%MOD;
	ans%=MOD;
}
if(ans%2==0)
ans/=2;
else
{
	ans+=MOD;
ans/=2;
}
cout<<ans;
ee;
	
	
}
return 0;
}



Measured memory_bytes: 5176
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		int k = sc.nextInt();
		String[] part = new String[n*k];
		Arrays.fill(part, "|");
		int cnt = 0;
		for(int i=1; i<=Math.min(k, n); i++){
			for(int j=0; j<n-i+1; j++){
				part[cnt] = s.substring(j, j+i);
				cnt++;
			}
		}
		Arrays.sort(part);
		int count = 0;
		String ans = "";
		for(int i=0; i<n*k; i++){
			if(!ans.equals(part[i])){
				ans = part[i];
				count++;
			}
			if(count==k)break;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define arrlen(arr) (sizeof(arr)/sizeof(arr[0]))
#define Sort(arr) sort(arr, arr+arrlen(arr))
#define For(i,s,n) for(int i=s;i<n;i++)

int main(){
	int A,P;
	cin >> A >> P;
	cout << (3*A+P)/2;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int p1 = 0, p2 = 0;
		
		for(int i = 0; i < n; i++){
			String s1 = sc.next();
			String s2 = sc.next();
			int comp = s1.compareTo(s2);
			if(comp > 0) p1 += 3;
			else if(comp < 0) p2 += 3;
			else{
				p1++;
				p2++;
			}
		}
		
		System.out.println(p1 + " " + p2);
	}
}


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

#ifdef DEBUG
#define ifd if(true)
#else
#define ifd if(false)
#endif

#define dout ifd cerr

#define uint unsigned long long
#define int int64_t

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  int mini = min(a, min(b, c));
  int maxi = max(a, max(b, c));
  int midi = a + b + c - mini - maxi;
  cout << (midi - mini) + (maxi - midi) << endl;
}


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

mylist =[]

for i in range(N):
    myx , myy = map(int, input().split())
    mylist += [[myx, myy]]
    
#print(mylist)

mydis = []
mysum = 0
for i in range(N-1):
    for j in range(i+1,N):
        mysum += math.sqrt((mylist[i][0]-mylist[j][0]) **2 + (mylist[i][1]-mylist[j][1]) ** 2)
        #print(math.sqrt((mylist[i][0]-mylist[j][0]) **2 + (mylist[i][1]-mylist[j][1]) ** 2))
        

print((mysum*2)/(N))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	int x[5];
	for (int i = 0; i < 5; i++)
		cin >> x[i];

	for (int i = 0; i < 5; i++) {
		if (x[i] == 0) {
			cout << i + 1;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3560
package main

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

// main is...
func main() {
	var n int
	fmt.Scanln(&n)

	var sc = bufio.NewScanner(os.Stdin)
	// var list = make([]string, n)
	// var listInt = make([]int64, n)
	var list = make([]int, n)

	sc.Split(bufio.ScanWords)
	// if sc.Scan() {
	// 	list = strings.Fields(sc.Text())
	// }

	// for idx, value := range list {
	// 	valueInt, _ := strconv.Atoi(value)
	// 	// valueInt, _ := strconv.ParseInt(value, 10, 64)
	// 	listInt[idx] = valueInt
	// }

	for idx := range list {
		if sc.Scan() {
			valueInt, _ := strconv.Atoi(sc.Text())
			// valueInt, _ := strconv.ParseInt(value, 10, 64)
			list[idx] = valueInt
		}
	}

	// max, tmp := 0, 0
	// for i := n - 1; i > 0; i-- {
	// 	if list[i-1] >= list[i] {
	// 		tmp++
	// 	} else {
	// 		tmp = 0
	// 	}

	// 	if tmp > max {
	// 		max = tmp
	// 	}
	// }
	// for i := 1; i < n; i++ {
	// 	if list[i-1] >= list[i] {
	// 		tmp++
	// 	} else {
	// 		tmp = 0
	// 	}

	// 	if tmp > max {
	// 		max = tmp
	// 	}
	// }

	max, tmp := 0, 0
	for i := 0; i < n-1; i++ {
		// tmp = 0
		i += tmp
		if 0 >= n-i-max {
			break
		}
		// j := i + tmp
		// if i+1 > j {
		j := i + 1
		// }
		tmp = 0
		for ; j < n; j++ {
			if list[j] > list[j-1] {
				break
			}
			tmp++
		}
		if tmp > max {
			max = tmp
		}

	}
	fmt.Println(max)

}



Measured memory_bytes: 3072
inf = 10**15
mod = 10**9+7
n = int(input())
ans=0
dp = [[0 for j in range(10)]for i in range(10)]
for k in range(1,n+1):
    tmp = str(k)
    dp[int(tmp[0])][int(tmp[-1])]+=1
for i in range(1,10):
    for j in range(1,10):
        ans+=dp[i][j]*dp[j][i]
print(ans)

Measured memory_bytes: 40428
# C
f = True
n,m = map(int, input().split())
num = [-1 for i in range(n)]
for i in range(m):
    s,c = map(int, input().split())
    if num[s-1] == -1:
        num[s-1] = c
    else:
        if num[s-1] != c:
            f = False
if f:
    if n == 1:
        if  num[0] == -1:
            print(0)
        else:
            print(num[0])
    elif n == 2:
        if num[0] == 0:
            print(-1)
        elif num[0] == -1:
            if num[1] == -1:
                print(10)
            else:
                print(10 + num[1])
        else:
            if num[1] == -1:
                print(num[0]*10)
            else:
                print(num[0]*10 + num[1])
    elif n == 3:
        if num[0] == 0:
            print(-1)
        elif num[0] == -1:
            if num[1] == -1:
                if num[2] == -1:
                    print(100)
                else:
                    print(100 + num[2])
            else:
                if num[2] == -1:
                    print(100 + num[1]*10)
                else:
                    print(100 + num[1]*10 + num[2])
        else:
            if num[1] == -1:
                if num[2] == -1:
                    print(num[0]*100)
                else:
                    print(num[0]*100 + num[2])
            else:
                if num[2] == -1:
                    print(num[0]*100 + num[1]*10)
                else:
                    print(num[0]*100 + num[1]*10 + num[2])
else:
    print(-1)

Measured memory_bytes: 38384
<?php
  $base_num = explode(" ",fgets(STDIN));
  $ans = 0;

  if((int)$base_num[0] == 0)
  {
    if((int)$base_num[1] == 100)
    {
  		$ans = 101;
    }
    else
    {
  		$ans = (int)$base_num[1];
    }
  }
  else if((int)$base_num[0] == 1)
  {
    if((int)$base_num[1] == 100)
    {
  		$ans = 10100;
    }
    else
    {
  		$ans = (int)$base_num[1] * 100;
    }
  }
  else
  {
    if((int)$base_num[1] == 100)
    {
  		$ans = 1010000;
    }
    else
    {
  		$ans = (int)$base_num[1] * 10000;
    }
  }
  echo $ans;

Measured memory_bytes: 3576
n, a, b = map(int, input().split())

souwa_saisyou = a + b + a * (n - 2)
souwa_saidai =  a + b + b * (n - 2)


if n == 1 and a == b:
  print(1)
elif n == 1 and a!= b:
  print(0)
elif a > b:
  print(0)
else:
  print(souwa_saidai - souwa_saisyou + 1)









Measured memory_bytes: 2940
[M,N]=[int(item) for item in input().split()]

num={}

for _ in range(N):
    [s,c] = [int(item) for item in input().split()]
    if s > M or  not M==1 and  s == 1 and c == 0:
        print(-1)
        exit()
    if s in num:
        if num[s] == c:
            continue
        else:
            print(-1)
            exit()
    num[s]=c

#print(num)
#数字にする
num_int = 0

if M == 1:
    if  1 in num:
        print(num[1])
    else:
        print(0)
    exit()

if  1 in num:
    num_int = num[1]
else:
    num_int=1

for i in range(2, M + 1):
    num_int*=10
    if i in num:
        num_int+=num[i]

print(num_int)

Measured memory_bytes: 3064
k = gets.strip.to_i

if k % 2 == 0 || k % 5 == 0
  puts(-1)
  exit(0)
end

s = 0
for i in 1.upto(k)
  s = s * 10 + 7
  s = s % k
  if s == 0
    puts(i)
    exit()
  end
end

Measured memory_bytes: 14368
#include<bits/stdc++.h>
using namespace std;
const int maxn=400100;
int beg[maxn],tto[maxn],nex[maxn],w[maxn],e;
long long a[maxn];
bool vis[maxn];
void putin(int s,int t,int v){
	tto[++e]=t;
	nex[e]=beg[s];
	beg[s]=e;
	w[e]=v;
}
void no(){
	puts("No");
	exit(0);
}
void yes(){
	puts("Yes");
	exit(0);
}
void dfs(int u){
	vis[u]=1;
	for(int i=beg[u];i;i=nex[i]){
		if(!vis[tto[i]]){
			a[tto[i]]=a[u]+w[i];
			dfs(tto[i]);
		}
		else{
			if(a[tto[i]]!=a[u]+w[i])
				no();
		}
	}
}
int main(){
//	freopen("A.in","r",stdin);
	int n,m;
	int s,t,v;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&s,&t,&v);
		putin(s,t,v);
		putin(t,s,-v);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])
			dfs(i);
	long long mn=a[1],mx=a[1];
	for(int i=1;i<=n;i++){
		if(a[i]>mx) mx=a[i];
		if(a[i]<mn) mn=a[i];
	}
	if(mx-mn>1000000000)
		no();
	else
		yes();
	return 0;
}


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

int main(){
    string s;
    cin >> s;
    int n;
    n = s.size();

    int cnt1 = 0;
    int cnt2 = 0;
    rep(i, n){
        if(i%2==0 && s[i]=='1' || i%2==1 && s[i]=='0'){
            cnt1++;
        }
    }
    rep(i, n){
        if(i%2==0 && s[i]=='0' || i%2==1 && s[i]=='1'){
            cnt2++;
        }
    }
    cout << min(n-cnt1, n-cnt2) << endl;
    return 0;
}

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

int main()
{
  int N,K,i,j,tmp,ans=0;
  int a[1000]={0};
  scanf("%d %d",&N,&K);
  for(i=0;i<N;i++)
  {
  scanf("%d",&a[i]);
  }
  for(i=0;i<N-1;i++)
  {
  for(j=0;j<N-1;j++)
  {
  if(a[j]>=a[j+1])
  {
    tmp=a[j+1];
    a[j+1]=a[j];
    a[j]=tmp;
  }
  }
  }
  for(i=0;i<K;i++)
  {
    ans=ans+a[i];
  }
  printf("%d",ans);
  return 0;
}

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

int main() {
  int A, B, S;
   cin >> A >> B;
  
  S = 0;
  for (int i = A; i <= B; i++) {
    int a,b,c,d;
    a = i / 10000 % 10;
    b = i / 1000 % 10;
    c = i / 10 % 10;
    d = i % 10;
    
    if (a == d && b == c) {
      S ++;
    }
    else {
      continue;
    }
  }
    cout << S << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>

int a,b,k,res;

int main(){

    std::cin>>a>>b>>k;

    res=std::min(a,b)+1;

    while(k!=0){
        res--;
    if(a%res==0&&b%res==0)
    k--;
    }

    std::cout<<res<<std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Anurag_Gupta ios_base::sync_with_stdio(0);
#define IIIT_ALLD cin.tie(0);cout.tie(0);
#define mod 1000000007
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
    Anurag_Gupta
    IIIT_ALLD
 
    
    
    int n,k;
    cin>>n>>k;

    vi ans(k+1);
    int sum=0;
    for(int i=k;i>1;i--)
    {
        int divCount = k/i;
        int totSequeces = mdpower(divCount,n,(int)mod);
        ans[i] = totSequeces;


        for(int j = i*2;j<=k;j+=i)
           ans[i]=(ans[i]%mod-ans[j]%mod+mod)%mod;
        sum = (sum%mod+ans[i]%mod)%mod;
    }

    ans[1] = (mdpower(k,n,(int)mod)%mod-sum%mod+mod)%mod;

    int tot = ans[1];
    for(int i=2;i<=k;i++)
    {
        tot = (tot%mod+(i%mod*ans[i]%mod)%mod)%mod; 
    }

    cout<<tot<<"\n";


 
 






 
#ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 3992
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include <bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                   long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                  1000000007
#define eps                  0.000000000000001
#define endl                       '\n'
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={-2,-2,1,-1,-1,-1,1,1};
int dy[8]={1,-1,-2,-2,-1,1,-1,1};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int h,w;
    cin>>h>>w;
    vector<vector<ll>> dp(h+1 ,vector<ll> (w+1,0));
    vector<string> v(h);
    f(i,h)
    {
        cin>>v[i];
    }
    dp[1][1]=1;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(i-1>0&&v[i-2][j-1]!='#')
            {
                dp[i][j]=(dp[i][j]%inf+dp[i-1][j]%inf)%inf;
            }
            if(j-1>0&&v[i-1][j-2]!='#')
            {
                dp[i][j]=(dp[i][j]%inf+dp[i][j-1]%inf)%inf;
            }
        }
    }
    cout<<dp[h][w]<<endl;
}


Measured memory_bytes: 9216
#include<iostream>
using namespace std;
int H, W, d, c[509][509]; char C[5] = "RBGY";
int main() {
	cin >> H >> W >> d;
	if (d % 2 == 1) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) { if ((i + j) % 2 == 0)c[i][j] = 1; }
		}
	}
	else {
		int dd = d * 2;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				int H1 = i + j, H2 = i - j;
				H1 += d * 10000; H2 += d * 10000;
				c[i][j] = ((H1%dd) / d) * 2 + ((H2%dd) / d);
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++)cout << C[c[i][j]]; cout << endl;
	}
	return 0;
}

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

int main(void){
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    double cx = w/2;
    double cy = h/2;
    bool f = (x == cx)&(y == cy);
    printf("%lf %d\n",w*h/2,f);
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n
for i in range(m):
  p,s=map(str,input().split())
  p=int(p)-1
  if ac[p]==0:
    if s=='AC':
      ac[p]=1
    else:
      wa[p]+=1

w=0
for i in range (n):
  w+=ac[i]*wa[i]
print(sum(ac),w)

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

ll board[3005][3005];
ll dp[3005][3005][4];

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}

  int R,C,K; cin>>R>>C>>K;
  FILL2(board,R,C,0LL);
  REP(i,K){
    ll r,c,v; cin>>r>>c>>v;
    --r; --c;
    board[r][c] = v;
  }
  if(DEBUG){
    REP(i,R){
      REP(j,C){
        cout << board[i][j] << " ";
      }
      cout << endl;
    }
  }

  REP(i,R){ REP(j,C){ REP(k,4){dp[i][j][k] = 0LL;}}}

  REP(i,R){
    REP(j,C){
      for(int k=2;k>=0;--k){
        chmax(dp[i][j][k+1],dp[i][j][k]+board[i][j]);
      }
      REP(k,4){
        chmax(dp[i+1][j][0],dp[i][j][k]);
        chmax(dp[i][j+1][k],dp[i][j][k]);
      }
    }
  }
  ll ans = dp[R-1][C-1][0];
  REP(k,4){
    chmax(ans,dp[R-1][C-1][k]);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 355764
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

LL lcd(LL a, LL b){
    LL c = a;
    LL d = b;
    while(d){
        c%=d;
        swap(c, d);
    }
    return a / c * b;
}

int main(){
    int N;
    cin >> N;
    LL a;
    cin >> a;
    REP(i, N-1){
        LL b;
        cin >> b;
        a = lcd(a, b);
    }
    cout << a << endl;
    return 0;
}



Measured memory_bytes: 256
import math

def is_prime(x):
    j = 2
    while j <= math.floor(x ** (1/2)) + 1 and x != 2:
        if x % j == 0:
            return False
        j += 1
    return True

n = int(input())
num_list = [int(input()) for _ in range(n)]
prime_cnt = 0
for num in num_list:
    if is_prime(num):
        prime_cnt += 1
print(prime_cnt)



Measured memory_bytes: 6008
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  ll n,m,x,c=10,ans=1e18;
  cin>>n>>m>>x;
  ll books[n+c][m+c];
  vector<ll>prices(n);
  for(int i=0;i<n;i++){
    cin>>prices[i];
    for(int j=0;j<m;j++){
      cin>>books[i][j];
    }
  }
  for(int i=0;i<pow(2,n);i++){
    ll money=0,cnt=0;
    vector<ll>each(m);
    for(int bit=0;bit<n;bit++){
      if(i&(1<<bit)){
        money+=prices[bit];
        for(int j=0;j<m;j++){
          each[j]+=books[bit][j];
        }
      }
    }
    for(int j=0;j<m;j++){
      if(each[j]>=x)cnt++;
    }
    if(cnt==m){
      ans=min(ans,money);
    }
  }
  if(ans==1e18){
    cout<<-1<<endl;
  }else{
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n;
int dp[114][5][5][5];
signed main() {
	cin >> n;
	rep(i, 4)rep(j, 4)rep(k, 4) {
		if (i == 0 && j == 1 && k == 2)continue;
		if (i == 0 && j == 2 && k == 1)continue;
		if (i == 2 && j == 0 && k == 1)continue;
		dp[3][i][j][k] = 1;
	}
	for (int i = 4; i <= n; i++) {
		rep(j, 4)rep(k, 4)rep(l, 4) rep(m, 4) {
			if (j == 0 && k == 2 && m == 1)continue;
			if (k == 0 && l == 2 && m == 1)continue;
			if (k == 0 && l == 1 && m == 2)continue;
			if (k == 2 && l == 0 && m == 1)continue;
			if (j == 0 && l == 2 && m == 1)continue;
			dp[i][k][l][m] += dp[i - 1][j][k][l];
			dp[i][k][l][m] %= mod;
		}
	}
	int ans = 0;
	rep(i, 4)rep(j, 4)rep(k, 4)ans += dp[n][i][j][k];
	cout << ans % mod << endl;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static final int fib = 1000000007;

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        int[] check = new int[n];
        boolean isEven = n % 2 == 0;
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
            if ((isEven && array[i] % 2 == 1) || (!isEven && array[i] % 2 == 0)) {
                check[i] = 0;
            } else {
                System.out.println(0);
                return;
            }
        }
        long a = pow(2, n / 2);

        int count = 0;
        for (int x : array) {
            check[x]++;
            if (check[x] > 2 || (check[x] == 2 && x == 0)) {
                System.out.println(0);
                return;
            }
        }

        if (a > fib) {
            a = a % fib;
        }
        System.out.println(a);
    }

    private static long pow(int base, int n) {
        long ret = 1L;
        for (int i = 0; i < n; i++) {
            ret *= base;
            ret %= fib;
        }
        return ret;
    }
}

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

int main(){
	ll n,W,i,j,sum_vals=0;
	cin>>n>>W;
	vector<ll> w(n+1),v(n+1);
	for(i=1; i<=n; ++i){
		cin>>w[i]>>v[i];
		sum_vals+=v[i];
	}
	// Repr minimum weight for exactly i val.
	vector<ll> dp(sum_vals+1,LLONG_MAX);
	dp[0]=0;
	for(i=1; i<=n; ++i){
		for(j=sum_vals-v[i]; j>=0; --j){
			if(dp[j]!=LLONG_MAX)
				dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
		}
	}
	int ans;
	for(i=0; i<=sum_vals; ++i)
		if(dp[i]<=W)
			ans=i;
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 15
using namespace std;
vector<int> sv;
void get(int x,int dn)
{
	int i;
	for(i=0;i<dn;i++)
	{
		if(x%2==0)
		{
			sv.push_back(0);
		}
		else
		{
			sv.push_back(1);
		}
		x/=2;
	}
	reverse(sv.begin(),sv.end());
}
int main(){
	int n,m,k[N],s[N][N],p[N],i,j,l,res,time,ans=0;
	cin>>n>>m;
	for(i=0;i<m;i++)
	{
		cin>>k[i];
		for(j=0;j<k[i];j++)
		{
			cin>>s[i][j];
		}
	}
	for(i=0;i<m;i++)
	{
		cin>>p[i];
	}
	res=1<<n;
	for(i=0;i<res;i++)
	{
		get(i,n);
		for(j=0;j<m;j++)
		{
			time=p[j];
			for(l=0;l<k[j];l++)
			{
				time+=sv[s[j][l]-1];
			}
			if(time%2!=0)
			{
				time=-1;
				break;
			}
		}
		if(time!=-1)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main {
    private static final Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        if(a<b&&b<c) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 26176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;
    static long E = 1000000000000000000L;
    static boolean zeros;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();


        int n = in.intNext();
        long[] nums = in.nextLongArray(n);
        out.println(solve(n, nums));

        out.close();
    }

    static long solve(int n, long[] nums) throws IOException {
        if (zeros) return 0;
        long res = 1;
        for (int i = 0; i < n; i++) {
            if (res > E/nums[i]) return -1;
            res *= nums[i];
        }

        return res;
    }


    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = longNext();
                if (a[i] == 0) zeros = true;
            }
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}
 

Measured memory_bytes: 49152
import numpy as np
N = int(input())
arr =  np.array([int(i) for i in input().split()])

count = 0
while(True):
    exits_odd = False
    for i in range(N):
        if arr[i] % 2 != 0:
            exits_odd = True
        else:
            continue
    if exits_odd:
        break
    else:
        count += 1
        arr = arr / 2


print(count)



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

ll maxm;
ll dp[100001][3];
int fn(ll a[][3],ll n)
{
    for(ll j=0; j<=2; j++)
    {
        dp[0][j] = a[0][j];
    }
    
    for(ll i=1; i<n; i++)
    {
        dp[i][0] = a[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][0],dp[i-1][1]);
    }
    return 0;
}
int main()
{
    ll i,j,n;
    cin>>n;
    ll a[n][3];
    for(i=0; i<n; i++)
    {
        for(j=0; j<3; j++)
        {
            cin>>a[i][j];
        }
    }
    fn(a,n);
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
    return 0;
}

Measured memory_bytes: 8180
#include <iostream>
#include <algorithm>

using namespace std;

int f(int N){
    int SOD = 0;
    while (N) SOD += N%10, N /= 10;
    return SOD;
}

int main(){
    int N; cin >> N;
    if (N % f(N) == 0) cout << "Yes" << endl;
    else               cout << "No"  << endl;
    return 0;
}


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

int main()
{
    ll n, d[110],ans=0;
    cin >> n;
    rep(i, n) cin >> d[i];
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;



int main(){
    vector<ll> ABC(3);
    rep(i,3) cin >> ABC[i];
    if (ABC[0]%2 == 0 || ABC[1]%2 == 0 || ABC[2]%2 == 0){
        cout << 0 << endl;
    }
    else{
        sort(ABC.begin(), ABC.end());
        cout << ABC[0]*ABC[1] << endl;
    }
}

Measured memory_bytes: 3604
import sys
input = sys.stdin.buffer.readline
n = int(input())
a = list(map(int, input().split()))
from fractions import gcd
def lcm(x,y):
  return (x*y)//gcd(x,y)
l = 1
mod = 10**9+7
for i in range(n):
  l = lcm(l, a[i])
ans = 0
for i in range(n):
  ans += l // a[i]
print(ans%mod)


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

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

    for (const char c : s) {
        if (c == 'a') {
            if (a > 0) {
                cout << "Yes" << endl;
                a--;
            } else if (b > 0) {
                cout << "Yes" << endl;
                b--;
            } else {
                cout << "No" << endl;
            }
        } else if (c == 'b') {
            if (b > 0) {
                cout << "Yes" << endl;
                b--;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896
n = int(input())
nums = list(map(int, input().split()))
counter = 0
flag = True
while flag == True:
  for i,num in enumerate(nums):
    if num % 2 != 0:
      flag = False
    else:
      nums[i] = int(nums[i] / 2)
  counter += 1
    
print(counter - 1)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	if (n == 1)cout << 1 << endl;
	else {
		int now = 0;
		int tmp = 0;
		rep(i, n) {
			now += i + 1;
			if (now >= n) {
				tmp = i+1; break;
			}
		}
		int y = now - n;
		for (int i = 1; i <= tmp; i++) {
			if (i != y)cout << i << endl;
		}
	}
	return 0;
}

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

int N;
int A[100002];
int S_A;

void solve(int n) {
	if (min(A[n - 1], A[n + 1]) <= A[n] && A[n] <= max(A[n - 1], A[n + 1])) {
		cout << S_A << endl;
	}
	else if (min(A[n - 1], A[n]) <= A[n + 1] && A[n + 1] <= max(A[n - 1], A[n])) {
		cout << S_A - 2 * abs(A[n] - A[n + 1]) << endl;
	}
	else {
		cout << S_A - 2 * abs(A[n] - A[n - 1]) << endl;
	}
}

int main() {
	cin >> N;
	S_A = 0;
	memset(A, 0, sizeof(A));
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i <= N; i++) {
		S_A += abs(A[i + 1] - A[i]);
	}

	for (int i = 1; i <= N; i++) {
		solve(i);
	}
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int n,ans,x,y,z;
string s;
int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> s;
		if(s[0]=='B')x++;
		if(s[s.size()-1]=='A')y++;
		if(s[0]=='B' and s[s.size()-1]=='A')z++;
		for(int j=0;j<s.size()-1;j++)
			if(s[j]=='A' and s[j+1]=='B')ans++;
	}
	if(x==z and y==z and x!=0)x--;
	cout << ans+min(x,y);
    return 0;
}

Measured memory_bytes: 384
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    n,m,d = LI()

    x = ((n-d) / n) * (1/n)
    if d > 0: x *= 2
    ans = x * (m-1)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 38636
array = []
for i in range(3):
  alist = list(map(int, input().split()))
  array.append([])
  array[i].append(alist[0])
  array[i].append(alist[1])
  array[i].append(alist[2])
n = int(input())
b = []
for i in range(n):
  b.append(int(input()))
for i in range(n):
  for j in range(3):
    for k in range(3):
      if b[i] == array[j][k]:
        array[j][k] = 0

flg = False
for i in range(3):
  if sum(array[i]) == 0:
    flg = True
for i in range(3):
  if (array[0][i] + array[1][i] + array[2][i]) == 0:
    flg = True
if (array[0][0] + array[1][1] + array[2][2]) == 0:
  flg = True
if (array[2][0] + array[1][1] + array[0][2]) == 0:
  flg = True
  
if flg:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,res=0,sum=0;
string s;
vector<pair<int,int> >v;
bool cmp(pair<int,int>p1,pair<int,int>p2) {return min(p1.second,p1.first+p2.second)>min(p2.second,p2.first+p1.second);}
main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        int cnt=0,mn=0;
        for(char c:s) c=='('?cnt++:cnt--,mn=min(mn,cnt);
        v.emplace_back(cnt,mn);
        sum+=cnt;
    }
    if(sum!=0) {puts("No");exit(0);}
    sort(v.begin(),v.end(),cmp);
    for(pair<int,int>p:v){
        if(res<-p.second){
            puts("No");exit(0);
        }
        res+=p.first;
    }
    puts("Yes");
    return 0;
}


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

int main()
{
    long long a, b, n;
    long long temp;
    long  long x = 0;
    cin >> a >> b >> n;
    if(a > b)
    {
        x = min(n, b - 1);
        cout << floor(a * x / b) - a * floor(x / b);
    }
    else if(a == b)
    {
        long long one =  floor(a * n / b) - a * floor(n / b);
        if(one > 0)
        {
            cout << one;
        }
        else
        {
            cout << 0;
        }    
    }
    else
    {
         x = min(n, b - 1);
        cout << floor(a * x / b) - a * floor(x / b);
    }
    
       
    return 0;
}

Measured memory_bytes: 3772
a,b=map(int, input().split())
  
a1 = a
b1 = b
if(a1%2 == 1) : a1 = a1+1
if(b1%2 == 0) : b1 = b1-1

c = (b1-a1+1)//2 % 2

ans = 0
if(a%2 == 1):ans = ans^a
if(b%2 == 0):ans = ans^b
print(ans^c)

Measured memory_bytes: 61880
N=int(input())
S=str(N)
s = ""
if N <1000:
    ans = 1000 - N
    print(ans)
    exit()
for i in range(3):
    s = S[len(S)-1-i] + s

n = int(s)
ans = 1000 - n
if ans == 1000:
    ans = 0

print(ans)

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

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

using namespace boost::multiprecision;
using namespace std;

int main(void){
    string oi="", s="ACL";
    ll K;
    cin>>K;
    rep(i, K) oi+=s;
    cout<<oi<<endl;
    return 0;
}


Measured memory_bytes: 3628
#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 INF = 1000000000;

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

  vector<ll> dp(n, INF);
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    dp[i] = min(dp[i], dp[i-1] + abs(hs[i]-hs[i-1]));
    if (1 < i) {
      dp[i] = min(dp[i], dp[i-2] + abs(hs[i]-hs[i-2]));
    }
  }

  ll ans = dp[n-1];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

int main(){
    //freopen("in.txt", "r", stdin);

    string s;
    cin>>s;
    bool prev = (s[0]=='1')? true : false;
    int cnt = 0;
    for (int i=1;i<(int)s.size();++i){
        char c = (prev)? '0' : '1';
        if (s[i]!=c){
            cnt++;
            s[i] = c; 
        }
        prev = !prev;
    }
    cout<<cnt<<endl;

    return 0;
}

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

//--- union-find ---
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N+1) { //最初は全てが根であるとして初期化
        for(int i = 1; i <= N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

};

int used[100001];

int main(){
    int n,m;cin >> n >> m;
    UnionFind u(n);
    for(int i=0;i<m;i++){
        int x,y,z; cin >> x >> y >> z;
        u.unite(x,y);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        int r=u.root(i);
        if(!used[r]){ ans++;}
        used[r]=true;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

/**
 *
 */

/**
 * @author bluen
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
//		Scanner sc=new Scanner(System.in);
//		int a=sc.nextInt();
//		int b=scanner.nextInt();
		Scanner sc=new Scanner(System.in);
		String str=sc.next();
		if(Character.isUpperCase(str.charAt(0))) {
			System.out.println("A");
		}else {
			System.out.println("a");
		}

		}
	}




Measured memory_bytes: 35532
#include <algorithm>
#include <iterator>
#include <iostream>
//#include <iomanip>
//#include <cstring>
//#include <cstdlib>
#include <string>
#include <vector>
//#include <queue>
//#include <cmath>
//#include <set>
#include <map>
using namespace std;
#ifdef LOCAL
#define DEBUGMSG()                                                              \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]" ;        \
}
#define DEBUGVAR(x)                                                             \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]:" ;       \
    cerr << "([" << typeid(x).name() << "]" << #x << ")" << x << endl ;         \
}
#define DEBUGARR(l, r)                                                          \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]:" ;       \
    copy(l, r, ostream_iterator<decltype(*l)>(cerr, " "));                      \
    cerr << endl ;                                                              \
}
#else
#define DEBUGMSG()
#define DEBUGVAR(x)
#define DEBUGARR(l, r)
#endif // LOCAL

typedef long long i64;
int H, W, N;
i64 empt, ans[11];
map <pair<int, int>, int> mp;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int u, v;
    cin >> H >> W >> N ;
    empt = 1LL * (H - 2) * (W - 2);
    while(N--)
    {
        cin >> u >> v ;
        for(int i = -1; i <= 1; i++)
        {
            for(int j = -1; j <= 1; j++)
            {
                if(u + i < 1 || u + i > H)
                    continue;
                if(v + j < 1 || v + j > W)
                    continue;
                mp[make_pair(u+i, v+j)]++;
            }
        }
    }

    for(auto itr = mp.begin(); itr != mp.end(); itr++)
    {
        if(itr->first.first <= 1 || itr->first.first >= H)
            continue;
        if(itr->first.second <= 1 || itr->first.second >= W)
            continue;
        //cerr << itr->first.first << " " << itr->first.second << " " << itr->second << endl ;
        ans[itr->second]++;
        empt--;
    }

    cout << empt << endl ;
    for(int i = 1; i <= 9; i++)
        cout << ans[i] << endl ;

}



Measured memory_bytes: 56576
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

const int N=1e5+5;

int n,k,a[N],ans;

int main()
{
    cin >> n >> k;
    for (int i=0;i<n;i++)
    {
        cin >> a[i];
        ans+=(a[i]>=k);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640