akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define vout(v) for(int i=0;i<(int)v.size()-1;i++){cout<<v[i]<<" ";}cout<<v[v.size()-1]<<"\n";
#define debg(a) cerr<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;

void plus1(ll H, ll W, ll h, ll w, std::vector<std::string>& S){
    if (h<0 || w<0 || h>=H || w>=W) {return;}
    if (S[h][w]=='.') {
        S[h][w] = '1';
    } else if (S[h][w]!='#'){
        S[h][w] +=1;
    }
}

void solve(long long H, long long W, std::vector<std::string> S){
    for (ll i = 0; i < H; i++) {
        for (ll j = 0; j < W; j++) {
            if(S[i][j]=='.') { S[i][j]='0';}
            if(S[i][j]=='#') {
                plus1(H, W, i+1, j, S);
                plus1(H, W, i+1, j+1, S);
                plus1(H, W, i, j+1, S);
                plus1(H, W, i-1, j+1, S);
                plus1(H, W, i-1, j, S);
                plus1(H, W, i-1, j-1, S);
                plus1(H, W, i, j-1, S);
                plus1(H, W, i+1, j-1, S);
            }
        }
    }
    for (ll i = 0; i < H; i++) {
        cout << S[i] << "\n";
    }
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::string> S(H);
    for(int i = 0 ; i < H ; i++){
        std::cin >> S[i];
    }
    solve(H, W, std::move(S));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int s[8] = {};
    for(int i = 0; i < 3; i++) {int x; cin >> x; s[x]++;}
    if(s[5] == 2 && s[7] == 1) cout << "YES";
    else cout << "NO";
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int n; cin >> n; vector<ll> a(n); REP(i,n) cin >> a[i];
  
  vector<ll> gcd(n), rgcd(n);
  gcd[0] = a[0]; rgcd[n-1] = a[n-1];
  REP(i,n-1) {
    gcd[i+1] = __gcd(a[i+1],gcd[i]);
    rgcd[n-i-2] = __gcd(a[n-i-2],rgcd[n-i-1]);
  }
  
  vector<ll> ans(n);
  ans[0] = rgcd[1];
  ans[n-1] = gcd[n-2];

  REP(i,n-2) {
    ans[i+1] = __gcd(gcd[i],rgcd[i+2]);
  }
  /* cout << "gcd" << endl; */

  /* /1* REP(i,n) { *1/ */
  /*   cout << gcd[i] << " " ; */
  /* } cout << endl; */
  /* cout << "rgcd " << endl; */
  
  /* REP(i,n) { */
  /*   cout << rgcd[i] << " "; */
  /* } cout << endl; */
  

  /* cout << "before sort" << endl; */
  /* REP(i,n) cout << ans[i] << " "; */
  /* cout << endl; */
  sort(ALL(ans));
  /* cout << "ans" << endl; */
  /* REP(i,SIZE(ans)) cout << ans[i] << " "; */
  /* cout << endl; */


  cout << ans[n-1] << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define FIO ios_base::sync_with_stdio(false); cin.tie(0);

int main()
{
    FIO
    
    ll n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int ans=0,f=1;char chr=getchar();
	while(!isdigit(chr)){if(chr=='-')f=-1;chr=getchar();}
	while(isdigit(chr)) {ans=(ans<<3)+(ans<<1)+chr-48;chr=getchar();}
	return ans*f;
}int x,y;
int main(){
	cin>>x>>y;
	cout<<max(x-y*2,0);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
#define PI 3.14159265358979
//#define rep(i,init,n) for(ll i=init;i<=n;++i)
using P = pair<ll , ll>;
using map = map<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    ll n;
    cin >> n;
    vl a(n);
    rep(i,n) cin >> a.at(i);

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

    ll ans = a.at(0);
    ll init = 1000000000000000000;

    rep(i,n){
        if(a.at(i) != 0) init /= a.at(i);
    }

    for (int i = 1; i < n; ++i) {
        ans *= a.at(i);
//        if(init < 0 || ans > 1000000000000000000) {
//            init = -1;
//            break;
//        }
    }

    bool is_0 = false;

    rep(i,n) {
        if(a.at(i)==0) {
            is_0 = true;
            break;
        }
    }
    if(is_0) cout << 0 << endl;
    else if(init == 0 || ans > 1000000000000000000) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4048
main = do
  s <- getLine
  let toInt x = read x :: Int
  let [a,b] = map toInt . words $ s
  if a == 0 && b == 0 then return ()
  else do
    if a < b then putStrLn $ (show a) ++ " " ++ (show b)
    else putStrLn $ (show b) ++ " " ++ (show a)
    main

Measured memory_bytes: 4132
#include<bits/stdc++.h>
#define int long long
using namespace std;
 
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
    }
signed main(){
 int a,b;
 while(cin>>a>>b){
     int c=gcd(a,b);
     printf("%lld %lld\n",c,a*b/c);
     }
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

#define N 55556

int prime[N];

void eratosthenes(){
  rep(i,N) prime[i]=1;
  prime[0]=prime[1]=0;
  rep(i,N){
    if(prime[i]){
      for(int j=i+i;j<N;j+=i) prime[j]=0;
    }
  }
}


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  eratosthenes();
  int ans[55];
  int now=0;
  rep(i,55556){
    if(prime[i]==1 && i%5==1){
      ans[now]=i;
      now++;
    }
    if(now==n) break;
  }
  rep(i,n){
    if(i!=n-1) cout<<ans[i]<<" ";
    else cout<<ans[i]<<endl;
  }

  

  return 0;
}


Measured memory_bytes: 640
#n,m=list(map(int,input().split()))
s = list(input())
h = len(s)//2

for i in range(h):
  if s[i] != s[-i-1]:
    print("No")
    exit()
  elif s[i] != s[h+i+1]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long int
main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //#define int long long int
    int g,h,e=0,n,r;
    cin>>g>>h;

    if(g!=1 && g!=0)
    {
    long long p = 1, k = 1;
	n=g;
	r=2;
	if (n - r < r)r = n - r;

	if (r != 0)
    {
		while (r)
		{
			p *= n;
			k *= r;
			long long m = __gcd(p, k);
			p /= m;
			k /= m;
            n--;
			r--;
		}
	}

	else p = 1;

     e=p ;
    }
	else if(g==0 || g==1) e=0;

	if(h!=1 && h!=0)
    {

	long long a = 1, b = 1;
	n=h;
	r=2;
	if (n - r < r)
		r = n - r;

	if (r != 0)
    {
		while (r)
		{
			a *= n;
			b *= r;
			long long m = __gcd(a, b);
			a /= m;
			b /= m;
            n--;
			r--;
		}
	}

	else
		a = 1;

	e+=a;
    }
	else if(h==0 || h==1) e+=0;

    cout<<e<<endl;


    return 0;
}


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

int main(){
	char s[6];
	for(int i = 0;i<=5;i++){
		cin >> s[i];
	}
	if(s[2]==s[3] && s[4]==s[5]){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int X;
    cin >> X;
    if (X == 3 || X == 5 || X == 7)
        cout << "YES";
    else
        cout << "NO";
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int R = sc.nextInt();
		int S = sc.nextInt();
		int P = sc.nextInt();
		String T = sc.next();
		char[] hand = T.toCharArray();
		int score[] = new int[N];
		for(int i=0;i<N;i++) {
			if(hand[i] == 'r') {
				score[i] = P;
			}
			else if(hand[i] == 's'){
				score[i] = R;
			}
			else {
				score[i] = S;
			}
		}
		ArrayList<ArrayList<Integer>> mod_score = new ArrayList<>();
		ArrayList<ArrayList<Character>> mod_hand = new ArrayList<>();
		for(int i=0;i<K;i++) {
			mod_score.add(new ArrayList<Integer>());
			mod_hand.add(new ArrayList<Character>());
		}
		for(int i=0;i<K;i++) {
			int now = i;
			while(now<N) {
				mod_score.get(i).add(score[now]);
				mod_hand.get(i).add(hand[now]);
				now += K;
			}
		}

		int result = 0;
		for(int i=0;i<K;i++) {
			char pred_hand = 'N';
			int count = 0;
			for(int j=0;j<mod_score.get(i).size();j++) {
				if(pred_hand != mod_hand.get(i).get(j)) {

					result += mod_score.get(i).get(j);
					pred_hand = mod_hand.get(i).get(j);
				}
				else {
					pred_hand = 'N';
				}
			}
		}




		out.println(result);




		out.flush();
	}


}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}else{
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() { return Double.parseDouble(next());}
}



Measured memory_bytes: 53884
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[10];
int tot[1010];
int in[1010];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<1000;i++)tot[i]=0;
		for(int i=0;i<1000;i++)in[i]=-1;
		for(int i=0;i<a;i++){
			int p,q,r;
			scanf("%s%d:%d%s%d",str,&p,&q,str,&r);
			p=p*60+q;
			if(str[0]=='I')in[r]=p;
			else{
				if(r){
					if(~in[0])tot[r]+=p-max(in[0],in[r]);
				}else{
					for(int i=1;i<1000;i++)if(~in[i])tot[i]+=p-max(in[i],in[0]);
				}
				in[r]=-1;
			}
		}
		int ret=0;
		for(int i=1;i<1000;i++)ret=max(ret,tot[i]);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1024
// Problem : A - Circle Pond
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/**         srijan_de
 _____      _ _              ______     
/  ___|    (_|_)             |  _  \    
\ `--. _ __ _ _  __ _ _ __   | | | |___ 
 `--. \ '__| | |/ _` | '_ \  | | | / _ \
/\__/ / |  | | | (_| | | | | | |/ /  __/
\____/|_|  |_| |\__,_|_| |_| |___/ \___|
            _/ |                         
           |__/           23.02.2001     **/
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
#include    <bits/stdc++.h>  
using       namespace       std;
using       lli=            long long  int;
using       ulli=           unsigned long long int;
using       ld=             long double;
#define     mem(a,val)      memset( a,  val,  sizeof(a) )
#define     b_s             binary_search
#define     u_b             upper_bound
#define     l_b             lower_bound
#define     nl              cout<<endl
#define     pb              push_back
#define     pf              push_front
#define     ppb             pop_back
#define     ppf             pop_front
#define     in              insert
#define     fi              first
#define     se              second
#define 	pqueue			priority_queue
const lli   MOD=            (int)1e9 + 7;
const lli   MOD1=           (int)1e9 + 9;
const lli   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;
lli         tests=          1;
template<class x,class y>x max(x a,y b){return (a>b)?a:b;}
template<class x,class y>x min(x a,y b){return (a<b)?a:b;}
template<class x,class y>x log(x n,y r){return (n>r-1)?1+log(n/r,r):0;}

///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
int32_t main() 
{
	auto start = clock();
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);	

//	cout<<fixed;
//	cout<<scientific;
	cout<<fixed<<setprecision(20);
	// cin>>tests;
	for(lli test=1;test<=tests;test++) 
	{
//		cout<<"Case #"<<test<<": ";
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
		
		
		
		lli n;
		cin>>n;
		cout<<double(2*n*pi);
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
	}
	cerr<<endl<<endl<<endl<< "Time : " << double(clock() - start) / CLOCKS_PER_SEC <<endl;
	return 0;
}
///.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.


Measured memory_bytes: 3808
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long int
ll ans = 0;

bool cheak_753 ( ll num ) {
  bool three = false, five = false, seven = false;
  ll temp = num;
  while ( num != 0 ) {
    ll x = num % 10;
    if ( x == 3 ) three = true;
    else if ( x == 5 ) five = true;
    else if ( x == 7 ) seven = true;
    num /= 10;
  }
  if ( three == true &&  five == true &&  seven == true ) {
    //cout << "条件を満たしたのは" << temp << "です、" << endl;
    ++ans;  
  }
  return 0;
}

ll get_sub_753 ( ll upper_limit, ll num ) {
  if ( num > upper_limit ) return 0;
  else {
    cheak_753 ( num );
    ll plus_seven = 10 * num + 7;
    ll plus_five  = 10 * num + 5;
    ll plus_three = 10 * num + 3;
    get_sub_753 ( upper_limit, plus_seven );
    get_sub_753 ( upper_limit, plus_five  );
    get_sub_753 ( upper_limit, plus_three );
    return 0;  
  }  
}
int main(){
  ll n; cin >> n;
  get_sub_753 ( n, 0 );
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    int d, t, s; cin >> d >> t >> s;
    cout << ((t*s >= d)?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3688
#include<stdio.h>
#include<math.h>

typedef struct{double x,y;  }Point;

void kock(int,Point,Point);

int main()
{
  Point s,t;
  int n;
  scanf("%d",&n);

  s.x=0;
  s.y=0;
  t.x=100;
  t.y=0;

  printf("%.8f %.8f\n",s.x,s.y);
  kock(n,s,t);
  printf("%.8f %.8f\n",t.x,t.y);

  return 0;
}
void kock(int n,Point p1,Point p2)
{
  Point a,b,c;
  double th=M_PI*60.0/180.0;
  if(n==0)return;

  a.x=(2*p1.x+1*p2.x)/3;
  a.y=(2*p1.y+1*p2.y)/3;
  b.x=(1*p1.x+2*p2.x)/3;
  b.y=(1*p1.y+2*p2.y)/3;
  c.x=(b.x-a.x)*cos(th)-(b.y-a.y)*sin(th)+a.x;
  c.y=(b.x-a.x)*sin(th)+(b.y-a.y)*cos(th)+a.y;
  
  kock(n-1,p1,a);
  printf("%.8f %.8f\n",a.x,a.y);
  kock(n-1,a,c);
  printf("%.8f %.8f\n",c.x,c.y);
  kock(n-1,c,b);
  printf("%.8f %.8f\n",b.x,b.y);
  kock(n-1,b,p2);
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define ll long long
using namespace std;
map<ll,ll>f;
ll p=1e9+7,n;
ll solve(ll x){
	if(f[x])return f[x];
	return f[x]=(solve(x/2)+solve((x-1)/2)+solve((x-2)/2))%p;
}
int main(){
	f[0]=1;f[1]=2;
	scanf("%lld",&n);
	printf("%lld",solve(n));
}
/*按位考虑，因为a xor b = a+b-2(a and b)<=a+b，实际上只需要考虑a+b<=n，
现在要求a的每一位不大于b的每一位，这样就不会有重复了*/ 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
int N,K;
int A[51];
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) cin>>A[i];
	sort(A,A+N);
	reverse(A,A+N);
	cout<<accumulate(A,A+K,0)<<endl;
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] lo = reader.readLine().split(" ");
        long N = Long.parseLong(lo[0]);
        long K = Long.parseLong(lo[1]);
        if(N<K){
            System.out.println(Math.min(N,Math.abs(N-K)));
        }
        else if(N>K){
            long q = N/K -1;
            N = N - q*K;
            N = Math.abs(N-K);
            System.out.println(Math.min(N,Math.abs(N-K)));
        }
        else System.out.println(0);
    }
}


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

int main(){
   int h, a;
  cin >> h >> a;
  int j = 0;
  rep(i,10000){
  if(h > 0 ){
    h -= a;
    j++;
  }
    else break;
  }
  intput(j);
}

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

int main() {
	int a, b, c;
	int ans = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c%i == 0) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3100
N=int(input())
A=list(map(int,input().split()))
X=[[1]*3 for i in range(10)]

for i in range(N):
   X[i][0]=A[i]-1
   X[i][1]=A[i]
   X[i][2]=A[i]+1
ans=0
for a in X[0] :
    if N==1:
        if a%2==0:
            ans+=1
    for b in X[1]:
        if N<2:
            break
        elif N==2:
            if (a*b)%2==0:
                ans+=1
        for c in X[2]:
            if N<3:
                break
            elif N==3:
                if (a*b*c)%2==0:
                    ans+=1
            for d in X[3]:
                if N<4:
                    break
                elif N==4:
                    if (a*b*c*d)%2==0:
                        ans+=1
                for e in X[4]:
                    if N<5:
                        break
                    elif N==5:
                        if (a*b*c*d*e)%2==0:
                            ans+=1
                    for f in X[5]:
                        if N<6:
                            break
                        elif N==6:
                            if (a*b*c*d*e*f)%2==0:
                                ans+=1
                        for g in X[6]:
                            if N<7:
                                break
                            elif N==7:
                                if (a*b*c*d*e*f*g)%2==0:
                                    ans+=1
                            for h in X[7]:
                                if N<8:
                                    break
                                elif N==8:
                                    if (a*b*c*d*e*f*g*h)%2==0:
                                        ans+=1
                                for i in X[8]:
                                    if N<9:
                                        break
                                    elif N==9:
                                        if (a*b*c*d*e*f*g*h*i)%2==0:
                                            ans+=1
                                    for j in X[9]:
                                        if N<10:
                                            break
                                        elif N==10:
                                            if (a*b*c*d*e*f*g*h*i*j)%2==0:
                                                ans+=1

print(ans)


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


int main() {
	int N, Y;
	cin >> N >> Y;

	for (int i=0; i< N+1; i++) {
		if (((10000 * i ) == Y) && i == N) {
			cout << i << " 0 0"  << endl;
			return 0;
		}
		for (int j=0; j < N - i + 1; j++) {
			if (((10000 * i + 5000 * j + (N - i - j) * 1000) == Y) && (i + j + N - i - j) == N) {
				cout << i << " " << j << " " << N - i - j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        t: String,
        s: String,
    };

    let mut ans = 0;
    for (i, j) in t.chars().zip(s.chars()) {
        if i != j {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2824
#include<stdio.h>

int main(){
  char moji;
  scanf("%c", &moji);
  if(moji == 'a' || moji == 'i' || moji == 'u' || moji == 'e' || moji == 'o'){
    printf("vowel\n");
  }else{
    printf("consonant\n");
  }

  return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int h, w;
    scanf("%d %d", &h, &w);
    char s[h][w];
    rep(i, h)
    {
        rep(j, w)
        {
            scanf(" %c", &s[i][j]);
        }
    }
    int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
    int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
    rep(i, h)
    {
        rep(j, w)
        {
            if (s[i][j] != '#')
            {
                int count = 0;
                rep(d, 8)
                {
                    int ni = i + dy[d];
                    int nj = j + dx[d];
                    if(ni < 0 || h <= ni) continue; //s[-1][*]やs[h以上][*]など表からはみ出す場合は除外する
                    if(nj < 0 || w <= nj) continue; //s[*][-1]やs[*][w以上]など表からはみ出す場合は除外する
                    if(s[ni][nj] == '#') count++;
                }
                printf("%d", count);
            }
            else printf("#");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = []
    for i in range(n):
        a.append(int(input()))

    a_sort = sorted(a)

    for i in range(n):
        if a[i] == a_sort[-1]:
            print(a_sort[-2])
        else:
            print(a_sort[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 90324
#include <stdio.h>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;
#define F first
#define S second
#define MP make_pair
const int N=5e5+10;
const ll INF=1LL<<60;
ll dis(pi a,pi b){
    ll x=a.F-b.F,y=a.S-b.S;
    return x*x+y*y;
}
int main(){
    int n,lim;
    ll ans=INF;
    pi a[N];
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d%d",&a[i].F,&a[i].S);
    sort(a,a+n);
    lim=min(3,n);
    for(int i=0;i<lim;i++)for(int j=i+1;j<lim;j++)ans=min(ans,dis(a[i],a[j]));
    for(int i=lim;i<n;i++)for(int j=1;j<=lim;j++)ans=min(ans,dis(a[i],a[i-j]));
    printf("%lld\n",ans);
}


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

#define F first
#define S second

using namespace std;

long long int mod = 1e9+7;

long long int wop(long long int x, long long int y) {
    if(y==0)return 1;
    long long int ret=wop(x,y/2);
    ret=(ret*ret)%mod;
    if(y&1)ret*=x;
    return ret%mod;
}

/*long long int chos(long long int r, long long int n) {
    return fac[n]*rev[r]*rev[n-r]
}*/

const int N = 1e5+100, M = 25;
long long int a[M], b[M], pw[M];
vector<long long int> vn1, vn2;

int main () {
    ios::sync_with_stdio(0);
    pw[0]=1;
    for(int i = 1 ; i < 20 ; i++)pw[i]=pw[i-1]*2;
    long long int n;
    cin >> n;
    for(int i = 0 ; i < n ; i ++ ) {
        cin >> a[i];
    }
    for(int i = 0 ; i < n ; i ++ ) {
        cin >> b[i];
    }
    long long int ans=1e18;
    for(int i = 0 ; i < pw[n] ; i++ ) {
        vector<long long int> v;
        v.clear();
        long long int com[n+4][4];
        memset(com,63,sizeof(com));
        for(int j = 0 ; j < n ; j++ ) {
            if(i&pw[j]) {
                v.push_back(b[j]);
                com[j][1]=b[j];
            }
            else {
                v.push_back(a[j]);
                com[j][0]=a[j];
            }
        }
        sort(v.begin(),v.end());
        long long int mas=0;
        bool adm=0;
        for(int p = n-1 ; p>= 0 ;p--) {
            bool ok=0;
            for(int j = p ; j >= 0 ; j--) {
                if((p-j)%2==0) {
                    if(com[j][0]==v[p]) {
                        for(int k = j ; k < p ; k++) {
                            swap(com[k][0],com[k+1][1]);
                            swap(com[k][1],com[k+1][0]);
                            mas++;
                        }
                        ok=1;
                    }
                }
                else {
                    if(com[j][1]==v[p]) {
                        for(int k = j ; k < p ; k++) {
                            swap(com[k][0],com[k+1][1]);
                            swap(com[k][1],com[k+1][0]);
                            mas++;
                        }
                        ok=1;
                    }
                }
                if(ok)break;
            }
            if(!ok) {
                adm=1;
                break;
            }
        }
        if(!adm) {
            ans=min(ans,mas);
        }
    }
    if(ans>1e9) return cout << -1,0;
    cout << ans;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << n/(a+b)*a+min(a, n%(a+b)) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<vector<int> > g(n);
	vector<int> a(n - 1), b(n - 1);
	for (int i = 0; i < n - 1; i++) {
		cin >> a[i] >> b[i]; a[i]--, b[i]--;
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	function<vector<int>(int, int)> shortest_paths = [&](int p1, int p2) {
		vector<int> dist(n, -1);
		queue<int> que;
		dist[p1] = 0, que.push(p1);
		if (p2 != -1) dist[p2] = 0, que.push(p2);
		while (!que.empty()) {
			int u = que.front(); que.pop();
			for (int i : g[u]) {
				if (dist[i] == -1) {
					dist[i] = dist[u] + 1;
					que.push(i);
				}
			}
		}
		return dist;
	};
	vector<int> dz = shortest_paths(0, -1);
	vector<int> dx = shortest_paths(max_element(dz.begin(), dz.end()) - dz.begin(), -1);
	vector<int> dy = shortest_paths(max_element(dx.begin(), dx.end()) - dx.begin(), -1);
	int ans = *max_element(dx.begin(), dx.end()) / 2 + 1;
	long long ret = 1LL << 62;
	if (n == 2) ret = 2;
	else {
		for (int i = 0; i < n; i++) {
			if (dx[i] < ans && dy[i] < ans) {
				vector<int> d = shortest_paths(i, -1);
				vector<int> mx(ans - 1);
				for (int j = 0; j < n; j++) {
					if (d[j] == ans - 1) continue;
					mx[d[j]] = max(mx[d[j]], (int)g[j].size());
				}
				long long mul = mx[0];
				for (int j = 1; j < ans - 1; j++) {
					mul *= mx[j] - 1;
				}
				ret = min(ret, mul);
			}
		}
		for (int i = 0; i < n - 1; i++) {
			vector<int> d = shortest_paths(a[i], b[i]);
			if (*max_element(d.begin(), d.end()) < ans) {
				vector<int> mx(ans - 1);
				for (int j = 0; j < n; j++) {
					if (d[j] == ans - 1) continue;
					mx[d[j]] = max(mx[d[j]], (int)g[j].size());
				}
				long long mul = mx[0] - 1;
				for (int j = 1; j < ans - 1; j++) {
					mul *= mx[j] - 1;
				}
				ret = min(ret, mul * 2);
			}
		}
	}
	cout << ans << ' ' << ret << '\n';
	return 0;
}

Measured memory_bytes: 256
n = int(input())
if n%2 ==0:
  print((n-1)*(n)//2-n//2)
else:
  print((n-2)*(n-1)//2-(n-1)//2 +n-1)

if n%2 ==1:
  for i in range(n-1):
    print(i+1,n)
  n = n-1

if n%2 ==0:
  wa = n+1
  for i in range(n):
    for j in range(i+1,n):
      if wa != i+j+2:
        print(i+1,j+1)

Measured memory_bytes: 3612
n = int(input())
list_A = list(map(int, input().split()))
list_A.sort(reverse=True)
ans = list_A.pop(0)
k = (n-2)//2
ans += 2*sum(list_A[:k])
if (n-2) % 2 == 1:
    ans += list_A[k]

print(ans)

Measured memory_bytes: 31432
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define d double
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int a,b;
  cin>>a>>b;
  if(a>=1&&a<=9&&b>=1&&b<=9){
  	cout<<a*b<<endl;
  	
  }
  
  else{
  	cout<<"-1"<<endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
long int a,b[100005],c,z;
int main()
{
    cin>>a>>c;
    for (int i=1;i<=a;i++)
    cin>>b[i];
    sort(b+1,b+a+1);
    for (int i=a;i>=a-c+1;i--)
    z+=b[i];
    cout<<z<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var hs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var memo = new List<int>(Enumerable.Range(0,N).Select(s=>int.MaxValue));
            //Action<List<int>, int, int> chmin = 
            //    (ls, index, val) => 
            //{
            //    if (val < ls[index]) ls[index] = val;
            //};
            memo[0] = 0;
            memo[1] = Math.Abs(hs[0] - hs[1]);
            for (var i=2;i<N;i++)
            {
                var tmpA = Math.Abs(hs[i - 1] - hs[i]) + memo[i - 1];
                var tmpB = Math.Abs(hs[i - 2] - hs[i]) + memo[i - 2];
                memo[i] = Math.Min(tmpA, tmpB);
//                chmin(memo, tmpA, tmpB);
            }
            Console.WriteLine(memo[N-1]);
        }
    }
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 0;
	for (ll i = 1; i * i <= n; ++i) {
		if (n % i != 0)continue;
		ll tmp = n / i - 1;
		if (n / tmp == i && n % tmp == i)ans += tmp;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <boost/range/algorithm.hpp>
#include <boost/integer/common_factor_rt.hpp>

using namespace std;

int N;

int main() {

    while (cin >> N) {
        cout << (N - 2) * 180 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N,Q = map(int,input().split())
Ki_Oya=dict()
for i in range(N-1):
  A,B = map(int,input().split())
  Ki_Oya[B-1]=A-1
Counter_list=[0]*N
for i in range(Q):
  P,X=map(int,input().split())
  Counter_list[P-1] += X
print(Counter_list[0],end=" ")
for i in range(1,len(Counter_list)):
  Counter_list[i] += Counter_list[Ki_Oya[i]]
  print(Counter_list[i],end=" ")
print("")

Measured memory_bytes: 39792
#include <stdio.h>
int main () {
  int N;
  int A[30];
  int B[30];
  int C[30];
  int i;
  int n;
  int ans = 0;
  scanf ("%d", &N);

  for (i = 0; i < N; i++) {
    scanf ("%d", &A[i]);
  }

  for (i = 0; i < N; i++) {
    scanf ("%d", &B[i]);
  }

  for (i = 0; i < N - 1; i++) {
    scanf ("%d", &C[i]);
  }
  for (i = 0; i < N; i++) {
    n = A[i];
    ans += B[n - 1];

    if (A [i + 1] - A[i] == 1) {
      ans += C[n - 1];
    }
  }

  printf ("%d", ans);


  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

struct st{
    int first;
    int second;
    int num;
};

bool comp(st a, st b){
    return a.first < b.first;
}

int main(){
    int N, a, b; 
    cin >> N;
    vector<st> town(N);
    rep(i,N){
        cin >> town[i].first >> town[i].second;
        town[i].num = i;
    }
    sort(all(town), comp);
    map<int,int> al;
    dsu uf(N);
    al[town[0].second] = 0;
    for(int i = 1; i < N; ++i){
        vector<int> erase_list;
        P minest = make_pair(inf, inf);
        for(auto x:al){
            if(x.first < town[i].second){
                uf.merge(i, x.second);
                erase_list.push_back(x.first);
                if(minest.first > x.first)minest = x;
            }else{
                break;
            }
        }
        for(auto x:erase_list){
            al.erase(x);
        }
        int push_pos = minest.second;
        if(minest.first > town[i].second){minest = make_pair(town[i].second, i); push_pos = i;}
        al[minest.first] = push_pos;
    }
    vector<int> ans(N);
    rep(i,N)ans[town[i].num] = uf.size(i);
    show(ans);
    return 0;
}


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

int main()
{
  int m, f, r;
  char result;
  while(true)
  {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) return 0;
    if ( m == -1 || f == -1 || m+f < 30 )
    {
      result = 'F';
    }else if( 80 <= m+f )
    {
      result = 'A';
    }else if( 65 <= m+f )
    {
      result = 'B';
    }else if( 50 <= m+f || (30 <= m+f && 50 <= r) )
    {
      result = 'C';
    }else if( 30 <= m+f )
    {
      result = 'D';
    }

    cout << result << endl;
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
const long long MOD = 1000000007;
int main()
{
    int N;
    cin >> N;
    vector<int> A(N + 1, 0);
    rep(i, N) {
        int a;
        cin >> a;
        A[a]++;
    }

    bool flag = true;
    if (N % 2 == 0) {
        for (int i = 1; i <= N; i += 2) {
            if (A[i] != 2) {
                flag = false;
                break;
            }
        }
    }
    else {
        if (A[0] != 1) {
            flag = false;
        }
        for (int i = 2; i <= N; i += 2) {
            if (A[i] != 2) {
                flag = false;
                break;
            }
        }
    }

    ll ans = 1;
    rep(i, N / 2) {
        ans *= 2;
        ans %= MOD;
    }

    if (!flag) ans = 0; 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
string s[10001], smin[10001], smax[10001], target;
int strict, pos, n;
 
int main(){
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>s[i];
        smin[i]=s[i];
        smax[i]=s[i];
        for(int j=0; j<s[i].size(); j++){
            if(s[i][j]=='?')smin[i][j]='a';
            if(s[i][j]=='?')smax[i][j]='z';
        }
    }
    cin>>target;
    for(int i=0; i<n; i++){
        if(smin[i]<=target && target<=smax[i]){
            pos++;
        }
        if(smax[i]<target){
            strict++;
        }
    }
    for(int i=0; i<pos; i++){
        cout<<strict+i+1<<" ";
    }
    cout << strict+1+pos << endl;
}

Measured memory_bytes: 1920
import Foundation

main()

func main() {
    let abc = readLine()!.split(separator: " ").map { Int($0)! }
    let k = Double(readLine()!)!
    let sorted = abc.sorted()
    let ans = sorted.reduce(0, +) + sorted.last! * (Int(pow(2.0, k)) - 1)
    print(ans)
}


Measured memory_bytes: 13844
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#include<vector>
#include<algorithm>
#include<string>
using ll=long long;
using P =pair<int,int>;


int main(){
  int n,m;
  cin >> n >> m;
  if(n==m)cout << "Yes";
  else cout << "No";

}


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

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

class Sol{
	public void Solve(){
		Console.WriteLine((3 * A + P)/ 2);
	}
	int A,P;
	public Sol(){
		var d = ria();
		A = d[0]; P = d[1];
	}

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


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<ll mod> struct Mod_Int{
    ll x;
    Mod_Int() {}
    Mod_Int(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod){}

    Mod_Int &operator += (const Mod_Int &p) {
        x = (x + p.x) % mod;
        return *this;
    }

    Mod_Int &operator -= (const Mod_Int &p) {
        x = (x + mod - p.x) % mod;
        return *this;
    }

    Mod_Int &operator *= (const Mod_Int &p) {
        x = (x * p.x) % mod;
        return *this;
    }

    Mod_Int &operator /= (const Mod_Int &p) {
        *this *= p.inverse();
        return *this;
    }

    Mod_Int operator -() const {return Mod_Int(-x);}

    Mod_Int operator + (const Mod_Int &p) const {return Mod_Int(*this) += p;}

    Mod_Int operator - (const Mod_Int &p) const {return Mod_Int(*this) -= p;}

    Mod_Int operator * (const Mod_Int &p) const {return Mod_Int(*this) *= p;}

    Mod_Int operator / (const Mod_Int &p) const {return Mod_Int(*this) /= p;}

    bool operator == (const Mod_Int &p) const {return x == p.x;}

    bool operator != (const Mod_Int &p) const {return x != p.x;}

    Mod_Int pow(ll n) const{
        Mod_Int now = *this, ret = 1;
        while(n > 0){
            if(n & 1) ret *= now;
            now *= now, n >>= 1;
        }
        return ret;
    }

    Mod_Int inverse() const{
        return pow(mod-2);
    }
};

using mint = Mod_Int<MOD>;
const int MAX_N = 1e6;
mint fac[MAX_N+1];

void init(){
    fac[0] = 1;
    rep2(i, 1, MAX_N){
        fac[i] = fac[i-1]*mint(i);
    }
}

mint comb(mint n, mint k){
    return fac[n.x]/(fac[n.x-k.x]*fac[k.x]);
}

mint perm(mint n, mint k){
    return fac[n.x]/fac[n.x-k.x];
}

int main(){
    init();
    int N, H, D;
    cin >> N >> H >> D;
    mint S = 0;
    rep2(i, 1, N) S += fac[i];
    mint dp[H+1], sum[H+2];
    fill(dp, dp+H+1, 0);
    sum[0] = 0;
    dp[0] = sum[1] = 1;
    rep2(i, 1, D) dp[i] = fac[N];
    rep2(i, 1, H){
        dp[i] += (sum[i]-sum[max(1, i-D)])*S;
        sum[i+1] = sum[i]+dp[i];
    }
    mint ans = 0;
    cout << dp[H].x << endl;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first;
#define se second;
using namespace std;
typedef pair<int, int> P;

int dy[6] = {1, 1, 0, 0, -1, -1};
int dx[6] = {1, 0, 1, -1, 0, -1};
const int INF = 1e9;

signed main(){
    int t, n;
    int sx, sy;
    while(1){
        cin >> t >> n;
        if(t == 0 &&  n == 0) break;
        set<P> st;
        rep(i, 0, n){
            int x, y;
            cin >> x >> y;
            st.insert(P(100 + y, 100 + x));
        }
        cin >> sx >> sy;
        int d[200][200] = {};
        rep(i, 0, 200) rep(j, 0, 200) d[i][j] = INF;
        queue<P> q;
        q.push(P(100 + sy, 100 + sx));
        d[100 + sy][100 + sx] = 0;
        while(!q.empty()){
            P p = q.front(); q.pop();
            int y = p.fi;
            int x = p.se;
            rep(i, 0, 6){
                int ny = y + dy[i];
                int nx = x + dx[i];
                if(st.count(P(ny, nx))) continue;
                if(d[ny][nx] != INF) continue;
                d[ny][nx] = d[y][x] + 1;
                if(d[ny][nx] > t) continue;
                q.push(P(ny, nx));
            }
        }
        int ans = 0;
        rep(i, 0, 200){
            rep(j, 0, 200){
                if(d[i][j] <= t) ans++;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3480
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <string>
#define mod 1000000007
using namespace std; 

int main(){
	long long a,b,n; cin >> a >> b >> n;
	if(b-1>n){
		cout << (a*n)/b << "\n";
	}
	else{
		cout << (a*(b-1))/b << "\n";
	}
}


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

void solve()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    rep(i, k)
    {
        if (a < b)
            swap(a, b);
        if (a < c)
            swap(a, c);
        a *= 2;
    }
    int ans = a + b + c;
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main() {
    char c;
    int w, h, k, i;
    scanf("%d %d", &h, &w);
    while (h--) {
        k = -1;
        for (i = 0; i<w; i++) {
            scanf(" %c", &c);
            if (c == 'c')k = 0;
            else if (k + 1)k++;
            if (i)printf(" ");
            printf("%d", k);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2692