akhauriyash/Code-Regression huggingface dataset:
N,A,B=map(int,input().split())
#print(N,A,B)

#moji="b"*A+"r"*B
#print(moji)

if A==B==0:
    print(0)
elif A==0:
    print(0)
else:

    if N==(A+B):
        print(A)
    elif N>A+B:
        if N%(A+B)>A:
            print((N//(A+B))*A+A)
        else:
            print((N//(A+B))*A+N%(A+B))
    else:
        if N<A:
            print(N)
        else:
            print(A)

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

const int Maxn = 2005;

int n, m, q;
char B[Maxn][Maxn];
int sq[Maxn][Maxn];
int edH[Maxn][Maxn], edV[Maxn][Maxn];

int main()
{
    scanf("%d %d %d", &n, &m, &q);
    for (int i = 1; i <= n; i++)
        scanf("%s", B[i] + 1);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            if (i + 1 <= n && B[i][j] == '1' && B[i + 1][j] == '1')
                edH[i + 1][j]++;
            if (j + 1 <= m && B[i][j] == '1' && B[i][j + 1] == '1')
                edV[i][j + 1]++;
        }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            sq[i][j] = sq[i - 1][j] + sq[i][j - 1] - sq[i - 1][j - 1] + int(B[i][j] == '1');
            edH[i][j] += edH[i - 1][j] + edH[i][j - 1] - edH[i - 1][j - 1];
            edV[i][j] += edV[i - 1][j] + edV[i][j - 1] - edV[i - 1][j - 1];
        }
    while (q--) {
        int r1, c1, r2, c2; scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
        int V = sq[r2][c2] - sq[r1 - 1][c2] - sq[r2][c1 - 1] + sq[r1 - 1][c1 - 1];
        int E = edH[r2][c2] - edH[r1][c2] - edH[r2][c1 - 1] + edH[r1][c1 - 1] +
                edV[r2][c2] - edV[r1 - 1][c2] - edV[r2][c1] + edV[r1 - 1][c1];
        printf("%d\n", V - E);
    }
    return 0;
}


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

int main(){
	long long N,K;
	cin >> N >> K;
	vector<long long> num(1e5+1,0);
	for(int i=0;i<N;i++){
		int a,b;
		cin >> a >> b;
		num.at(a)+=b;
	}

	long long count=0;
	for(int i=0;i<1e5+1;i++){
		count+=num.at(i);
		if(count>=K){
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <cctype>
using namespace std;
int main(){
  char ch;

  while(1){
    scanf("%c",&ch);
    if(islower(ch))printf("%c",toupper(ch));
    else if(isupper(ch))printf("%c",tolower(ch));
    else printf("%c",ch);

    //??????????????????

    if(ch == '\n')break;
  }
}

Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
#define inf 2123333333

struct hhhh { int x,y; }h[10010];

multiset<int> st;

int a[2010],b[2010],c[4010],L[4010],R[4010],n,tt;
char s[2010],t[2010];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline bool cmp(hhhh x,hhhh y) { return x.x<y.x; }

inline int gao(int x) { if (x%n==0) return n;return x%n; }

int main()
{
	scanf("%s%s",s+1,t+1);
	n=strlen(s+1);
	for (int i=1;i<=n;i++) a[i]=s[i]-'0',b[i]=t[i]-'0';
	bool flag1=true,flag2=true;
	for (int i=1;i<=n;i++)
	{
		if (a[i]) flag1=false;
		if (b[i]) flag2=false;
	}
	if (flag2) { puts(flag1?"0":"-1");return 0; }
	for (int i=1;i<=n;i++) c[i]=c[i+n]=b[i];
	for (int i=1;i<=n*2;i++) L[i]=(c[i])?0:L[i-1]+1;
	for (int i=n*2;i;i--) R[i]=(c[i])?0:R[i+1]+1;
	for (int i=1;i<=n;i++) L[i]=L[i+n];
	int ans=inf;
	for (int hhh=0;hhh<n;hhh++)
	{
		int res=0;tt=0;
		st.clear();
		for (int i=1;i<=n;i++)
		{
			if (a[i]==b[gao(i+hhh)]) continue;
			res++;
			if (R[i]) st.insert(L[i]),h[++tt]=(hhhh){R[i],L[i]};
		}
		sort(h+1,h+tt+1,cmp);
		int rnow=hhh,lnow=(n-hhh)%n,now=1;
		ans=min(ans,res+n+min(lnow,rnow));
		int hh=inf;
		for (int i=0;i<n;i++)
		{
			while (now<=tt&&h[now].x<=i)
			{
				multiset<int>::iterator it=st.find(h[now++].y);
				st.erase(it);
			}
			int l,r=i;
			if (st.empty()) l=0;
			else { multiset<int>::iterator it=st.end();it--;l=*it; }
			if (l<=lnow) hh=min(hh,r*2+lnow);
			else hh=min(hh,r*2+l+(l-lnow));
			if (r<=rnow) hh=min(hh,l*2+rnow);
			else hh=min(hh,l*2+r+(r-rnow));
		}
		ans=min(ans,res+hh);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#define MAXN 25
int n, v[MAXN], c[MAXN];
int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &v[i]);
    for(int i = 1; i <= n; i++) scanf("%d", &c[i]);
    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        if(v[i] > c[i])
            cnt += v[i] - c[i];
    }
    printf("%d\n", cnt);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int k,n,s=0;

int a[100005];
 
 
int cache[100005];
 
 
int dp(int n)
{
    if (n==0)
        return 0;
    if (n<0) 
        return  1e8;
    if (cache[n]!=-1)
        return cache[n];
    else
    {
        cache[n]=abs(a[n]-a[n-1])+dp(n-1);
        for (int j=1;j<k;j++)
            cache[n]=min(cache[n],abs(a[n]-a[n-j-1])+dp(n-j-1));
        return cache[n];
    }
}
 
int main()
    {
        cin>>n>>k;
        for(int i=0;i<n;i++)
            cin>>a[i];
        memset(cache,-1,sizeof(cache));
        
        cout<<dp(n-1)<<endl;
        return 0;
    }

Measured memory_bytes: 5760
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let A = 26;
    let a = 'a' as usize;

    let s: Vec<usize> = read::<String>().chars().map(|c| c as usize).collect();
    let t: Vec<usize> = read::<String>().chars().map(|c| c as usize).collect();
    let sn = s.len();

    let mut nxt = vec![vec![!0; A]; sn];
    let mut tbl = vec![!0; A];

    for i in (0..sn).rev() {
        tbl[s[i] - a] = sn + i;
    }
    for i in (0..sn).rev() {
        for c in 0..A {
            nxt[i][c] = tbl[c];
        }
        tbl[s[i] - a] = i;
    }

    let mut i = 0;
    for (k, c) in t.iter().enumerate() {
        let t;
        if k == 0 {
            t = tbl[c - a];
        } else {
            t = nxt[i % sn][(c - a) as usize];
        }
        if t == !0 {
            println!("-1");
            return;
        }
        i += (t - (i % sn));
    }
    println!("{}", i + 1);
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String[] line = bufferedReader.readLine().split(" ");
        int A = Integer.parseInt(line[0]);
        int B = Integer.parseInt(line[1]);
        System.out.println(A * B);
    }
}


Measured memory_bytes: 32600
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    vector<long long> v;
    long long i,j,k,l,n=0,m=0,x,y;
    cin>>k;
    while(k){
        v.push_back(k%10);
        k/=10;
    }
    while(v.size()!=4)
        v.push_back(0);
        
    reverse(v.begin(),v.end());
    x=v[0]*10+v[1];
    y=v[2]*10+v[3];
    
    
    if(1<=x &&x<=12)
        m=1;
    if(1<=y && y<=12)
        n=1;
    if(n==1&&m==1)
    {
        cout << "AMBIGUOUS" << endl;
        return 0;
    }
    if(n==1)
    {
        cout << "YYMM" << endl;
        return 0;
    }
    if(m==1)
    {
        cout << "MMYY" << endl;
        return 0;
    }
    cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  string a;
  cin>>a;
  for(int i=0;i<2;++i){
    if(a[i]==a[i+1]&&a[i]==a[i+2]){
      cout<<"Yes";
      return 0;
    }
  }
    cout<<"No";
}

Measured memory_bytes: 256
count = int(input())

ls = {}

for i in range(count):
    s = input()
    if s in ls:
        ls[s] += ls[s] + 1
    else:
        ls.setdefault(s, 1)

m = max(ls.values())

ans = [k for k, v in ls.items() if v == m]

print('\n'.join(sorted(ans)))

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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] d = na(n);
		long mod = 998244353L;
		
		if(d[0] > 0) {
			System.out.println(0);
			return;
		}
		if(n == 1) {
			System.out.println(1);
			return;
		}
		
		Arrays.sort(d);	
		
		if(d[1] == 0) {
			System.out.println(0);
			return;
		}

		long result = 1L;		
		int now = 0;
		long pcnt = -1L;
		long cnt = 1L;

		for(int i = 1; i < n; i++) {			
			if(d[i] == now) {
				cnt++;
			} else {
				if(d[i] == now + 1) {					
					if(pcnt > 0) {
						for(int j = 0; j < cnt; j++) {
							result = ((result % mod) * (pcnt % mod)) % mod;
						}											
					}
					now = d[i];
					pcnt = cnt;
					cnt = 1L;					
				} else {
					result = 0L;
					break;
				}
			}
		}

		for(int j = 0; j < cnt; j++) {
			result = ((result % mod) * (pcnt % mod)) % mod;
		}		
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 33684
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
 char s[10];
 scanf("%s", s);
 if(s[0] == s[1] ||s[1] == s[2]||s[2] == s[3])cout<<"Bad"<<endl;
 else cout<<"Good"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using LL = long long;

int main(){
    int n;
    int xi;
    cin >> n;
    vector<int> x;
    for(int i=0; i<n; i++){
        cin >> xi;
        x.push_back(xi);
    }

    int sum;
    int ans = 10000000;
    for(int p=1; p<101; p++){
        sum = 0;
        for(int i=0; i<n; i++){
            sum += (x[i]-p)*(x[i]-p);
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
/******
author :- Mahmoud Tarek.
*******/

#include<bits/stdc++.h>

using namespace std ;

#define rg register
#define dbg(v) cerr << #v << " " << v ;
typedef long long ll ;

int n;
vector<int> a ;
int mem[100002] ;

int solve(int i){
if(i == n) return 0 ;
int & ret = mem[i];
if(~ret) return ret ;
ret = 0 ;
if(i + 1 < n) ret = abs(a[i] - a[i + 1]) + solve(i + 1) ;
if(i + 2 < n) ret = min(ret, abs(a[i] - a[i + 2]) + solve(i + 2)) ;
return ret ;
}

int main() {
//    freopen("in.txt", "r", stdin) ;
     cin >> n ;
     a.resize(n) ;
     for(int i = 0 ; i < n ; i++){
        cin >> a[i] ;
     }

     memset(mem, -1, sizeof mem) ;

     cout << solve(0);
}

/*
  Empty set of troubles.
*/


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>

using namespace std;

#define INF 10000000



int main(){
  int n,m,x;
  int c[13], a[13][13];
  int ans[13];

  cin >> n >> m >> x;
  for(int i = 0; i < n; i++){
    cin >> c[i];
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }

  // for(int i = 0; i < n; i++){
  //   cout << c[i] << ',';
  //   for(int j = 0; j < m; j++){
  //     cout << a[i][j] << ',';
  //   }
  // }
  // cout << endl;

  bool flag = 0;
  int res = INF;
  int money;

  for(int bit = 0; bit < (1 << n); bit++){
    flag = 0;
    money = 0;
    for(int i = 0; i < m; i++) ans[i] = 0;

    for(int i = 0; i < n; i++){
      if(bit&(1<<i)){
        money += c[i];
        for(int j = 0; j < m; j++){
          ans[j] += a[i][j];
        }
      }
    }


    for(int i = 0; i < m; i++){
      // printf("ans[%d] = %d\r\n", i, ans[i]);
      if(ans[i] < x) flag = 1;
    }
    if(!flag) res = min(res, money);
  }

  if(res == INF) res = -1;

  cout << res << endl;


  return 0;
}

Measured memory_bytes: 3508
#include <iostream>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int main(void){
    int N, M;
    long long s=0;
    cin >> N >> M;
    int A[M];
    rep(i, M) cin >> A[i];
    rep(i, M) s = s + A[i];
    if (s > N) cout << -1 << endl;
    else cout << N - s << endl;
    return 0;
}


Measured memory_bytes: 3664
n ,t = gets.split.map(&:to_i)
tn = gets.split.map(&:to_i)
sum = 0
n.times do |i|
  break if i + 1 == n
  sum += tn[i+ 1] - tn[i] < t ? tn[i+ 1] - tn[i] : t
end
sum += t
print sum

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  int r = 0;
  cin >> N;
 
  // ここにプログラムを追記
  rep(i, N) {
    int a, b;
    cin >> a >> b;

    r += b - a + 1;
  }
  cout << r << endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from itertools import accumulate
    S = list(accumulate([0] + A))
    ans = 10**18
    for i in range(1, N):
        snuke = S[i] - S[0]
        arai = S[N] - S[i]
        cur = abs(snuke - arai)
        ans = min(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

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

    int n;
    cin >> n;

    switch(n%10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon";
            break;
        default:
            cout << "bon";
    }

    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#define N 10000
#define inf 1000000
#define BLACK 2
#define WHITE 0
#define GRAY 1
#define nil -1;

int A[N][N];

int main(){
  int n,i,j,a,u,num,way,weight;
  int mincost;
  int d[N],color[N];
  
  scanf("%d",&n);
  for(i=0;i<n;++i){
    for(j=0;j<n;++j)A[i][j] = nil;
    d[i] = inf;
   
    color[i] = WHITE;
  }
    
  for(i=0;i<n;++i){
    scanf("%d%d",&a,&num);

    for(j=0;j<num;++j){
      scanf("%d%d",&way,&weight);
      A[a][way] = weight;
    }
  }
  d[0] = 0;

  while(1){
    mincost = inf;

    for(i=0;i<n;++i){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }

    if(mincost == inf)break;

    color[u] = BLACK;

    for(i=0;i<n;++i){
      if(A[u][i] == -1)continue;

      if(color[i] != BLACK && d[u] + A[u][i] < d[i]){
       
	d[i] = d[u] + A[u][i];
      }
    }
  }

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


  
  return 0;
}



Measured memory_bytes: 2180
#include<stdio.h>
int main(void)
{
	int a,b,c,x,y,z,g,f,r;
	scanf("%d %d %d",&a,&b,&c);
	x=a+b;
	y=a+c;
	z=b+c;
	g=a+b;
	f=a+c;
	r=b+c;
	if(g==c || f==b || r==a){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	n%=10;
	if(n==2||n==4||n==5||n==7||n==9) printf("hon\n");
	else if(n==3) printf("bon\n");
	else printf("pon\n");
}

Measured memory_bytes: 3584
from operator import add,getitem
b2q = {"00":"0","01":"1","10":"2","11":"3"}
while True:
    n = input()
    if n == -1:
        break
    s = format(n,"b")
    if len(s) % 2 == 1:
        s = "0" + s
    print "".join(map(b2q.get,map(add,s[::2],s[1::2])))

Measured memory_bytes: 4360
from itertools import product
n=int(input())
f=[list(map(int,input().split())) for _ in range(n)]
p=[list(map(int,input().split())) for _ in range(n)]
cd=[]

for i in product([0,1],repeat=10):
  if i==(0,0,0,0,0,0,0,0,0,0):continue
  s=0
  for (idx,j) in enumerate(f):
    s+=p[idx][sum(k*l for (k,l) in zip(i,j))]
  cd.extend([s])
print(max(cd))



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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 100179;
int sum(int x) {
    int s = 0;
    while (x > 0) {
        s += x % 10;
        x /= 10;
    }
    return s;
}

int main() {
    ios::sync_with_stdio(false);

    int ans = IINF;
    int n;
    cin >> n;
    for (int a = 1; a < n; ++a) {
        int b = n - a;
        ans = min(ans, sum(a) + sum(b));
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>

#include <cctype>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  long long a,b,c;cin>>a>>b>>c;
	if(4*a*b < (c-a-b)*(c-a-b) && (c-a-b) > 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
*a, = map(int, input().split())

if not 1 in a:
    print(-1)
else:
    p = a.index(1)
    target = 2

    for i in range(p, N):
        if a[i]==target:
            target += 1
    
    print(N-target+1)

Measured memory_bytes: 26268
#include <iostream>

int main() {
  int n = 0, k = 0, x = 0, tot = 0;
  
  std::cin >> n >> k;
  
  for (int i = 0; i < n; i++) {
    std::cin >> x;
    if (x > (k - x)) {
      tot += (k - x);
    } else {
      tot += x;
    }
  }
  
  std::cout << tot * 2 << std::endl;
  
  return 0;
}


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

#define int long long
#define endl "\n"
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);

const int N = 2e5 + 5;

int32_t main()
{
    IOS;
    int n;
    cin >> n;
    
    int i=1;
    while(1){
        if(n*i%360==0)
            break;
        i++;
    }
    cout << i << endl;
}


Measured memory_bytes: 3592
<?php
fscanf(STDIN,"%d",$n);
fscanf(STDIN,"%s",$s);
fscanf(STDIN,"%d",$k);

$S=substr($s,$k-1,1);
$result="";
//echo($S);
for($i = 0; $i < strlen($s); $i++) {

  if($s[$i]==$S){
    $result.=$S;
  }else{
    $result.="*";
  }

}
echo($result);
?>


Measured memory_bytes: 3956
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,w,t,r,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n;
	a = w = t = r = 0;
	for(i=0;i<n;i++) {
		cin >> s;
		if (s == "AC") a++;
		if (s == "WA") w++;
		if (s == "TLE") t++;
		if (s == "RE") r++;
	}

	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

	cout << "AC x " << a << endl;
	cout << "WA x " << w << endl;
	cout << "TLE x " << t << endl;
	cout << "RE x " << r << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  string S;
  int test=0;
  
  for(int i=0; i<N; i++){
  	S = "";
    cin >> S;
    if(S == "Y") test++;
  }
  
  cout << (test>0 ? "Four" : "Three") << endl;
}

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

int main(void){
    string S;
    cin>>S;
    S.erase(S.begin()+S.size()-1);
    int cnt=1;
    while(S.size()>1){
        if(S.size()%2==1){
            S.erase(S.begin()+S.size()-1);
            continue;
        }
        string f=S.substr(0,S.size()/2);
        string s=S.substr(S.size()/2,+S.size()/2);

        if(f==s){
            cout<<S.size()<<endl;
            return 0;
        }
            S.erase(S.begin()+S.size()-1);
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2000)

n = int(input())
lst = []
for _ in range(n - 1):
  lst.append([int(i) for i in input().split()])

def time_cost(i, now, lst):
  if i == n - 1:
    return now
  if now >= lst[i][1]:
    if now % lst[i][2] == 0:
      now += lst[i][0]
    else:
      now += lst[i][0] + lst[i][2] - now % lst[i][2]
  else:
    now = lst[i][1] + lst[i][0]
  return time_cost(i+1, now, lst)

for i in range(n):
  print(time_cost(i, 0, lst))


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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int nax = 2e5 + 100;

vector<int> g[nax];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
//		freopen("input.txt","r",stdin);
	#endif
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	bool can = 0;
	for(int u : g[1]){
		for(int v : g[u]){
			if(v == n)can = 1;
		}
	}
	cout << (can ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
}

Measured memory_bytes: 12016
import bisect

INF = 10 ** 18
A, B, Q = map(int, input().split())
shrine_list = [-INF] + [int(input()) for i in range(A)] + [INF]
temple_list = [-INF] + [int(input()) for i in range(B)] + [INF]
question_list = [int(input()) for i in range(Q)]
for q in question_list:
    b, d = bisect.bisect_right(shrine_list, q), bisect.bisect_right(temple_list, q)
    ans = INF
    for s in [shrine_list[b - 1], shrine_list[b]]:
        for t in [temple_list[d - 1], temple_list[d]]:
            ans = min(abs(q - s) + abs(t - s), abs(q - t) + abs(s - t), ans)
    print(ans)

'''
二分検索
深さ優先検索
幅優先検索
累積和
尺取法
動的計画法
mod
XOR
データ構造
'''


Measured memory_bytes: 16144
#include <bits/stdc++.h>
using namespace std;
const int mod=1000000007;
int main(){
	int n,a;
	__int128 s=0,ss=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		s+=a;
		ss+=a*1LL*a;
	}
	cout<<(int)(((s*s-ss)/2LL)%mod)<<endl;
}

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int N=21,M=(1<<N);
ll dp[N][M];
int n,arr[N][N];

ll fun(int i,int mask){
  if(i!=__builtin_popcount(mask))
    return dp[i][mask]=0;
  if(dp[i][mask]!=-1)
    return dp[i][mask];
  ll ans=0;
  fr(j,0,n){
    if(arr[i][j]==1 && ((mask>>j)&1)==0){
      ans+=fun(i+1,mask^(1<<j));
      ans%=MOD;
    }
  }
  return dp[i][mask]=ans;
}

void solve(){
  cin>>n;
  fr(i,0,n){
    fr(j,0,n){
      cin>>arr[i][j];
    }
  }
  fr(i,0,N){
    fr(j,0,M){
      dp[i][j]=-1;
    }
  }
  fr(j,0,(1<<n))
  dp[n-1][j]=0;
  fr(j,0,n){
    if(arr[n-1][j]==1){
      dp[n-1][((1<<n)-1)^(1<<j)]=1;
    }
  }
  ll ans=0;
  cout<<fun(0,0);
  return;
}

int main()
{
  boost();
  
  int tc=1;
  //cin>>tc;
  while(tc--)
    solve();
  return 0;
}

Measured memory_bytes: 347692
#include <stdio.h>
 
int array[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 
int main(){
  int temp;
  scanf("%d",&temp);
  printf("%d",array[temp-1]);
  return 0;
}

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

void solve(long long A, long long B, long long C)
{
    cout << max(0LL, C - A + B) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (h, w, k) = readLine()!!.split(" ").map { it.toInt() }
    val cake = Array(h){ readLine()!!}

    val ans = Array(h){""}
    var num = 1
    var copy = 0
    repeat(h) { hIdx ->
        var row = ""
        var berry = false

        repeat(w) { wIdx ->
            val c = cake[hIdx][wIdx]
            if (c == '#') {
                if (berry) num++
                berry = true
            }
            row += "$num "
        }

        if (!berry) {
            copy++
        }  else {
            ans[hIdx] = row
            num++

            for (i in hIdx-copy until hIdx) {
                ans[i] = row
            }
            copy = 0
        }
    }

    if (copy > 0) {
        for (i in h-copy until h) {
            ans[i] = ans[h-copy-1]
        }
    }

    ans.forEach { println(it.dropLast(1)) }
}

Measured memory_bytes: 123760
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0]*(10**6)
dp[0] = 0
for i in range(1, n):
    dp[i] = 10**9
    for j in range(1, k+1):
        if i-j >= 0:
            dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))

print(dp[n-1])


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

typedef long long ll;
ll N;
vector<pair<ll, ll>> V;

int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    V.push_back({a, i + 1});
  }
  sort(V.begin(), V.end());
  bool first = true;
  for (auto p : V) {
    cout << (first ? "" : " ") << p.second;
    first = false;
  }
  cout << endl;
}


Measured memory_bytes: 2544
# coding: utf-8
# Your code here!

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

ans = 0
for _ in range(N):
    A = list(map(int,input().split()))
    
    score = 0
    for i in range(M):
        score += A[i]*B[i]
    score += C
    if score > 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    int N,M;
    cin>>N>>M;
    vector <int> s(M),c(M);
    rep(i,0,M)cin>>s[i]>>c[i];

    vector<int> ans(N,-1);

    rep(i,0,M){
        if(ans[s[i]-1] == -1){
            ans[s[i]-1] = c[i];
        }
        else {
            if(ans[s[i]-1] != c[i]){
                cout<<-1;
                return 0;
            }
        }
    }
    if(N==1){
        if(ans[0] != -1)cout<<ans[0];
        else cout<<0;
        return 0;
    }
    rep(i,0,M)if(s[i]==1 && c[i]==0){
        cout<<-1;
        return 0;
    }

    if(ans[0] != -1){
        cout<<ans[0];
    }
    else cout<<1;
    rep(i,1,N){
        if(ans[i] == -1){
            cout<<0;
        }
        else cout<<ans[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define trace(it,mp) for(auto it = (mp).begin(); it != (mp).end(); it++)
#define fr(i,n) for(ll i=0;i<n;i++)
#define mod 1000000000
using namespace std;

// covert number to string to_string(x);
void LCS(string s1,string s2)
{
	// cout << s1 << " " << s2 << endl;
	ll x=s1.length(),y=s2.length();
	ll a[x+1][y+1];

	for(ll i=0;i<=x;i++)
	{
		for(ll j=0;j<=y;j++)
		{
			if(i==0 || j==0)
				a[i][j]=0;
			else if(s1[i-1]==s2[j-1])
				a[i][j]=1+a[i-1][j-1];
			else
				a[i][j]=max(a[i-1][j],a[i][j-1]);
		}
	}

	// for(ll i=0;i<=x;i++)
	// {
	// 	for(ll j=0;j<=y;j++)
	// 		cout << a[i][j] << " ";

	// 	cout << endl;
	// }

	ll i=x,j=y;
	string s="";

	while(i>0 && j>0)
	{
		if(s1[i-1]==s2[j-1])
		{
			s=s1[i-1]+s;
			i--;
			j--;
		}
		else
		{
			if(a[i-1][j]>a[i][j-1])
				i--;
			else
				j--;
		}
	}

	// reverse(ans.begin(),ans.end());

	cout <<s;
}


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

    string s1,s2;

    cin >> s1 >> s2;

    LCS(s1,s2);

    cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
}

Measured memory_bytes: 70656
n = int(input())
a = list(map(int, input().split()))

total = sum(a)
ans = 1000000000000007
x = 0
for i in range(n):
  x += a[i]
  if i + 1 < n:
    ans = min(ans, abs(total - 2 * x))

print(ans)

Measured memory_bytes: 24824
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
	int a,b;
	cin >> a >> b;
	if(a==b)
	{
		cout<<"Draw"<<endl;
	}
	else if((a==1||a>b)&&b!=1)
	{
		cout<<"Alice"<<endl;
	}
	else
	{
		cout<<"Bob"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>
#include <cmath>
#include <algorithm>
#define INF 1e12
using namespace std;
typedef long long ll;
struct P{
	ll x,y,id;
	double dir;
	P(){}
	P(ll xx,ll yy,ll pp){
		x=xx;
		y=yy;
		id=pp;
		dir=atan2((double)yy,(double)xx);
		if(dir<0)dir=M_PI*2.0+dir;
	}
	P operator -(P p2){
		return P(x-p2.x,y-p2.y,id);
	}
	bool operator<(const P& p1)const{
		if(dir==p1.dir){
			if(p1.x==x)return y<p1.y;
			return x<p1.x;
		}else return dir<p1.dir;
	}
};
P p[55];
bool used[55];
P pp[55];
ll n,q;
//dp[????????°][??????-1][??????]
ll dp[41][41][41];
ll poll[41][41][41][41];
ll res[41];
ll resp[41][41];

int main(void){
	scanf("%lld",&n);
	for(ll i=0;i<n;i++){
		ll x,y;
		scanf("%lld %lld",&x,&y);
		p[i]=P(x,y,i+1);
		res[i+1]=INF;
	}
	for(ll turn=0;turn<n-2;turn++){
		ll nec=-1;
		for(ll i=0;i<n;i++){
			if(used[i])continue;
			if(nec==-1)nec=i;
			else if(p[i].y<p[nec].y || (p[i].y==p[nec].y && p[i].x<p[nec].x))nec=i;
		}
		P ch=p[nec];
		ll cnt=0;
		for(ll i=0;i<n;i++){
			if(used[i])continue;
			pp[cnt++]=p[i]-ch;
		}
		sort(pp,pp+n-turn);
		for(ll i=3;i<=cnt;i++){
			for(ll j=0;j<=cnt;j++){
				for(ll k=0;k<=cnt;k++){
					dp[i][j][k]=INF;
				}
			}
		}
		for(ll i=1;i<cnt;i++){
			for(ll j=i+1;j<cnt;j++){
				ll cross=pp[i].x*pp[j].y-pp[j].x*pp[i].y;
				if(cross<0)cross=-cross;
				if(cross>0){
					dp[3][i][j]=cross;
					poll[3][i][j][0]=pp[0].id;
					poll[3][i][j][1]=pp[i].id;
					poll[3][i][j][2]=pp[j].id;
					if(dp[3][i][j]<res[3]){
						res[3]=dp[3][i][j];
						resp[3][0]=pp[0].id;
						resp[3][1]=pp[i].id;
						resp[3][2]=pp[j].id;
					}
				}
			}
		}
		for(ll i=3;i<cnt;i++){
			for(ll j=1;j<cnt;j++){
				for(ll k=j+1;k<cnt;k++){
					for(ll l=k+1;l<cnt;l++){
						ll cross=pp[k].x*pp[l].y-pp[k].y*pp[l].x;
						ll cross2=(pp[j].x-pp[k].x)*(pp[l].y-pp[k].y)-(pp[j].y-pp[k].y)*(pp[l].x-pp[k].x);
						if(cross<0)cross=-cross;
						if(cross2<0 && cross+dp[i][j][k]<dp[i+1][k][l]){
							dp[i+1][k][l]=cross+dp[i][j][k];
							for(int m=0;m<i;m++){
								poll[i+1][k][l][m]=poll[i][j][k][m];
							}
							poll[i+1][k][l][i]=pp[l].id;
							if(dp[i+1][k][l]<res[i+1]){
								res[i+1]=dp[i+1][k][l];
								for(int m=0;m<i+1;m++){
									resp[i+1][m]=poll[i+1][k][l][m];
								}
							}
						}
					}
				}
			}
		}
		used[nec]=true;
	}
	scanf("%d",&q);
	for(ll i=0;i<q;i++){
		ll que;
		scanf("%lld",&que);
		if(res[que]==INF)printf("NA\n");
		else{
			for(ll i=0;i<que;i++){
				printf("%lld%c",resp[que][i],i==que-1?'\n':' ');
			}
		}
	}
	return 0;
}

Measured memory_bytes: 11812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;
ll a[100100];

ll changei(string s) {
	ll res;
	stringstream ss;
	ss << s;
	ss >> res;
	return res;
}

int main() {
	while (cin >> n&&n) {
		ll lb = -INF, ub = INF;
		bool f = 0;
		rep(i, n) {
			string num;
			cin >> num;
			if (num == "x")a[i] = -INF;
			else a[i] = changei(num);
		}
		rep(i, n - 1) {
			if (i % 2 == 0) {
				if (a[i] == -INF) {
					if (a[i + 1] == -INF)f = 1;
					else ub = min(a[i + 1] - 1, ub);
				}
				else {
					if (a[i + 1] == -INF)lb = max(a[i] + 1, lb);
					else {
						if (a[i] >= a[i + 1])f = 1;
					}
				}
			}
			else {
				if (a[i] == -INF) {
					if (a[i + 1] == -INF)f = 1;
					else lb = max(a[i + 1] + 1, lb);
				}
				else {
					if (a[i + 1] == -INF)ub = min(a[i] - 1, ub);
					else {
						if (a[i] <= a[i + 1])f = 1;
					}
				}
			}
		}
		if (lb > ub)f = 1;
		if (f)cout << "none" << endl;
		else {
			if (lb == ub)cout << lb << endl;
			else cout << "ambiguous" << endl;
		}
	}
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int fac[500005], finv[500005], inv[500005];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 500005; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int mod_pow(int x,int y) {
    int res = 1;
    while(y > 0) {
        if(y%2) {
            res = res*x%INF;
        }
        x = x*x%INF;
        y/=2;
    }
    return res;
}
signed main(){
    int N,M;
    cin >> N >> M;
    COMinit();
    // Aのダブらない選び方
    int cnt = COM(M,N);
    cnt *= fac[N];
    cnt %= mod;
    // Bのダブらない選び方
    int res = cnt;
    for(int i = 1; i <= N; i++) {
        //AとBでi個ダブる選び方
        int sum = COM(N,i)*fac[N-i]%mod*COM(M-i,N-i)%mod;
        if(i%2 == 0) res = (res+sum)%mod;
        else res = (res+mod-sum)%mod;
    }
    cnt *= res;
    cnt %= mod;
    cout << cnt << endl;
}


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

int main(){
    int X;
    cin >> X;

    vector<bool> isExp(1010, false);
    isExp.at(1) = true;
    for(int i=2; i<=1000; ++i){
        for(int j=2; pow(i, j)<=1000; ++j){
            isExp.at((int)pow(i, j)) = true;
        }
    }

    for(int i=X; i>0; --i){
        if(isExp.at(i)){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list(input())

def calculate(n,k,r,s,p,trr):
    points = []
    total = 0
    for i in range(n):
        t = trr[i]
        score = 0
        if t == 'r':
            point = "p"
            score = p
        if t == "s":
            point = "r"
            score = r
        if t == "p":
            point = "s"
            score = s

        if i - k >= 0:
            if point == points[i - k]:
                point = ""
                score = 0

        total = total + score

        points.append(point)

    print(total)

calculate(N,K,R,S,P,T)

Measured memory_bytes: 4796
#include <iostream>

using namespace std;
#define rep(i, n) for (int i = 1; i <= n; i++)

int main()
{
	int a;
	string s;

	cin >> a;
	cin >> s;

	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;

	return 0;
}


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

int main(){
    int c[10][10];
    int d[10][10];
    int i, j, a = 0;
    for(i = 1; i < 4; i++){
        for(j = 1; j < 4; j++){
            cin >> c[i][j]; //入れる
        }
    }
    for(i = 1; i < 4; i++){
        c[i][4] = c[i][1]; //右端の操作
    }
    for(i = 1; i < 4; i++){
        for(j = 1; j < 4; j++){
            d[i][j] = c[i][j] - c[i][j+1]; //差をとる
        }
    }
    if(d[1][1] == d[2][1] && d[2][1] == d[3][1] && d[1][2] == d[2][2] && d[2][2] == d[3][2] && d[1][3] == d[2][3] && d[2][3] == d[3][3]){
        a = 1;
    }

    for(i = 1; i < 4; i++){
        c[4][i] = c[1][i];
    }
    for(i = 1; i < 4; i++){
        for(j = 1; j < 4; j++){
            d[i][j] = c[i][j] - c[i+1][j];
        }
    }
    if(d[1][1] == d[1][2] && d[1][2] == d[1][3] && d[2][1] == d[2][2] && d[2][2] == d[2][3] && d[3][1] == d[3][2] && d[3][2] == d[3][3]){
        a = 1;
    }
    if(a == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=105;

struct edge{int to,cap,rev;};

int n,m;
int iter[maxn];
int level[maxn];
vector<edge>G[maxn];

void add_edge(int u,int v,int c) {
	G[u].pb(edge{v,c,int(G[v].size())});
	G[v].pb(edge{u,0,int(G[u].size()-1)});
}

bool bfs(int s,int t) {
	memset(level,0,sizeof(level));
	level[s]=1;
	int qh=0,qt=0,q[maxn];
	q[qt++]=s;
	while (qh<qt) {
		int u=q[qh++];
		for (edge e:G[u]) {
			if (!level[e.to] && e.cap) {
				level[e.to]=level[u]+1;
				if (level[t]) break;
				q[qt++]=e.to;
			}
		}
		if (level[t]) break;
	}
	return level[t];
}

int dfs(int u,int t,int f) {
	if (!f) return 0;
	if (u==t) return f;
	for (int& i=iter[u];i<G[u].size();i++) {
		edge& e=G[u][i];
		if (level[e.to]>level[u] && e.cap) {
			int d=dfs(e.to,t,min(f,e.cap));
			if (d) {
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int dinic(int s,int t) {
	int res=0;
	while (bfs(s,t)) {
		memset(iter,0,sizeof(iter));
		while (int flow=dfs(s,t,INF))
			res+=flow;
	}
	return res;
}

int main() {
	cin>>n>>m;
	for (int i=0;i<m;i++) {
		int u,v,c; cin>>u>>v>>c;
		add_edge(u,v,c);
	}
	cout<<dinic(0,n-1)<<'\n';
}



Measured memory_bytes: 3192
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

k = int(input())
s = input()
if len(s)<=k:
    print(s)
else:
    ans = ""
    for i in range(k):
        ans += s[i]
    ans += "..."
    print(ans)

Measured memory_bytes: 9604
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if((a < c && c < b)||(b < c && c < a)) System.out.println("Yes");
        else System.out.println("No");

    }


}


Measured memory_bytes: 21588
n, m = map(int, input().split())
inf = 10**11
dp = [inf] * (1000 * n + 1)
dp[0] = 0

for i in range(n):
    w, v = map(int, input().split())
    for j in range(1000 * n - v, -1, -1):
        if dp[j] != inf:
            dp[j + v] = min(dp[j + v], dp[j] + w)
ans = 0
for a, b in enumerate(dp):
    if b <= m:
        ans = max(ans, a)
print(ans)


Measured memory_bytes: 42076
class Line:
    def __init__(self, n, points):
        self.n = n
        self.points = points

    def getDesc(self):
        desc1 = self.getDist(self.points[0], self.points[1])
        faceDir = self.getDir(self.points[0], self.points[1])
        for i in range(1, self.n - 1):
            newDir = self.getDir(self.points[i], self.points[i+1])
            desc1 += self.getTurn(faceDir, newDir)
            desc1 += self.getDist(self.points[i], self.points[i+1])
            faceDir = newDir

        desc2 = self.getDist(self.points[-1], self.points[-2])
        faceDir = self.getDir(self.points[-1], self.points[-2])
        for i in range(self.n - 2, 0, -1):
            newDir = self.getDir(self.points[i], self.points[i-1])
            desc2 += self.getTurn(faceDir, newDir)
            desc2 += self.getDist(self.points[i], self.points[i-1])
            faceDir = newDir

        return sorted([desc1, desc2])

    def getTurn(self, origDir, destDir):
        if origDir == 'N':
            if destDir == 'E':
                return '1'
            elif destDir == 'S':
                return '2'
            elif destDir == 'W':
                return '3'
        if origDir == 'E':
            if destDir == 'S':
                return '1'
            elif destDir == 'W':
                return '2'
            elif destDir == 'N':
                return '3'
        if origDir == 'S':
            if destDir == 'W':
                return '1'
            elif destDir == 'N':
                return '2'
            elif destDir == 'E':
                return '3'
        if origDir == 'W':
            if destDir == 'N':
                return '1'
            elif destDir == 'E':
                return '2'
            elif destDir == 'S':
                return '3'
        
    def getDir(self, p1, p2):
        if p1[1] < p2[1]:
            return 'N'
        if p1[0] < p2[0]:
            return 'E'
        if p1[0] > p2[0]:
            return 'W'
        if p1[1] > p2[1]:
            return 'S'

    def getDist(self, p1, p2):
        if p1[0] != p2[0]:
            return str(abs(p1[0] - p2[0]))
        return str(abs(p1[1] - p2[1]))

def getPolyLine():
    n = int(input())
    points = []
    for _ in range(n):
        x, y = list(map(int, input().strip().split()))
        points.append( (x, y) )
    return Line(n, points)

if __name__ == '__main__':
    while True:
        N = int(input())
        if N == 0:
            break

        polyLine = getPolyLine()
        template = polyLine.getDesc()
        P = polyLine.n

        for idx in range(1, N + 1):
            polyLine = getPolyLine()
            desc = polyLine.getDesc()
            if polyLine.n == P and desc[0] == template[0] and desc[1] == template[1]:
                print(idx)

        print("+++++")


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
    int h,w;
    cin>>h>>w;
for (int i = 0; i < h; i++)
{
    string a;
    cin>>a;
    cout<<a<<endl<<a<<endl;
}
}

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

int main()
{
        double x, h, y;
        while ( scanf( "%lf %lf", &x, &h ) && x * h ) {
                y = sqrt( (x/2) * (x/2) + h * h );
                printf( "%.6lf\n", x*x + 4 * x * y / 2 );
        }

        return 0;
}



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

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

    double A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    double ans = 0;
    double bns = 0;

    for(int i = 0; i <= 30; i++) {
        for(int j = 0; j <= 30; j++) {
            if(A * 100 * i + B * 100 * j > F) break;
            for(int k = 0; k <= 1500; k++) {
                double x = F - (A * 100 * i + B * 100 * j + C * k);
                double y = (A * 100 * i + B * 100 * j) * E / 100 - C * k;
                if(x < 0) break;
                if(y < 0) break;
                double z = min(x, y);
                int l = z / D;

                double a = A * 100 * i + B * 100 * j + C * k + D * l;
                double b = C * k + D * l;

                if((ans == 0 && bns == 0) || bns / (ans + bns) < b / (a + b)) {
                    ans = a;
                    bns = b;
                }
            }
        }
    }

    cout << ans << " " << bns << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
   int a,b,c;
    cin >> a >> b >> c;
    bool ans = ((a==b)&&b!=c) || ((b==c)&&c!=a) || ((a==c)&&c!=b);
    cout << (ans? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

a, b = getList()
if b * 2 >= a:
    print(0)
else:
    print(a - 2 * b)
    

Measured memory_bytes: 38384