akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int[] chars = new int[256];
    while(scanner.hasNextLine()){
      String line = scanner.nextLine();
      for(int i = 0; i < line.length(); i++){
        char c = line.toLowerCase().charAt(i);
        for(char j = 'a'; j <= 'z'; j++){
          if(c == j) chars[j] += 1;
        }
      }
    }
    for(char ch = 'a'; ch <= 'z'; ch++){
      System.out.println(ch + " : " + chars[ch]);
    }
  }
}

Measured memory_bytes: 30424
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    string s;
    int ac = 0, tle = 0, wa = 0, re = 0;
    for (int i = 1; i <= n; i++) {
        cin >> s;
        if(s == "AC") ac++;
        else if(s == "TLE") tle++;
        else if(s == "WA") wa++;
        else re++;
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
}


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


using namespace std;


int main() {
    long long h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int curi = 0, curj = 0;
    char dir = 'r';
    int ans[h][w];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < a[i]; j++) {
            if (dir == 'r') {
                ans[curi][curj] = i + 1;
                curj++;
            } else {
                ans[curi][curj] = i + 1;
                curj--;
            }
            if (dir == 'r' && curj == w) {
                dir = 'l';
                curi++;
                curj--;
            } else if (dir == 'l' && curj == -1) {
                curi++;
                dir = 'r';
                curj++;
            }
        }
    }
    for (int i =0 ; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define pi acos(-1.0)
using namespace std;

int main()
{
    double a,b,h,m,i,j,k,ang;
    cin>>a>>b>>h>>m;
   // ang=min(abs((60*h+m)*0.5-(m*6.0),360-abs((60*h+m)*0.5-(m*6.0))));
    i=(60*h+m)*0.5;
    j=(m*6.0);
    if(i>j)
    {
        k=i-j;
    }
    else
    {
        k=j-i;
    }
//    cout<<k<<endl;
//    cout<<i<<endl;
//    cout<<j<<endl;
    ang=min(k,360-k);
    //ang=pi*ang/180.0;
    cout<<fixed<<setprecision(20)<<sqrt(a*a+b*b-2*a*b*cos(pi*ang/180.0))<<endl;


    return 0;
}


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

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

    int n;
    cin >> n;
    int a;
    for(int i = 0; i < n; ++i){
        cin >> a;
        if(a%2 == 1){
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;

    return 0;
}

Measured memory_bytes: 3620
candidate_num = int(input())
temperature_str = input()
temperature_list = temperature_str.split()
temperature_base = int( temperature_list[0] )
temperature_ideal = int( temperature_list[1] )
candidate_list_str = input() 
candidate_list = candidate_list_str.split()
 
candidate = int(candidate_list[0])
candidate_temperature = temperature_base - candidate*0.006
answer = 1
diff = abs(temperature_ideal - candidate_temperature)
for i in range( 1, len( candidate_list) ):
    candidate = int(candidate_list[i])
    candidate_temperature = temperature_base - candidate*0.006
    if  abs(temperature_ideal -  candidate_temperature) < diff:
        diff = abs(temperature_ideal - candidate_temperature)
        answer = i+1
    
 
 
print(answer)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld ",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define fo(i,a,b) for(int i=a;i<b;i++)
#define all(c) (c).begin(),(c).end()
#define ll long long
const int M=1e9+7;
#define endl "\n"
const double pyi=3.14159265358979323846;


ll temp=1e18;


int main() 
{ 
    ll n; cin>>n;
    ll arr[n];
    int zc=0;
    for(int i=0;i<n;i++)
    {
    	 cin>>arr[i];
    	 if(arr[i]==0) zc++;
    }
    if(zc>0)
    {
    	cout<<0<<endl;
    	return(0);
    }
    ll ans=1;
    for(int i=0;i<n;i++)
    {
    	if(ans>temp/arr[i])
    	{
    		ans=-1;
    		break;
    	}
    	ans=ans*arr[i];
    }
    cout<<ans<<endl;
    return(0);
}





Measured memory_bytes: 4360
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int mod=1e9+7;
int a[100010];
int k[4];
int main()
{
    int x,n;
    cin>>n;
    ll ans=1;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    for(int i=1; i<=n; i++)
    {
        ll sum=0;
        for(int j = 1; j <= 3; ++j)
        {
            if(k[j] == a[i])
                sum++;
        }
        ans=ans*sum%mod;
        for(int j = 1; j <= 3; ++j)
        {
            if(k[j] == a[i])
            {
                k[j]++;
                break;
            }
        }
    }
    cout<<(ans+mod)%mod;
    return 0;
}


Measured memory_bytes: 4004
fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val a= readLine()!!.split(" ").map { it.toInt() }.sortedDescending()
    val alice = a.filterIndexed { i, o -> i%2==0 }.sum()
    val bob   = a.filterIndexed { i, o -> i%2==1 }.sum()
    println(alice-bob)

}

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

typedef long long int ll;

int main()
{
    ll n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);

    if((n%(a+b))>=a)
        printf("%lld\n",((n/(a+b))*a)+a);
    else
        printf("%lld\n",((n/(a+b))*a)+(n%(a+b)));

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;
using P = pair<ll, ll>;
using Tu = tuple<ll, ll, ll>;
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> v;
  vector<vector<ll>> dp(K, vector<ll>(100000, 0));
  ll cnt = 0;
  for(ll i=1;i<=N;){
    ll left = i;
    ll right = N+1;
    while(right - left > 1){
      ll m = (left + right) / 2;
      if(N / m < N / i)
	right = m;
      else
	left = m;
    }
    dp[0][v.size()] = right - i;
    v.push_back(N/i);
    i = right;
  }
  reverse(v.begin(), v.end());
  vector<ll> moveto(v.size(), -1);
  for(int i = 0; i < v.size();i++){
    ll p = 0;
    while(p < v.size() && v[i] * v[p] <= N)
      p++;
    moveto[i] = p - 1;
  }
  for(int i=0;i<K-1;i++){
    vector<ll> tmp(v.size()+2);
    for(int j=0;j<v.size();j++){
      tmp[moveto[j]] += dp[i][j];
      dp[i+1][moveto[j]] += dp[i][j] * dp[0][moveto[j]];
      dp[i+1][moveto[j]] %= MOD;
    }
    for(int j=(ll)v.size()-2;j>=0;j--){
      dp[i+1][j] += tmp[j+1] * dp[0][j];
      tmp[j] += tmp[j+1];
      dp[i+1][j] %= MOD;
    }
  }
  ll ans = 0;
  for(int j=0;j<v.size();j++){
    ans += dp[K-1][j];
    ans %= MOD;
  }
  cout << ans << endl;
  /*for(int i=0;i<K;i++){
    for(int j=0;j<v.size();j++)
      cout << dp[i][j] << " ";
    cout << endl;
  }
  for(auto &&x : moveto)
    cout << x << " ";
    cout << endl;*/
}


Measured memory_bytes: 80112
X = int(input())
i = 0
fain = 0

while i == 0:
    while 500 <= X:
        X -= 500
        fain += 1000
        #print(fain)
    if 5 <= X:
        X -= 5
        fain += 5
    else:
        i += 1

print(fain)

Measured memory_bytes: 2940
///****In the name of ALLAH, most Gracious, most Compassionate****//

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

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

#define ALL(a) a.begin(), a.end()
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

#define DBG(a) cerr<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
#define NL cout<<endl

template < class T1,class T2>
ostream &operator <<(ostream &os,const pair < T1,T2 > &p)
{
    os<<"{"<<p.first<<","<<p.second<<"}";
    return os;
}

const int N=3e5+5;
const int oo=1e9+7;

int32_t main()
{
    FastIO;
    int x;
    cin>>x;
    cout<<!x<<"\n";
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
void swap (int *x, int *y) {
  int temp;    
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }
 
  if(b==0){
    return a;
  }
 
  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }
 
  return b;
}
 
/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}
 
 
int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}
 
int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}
 
int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}
 
void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }
 
  return;
}
 
void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }
 
  return;
}
 

int main(void){
  int n,k;
  scanf("%d%d",&n,&k);
  char s[n+10];
  scanf("%s",s);
  if(65<=s[k-1] && s[k-1]<=90){
    s[k-1]+=32;
    printf("%s\n",s);
  }else{
    printf("%s\n",s);
  }
  return 0;
}

Measured memory_bytes: 1616
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"Draw"<<endl;
    }
    else if(a==1){
        cout<<"Alice"<<endl;
    }
    else if(b==1){
        cout<<"Bob"<<endl;
    }
    else
    {
        if(a>b)cout<<"Alice"<<endl;
        else cout<<"Bob"<<endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
   
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
    
    
    if(n%2 != 0){
      for(int i = n-1; i >= 0; i-=2){
         System.out.print(a[i] + " ");
      }
      for(int i = 1; i < n-1 ; i+=2){
         System.out.print(a[i] + " ");
      }  
      System.out.println();
    }else{
      for(int i = n-1; i >= 1; i-=2){
         System.out.print(a[i] + " ");
      }
       for(int i = 0; i < n-1 ; i+=2){
         System.out.print(a[i] + " ");
      }
      System.out.println();
    }
    
  }  
}

Measured memory_bytes: 61672
N=int(input())
A=list(map(int,input().split()))
B=[]
for k in range(N):
    B.append([A[k],k+1])
B.sort(key=lambda x: x[0], reverse=True)
dp=[[0 for k in range(N+1)]for k in range(N+1)]
dp[1][0]=dp[0][0]+B[0][0]*(B[0][1]-1)
dp[0][1]=dp[0][0]+B[0][0]*(N-B[0][1])
for k in range(1,N):
    #j=0
    dp[0][k+1]=dp[0][k]+B[k][0]*(N-k-B[k][1])
    dp[1][k]=max(dp[0][k]+B[k][0]*(B[k][1]-1), dp[1][k-1]+B[k][0]*(N-k+1-B[k][1]))
    #j=k
    dp[k+1][0]=dp[k][0]+B[k][0]*(B[k][1]-k-1)
    dp[k][1]=max(dp[k-1][+1]+B[k][0]*(B[k][1]-k), dp[k][0]+B[k][0]*(N-B[k][1]))
    for j in range(1,k):
        dp[j+1][k-j]=max(dp[j][k-j]+B[k][0]*(B[k][1]-j-1), dp[j+1][k-j-1]+B[k][0]*(N-k+j+1-B[k][1]))
        dp[j][k-j+1]=max(dp[j-1][k-j+1]+B[k][0]*(B[k][1]-j), dp[j][k-j]+B[k][0]*(N-k+j-B[k][1]))
ans=[]
for k in range(N+1):
    ans.append(dp[k][N-k])
print(max(ans))               

Measured memory_bytes: 107708
(defun app ()
    (let ((n (read))
        (k (read))
        (ans 0))
    (loop while (> n 0) do
        (progn
            (setq n (floor (/ n k)))
            (incf ans)
        )
    )
    (format t "~D~%" ans)
    )
)
(app)


Measured memory_bytes: 24224
N=int(input())
A=list(map(int,input().strip().split(' ')))

dp=[[0]*2 for i in range(len(A))]


dp[0][0]=A[0]
dp[0][1]=A[0]

for i in range(1,len(A)):
    if i!=1:
        dp[i][0]=max(dp[i-1][0]+A[i],dp[i-1][1]+A[i])
        dp[i][1]=max(dp[i-1][0]-2*A[i-1]-A[i],dp[i-1][1]+2*A[i-1]-A[i])  
    else:
        dp[i][0]=A[i-1]+A[i]
        dp[i][1]=-A[i-1]-A[i]              
print(max(dp[-1][0],dp[-1][1]))    

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll a, b, v, w, t;
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;

    if(a<b){
        if(a+(t*v) >= b+(t*w)){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    else{
        if(a-(t*v) <= b-(t*w)){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdbool.h>

#define min(a, b) ((a) < (b) ? (a) : (b))
#define MAX 100

const int INFTY = 100000000;
int cost[MAX][MAX];
int Number;

void Dijkstra();

int main(int argc, char** argv)
{
	int i, j;
	int a, b, k, c;

	scanf("%d", &Number);
	for (i = 0; i < Number; ++i)
	{
		scanf("%d", &b);
		for (a = 0; a < Number; ++a)
			cost[b][a] = INFTY;

		scanf("%d", &k);
		for (j = 0; j < k; ++j)
		{
			scanf("%d %d", &a, &c);
			cost[b][a] = c;
		}
	}

	Dijkstra();
	return 0;
}

void Dijkstra()
{
	int d[MAX];
	bool used[MAX];
	int a, b;
	int i;

	for (i = 0; i < Number; ++i)
	{
		d[i] = INFTY;
		used[i] = false;
	}

	d[0] = 0;
	while (true)
	{
		b = -1;
		int mincost = INFTY;
		for (a = 0; a < Number; ++a)
		{
			if (!used[a] && d[a] < mincost)
			{
				mincost = d[a];
				b = a;
			}
		}

		if (b == -1)
			break;

		used[b] = true;
		for (a = 0; a < Number; ++a)
			d[a] = min(d[a], d[b] + cost[b][a]);
	}

	for (b = 0; b < Number; ++b)
		printf("%d %d\n", b, d[b]);
}



Measured memory_bytes: 1996
//#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<ll, ll>;
const int maxn = 2e4 + 55;
string a, b;
int n, l[maxn], r[maxn], mm[maxn];
vector<pi> t;
int ans = INT_MAX;
int eq(int x) {
	x %= n;
	if(x < 0) x += n;
	return x;
}
void upd(int l, int r, int s, int m) {
	ans = min(ans, m + 2*l + (r<s?s:(2*r-s)));
	s = eq(n-s), swap(l, r);
	ans = min(ans, m + 2*l + (r<s?s:(2*r-s)));
}
void go(int s) {
	memset(mm, 0, sizeof mm);
	int rsh = 0, m = 0;
	for(int i = 0; i < n; i++) {
		if(a[eq(i+s)]!=b[i]) mm[i] = 1, m++;
	}
	for(auto i : t) {
		if(!mm[i.second]) continue;
		upd(i.first, rsh, s, m);
		//cout << i.first << " " << rsh << "\n";
		rsh = max(rsh, r[i.second]);
	}
	upd(0, rsh, s, m);
//	cout << s << " - " << ans << '\n';
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> a >> b;
	n = a.size();
	if(count(all(b), '1')==0) return cout << (count(all(a), '1')==0?0:-1), 0;
	for(int i = 0; i < n; i++) {
		while(b[eq(i-l[i])]=='0') l[i]++;
		while(b[eq(i+r[i])]=='0') r[i]++;
		//cout << l[i] << " " << r[i] << '\n';
		t.pb({l[i], i});
	}
	sort(rall(t));
	for(int i = 0; i < n; i++) go(i);
	cout << ans;
}


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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define mod 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()

int main() {
  string S;
  cin >> S;

  tm tm1;

	sscanf(S.c_str(),"%4d/%2d/%2d", &tm1.tm_year, &tm1.tm_mon, &tm1.tm_mday);

  if(2019 <= tm1.tm_year && 5 <= tm1.tm_mon) {
    cout << "TBD" << endl;
  } else {

    cout << "Heisei" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
#include <utility>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数


template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*///map < string, ll> s;

/*i++ずつずらす
a[0] a[1] a[2]//a[1] a[2] a[3]
a[0] a[2] a[4]//a[1] a[3] a[5]
/*if (N % 2 != 0)a = N / 2;
else a = N / 2 - 1;
for (int i = 1;i <= a;i++) {
	for (int j = 0;j < N - (i * 2);j++) {
		if (S[j] != S[j + i] && S[j + i * 2] != S[j] && S[j + i] != S[j + i * 2]) sum--;
		if (sum == 0)break;
	}
}*/

//mapの使い方
/*map<int, int> mp;
for (int i = 0; i < N; i++)
	mp[a[i]]++;

int ans = 0;
for (auto p : mp) {
	int x = p.first;
	int n = p.second;
	if (n < x) ans += n;
	else ans += n - x;
}*/
//cout << std::fixed << std::setprecision(12) <<<< endl;

int main() {
	unsigned long long N,A,B,ans=0;
	cin>>N>>A>>B;
	if(N<=A)cout<<N<<endl;
	else if(N<=(A+B))cout<<A<<endl;
	else {
		ans+=(N/(A+B)*A);
		if(N%(A+B)>A) ans+=A;
		else ans+=N%(A+B);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
#define MAX_LEN 250     // １行の長さの最大値(少し大きめに取っておく）

int check(char *str1, char *str2){      // str1, str2 はプログラム
// 非文字列定数部分が不一致 or 文字列定数の不一致数が2以上 -> 2 を返す
// それ以外 -> 文字列定数の不一致数(0 or 1)を返す
    char c1, c2;
    int ndcc = 0;       // 文字列定数の不一致数
    while(1){
        // 先頭部分は文字列定数ではない
        while(1){               // 文字が一致している間 " まで繰り返す
            c1 = *str1++; c2 = *str2++;                 // 比較する文字
            if(c1 != c2) return 2;                      // 不一致なのでダメ
            if(c1 == 0 && c2 == 0) return ndcc;         // プログラム終了
            if(c1 == '\"' && c2 == '\"') break;         // 次は文字列定数
        }
        // 文字列定数の処理
        while(1){               // 文字が一致している間 " まで繰り返す
            c1 = *str1++; c2 = *str2++;                 // 比較する文字
            if(c1 == '\"' && c2 == '\"') break;         // 次は非文字列定数
            if(c1 != c2){                               // 不一致
                ndcc++;                                 // 不一致カウンタ増やす
                if(ndcc >= 2) return ndcc;      // 2個以上の不一致文字列はダメ
                while(c1 != '\"') c1 = *str1++; // " までポインタを進める
                while(c2 != '\"') c2 = *str2++; // " までポインタを進める
                break;          // 文字列定数処理終了。次は非文字列処理
            }
        }
    }
    return ndcc;
}
    
int main(){
    char line1[MAX_LEN], line2[MAX_LEN];
    char *nl;
    int result;
    while(1){
        // １行目を入力
        fgets(line1, MAX_LEN, stdin);
        nl = strstr(line1, "\n");
        if(nl != NULL) *nl = 0;         // 改行文字はヌル文字に置き換える
        if(line1[0]=='.' && line1[1]==0) break;         // 入力終了
        // ２行目を入力
        fgets(line2, MAX_LEN, stdin);
        nl = strstr(line2, "\n");
        if(nl != NULL) *nl = 0;         // 改行文字はヌル文字に置き換える
        result = check(line1, line2);
        if(result==0) printf("IDENTICAL\n");
        else if(result==1) printf("CLOSE\n");
        else printf("DIFFERENT\n");
    }
    return 0;
}



Measured memory_bytes: 2124
n = int(input())
h_list = [int(i) for i in input().split()]

k = 0
while any([i > 0 for i in h_list]):
    bool_list = [True if i==max(h_list) else False for i in h_list]
    indexes = []
    true_index = bool_list.index(True)
    while bool_list[true_index]:
        indexes.append(true_index)
        true_index += 1
        if true_index == len(h_list):
            break

    h_list = [h_list[i]-1 if i in indexes else h_list[i] for i in range(len(h_list))]
    k += 1
  
print(k)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
long long n,m;
int main()
{
    scanf("%d%d",&n,&m);
    if(n==1&&m==1){printf("1\n");return 0;}
    if(n>m)swap(n,m);
    if(n==1){printf("%lld\n",m-2);return 0;}
    printf("%lld\n",(n-2)*(m-2));
}

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

using namespace std;

const int N = 3000 + 77 , NN = 300000 + 77 , Mod = 998244353;
int n , k , dp[N][(N << 1)] , A;
int Fact[NN] , InvFact[NN];
inline int Pow(int x , long long y){
	int C = 1;
	while(y){
		if(y & 1)
         C = C * 1ll * x % Mod;
		x = x * 1ll * x % Mod;
		y >>= 1;
	}
	return C;
}
inline int Choice(int x , int y){
	if(x > y || x < 0)
      return 0;
	return Fact[y] * 1ll * InvFact[x] % Mod * 1ll * InvFact[y - x] % Mod;
}
int main() {
   Fact[0] = InvFact[0] = 1;
	for(int i = 1;i < NN;i++)
      Fact[i] = (Fact[i - 1] * 1ll * i) % Mod;
	InvFact[NN - 1] = Pow(Fact[NN - 1] , Mod - 2);
	for(int i = NN - 2;i > 0;-- i)
		InvFact[i] = (InvFact[i + 1] * 1ll * (i + 1)) % Mod;

   dp[0][0] = dp[1][1] = dp[1][2] = 1;

   cin >> n >> k;
   for(int i = 2;i <= n;++ i)
      for(int j = 2;j < (N << 1);++ j)
         dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j - 2]) % Mod;
   for(int i = 0;i <= n;++ i)
      for(int j = 0;j < k;++ j) {
         int ways = dp[i][j];
         ways = ways * 1ll * Choice(i , n) % Mod;
         A = (A + ways) % Mod;
      }
   for(int j = k + 1;j <= (n << 1);j += 2)
      for(int i = 0;i <= n;++ i) {
         if(i * 2 < j)
            continue ;
         int ways = Choice(i , n);
         int need = (j - k + 1) / 2;
         if(need * 2 < i) {
            int s = j - need * 4;
            if(need > j)
               continue ;
            ways = ways * 1ll * dp[i - need * 2][s] % Mod;
         } else if(i * 2 != j) {
            ways = 0;
         }
         A = (A + ways) % Mod;
      }
   printf("%d\n" , A);
   return 0;
}


Measured memory_bytes: 76032
def main():

    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    lack = 0
    excess = []
    ans = 0
    for i in range(N):
        if A[i] < B[i]:
            lack += B[i]-A[i]
            ans += 1
        elif A[i] > B[i]:
            excess.append(A[i]-B[i])
    excess.sort(reverse = True)
    while excess and lack > 0:
        lack -= excess.pop(0)
        ans += 1

    if lack > 0:
        return -1
    else:
        return ans


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 18356
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        int[] h = new int[n];
        for(int i=0;i<n;i++)
        {
            h[i] = scan.nextInt();
        }
        Arrays.sort(h);
        int ans = MinInterval(h,k-1);
        System.out.println(ans);
    }
    
    static int MinInterval(int[] h,int k){
        int smallnum = 1000000010;
        for(int i=0;i+k<h.length;i++)
        {
            smallnum = Math.min(smallnum,h[i+k]-h[i]);
        }
        return smallnum;
    }
}

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

public class Main {

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);
	      String s=sc.next();
	      if(s.charAt(s.length()-1)!='s') {
	      System.out.println(s+"s");}
	      else if(s.charAt(s.length()-1)=='s')
	        System.out.println(s+"es");
	}


static long nCr(int n, int r, 
    int p) 
{ 


if (r == 0) 
return 1; 


int[] fac = new int[n + 1]; 
fac[0] = 1; 

for (int i = 1; i <= n; i++) 
fac[i] = fac[i - 1] * i % p; 

return (fac[n] * modInverse(fac[r], p) 
% p * modInverse(fac[n - r], p) 
% p) 
% p; 
} 
static long modInverse(int n, int p) 
{ 
    return pow(n, p - 2)%mod; 
} 
static long pow(long x,long y) {
  long res=1l;
  while(y!=0) {
    if(y%2==1) {
      res=x*res%mod;
    }
    y/=2;
    x=x*x%mod;
  }
  return res;
} 
}




Measured memory_bytes: 38280
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define PI 3.1415926

#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)

using namespace std;

int main()
{
	double r;
	cin>>r;
	cout<<r*2.0*PI<<endl;
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A[3];
	rep(i, 0, 3)cin >> A[i];
	sort(A, A + 3);

	if (A[0] + A[1] == A[2])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
x = I()
ma = 1
for b in range(1,x+1):
    for p in range(2,x+1):
        if b**p <= x:
            ma = max(ma,b**p)
        else:
            break
print(ma)


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

using namespace std;

int
main(void){
	long long N; cin >> N;
	for(int h = 1; h <= 3500; h++){
		for(int n = 1; n <= 3500; n++){
			long long D = N * h * n;
			long long A = 4 * h * n;
			long long B = N * n;
			long long C = N * h;
			if(A - B - C <= 0) continue;
			if(D%(A - B - C) == 0){
				cout << h << " " << n <<  " " << D/(A - B - C);
				return 0;
			} 
		}
	}
}

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

using namespace std;

string n;

void diff(int i) {
  if(n[i] == '0') {
    n[i] = '9';
    diff(i - 1);
  }
  else {
    n[i]--;
  }
}

int main(void) {
  cin >> n;

  if(n.length() == 1) {
    cout << n << endl;
    return 0;
  }
  for(int i = n.length() - 1; i > 0; i--) {
    if(n[i] != '9') {
      n[i] = '9';
      diff(i - 1);
    }
  }

  int ans = 0;
  for(int i = 0; i < n.length(); i++) {
    ans += n[i] - '0';
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
m = A[0]
A = A[1:]
while True:
  l = len(A)
  A = [A[i]%m for i in range(l) if A[i]%m != 0]
  A.append(m)
  A.sort()
  m = A[0]
  A = A[1:]
  if A == []:
    break
print(m)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20)
#define int long long
#define double long double
const int INF = 1e18, MOD = 1e9 + 7;

int n, a;

signed main() {
    INCANT;
    cin>>n;
    deque<int> q, d;
    for (int i = 0; i < n; i++) {
        cin>>a;
        q.push_back(a);
    }
    sort(q.begin(), q.end());
    d.push_back(q.back()); q.pop_back();
    int turn = 0;
    while (!q.empty()) {
        if (turn % 2) {
            d.push_front(q.back()); q.pop_back();
            if (q.empty()) break;
            d.push_back(q.back()); q.pop_back();
        } else {
            d.push_front(q.front()); q.pop_front();
            if (q.empty()) break;
            d.push_back(q.front()); q.pop_front();
        }
        turn++;
    }
    int res = 0;
    int mn = INF;
    for (int i = 0; i < n - 1; i++) {
        res += abs(d[i + 1] - d[i]);
        mn = min(mn, abs(d[i + 1] - d[i]));
    }
    res += abs(d[0] - d[n - 1]);
    mn = min(mn, abs(d[0] - d[n - 1]));
    cout<<res - mn<<endl;
}

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

int N;
int X[100100], Y[100100], W[100100];
map<int, map<int, int>> foxs;

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

int hoge(int x, int y){
    if(foxs.find(x) != foxs.end()){
        if(foxs[x].find(y) != foxs[y].end()){
            return foxs[x][y];
        }
    }
    return 0;
}

int main(){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> X[i] >> Y[i] >> W[i];
        foxs[X[i]][Y[i]] = W[i];
    }
    
    int ans = 0;
    for(int i=0; i<N; i++){
        int &x = X[i], y = Y[i];
        for(int j=0; j<4; j++){
            int sum = 0;
            for(int k=0; k<4; k++){
                sum += hoge(x + dx[j] - dx[k], y + dy[j] - dy[k]);
            }
            ans = max(ans, sum);
        }
    }
    
    cout << ans << " / 1" << endl;
    
    return 0;
}

Measured memory_bytes: 55804
def solve(N, K):
    if K==0:
        return N*N
    ans = 0
    for b in range(K+1, N+1):
        ans += (N//b) * (b-K) + max(0, (N%b) - (K-1))
    return ans

N, K = map(int, input().split())
print(solve(N, K))

Measured memory_bytes: 3060
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-05 17:17:30
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

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

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, t; cin >> n >> t;
  vector<int> cnt(101010, 0);

  for (int i = 0; i < n; ++i) {
    int l, r; cin >> l >> r;
    ++cnt[l]; --cnt[r];
  }

  for (int i = 0; i < 101010 - 1; ++i) {
    cnt[i + 1] += cnt[i];
  }

  cout << *max_element(all(cnt)) << endl;

  return 0;
}


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

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

#define rep(i, a) for (int i=0; i<(a); i++) 
#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)

#define mp make_pair
#define pb push_back
#define pi 3.141592653589793
//#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define bitcount(a) __builtin_popcount(a) // count set bits
#define all(x) (x).begin(),(x).end()

const ll MOD = 1e9 + 7;
const int inf = 1e9+9;
const long long INF = 1e18+3;

//to debug 
#define dbg(x) cout << "Line " << __LINE__ << " | " #x ": " << (x) << endl

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M)  { return ( mod(a,M ) + mod(b,M ))%M;     }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M;   }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

  
               /* -------------------------------Main Code------------------------------- */



int main() {
	FAST
	int n;cin>>n;
	vector<double> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	//double answer = 0;
	while(a.size() != 1){
		sort(a.rbegin(),a.rend());

		double lst = a[a.size()-1];
		double lst1 = a[a.size()-2];
		
		double nw = (double)(lst+lst1)/2;
		//cout<<lst<<" "<<lst1<<" "<<nw<<endl;
		a.pop_back();
		a.pop_back();
		a.push_back(nw);
	}
	cout<<a[0]<<endl;
 	return 0;
	
}

	

Measured memory_bytes: 256
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = a ; i <= b ; i++)
#define per(i,a,b) for(int i = b ; i >= a ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 1e18;
const int mod = 2010;
const int maxn = 2e5 + 7;

int a[maxn];

bool cmp(int a,int b) {
    return a > b;
}

int main() {
    int n,m;
    while(cin >> n >> m) {
        int ans = 0;
        for(int i = 1 ; i <= n ; i++) {
            cin >> a[i];
            ans += a[i];
        }
        sort(a + 1 , a + n + 1 , cmp);
        for(int i = 1 ;  i <= m ; i++) {
            if(a[i] * m * 4 < ans) {
                ans = -1;
                break;
            }
        }
        if(ans == -1) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef struct pair<int,int> P;
typedef long long ll;
int main() {
	int a,b;
	string s;

	cin>>a>>b>>s;
	bool flg=true;
	int i;
	for(i=0;i<a;++i){
		if(s[i]=='-')flg=false;
	}
	if(s[i]!='-')flg=false;
	for(i=a+1;i<a+b+1;++i){
		if(s[i]=='-')flg=false;
	}
	if(flg){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
//	cout<<48-n<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"


int getans(vector<int>&l, deque<int>&r) {
	if (l.empty() || r.empty())return 0;
	int lt = l.back();
	int rt = r[0];
	int a = l.size() - 1;
	while (a >= 0) {
		if (lt == l[a]) {
			a--;
		}
		else {
			break;
		}
	}
	int b = 0;
	while (b <= r.size() - 1) {
		if (rt == r[b]) {
			b++;
		}
		else {
			break;
		}
	}
	if (lt == rt) {
		int num = (l.size() - 1) - a + b;
		if (num >= 4) {
			int ls = l.size();
			for (int i = a + 1; i < ls; ++i) {
				l.pop_back();
			}
			for (int i = 0; i < b; ++i) {
				r.pop_front();
			}
			return num + getans(l, r);
		}
		else {
			return 0;
		}
	}
	else {
		return 0;
	}
}
int getans(const vector<int>&as, int a) {
	int f = a;
	int t = a;
	int color = as[a];
	while (f >= 0) {
		if (color == as[f])f--;
		else break;
	}
	f++;
	while (t <= as.size() - 1) {
		if (color == as[t])t++;
		else break;
	}
	t--;
	if (t - f >= 3) {
		vector<int>l(as.begin(), as.begin() + f);
		deque<int> r;
		for (int i = t + 1; i < as.size(); ++i) {
			r.push_back(as[i]);
		}
		return (t - f + 1) + getans(l, r);
	}
	else {
		return 0;
	}
}
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<int>as(N);
		for (int i = 0; i < N; ++i) {
			cin >> as[i];
			as[i]--;
		}
		int ans = 0;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < 3; ++j) {
				int a = as[i];
				as[i] = j;
				ans = max(ans, getans(as, i));
				as[i] = a;

			}
		}
		cout << N - ans << endl;
	}

	return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    ll nax = 1e10;
    int n; cin >> n;
    for(int i = 0; i < n; i++) {
        int a, b; cin >> a >> b;
        nax = min((ll)(a + b), nax);
    }
    cout << nax << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}

ll combination(ll n, ll r) {
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}

int main()
{
	int k, s;
	cin >> k >> s;
	int count = 0;
	rep(i, k + 1) {
		rep(j, k + 1) {
			if (s - (i + j) >=0&& s-i-j<=k) {
				count++;
			}
		}
	}
	cout << count << endl;
}


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n)*(n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
  string power_s = "23456789TJQKA";
  map<char, int> power;
  REP(i, power_s.length()) power[power_s[i]] = i;

  char strong;
  while(cin>>strong,strong!='#') {
    vector<tuple<int,int,char,int> > cards[13];

    REP(i, 4){
      REP(j, 13){
        char n, m;
        cin >> n >> m;
        cards[j].push_back(make_tuple((m==strong) ? 2 : 0, power[n], m, i));
      }
    }
    int direction = 3;
    int p[4] = {0};
    REP(j, 13){
      REP(i, 4){
        strong = get<2>(cards[j][direction]);
        if (get<2>(cards[j][i]) == strong) get<0>(cards[j][i]) = 1;
      }
      RSORT(cards[j]);
      direction = get<3>(cards[j][0]);
      p[direction]++;
      // LOG("%d", direction);
    }
    if (p[0] + p[2] > p[1] + p[3]) {
      printf("NS %d\n", (p[0]+p[2])%6);
    }else{
      printf("EW %d\n", (p[1]+p[3])%6);
    }
  }
}

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

#define endl '\n'

const int INF = 1e6 + 5 ;

void solve()
{
	int n ;
  	cin >> n ;
  	
  	int height[n] ;
  	for (int i = 0 ; i < n ; i++) cin >> height[i] ;
  	
  	int dp[n];
  	memset (dp , INF , sizeof(dp)) ;
  	dp[0] = 0 ;
  	for (int i = 0 ; i < n ; i++) 
    {
    	for ( int j : { i + 1 , i + 2 } )
        {
        	if ( j < n )
     	    {  dp[j] = min( dp[j] , dp[i] + abs ( height[i] - height[j] ) ) ; }
        }
    }
  	cout << dp[n - 1] << endl ;
}
int main()
{
    solve() ;
}

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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];

  int ans = n;
  int cur = 1;
  rep(i, n) {
    if (a[i] == cur) {
      --ans;
      ++cur;
    }
  }

  if (ans == n) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int[][] a=new int[3][3];
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        a[i][j]=sc.nextInt();
      }
    }
    int n=sc.nextInt();
    int[] c=new int[n];
    for(int i=0;i<n;i++){
      c[i]=sc.nextInt();
    }
    for(int k=0;k<n;k++){
      for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
          if(a[i][j]==c[k]){
            a[i][j]=0;
          }
        }
      }
    }
          if(a[0][0]==a[0][1] && a[0][1]==a[0][2]){
      System.out.println("Yes");
    }else if(a[1][0]==a[1][1] && a[1][1]==a[1][2]){
      System.out.println("Yes");
    }else if(a[2][0]==a[2][1] && a[2][1]==a[2][2]){
      System.out.println("Yes");
    }else if(a[0][0]==a[1][0] && a[1][0]==a[2][0]){
      System.out.println("Yes");
    }else if(a[0][1]==a[1][1] && a[1][1]==a[2][1]){
      System.out.println("Yes");
    }else if(a[0][2]==a[1][2] && a[1][2]==a[2][2]){
      System.out.println("Yes");
    }else if(a[0][0]==a[1][1] && a[1][1]==a[2][2]){
      System.out.println("Yes");
    }else if(a[0][2]==a[1][1] && a[1][1]==a[2][0]){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;


int main()
{
	LL a, b, c, k;
	cin >> a >> b >> c >> k;

	LL mnak = min(a, k);
	k -= mnak;
	a -= mnak;
	LL sum = mnak;
	
	if (k) {
		LL mnkb = min(b, k);
		k -= mnkb;
		b -= mnkb;
	}
	if (k) {
		LL mnkc = min(k, c);
		k -= mnkc;
		c -= mnkc;
		sum -= mnkc;
	}
	cout << sum << "\n";

}

Measured memory_bytes: 3632
X = int(input())
def hoge(X):
    if ((X%100)%5) > 0:
        if 1+ ((X%100)//5) <= X//100:
            return 1
        else:
            return 0
    else:
        if ((X%100)//5) <= X//100:
            return 1
        else:
            return 0
print(hoge(X))




Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int b,r,g,c,s,t;
    while(scanf("%d%d%d%d%d%d",&b,&r,&g,&c,&s,&t),b,r,g,c,s,t){
        int ans = 0;

        ans += b*65;
        ans += b*15;
        t -= b+b*5;
        ans -= b*3;
        ans += r*39;
        ans += r*15;
        t -= r+r*3;
        ans -= r*3;
        ans += g*7;
        t -= g;
        ans -= g*3;
        ans += c*2;
        t -= c;
        ans -= c*3;
        t -= s;
        ans -= t*3;

        ans += 100;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1188