akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    num_break = 0
    n = 1
    for a_ in a:
        if a_ == n:
            n+=1
        else:
            num_break+=1
    if n > 1:
        print(num_break)
    else:
        print(-1)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 25824
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <complex>


#ifndef _USEFUL_MACROS_
#define _USEFUL_MACROS_
#define INF 99999999
#define N_PRIME 1000000007
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define OUTPUT_DEBUG
#ifdef OUTPUT_DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x) do{}while(false)
#endif
#endif 

using namespace std;


int main(void){
    complex< double> p1,p2,z,r,r2;
    double x,y;
    
    cin >> x >> y;
    p1 = x + y * 1.0i;
    
    cin >> x >> y;
    p2 = x + y * 1.0i;
    
    r = exp( complex< double>(1.0i * arg(p2-p1)) );
    r2 = exp( complex< double>(-1.0i * arg(p2-p1)) );
  // cout << r << endl;
    cout.precision(16);
    int n;
    cin >> n;
    REP(i,n){
        cin >> x >> y;
        z = x + y * 1.0i;
        
        z = conj((z-p1)*r2)*r+p1;
        
        printf("%9.9lf %9.9lf\n",z.real(),z.imag());
    }
    
    return 0;
}

Measured memory_bytes: 3532
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;


void solve(){
	int n,m; cin>>n>>m;
	int dp[n][m];
	f(i,0,n) f(j,0,m) dp[i][j]=0;
	string s[n]; f(i,0,n) cin>>s[i];
	f(i,0,n) f(j,0,m){
		if(s[i][j]=='#') dp[i][j]=0;
		else{
			if(i==0 && j==0) dp[i][j]=1;
			else if(i==0) dp[i][j]= dp[i][j-1];
			else if(j==0) dp[i][j]=dp[i-1][j];
			else dp[i][j]=dp[i-1][j]+dp[i][j-1];
		}
		dp[i][j]%=mod;
	}
	cout<<dp[n-1][m-1];
	return ;
}



signed main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!


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


Measured memory_bytes: 2112
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	string str;
	int k; cin >> str >> k;
	rep(i, str.size()){
		if(str[i] == 'a') continue;
		int dist = 'z' - str[i] + 1;
		if(dist <= k){
			k -= dist;
			str[i] = 'a';
		}
	}

	if(k > 0){
		str[str.size()-1] = (str[str.size()-1] - 'a' + k) % 26  + 'a';
	}

	cout << str << endl;

	return 0;
}


Measured memory_bytes: 3744
def main():
    K, S = map(int, raw_input().split())

    count = 0

    # X
    for i in range(K+1):
        # Y
        for j in range(K+1):
            if i + j > S:
                break
            if S-i-j > K:
                continue
            count += 1

    print count

main()

Measured memory_bytes: 2692
n,x = gets.chomp.split.map(&:to_i)
ary_x = gets.chomp.split.map(&:to_i)

ary_x << x
ary_x.sort!
# p ary_x

diff = []
n.times do |i|
  diff << ary_x[i+1]-ary_x[i]
end
# p diff

def gcd(a, b)
  return a if b==0
  gcd(b, a%b)
end

gcd = diff[0]
diff.each do |item|
  gcd = gcd(gcd,item)
end



puts gcd


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

using namespace std ;

int n , a[ 200 ] ;
long long sum = 0 , ans = 0x3f3f3f3f ;
long long x[ 10000 ] ;
 
int main() {
	scanf( "%d" , &n ) ;
	for( int i = 1 ; i <= n ; i ++ ) {
		scanf( "%d" , &a[ i ] ) ;
		sum += a[ i ] ;
	}
	int t = sum / n ;
	int t1 = 0 , t3 = -100 ;
	while( t3 <= t ) {
		t1 = t3 ;
		t3 += n ;
	}
	for( int i = 1 ; i <= n ; i ++ ) {
		int cnt = 0 ;
		for( int j = t1 ; j <= t3 ; j ++ ) {
			x[ ++ cnt ] += abs( a[ i ] - j ) * abs( a[ i ] - j ) ;
		}
	}
	int cnt = 0 ;
	for( int j = t1 ; j <= t3 ; j ++ ) {
		ans = min( ans , x[ ++ cnt ] ) ;
	}
	printf( "%lld" , ans ) ;
	return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static final long MOD = 1000000007;
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if (n*a >= b) {
            System.out.println(b);
        } else {
            System.out.println(n*a);
        }
    }
}


Measured memory_bytes: 23892
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a[N][4], dp[N][4];

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> a[i][1] >> a[i][2] >> a[i][3];
   for (int i = 1; i <= n; i ++) {
      dp[i][1] = max (dp[i - 1][2], dp[i - 1][3]) + a[i][1];
      dp[i][2] = max (dp[i - 1][1], dp[i - 1][3]) + a[i][2];
      dp[i][3] = max (dp[i - 1][1], dp[i - 1][2]) + a[i][3];
   }                                              
   cout << max (max (dp[n][1], dp[n][2]), dp[n][3]);
      
     
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 5888
"""
AtCoder Beginner Contest 113  D - Number of Amidakuji

愚直に考えると、
・それぞれの縦棒の間に、横棒があるかないかの2通り。これがある高さhだけで、2^(W-1)通りある（横棒が２連続で続かないので、厳密には違うが）。
・これが高さH（最大100個分）あるので、(2^7)^100 とか？とにかく全探索は間に合わない。

メタ視点だが、W<=8なので、bitDPとかやれそう。
愚直解の何がよくないかというと、たとえば H = 6,W = 4 みたいなあみだくじについて考えるとして、
・この中で上から3段目までが同じでそれより下が異なるあみだくじというのがあるが、同じ部分も毎回シミュレートしてしまうのが重複計算になって無駄。

なので、高さごとに取りうる横棒のパターンを確認して、それらについて移動先の場合の数を求めていけばいいか。

各高さについて毎回横棒のパターンをbitで探索するが何故か思いつかなかった。
"""

H,W,K = map(int, input().split())
MOD = 10**9 + 7


dp = [[0 for _ in range(W)] for _ in range(H+1)]
dp[0][0] = 1

ws = set()
for bit in range(1 << (W-1)):
    if "11" in bin(bit):
        continue
    ws.add(bit)


for i in range(H):
    for bit in ws:
        # 高さi、左からj本目の縦棒にいるとき、どう移動するか。
        for j in range(W):
          

            # 右に移る棒がある時に、右に行ってから下へ移動する場合
            if j != W-1 and bit & (1 << (W-2-j)): # j=0 の時に左端に1が立っているか確認したい、
                    dp[i+1][j+1] += dp[i][j]
                    dp[i+1][j+1] %= MOD

            # 左に移る棒があるときに、左に行ってから下へ移動する場合
            elif j != 0 and bit & (1 << (W-1-j)): # j=W-1 のときに、右端に1が立っているか確認したい。
                dp[i+1][j-1] += dp[i][j]
                dp[i+1][j-1] %= MOD

            else:
                  # そのまま下への移動
                dp[i+1][j] += dp[i][j]
                dp[i+1][j] %= MOD
                #print(i,bin(bit),j,dp)



print(dp[-1][K-1])
#print(dp)
#print(ws)

Measured memory_bytes: 41712
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main()
{
	int i, j, k;
	char S[4];
	scanf("%s", &S);

	int x = 0;
	for (i = 0; i <= 3; i++) {
		if (S[i] == 'a') {
			for (j = 0; j <= 3; j++) {
				if (S[j] == 'b') {
					for (k = 0; k <= 3; k++) {
						if (S[k] == 'c') {
							printf("Yes\n");
							x = 1;
						}

					}
				}
			}
		}
	}

	if (x == 0)
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
    int n;
    int a=1,b=1;
    int m;
    int flag;
    scanf("%d",&n);
    for(a=1;a<=9;a++)
    {
        for(b=1;b<=9;b++)
        {
            m=a*b;
            if(m==n)
            {
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	vector<unsigned long long>a(n), t(n);
	unsigned long long sum, m1, m2;
	for (int i = 0; i < n; i++) {
		cin >> t[i] >> a[i];
		if (!i) {
			sum = t[i] + a[i];
		}
		else {
			unsigned long long x;
			if (t[i - 1] % t[i] == 0)m1 = t[i - 1] / t[i];
			else m1 = t[i - 1] / t[i] + 1;
			if (a[i - 1] % a[i] == 0)m2 = a[i - 1] / a[i];
			else m2 = a[i - 1] / a[i] + 1;
			x = max(m1, m2);
			t[i] = x*t[i];
			a[i] = x*a[i];
		
		
		}
		//cout << endl;
		//cout << "t[" << i << "] " << t[i] << " a[" << i << "] " << a[i] << endl << endl;
	}
	sum = t[n - 1] + a[n - 1];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define MID ((l+r)>>1)
#define lc (rt<<1)
#define rc (rt<<1|1)
#define ls lc,l,MID
#define rs rc,MID+1,r
#define st 1,1,n
#define PII pair<int,int>
#define PLL pair<LL,LL>
using namespace std;
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
const int N=1e5+1;
const LL M=1e18;
int main(){Accel
	LL n,h,s=0,md=0,x,y;
	cin>>n>>h;
	priority_queue<LL>q;
	REP(i,n){
		cin>>x>>y;	
		q.push(y);
		md=max(md,x);
	}
	while(h>0&&q.size()){
		if(q.top()<=md)break;
		h-=q.top(),s++,q.pop();
	}
	while(h>0)h-=md,s++;
	cout<<s<<endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(long long int i=a;i<b;i++)
#define f(i,n) for(long long int i=0;i<n;i++)
typedef unsigned long long ull;
typedef long long ll;
#define vint vector<int>
#define vll vector<long long int>
#define pb(a) push_back(a);
#define bug(x) cout<<#x<<" = "<<x<<"\n";
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)

int main(){
	fastio;
	int t; cin>>t;
  if(t%1000!=0)
	cout<<1000 - t%1000<<"\n";
  else
    cout<<0<<"\n";
  	return 0;
}

Measured memory_bytes: 3644
def resolve():
    n, m  = list(map(int, input().split()))
    aaa = [int(input()) for _ in range(m)]
    dp = [0 for i in range(n+1)]
    mod = 10**9 + 7
    dp[0] = 1
    isbroken = [1 for i in range(n+1)]
    for i in range(m):
        isbroken[aaa[i]] = 0
    for i in range(n):
        if i-1 >= 0:
            dp[i+1] = dp[i] * isbroken[i] + dp[i-1] * isbroken[i-1]
        else:
            dp[i+1] = dp[i] * isbroken[i]
        dp[i+1] %= mod 
    
    print(dp[n])
resolve()

Measured memory_bytes: 9592
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
int main() {
    int P, Q, R;
    cin >> P >> Q >> R;

    int res = P + Q;

    res = min(res, Q + R);
    res = min(res, P + R);

    cout << res << "\n";
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  long long x,y;cin>>x>>y;
  if(!(x%3) || !(y%3)){
    cout << 0 << endl;
    return 0;
  }
  long long a = y/2;
  long long b = y/2;
  if(y%2)b++;
  //cout << a << " " << b << endl;
  long long ans = x*y;
  for(long long i = 1; x > i; i++){
    long long mx = max((i*y),max(((x-i)*a),((x-i)*b)));
    long long mn = min((i*y),min(((x-i)*a),((x-i)*b)));
    ans = min(ans,mx-mn);
    //cout << (i*y) << " " << (x-i)*a << " " << (x-i)*b << endl;
  }
  a = x/2;
  b = x/2;
  if(x%2)b++;
  for(long long i = 1; y > i; i++){
    long long mx = max((i*x),max(((y-i)*a),((y-i)*b)));
    long long mn = min((i*x),min(((y-i)*a),((y-i)*b)));
    ans = min(ans,mx-mn);
    //cout << (i*x) << " " << (y-i)*a << " " << (y-i)*b << endl;
  }
  if(x > 2)ans = min(ans,y);
  if(y > 2)ans = min(ans,x);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll n, c;
    cin >> n >> c;
    ll x[n+1], v[n+1];
    x[0] = v[0] = 0;
    rep(i, n)cin >> x[i+1] >> v[i+1];

    //clock wise
    ll rmax[n+1], rpos[n+1];
    rmax[0] = rpos[0] =0;
    ll rsum = 0;
    for(ll i = 1; i <= n; ++i){
        rsum += v[i];
        rmax[i] = rsum - x[i];
        rpos[i] = x[i];
        if(rmax[i] <= rmax[i-1]){
            rmax[i] = rmax[i-1];
            rpos[i] = rpos[i-1];
        }
    }
    //counter clock wise
    ll lmax[n+2], lpos[n+2];
    lmax[n+1] = lpos[n+1] = lmax[0] = lpos[0] = 0;
    ll lsum = 0;
    for(ll i = n; i > 0; --i){
        lsum += v[i];
        lmax[i] = lsum - c+x[i];
        lpos[i] = x[i];
        if(lmax[i] <= lmax[i+1]){
            lmax[i] = lmax[i+1];
            lpos[i] = lpos[i+1];
        }
    }
    ll res = max(lmax[1], rmax[n]);
    rsum = lsum = 0;
    for(ll i = 1; i <= n; ++i){
        rsum += v[i];
        res = max(res, lmax[i+1]+rsum-2*x[i]);
    }
    for(ll i = n; i > 0; --i){
        lsum += v[i];
        res = max(res, rmax[i-1]+lsum -2*(c-x[i]));
    }
    cout << res << endl;

}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#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()
using namespace std;

int main(){
    string s;
    cin >> s;
    if(s == "SUN")cout << "7";
    if(s == "MON")cout << "6";
    if(s == "TUE")cout << "5";
    if(s == "WED")cout << "4";
    if(s == "THU")cout << "3";
    if(s == "FRI")cout << "2";
    if(s == "SAT")cout << "1";
}   


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $k, $x);

if ($k == 1) {
    $result = $x;
} else {
    for ($i = $x - $k + 1; $i < $x + $k; $i++) {
        $arr[] = $i;
    }
    $result = implode(" ", $arr);
}

echo $result, PHP_EOL;


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repe1(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
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);}

int main() {
  int n,a;
  cin >> n;
  vector<int> v;
  rep(i, n) {
    cin >> a;
    v.pb(a);
  }
  int j = 1, cnt = 0;
  rep(i, v.size()) {
    if (v[i] != j) {
      cnt++;
    } else {
      j++;
    }
  }
  if (j == 1) {
    cout << -1 << "\n";
  } else {
    cout << cnt << "\n";
  }
}


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

int main() {
  int K;
  cin>>K;
  string s;
  cin>>s;
  string ss[K];
  
  for(int i=0;i<K;i++) {
    ss[i]=s[i];
  }
  
  
  if(s.size()<=K){
    cout<<s<<endl;
  }
  
  else{
    for(int i=0;i<K;i++) {
      cout<<ss[i];
    }
    cout<<"..."<<endl;
  }
  return 0;
}


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

int main()
{
    ll n;
    cin>>n;
    ll arr[n];

    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }
    ll swaps=0;
    for(ll i=0;i<n;i++){
        int minIndex=i;
        for(int j=i;j<n;j++){
            if(arr[j]<arr[minIndex]) minIndex=j;
        }
        if(minIndex!=i){
            ll temp=arr[minIndex];
            arr[minIndex]=arr[i];
            arr[i]=temp;
            swaps++;
        }
    }
    for(ll i=0;i<n-1;i++) cout<<arr[i]<<" ";
    cout<<arr[n-1]<<endl;
    cout<<swaps<<endl;
}

Measured memory_bytes: 3092
#include<stdio.h>

int main(){
  int N;
  scanf("%d",&N);
  int ans=N;
  int A[N];
  for (int i = 0; i < N; i++)
  {
    scanf("%d",&A[i]);
    int j=i-1;
    while (A[i]!=A[j]&&j>=0){ j--;}
    if (j<0)
    {
      continue;
    }else
    {
      A[j]=0;A[i]=0;
      ans-=2;
    }
  }
  
  printf("%d",ans);

  return 0;
}

Measured memory_bytes: 2112
A, B = map(int, input().split())

a, b = A, B
set_a = set([1])
set_b = set([1])

for n in range(2, int(A ** 0.5) + 1):
    if a % n == 0:
        set_a.add(n)
    while a % n == 0:
        a //= n

if a != 1:
    set_a.add(a)

for n in range(2, int(B ** 0.5) + 1):
    if b % n == 0:
        set_b.add(n)
    while b % n == 0:
        b //= n

if b != 1:
    set_b.add(b)

ans = len(set_a & set_b)
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <vector>
#include <algorithm>
#define pb push_back
using namespace std;

const int MAX_H = (int)1e5 + 5;
const int MAXN = 3005;
const int MOD = (int)1e9 + 7;

vector<pair<int, int> > v;

long long fat[2 * MAX_H];
long long inv[2 * MAX_H];
long long dp[MAXN];
int h, w, n;

void gcd(long long a, long long b, long long& x, long long& y) {
    if(!b) {
        x = 1;
        y = 0;
        return;
    }
    gcd(b, a % b, y, x);
    y -= (a / b) * x;
    return;
}

long long get_inv(long long a) {
    long long x, y;
    gcd(a, MOD, x, y);
    return (x % MOD + MOD) % MOD;
}

long long solve(int rows, int cols) {
    long long ans = ((fat[rows + cols] * inv[rows] % MOD) * inv[cols]) % MOD;
    return ans;
}

bool can_reach(int i, int j) {
    return v[i].first <= v[j].first && v[i].second <= v[j].second;
}

int main(void) {
    int r, c;

    fat[0] = 1;
    inv[0] = 1;
    for (int i = 1; i < 2 * MAX_H; i++) {
        fat[i] = (fat[i - 1] * i) % MOD;
        inv[i] = get_inv(fat[i]);
    }

    scanf(" %d %d %d", &h, &w, &n);
    for (int i = 0; i < n; i++) {
        scanf(" %d %d", &r, &c);
        v.pb({r, c});
    }
    v.pb({h, w});

    sort(v.begin(), v.end());
    for (int i = 0; i <= n; i++) {
        dp[i] = solve(v[i].first - 1, v[i].second - 1);
        for (int j = 0; j < i; j++) {
            if (can_reach(j, i)) {
                dp[i] -= dp[j] * solve(v[i].first - v[j].first, v[i].second - v[j].second);
                dp[i] = (dp[i] % MOD + MOD) % MOD;
            }
        }
    }
    printf("%lld\n", dp[n]);

    return 0;
}


Measured memory_bytes: 3456
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  double L; cin >> L;
  printf("%.6lf\n", (L / 3) * (L / 3) * (L / 3));
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void trace(int a[],int n){
    for(int i = 0 ; i < n;i++){
        if(i)   cout << " ";
        cout << a[i];
    }
    cout << endl;
}
///插入排序
void insertSort(int a[],int n){
    int i,j,v;
    for(int i = 1 ; i < n;i++){
        v = a[i];
        j = i - 1;
        while(j>=0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        trace(a,n);
    }
}
int main()
{
    int n;
    int a[1005];
    cin >> n;
    for(int i = 0 ;i < n;i++)cin >> a[i];

    trace(a,n);
    insertSort(a,n);

    return 0;
}



Measured memory_bytes: 3080
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c;
vector<ll>v;
map<ll,ll>m;
string s,s2;
void input(){
    cin>>s;
    s2="aiueo";
}
void src(){
    cout<<(s2.find(s[0])!=string::npos? "vowel":"consonant");
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001
typedef long long ll;

int n,k;

// char X[100][100];
// int dp[1000000001];

int main(void) {
    cin >> n >> k;
    vector<int> a(n);
    REP(i,0,n) cin >> a[i];
    
    ll ans = INT_MAX;
    REP(i,0,n-k+1) {
        ll t = min(a[i+k-1] - a[i] + abs(a[i]), a[i+k-1] - a[i] + abs(a[i+k-1]));
        ans = min(t,ans);
    }
    
    cout << ans << endl;
}

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

const int INF = 1000000000;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;

		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}


    for(int k=0; k<m; k++){
      for(int i=0; i<m; i++){
        for(int j=0; j<m; j++){
          if(T[i][j]>T[i][k]+T[k][j]){
            T[i][j] = T[i][k]+T[k][j];
          }
        }
      }
    }

    int ans = INF;
        int t;
        for(int i=0; i<m; i++){
          int sum = 0;
          for(int j=0; j<m; j++){
            sum = sum+T[i][j];
          }
          if(sum<ans){
            ans = sum;
            t=i;
          }
        }
        cout << t << ' ' << ans << endl;
    }








	

	return 0;
}



Measured memory_bytes: 3096
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int A = sc.nextInt();
      	int P = sc.nextInt();
      	
      	System.out.println((int)Math.floor((3 * A + P) / 2));
    }
}

Measured memory_bytes: 23124
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
 
int main(void){
	int n;
	cin >>n;
	vector<int> a(n);

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

	reverse(a.begin(), a.end());

	for (int i=0; i<n; ++i) {
		cout<< a[i];
		i != n-1 ? cout << " ": cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-6
#define MOD 998244353ll
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;

inline void solve()
{
	int n, x, y;
	cin >> n >> x >> y;

	vector<int> otv(n, 0);

	fore(i, 1, n + 1)
	{
		set<pair<int, int>> q;
		vector<int> used(n + 1, 0);

		q.insert({ 0, i });

		while (q.size())
		{
			pair<int, int> v = *q.begin();
			q.erase(q.begin());

			if (used[v.second])
				continue;

			if (v.second > i)
				otv[v.first]++;

			used[v.second] = 1;

			if (v.second < n)
				q.insert({ v.first + 1, v.second + 1 });
			if (v.second > 1)
				q.insert({ v.first + 1, v.second - 1 });

			if (v.second == x)
				q.insert({ v.first + 1, y });
			if (v.second == y)
				q.insert({ v.first + 1, x });
		}
	}

	fore(i, 1, n)
		cout << otv[i] << '\n';
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	while (q--)
	{
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n;
    cin>>n;
    ll h[n+2];
    for(ll i=1;i<=n;i++)
        cin>>h[i];
    ll dp[n+2];
    memset(dp,0,sizeof(dp));
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(ll i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n] <<"\n";

}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main() {
	while (cin >> N) {
		vector<int> ap, an;
		for (int i = 0; i < N; i++) {
			cin >> A;
			if (A >= 0) {
				ap.push_back(A);
			}
			else an.push_back(A);
		}
		if (ap.size() == 0) {
			sort(rall(an));
			M = -accumulate(all(an), 0) + 2 * an[0];
			cout << M << endl;
			int tmp = an[0];
			for (int i = 1; i < N; i++) {
				cout << tmp <<" " << an[i] << endl;
				tmp -= an[i];
			}
		}
		else if (an.size() == 0) {
			sort(all(ap));
			M = accumulate(all(ap), 0) - 2 * ap[0];
			cout << M << endl;
			int tmp = ap[0];
			for (int i = 1; i < N-1; i++) {
				cout << tmp <<" "<< ap[i] << endl;
				tmp -= ap[i];
			}
			cout << ap[N - 1] << " " << tmp << endl;
		}
		else {
			M = accumulate(all(ap), 0) - accumulate(all(an), 0);
			cout << M << endl;
			int tmp1 = ap[0];
			for (int i = 1; i < an.size(); i++) {
				cout << tmp1 << " " << an[i] << endl;
				tmp1 = tmp1 - an[i];
			}
			int tmp2 = an[0];
			for (int i = 1; i < ap.size(); i++) {
				cout << tmp2 << " " << ap[i] << endl;
				tmp2 = tmp2 - ap[i];
			}
			cout << tmp1 << " " << tmp2 << endl;
		}
	}
}


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

int main(){
  int a,b; cin>>a>>b;
  double ans=0;
  for(int i=1;i<=a;i++){
    double x=1.0/a;
    int now=i;
    while(now<b){
      now*=2;
      x/=2;
    }
    ans+=x;
  }
  cout<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int A[MAXN];
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N, M; cin >> N >> M;
	int total = 0;
	for (int i=0; i<N; i++){
		cin >> A[i];
		total += A[i];
	}
	int cnt = 0;
	for (int i=0; i<N; i++){
		if (4*M*A[i] >= total) cnt++;
	}
	if (cnt >= M) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define op(x) cout<<x<<endl;
#define maxn 100005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,d=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0;string s;bool flag=false;
        cin>>x>>k>>d;
        y = abs(x)/d;
        if(k<y)
            ans = abs(x) - k*d;
        else
        {
            x = abs(x)- (y*d);
            k-=y;
            if(k%2==1)
                ans = abs(abs(x) - d);
            else
                ans = abs(x);
        }
        op(ans)
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){

    int N;
    cin >> N;

    int max = 1000000007;

    long long ans = 1;
    for (int i = 1; i <= N; i++){
        ans = ans * i;
        ans = ans % max;
    }
    
    cout << ans << endl;



    return 0;
}

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

#define                           ll                          long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline ll bigmod(ll B,ll P){ll R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline ll ad(ll x,ll y){ll ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll sub(ll x,ll y){ll ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline ll gun(ll x,ll y){ll ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

vector<pi>adj[M+4];
ll dis[M+2];
bool vis[M+2];
void bfs(int src)
{
    queue<int>q;
    q.push(src);
    dis[src]=0;
    vis[src]=1;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(auto v:adj[u])
        {
            if(vis[v.fi]==0)
            {
                vis[v.fi]=1;
                dis[v.fi]=dis[u]+v.si;
                q.push(v.fi);
            }
        }
    }
}
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n-1)
    {
        int u,v,w;
        cin>>u>>v>>w;
        adj[u].pb(mp(v,w));
        adj[v].pb(mp(u,w));
    }
    bfs(1);
    f(i,1,n)
    {
        if(dis[i]%2==0)cout<<"0"<<endl;
        else cout<<"1"<<endl;
    }
    return 0;

}





































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

int main(){
    int w, h , x, y , r;
    cin >> w >> h >> x >> y >> r;
    if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h ) cout << "Yes" << endl;
    else  cout << "No" << endl;
}


Measured memory_bytes: 3120
n=int(input())

a=[]
a.append(2)
a.append(1)

if n==1:
    print(1)
elif n==2:
    print(3) 
else:    
    for i in range(n-1):
        a.append(a[0]+a[1])
        del a[0]
    print(a[1])

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

typedef pair<double,int> P;


int H,W;
string str;

vector <P> u;
char t[600][600];

double change(double x,double y){
  if(x>0.0)return y/x;
  else return 99999999.99999999;
}
char T(int y,int x){
  if(y<0||x<0)return '.';
  if(y>=H||x>=W)return '.';
  return t[y][x];
}
int main(){

  double a,x,y;
  
  cin>>H>>W;

  u.clear();
  for(int i=H-1;i>=0;i--){
    cin>>str;
    for(int j=0;j<W;j++){
      t[i][j]=str[j];
    }
  }
  
  
  for(int i=-1;i<H;i++){
    for(int j=-1;j<W;j++){
      if(T(i,j)=='#'&&T(i+1,j)=='#'&&T(i,j+1)=='.'&&T(i+1,j+1)=='#'){
	x=j+1;y=i+1;
	a=acos( (x)/(sqrt(x*x+y*y)) );
	u.push_back(P(change(x,y),-1));
      }
      if(T(i,j)=='.'&&T(i+1,j)=='#'&&T(i,j+1)=='.'&&T(i+1,j+1)=='.'){
	x=j+1;y=i+1;
	a=acos( (x)/(sqrt(x*x+y*y)) );
	u.push_back(P(change(x,y),1));
      }
      if(T(i,j)=='#'&&T(i+1,j)=='.'&&T(i,j+1)=='#'&&T(i+1,j+1)=='#'){
	x=j+1;y=i+1;
	a=acos( (x)/(sqrt(x*x+y*y)) );
	u.push_back(P(change(x,y),1));
      }
      if(T(i,j)=='.'&&T(i+1,j)=='.'&&T(i,j+1)=='#'&&T(i+1,j+1)=='.'){
	x=j+1;y=i+1;
	a=acos( (x)/(sqrt(x*x+y*y)) );
	u.push_back(P(change(x,y),-1));
      }
    }
  }
  
  

  int cnt=1,ans=1;
  sort(u.begin(),u.end());
  for(int i=0;i<(int)u.size();i++){
    
    cnt+=u[i].second;
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3472
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    if (N != 0) {
      for (idx <- 0 until N)
        println((sc.nextInt, sc.nextInt, sc.nextInt) match {
          case (m, e, j) if (m == 100 || e == 100 || j == 100 || m + e >= 180 || m + e + j >= 240) => "A"
          case (m, e, j) if (m + e + j >= 210 || (m + e + j >= 150 && (m >= 80 || e >= 80))) => "B"
          case _ => "C"
        })
      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 56540
h, w, d = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]

nc = dict()
for row in range(h):
    for col in range(w):
        v = A[row][col]
        nc[v] = (row, col)

q = int(input())
lrs = [list(map(int, input().split())) for _ in range(q)]

c_sums = [[0] for _ in range(d)]
for r in range(d):
    k = 0
    if r == 0: k = 1
    while r + (k + 1) * d <= h * w:
        i, j = nc[r + k * d]
        x, y = nc[r + (k + 1) * d]
        t = c_sums[r][-1] + abs(x - i) + abs(y - j)
        c_sums[r].append(t)
        k += 1

for lr in lrs:
    l, r = lr
    ld, rest = divmod(l, d)
    rd = r // d
    if rest == 0:
        ld -=1
        rd -=1
    print(c_sums[rest][rd] - c_sums[rest][ld])

Measured memory_bytes: 50628
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        long v = n % k;
        v = Math.min(v, Math.abs(v - k));

        System.out.println(v);
    }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define mod 998244353
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n;
int arr[100000+9][4];
ll dp[100000+5][5];
int main() {
    cin>>n;
    for(int i = 1;i<=n;i++){
        for(int j = 0;j<3;j++){
            cin>>arr[i][j];
        }
    }
    for(int i = 1 ; i<=n;i++){
        for(int j = 0;j<3;j++){
            for(int k = 0;k<3;k++){
                if(k != j){
                    dp[i][j] = max(dp[i-1][k]+arr[i][j],dp[i][j]);
                }
            }
        }
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
    return 0;
}


Measured memory_bytes: 5760
a, b, c, x, y = map(int, input().split())

n = max(int((x + 2 * c - 1) / (2 * c)),
        int((y + 2 * c - 1) / (2 * c)))
ret = float('inf')
for c_i in range(2 * (10 ** 5) + 1):
    a_i = max(x - c_i, 0)
    b_i = max(y - c_i, 0)
    cost = a_i * a + b_i * b + 2 * c_i * c
    ret = min(ret, cost)
print(ret)


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


int main(void){
    int64_t N,ans=1;
    cin >> N;
  vector<int64_t> A(N);
  for(int64_t i=0;i<N;i++){
    cin >> A.at(i);
    if(A.at(i)==0){
      cout << 0 << endl;
      return 0;
    }
  }
  for(int64_t i=0;i<N;i++){
    if(1000000000000000000/ans<A.at(i)){
      cout << -1 << endl;
      return 0;
    }
    ans*=A.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3984
#include <iostream>
using namespace std;
typedef long long ll;
ll n,m;
ll ans;
inline void dfs(ll x,ll y){
    if(x%y==0){//如果到最后一步
        ans+=x*2-y;//根据观察得到的规律
        return ;
    }
    else{
        ans+=(x-x%y)*2;//注意减去多出来的部分
        dfs(y,x%y);//递归，较短的部分和多出来的部分
    }
}
main(){
    cin>>n>>m;
    ans=n;//初始值由n开始
    n-=m;
    dfs(max(n,m),min(n,m));//递归
    cout<<ans<<endl; 
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    static final int INF = Integer.MAX_VALUE;

    static class Edge {
        int from, to, cost;

        public Edge(int from, int to, int cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }
    }

    static class BellmanFord {
        int n;
        List<Edge> edges;
        int[] dist;
        boolean negativeCycle;

        public BellmanFord(int n, List<Edge> edges) {
            this.n = n;
            this.edges = edges;
            dist = new int[n];
            Arrays.fill(dist, INF);
            dist[0] = 0;
            run();
        }

        private void run() {
            boolean[] reachableFrom = new boolean[n];
            reachableFrom[n - 1] = true;

            for (int i = 0; i < n - 1; i++) {
                for (Edge e : edges) {
                    if (reachableFrom[e.to]) reachableFrom[e.from] = true;
                    if (dist[e.from] == INF) continue;
                    dist[e.to] = Math.min(dist[e.to], dist[e.from] + e.cost);
                }
            }

            for (Edge e : edges) {
                if (dist[e.from] == INF || !reachableFrom[e.from]) continue;
                if (dist[e.to] > dist[e.from] + e.cost) negativeCycle = true;
            }
        }
    }

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int P = sc.nextInt();

        List<Edge> edges = new ArrayList<>();
        for (int i = 0; i < M; i++) {
            edges.add(new Edge(sc.nextInt() - 1, sc.nextInt() - 1, -sc.nextInt() + P));
        }

        BellmanFord sol = new BellmanFord(N, edges);

        if (sol.negativeCycle) {
            System.out.println(-1);
        } else {
            System.out.println(Math.max(-sol.dist[N - 1], 0));
        }
    }
}


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

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



// Main Code

vector<int> v;
bool b[55560];
void sieve()
{
	for(int i=2; i*i <=55555; i++)
	{
		if(b[i] == 0)
		{
			for(int j = i*i; j <= 55555; j+= i)
				b[j] = 1;
		}
	}
	repn(i, 2, 55555)
		if(b[i] == 0 && i%5 == 1)
			v.pb(i);
}

int main()
{
	int n;
	cin>>n;
	sieve();
	rep(i, 0, n)
		cout<<v[i]<<" ";
	cout<<endl; 
}


Measured memory_bytes: 256
#include<stdio.h>
#define H 251


typedef struct{
  int key;
  int p;
  int dep;
  int left;
  int right;
}Node;

Node T[H];

int main(){

  int h,i;

  scanf("%d",&h);

  for(i=1;i<=h;i++){
    T[i].p=2000000001;
    T[i].left=2000000001;
    T[i].right=2000000001;
  }

  for(i=1;i<=h;i++){
    scanf("%d",&T[i].key);
  }

  
 for(i=1;i<=h;i++){
   if(i!=1)T[i].p = T[i/2].key;

   if(2*i<=h) T[i].left=T[2*i].key;
 
   if(2*i+1<=h) T[i].right=T[2*i+1].key;
  }

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,T[i].key);
  
    if(i!=1) printf("parent key = %d, ",T[i].p);

    if(T[i].left!=2000000001) printf("left key = %d, ",T[i].left);
    
    if(T[i].right!=2000000001) printf("right key = %d, ",T[i].right); 

    printf("\n");
  }

  return 0;
}

 
   
    

Measured memory_bytes: 604
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int a, b, c;
	cin >> a >> b >> c;

	if (a == b && a != c)
	{
		cout << "Yes" << endl;
	}
	else if (b == c && a != c)
	{
		cout << "Yes" << endl;
	}
	else if (a == c && b != c)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = (1<<30);
int d,g;
int p[11], c[11];




int main(){
    cin >> d >> g;
    for(int i=0;i<d;++i){
        cin >> p[i] >> c[i];
    }
    int ret = INF;
    //d問の問題をそれぞれ全部解くか
    for(int i = 0;i < (1 << d);++i){
        //cout << i << endl;
        int s = 0, num = 0, rest_max = -1;//rest_max: 選ばれない問題の中で最大のポイント
        for(int j = 0; j < d; ++j){
            if(i >> j & 1){
                s += 100 * (j+1) * p[j] + c[j];
                num += p[j];
            }else{
                rest_max = j;
            }
        }
        if(s < g){
            int s1 = 100 * (rest_max + 1);
            //if(s1==0)continue;
            int need = (g - s + s1 - 1) / s1; //切り上げ割り算
            if(need >= p[rest_max]){continue;}//その問題は解き切らない
            num += need;
        }
        ret = min(ret, num);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256