akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
using namespace std;
const int N=1e6+11,mod=1e9+7;
int n,ans;
int a[N],inv[N];
int main(){
	scanf("%d",&n);
	rep(i,1,n)
		scanf("%d",a+i);
	inv[1]=1;
	rep(i,2,n)
		inv[i]=mod-1ll*mod/i*inv[mod%i]%mod;
	rep(i,2,n)
		inv[i]=(inv[i]+inv[i-1])%mod;
	rep(i,1,n)
		ans=(ans+1ll*(inv[i]+inv[n-i+1]-1)*a[i])%mod;
	rep(i,1,n)
		ans=1ll*ans*i%mod;
	ans=(ans+mod)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
int a,b,k,x,num; 
int main(){
	cin>>a>>b>>k;
	x=min(a,b);
	for(int i=x;i>=1;i--)
	{
		if(a%i==0&&b%i==0) num++;
		if(num==k) {cout<<i;break;}
	}
 	return 0;
}

Measured memory_bytes: 256
r = 1000001
s = int(r**0.5)
p = [1]*r
p[0] = p[1] = 0
for i in range(s):
	if p[i]:
		p[2*i::i] = [0 for j in range(2*i,r,i)]

while 1:
	a,d,n = map(int,raw_input().split())
	if n == 0: break
	c = 0
	for i in range(a,r,d):
		if p[i]: 
			c += 1
		if c == n:
			print i
			break
	

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

template<typename T>
struct BIT {
    int n;
    vector<T> dat;

    BIT(int n=0){
        initialize(n);
    }

    void initialize(int nin){
        n = nin;
        dat.resize(n, 0);
    }

    T sum(int i){
        T s = 0;
        while(i >= 0){
            s += dat[i];
            i = (i & (i+1)) - 1;
        }
        return s;
    }

    T sum_between(int i, int j){
        return sum(j) - sum(i-1);
    }

    void plus(int i, T x){
        while(i < n){
            dat[i] += x;
            i |= i+1;
        }
    }

    // a[0]+...+a[ret] >= x
    int lower_bound(T x){
        if(x <= 0) return -1;
        int ret = -1;
        int k = 1;
        while(2*k <= n) k <<= 1;
        for( ;k>0; k>>=1){
            if(ret+k < n && dat[ret+k] < x){
                x -= dat[ret+k];
                ret += k;
            }
        }
        return ret + 1;
    }
};

int main(){
    int N, P[100000], pos[100001];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> P[i];
        pos[P[i]] = i;
    }
    BIT<int> bit(N);
    int64_t ans = 0;
    for(int i=N; i>0; i--){
        bit.plus(pos[i], 1);
        int s = bit.sum(pos[i]);
        int64_t l2 = bit.lower_bound(s-2);
        int64_t l1 = bit.lower_bound(s-1);
        int64_t r1 = bit.lower_bound(s+1);
        int64_t r2 = bit.lower_bound(s+2);
        ans += i * ((l1-l2)*(r1-pos[i]) + (pos[i]-l1)*(r2-r1));
        
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>

using namespace std;

int dfs(vector<vector<int> > G, int n, bool *visited, int u) {
    bool all_visited = true;
    for (int i = 0; i < n; i++) {
        if (visited[i] == false)
            all_visited = false;
    }

    if (all_visited) {
        return 1;
    }

    int ret = 0;

    for (int i = 0; i < G[u].size(); i++) {
        int v = G[u][i];
        if (visited[v])
            continue;
        
        visited[v] = true;
        ret += dfs(G, n, visited, v);
        visited[v] = false;
    }

    return ret;
}

int main() {
    int n, m;   cin >> n >> m;
    vector<vector<int> > G(n);
    int a, b;   
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    bool *visited = new bool[n];
    for (int i = 0; i < n; i++)
        visited[i] = false;
    visited[0] = true;

    int ans = dfs(G, n, visited, 0);

    cout << ans << endl;

    return 0;
}

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

public class Main {
    static BufferedReader br;
    static PrintWriter out;
    static StringTokenizer st;

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = nextInt();
        int m = nextInt();
        int total = 0;
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = nextInt();
            total += nums[i];
        }

        double halve = (double) total / (4 * m);
        int selected = 0;
        for (int num: nums) if (num >= halve) selected++;
        out.println(selected >= m ? "Yes" : "No");

        out.close();
    }


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

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

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

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

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

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


Measured memory_bytes: 23252
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;


class Main{
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        String str =  in.next();
        char[] ch = str.toCharArray();
        boolean flag = false;

        while (str.length() >0 ){
            if (str.length() == 1) {
                flag =false;
                break;
            }if ("hi".equals(str.substring(0,2))){
                flag = true;
                str = str.substring(2,str.length());
            }else
            {
                flag = false;
                break;
            }
        }
        if (flag)
            System.out.println("Yes");
        else
            System.out.println("No");

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  string s;
  cin >> s;
  map<char,int> mp;
  rep(i,4) mp[s[i]]++;

  for(auto it:mp){
    if(it.S!=2){cout << "No" << endl; return 0;}
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define mp make_pair

int main()
{
    int a,b;
    cin >> a >> b;
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
        cout << "Possible";
    }
    else{
        cout << "Impossible";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    long long i,j,k,a,b,c,x,y,z,n,ans,mn;
	string s;
	cin>>s;
	n=s.length();
	for (i=0;i<n;i++)
	{
		if (s[i]=='S')
		{
			break;
		}
	}
	a=i;
	for (i=n-1;i>0;i--)
	{
		if (s[i]=='T')
		{
			break;
		}
	}
	b=i;
	ans=0;
	x=a+n-b-1;
	for (i=a;i<=b;i++)
	{
		if (s[i]=='S')
		{
			ans++;
		}
		else
		{
			ans--;
		}
		if (ans<0)
		{
			x=x+abs(ans);
			ans=0;
		}
	}
	x+=ans;
	cout<<x<<endl;
}

Measured memory_bytes: 720
import java.util.Scanner;
  
  
public class Main{
    public void solve(){
        Scanner sc = new Scanner(System.in);
       
	   
        int n = sc.nextInt();
         for(int i=0;i<n;i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            int b = sc.nextInt();
            int p = sc.nextInt();
            int kei = x*b +y*p;
              
             if(b>=5 && p>=2){
                 kei= (x*b + y*p)*4/5;
             }else{
                if(b<5){
                b=5;
                }
                if(p<2){
                p=2;
                }
                int wari = (x*b + y*p)*4/5;
                  
                if(kei>wari){
                    kei = wari;
                 }
             }
            System.out.println(kei);
        }
    }
      
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

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

long long lcm(long long x, long long y){
    if(x<y) swap(x,y);
    long long r = x%y , xy = x*y;
    while(r!=0){
        x = y;
        y = r;
        r = x%y;
    }
    return xy / y;
}

int main() {
    long long A,B,C,D;
    cin >> A >> B >> C >> D;
    A--;

    long long L = lcm(C,D);
    long long X = B/C - A/C, Y = B/D - A/D, Z = B/L - A/L;
    cout << (B-A) - (X+Y-Z) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

struct perm {
private:
	int sz;
	vector<ll> p, invp;
public:
	perm(int n) {
		sz = n + 1;
		p.resize(sz), invp.resize(sz);
		p[0] = 1;
		rep1(i, sz - 1) {
			p[i] = p[i - 1] * i%mod;
		}
		invp[sz - 1] = 1;
		ll cop = mod - 2, x = p[sz - 1];
		while (cop) {
			if (cop % 2)invp[sz - 1] = invp[sz - 1] * x%mod;
			cop >>= 1; x = x * x % mod;
		}
		per(i, sz - 1) {
			invp[i] = invp[i + 1] * (i + 1) % mod;
		}
	}
	ll comb(ll x, ll y) {
		if (x < y || y < 0)return 0;
		ll ret = p[x];
		(ret *= invp[y]) %= mod;
		(ret *= invp[x - y]) %= mod;
		return ret;
	}
	ll combP(ll x, ll y) {
		if (x < y || y < 0)return 0;
		return p[x] * invp[x - y] % mod;
	}
};
perm p(1 << 18);

void solve() {
	int n, m; cin >> n >> m; ll k; cin >> k;
	ll ans = 0;
	rep1(i, n - 1) {
		ll num = m *m%mod* (n - i) % mod;
		ll score = num * i%mod*p.comb(n*m - 2, k - 2) % mod;
		(ans += score)%=mod;
	}
	//cout << ans << endl;
	swap(n, m);
	rep1(i, n - 1) {
		ll num = m * m%mod* (n - i) % mod;
		ll score = num * i%mod*p.comb(n*m - 2, k - 2) % mod;
		(ans += score) %= mod;
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 4480
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
  void Solve()
  {
    var N = ToInts()[0];
    var Hn = ToInts();
    int ret = 0;
    int r = 0;
    for (int i=0;i<N-1 ;i++)
    {
      if (Hn[i] - Hn[i + 1] >= 0)
      {
        r++;
        ret = Math.Max(ret, r);
      }
      else
        r = 0;
        
    }
    Console.WriteLine(ret); ;
  }
  static int[] ToInts()
  {
    var ss = Console.ReadLine().Split();
    var ret = new /**/int[ss.Length];
    for (int i=0;i<ss.Length ;i++)
    {
      ret[i] = /**/int.Parse(ss[i]);
    }
    return ret;
  }

  static void Main(string[] args)
  {
    new Program().Solve();
  }
}



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

using namespace std;
using ll = long long;
using ld = long double;

const string ss[] = {"AC", "WA", "TLE", "RE"};
map<string, int> mp;

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

  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }

  for(int i = 0; i < 4; i++) {
    int k = mp[ss[i]];
    cout << ss[i] << " x " << k << '\n'; 
  }

  return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int n,l,sz;
int a,b;
bool canUntie2[100001];
int order[100001];
int main()
{
    cin>>n>>l>>a;
    for(int i = 2;i<=n;i++)
    {
        cin>>b;
        canUntie2[i-1]=((a+b)>=l);
        a=b;
    }

    for(int i = 1;i<=n-1;i++)
    {
        if(canUntie2[i]==1)
        {
            int stop = n;
            for(int j = i+1;j<=n-1;j++)
            {
                if(canUntie2[j]==1)
                {
                    stop=j;
                    break;
                }
            }
            if(stop!=n)
            {
                for(int j = i+1; j<= stop-1; j++)
                {
                    order[++sz]=j;
                }
            }
            else
            {
                for(int j = n-1; j>=i+1; j--)
                    order[++sz]=j;
            }
            i=stop-1;
        }
        else
        {
            bool ok=false;
            for(int j = i; j<=n-1;j++, i++)
            {
                if(canUntie2[j]==1)
                {
                    ok=true;
                    break;
                }
                order[++sz]=j;
            }
            i--;
            if(!ok)
            {
                cout<<"Impossible";
                return 0;
            }
        }
    }
    for(int i = 1;i<=n-1;i++)
    {
        if(canUntie2[i]==1)
            order[++sz]=i;
    }
    if(sz==n-1)
    {
        cout<<"Possible\n";
        for(int i = 1;i<=n-1;i++)
        {
            cout<<order[i]<<'\n';
        }
    }
    return 0;
}


Measured memory_bytes: 1280
N, T = list(map(int, input().split()))
ct = []
for i in range(N):
    c, t = list(map(int, input().split()))
    ct.append([c, t])

ans = 1000000007
for i in range(N):
    if ct[i][1] <= T:
        ans = min(ans, ct[i][0])

print(ans) if ans != 1000000007 else print('TLE')

Measured memory_bytes: 3064
S = input()
T = input()
U = "abcdefghijklmnopqrstuvwxyz"
s = [0 for k in range(26)]
t = [0 for k in range(26)]

for k in range(26):
    s[k] += S.count(U[k])
    t[k] += T.count(U[k])
print("Yes" if sorted(s)==sorted(t) else "No")

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

int main(){
  
  int n;

  cin>>n;

  int ans=0;
  
  for(int i=1;i<=n;i+=2){
    int cnt=0;
    for(int j=1;j<=i;j++){
      if(i%j==0){
	cnt++;
      }
    }

    if(cnt==8){
      ans++;
    }
  }

  cout<<ans<<endl;
  
  return 0;

}


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

int main(){
    char num[100];
    int s,value;
    while(cin >> s && s != -1){
        value = 0;
        if(s == 0){
            cout << "0" << endl;
            continue;
        }
        memset(num,0,sizeof(num));
        while(s !=  0){
            num[value] = (s%4)+'0';
            s /= 4;
            value++;
        }
        for(int i=value-1;i>=0;i--){
            (i == 0)? cout << num[i] << endl : cout << num[i];
        }
    }
}

Measured memory_bytes: 1152
void main() {
    int[] abc = readln.split.to!(int[]);
    int k = readln.chomp.to!int;
    abc.sort!"a > b";
    foreach (i; 0 .. k) {
        abc[0] *= 2;
    }
    abc.sum.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.uni;

Measured memory_bytes: 256
n=int(input())
arr=list(map(int,input().split()))
amax=max(arr)
amin=min(arr)
if amax-amin>=2:
  print('No')
elif amax-amin==0:
  flag=False
  for i in range(n):
    if arr[i]!=n-1:
      break
  else:
    flag=True
  for i in range(n):
    if 2*arr[i]>n:
      break
  else:
    flag=True
  if flag==True:
    print('Yes')
  else:
    print('No')
elif amax-amin==1:
  cnt1=0
  cnt2=0
  for i in range(n):
    if arr[i]==amax-1:
      cnt1+=1
    else:
      cnt2+=1
  if cnt1<amax and 2*(amax-cnt1)<=cnt2:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 14092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

int n,k;
ll v[55];
ll a[105];
ll ans;

ll calc(int l,int r){
  ll ret=0;
  int kk=k-(l+r);
  int nn=0;
  for(int i=0; i<105; i++){
    a[i]=0;
  }
  for(int i=0; i<l; i++){
    ret+=v[i];
    if(v[i]<0){
      a[nn]=v[i]; nn++;
    }
  }
  for(int i=n-1; i>n-1-r; i--){
    ret+=v[i];
    if(v[i]<0){
      a[nn]=v[i]; nn++;
    }
  }
  sort(a,a+nn);
  for(int i=0; i<kk; i++){
    ret+=(-a[i]);
  }
  return ret;
}

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>n>>k;

for(int i=0; i<n; i++){
  cin>>v[i];
}

for(int i=0; i<=n; i++){
  for(int j=0; j<=n; j++){
    if(i+j<=n){
      if(i+j<=k){
        ans=max(ans,calc(i,j));
      }
    }
  }
}

cout<<ans<<endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
using namespace std;



int main(){
  long long N,X;
  cin >> N >> X;

  long long x[N];
  cin >> x[0];
  x[0] = abs(x[0] - X);
  long long result = x[0];
  for(int i=1;i<N;i++){
    cin >> x[i];
    x[i] = abs(x[i] - X);

    long long a = x[i];
    long long b = result;
    long long r = a % b;
    while(r > 0){
      a = b;
      b = r;
      r = a % b;
    }

    result = b;
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 1024
from heapq import heapify, heappush, heappop
from collections import deque
from copy import deepcopy, copy
N = 3
m = {8:{7, 5}, 7:{8, 6, 4}, 6:{7, 3}, 5:{8, 4, 2}, 4:{7, 5, 3, 1}, 3:{6, 4, 0}, 2:{5, 1}, 1:{4, 2, 0}, 0:{3, 1}}
def g(i, j, a):
    if i > j:
        i, j = j, i
    return a[:i] + a[j] + a[i + 1:j] + a[i] + a[j + 1:]
def MAIN():
    MAP = "".join(input().replace(" ", "") for _ in range(N))
    goal = "123456780"
    if MAP == goal:
        print(0)
        return
    start = MAP.find("0")
    dp = [(0, MAP, start)]
    LOG = {MAP}
    while dp:
        cnt, M, yx = heappop(dp)
        cnt += 1
        for nyx in m[yx]:
            CM = g(yx, nyx, M)
            if not CM in LOG:
                if CM == goal:
                    print(cnt)
                    return
                heappush(dp, (cnt, CM, nyx))
                LOG.add(CM)
MAIN()



Measured memory_bytes: 31360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
typedef long long LL;
const LL mod = 1e9 + 7;
const int N = 3e5 + 5;

int n, l, r, x, y;
bool vis[N];
struct node {
	int val, id;
} a[N], b[N];
LL ans;

bool cmp(node a, node b) {
	return a.val < b.val;
}

bool cmp1(node a, node b) {
	return a.val > b.val;
}

int main() {
	cin>>n;
	rep(i, 1, n) {
		cin>>l>>r;
		a[++x] = (node) {r, i};
		b[++y] = (node) {l, i};
	}
	sort(a + 1, a + x + 1, cmp1);
	sort(b + 1, b + y + 1, cmp);
	int cur = 0, p = x, q = y;
	rep(i, 1, n) {
		if(i&1) {
			while(vis[b[y].id] && y) y--; 
			if(!y || cur >= b[y].val) break;
			ans += b[y].val - cur;
			vis[b[y].id] = 1; cur = b[y].val;
		}
		else {
			while(vis[a[x].id] && x) x--;
			if(!x || cur <= a[x].val) break;
			ans += cur - a[x].val;
			vis[a[x].id] = 1; cur = a[x].val;
		}
	}
	ans += abs(cur);
	cur = 0;
	LL res = 0;
	x = p, y = q;
	memset(vis, 0, sizeof(vis));
	rep(i, 1, n) {
		if(!(i&1)) {
			while(vis[b[y].id] && y) y--; 
			if(!y || cur >= b[y].val) break;
			res += b[y].val - cur;
			vis[b[y].id] = 1; cur = b[y].val;
		}
		else {
			while(vis[a[x].id] && x) x--;
			if(!x || cur <= a[x].val) break;
			res += cur - a[x].val;
			vis[a[x].id] = 1; cur = a[x].val;
		}
	}
	res += abs(cur);
	cout<<max(ans, res)<<endl;
}

Measured memory_bytes: 5464
n, d = gets.split.map(&:to_i)
xy = []
n.times do
  xy << gets.split.map(&:to_i)
end
ans = 0
xy.each do |i|
  num = 0
  i.each do |k|
    num+=k**2
  end
  ans+=1 if d>=Math.sqrt(num)
end
puts ans

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

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

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

int main() {
    int a, b, c, d, e, f;
    auto get = [&](int y, int m, int d){
        if(m <= 2) y--, m += 12;
        return 365*y+y/4-y/100+y/400+306*(m+1)/10+d-428;
    };
    while(cin >> a >> b >> c >> d >> e >> f, ~a){
        cout << get(d, e, f) - get(a, b, c) << "\n";
    }
    return 0;
}


Measured memory_bytes: 3084
using System;
using System.Linq;class A
{
static void Main()
{
//////////////////////////////
ulong[]a=Console.ReadLine().Split().Select(ulong.Parse).ToArray();
if(a[0]!=0){ulong s=a[2-1]/a[2];ulong d=(a[0]-1)/a[2];Console.WriteLine(s-d);
}
else{Console.WriteLine((ulong)a[1]/a[2]+1);}
//////////////////////////////
}
}

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

Measured memory_bytes: 584
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;
using U = unordered_map<int,long long>; //mapとの違いはkeyの順番を保持していない

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    map<string,string> m;
    m["Sunny"]="Cloudy";
    m["Cloudy"]="Rainy";
    m["Rainy"]="Sunny";
    
    cin>>s;
    cout<<m[s]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define maxx 100010
#define mp make_pair
typedef pair<int,int> ii;
int dp[maxx][3],peso[maxx][3];
int x;
int main() {
	cin >> x;
	
	for(int i = 0; i < x; i++) cin >> peso[i][0] >> peso[i][1] >> peso[i][2];
	
	dp[0][0] = peso[0][0];
	dp[0][1] = peso[0][1];
	dp[0][2] = peso[0][2];
	
	for(int i = 1; i < x; i++){
		for(int j = 0; j < 3; j++){
			dp[i][j] = max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]) + peso[i][j];
		}
	}
	
	int ans = max(dp[x-1][0],max(dp[x-1][1],dp[x-1][2]));
	
	cout << ans << endl;
	return 0;
}

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

#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

//#define max(a,b) a>b?a:b
//#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }




vector<vector<int> > gr;
int dp[100005];
int n,m;
//int cnt ;
int dfs(int i){
	if(dp[i] != -1) return dp[i];
	int cnt = 0;
	for (int j = 0; j < gr[i].size(); ++j)
	{	int f = gr[i][j];
		//if(vis[f] != true){
			//cnt++;
			cnt =  max(cnt ,  dfs(f) + 1);
		//}
	}
	return dp[i] = cnt;



}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin>>n>>m;
	//vis.assign(n ,false);
	gr.assign( n , vector<int>());
	int a,b;
	for (int i = 0; i < m; ++i)
	{
		cin>>a>>b;
		a--;b--;
		gr[a].push_back(b);
	}
	int ans = 0;
	REP(i,n) dp[i] = -1;
	for (int i = 0; i < n; ++i)
	{	//cnt = 0;
	     //vis.clear();
	     //vis.assign(n , false);

		 ans = max(ans , dfs(i));
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 10952
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <list>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;


char buf[100000+10];
int main(void) {
  list<char> res;
  int nQuery;
  scanf("%s%d", buf, &nQuery);
  int n = strlen(buf);
  REP(i, n) {
    res.push_back(buf[i]);
  }
  bool reversed = false;
  REP(iQuery, nQuery) {
    int t;
    scanf("%d", &t);
    if(t == 1) {
      reversed = !reversed;
    } else {
      int f;
      char ch;
      scanf("%d %c", &f, &ch);
      --f;
      if(!!f == !reversed) {
        res.push_back(ch);
      } else {
        res.push_front(ch);
      }
    }
  }
  if(reversed) {
    reverse(res.begin(), res.end());
  }
  for(char c : res) {
    printf("%c", c);
  }
  puts("");
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;

int main(){
	vl t(2); rep(i,2) cin >> t[i];
	vl a(2); rep(i,2) cin >> a[i];
	vl b(2); rep(i,2) cin >> b[i];
	vl da(2), db(2);
	a[0] = t[0] * a[0];
	b[0] = t[0] * b[0];
	a[1] = t[1] * a[1] + a[0];
	b[1] = t[1] * b[1] + b[0];
	if(a[1] == b[1]){
		cout << "infinity" << endl;
		return 0;
	}
	
	if(a[1] <  b[1]){
		swap(b[0], a[0]);
		swap(b[1], a[1]);
	}
	ll ans = 0; 
	ll p1 = b[0] - a[0];
 	ll p2 = a[1] - b[1];
	if(p1>0){
		ans  = ceil(p1 / (double) p2) * 2 -1;
		if(p1 % p2 == 0) ans ++;	
	}
	
	cout << ans << endl; 
}


Measured memory_bytes: 256
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 

bool pali(string s)
{
    string r;
    r=s;
    reverse(s.begin(),s.end());
    if(s==r)
    return true;
    else
    return false;
    
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    double l;
    cin>>l;
    double r=l/3;
    double s=r;
    double t=l-(r+s);
    double mul=r*s*t;
    cout << fixed << setprecision(12) << mul;
}




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

typedef long long LL;

void fastIO_test(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(void)
{
    LL d, t, s;
    cin >> d >> t >> s;
    float time = d/((float)s);
    if(time<=((float)t))
        cout << "Yes\n";
    else 
        cout << "No\n";
}

int main()
{
    fastIO_test();

    LL t=1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
(defun App (n)
    (let ((x (rem n 10))
        (ans ""))
        (cond 
            ((= x 0) (setq ans "pon"))
            ((= x 1) (setq ans "pon"))
            ((= x 2) (setq ans "hon"))
            ((= x 3) (setq ans "bon"))
            ((= x 4) (setq ans "hon"))
            ((= x 5) (setq ans "hon"))
            ((= x 6) (setq ans "pon"))
            ((= x 7) (setq ans "hon"))
            ((= x 8) (setq ans "pon"))
            ((= x 9) (setq ans "hon"))
        )
    ans)
)
(format t "~(~A~%~)" (App (read)))

Measured memory_bytes: 24312
N = int(input())
a = list(map(int, input().split()))

fix_color = set()
n_any_color = 0
for color in a:

  if color < 400:
    fix_color.add(400)
  elif color < 800:
    fix_color.add(800)
  elif color < 1200:
    fix_color.add(1200)
  elif color < 1600:
    fix_color.add(1600)
  elif color < 2000:
    fix_color.add(2000)
  elif color < 2400:
    fix_color.add(2400)
  elif color < 2800:
    fix_color.add(2800)
  elif color < 3200:
    fix_color.add(3200)
  else:
    n_any_color += 1

n_min = max(1, len(fix_color))
n_max = len(fix_color) + n_any_color
print(n_min, n_max)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include<unordered_map>
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
map<string,int>mp;
int main()
{
    string s;
    int t,sum=0;
    scanf("%d",&t);
    while(t--){
        cin>>s;
        if(!mp[s]){
            mp[s]++;
            sum++;
        }
        
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 18916
//abc098_b.cpp
//Sat May 26 20:47:08 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;

	int ansnum = 0;

	for (int i=1;i<n;i++){
		int count = 0;
		unordered_map<char, int> mp;

		string s1 = s.substr(0,i);
		string s2 = s.substr(i,n-i);
		for (int j=0;j<i;j++){
			char x = s[j];
			if ((int)s2.find(x)>=0){
				auto itr = mp.find(x);
				if (itr != mp.end()){
				}else{
					count++;
				}
				mp[x] = 1;
			}
		}
		if (ansnum < count){
			ansnum = count;
		}
	}

	cout << ansnum << endl;
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

l = S_LIST()
print("A" + l[1][0] +  "C")
# if l[1] == "Beginner":
#     print("ABC")
# else:
#     print("ASC")

Measured memory_bytes: 5156
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vpll path;
//***********//
int main() { 
	cin >> N;
	vl A(N);
	vl L(100001);
	for (i = 0; i < N; i++) {
		cin >> A[i];
		L[A[i]]++;
		ans += A[i];
	}
	cin >> Q;
	for (i = 0; i < Q; i++) {
		ll b, c;
		cin >> b >> c;
		ans += L[b] * (c - b);
		L[c] += L[b]; L[b] = 0;
		cout << ans << endl;
	}
}

Measured memory_bytes: 4740
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, K: int, A: "List[int]"):
    m = min(A)
    m1 = A.index(m)
    ans = -(-m1 // (K - 1))
    c = ans * (K - 1) + 1
    while c < N:
        while A[c] == m:
            c += 1
        c += K - 1
        ans += 1
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14452
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int gcd(int x, int y){
	int r=x%y;
	while(r){
		x=y;
		y=r;
		r=x%y;
	}
	return y;
}

int main(){
	int n, x;
	cin >> n >> x;
	int d;
	for(int i=0; i<n; i++){
		int a;
		cin >> a;
		if(!i)
			d=abs(a-x);
		else
			d=gcd(abs(a-x), d);
	}
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <unordered_set>
#include <set>

#define prev asasddlsa
#define rank aljds

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, v;
    cin >> a >> v;
    cout << max(a - 2 * v, 0) << endl;
    return 0;
}

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

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

int main(void){
    string s;
    cin >> s;
    bool f = true;
    for(int i = 1; i < s.size(); i++){
        if(s.at(i) == s.at(i-1)) f = false;
    }
    if(f) cout << "Good" << endl;
    else cout << "Bad" << endl;
    return 0;
}


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

using namespace std;

int main(void) {
    int N, Q;
    string S;
    cin >> N >> S >> Q;

    vector< set<int> > vst(26);
    for(int i=0; i<N; i++) {
        vst[S[i] - 'a'].insert(i);
    }

    while(Q--) {
        int q;
        cin >> q;
        if(q == 1) {
            int i;
            char c;
            cin >> i >> c;
            --i;
            vst[S[i] - 'a'].erase(i);
            S[i] = c;
            vst[S[i] - 'a'].insert(i);
        } else if(q == 2) {
            int l, r;
            cin >> l >> r;
            --l; --r;
            int ans = 0;
            for(int i=0; i<26; i++) {
                if(vst[i].upper_bound(r) != vst[i].lower_bound(l)){
                    ++ans;
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}


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

#define f first
#define s second
#define p pair<int,int>
#define P pair<ll,ll>
#define pb push_back
#define ll long long
#define db double
#define zero(a) memset(a,0,sizeof(a))
#define inff(a,n) fill(a,a+n+1,inf)
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define read(x) scanf("%lld",&x)
#define read2(x,y) scanf("%lld%lld",&x,&y)
#define write(x) printf("%lld\n",x)

const int maxn=2e6+10;
const ll inf=1e9;

ll n,m,ans,sum,num,a[maxn],b[maxn],vis[maxn];
string s,t,s1,s2;

int main()
{
    read(n);
    for(int i=1;i<=n;i++)
    {
        read(a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        if(i==a[i])
        {
            if(i==1)swap(a[i],a[i+1]);
            else if(i==n)swap(a[n],a[n-1]);
            else
            {
                if(a[i+1]!=i)swap(a[i+1],a[i]);
                else if(a[i-1]!=i)swap(a[i],a[i-1]);
            }
            ans++;
        }
    }
    write(ans);
    return 0;
}

Measured memory_bytes: 2304
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
typedef int TInt;
typedef std::vector<TInt> TList;
TList Input()
{
    int Count;
    std::cin >> Count;
    TList List(Count);
    for(int i = 0; i < Count; ++i){
        std::cin >> List[i];
    }
    return List;
}
int main()
{
    TList Values = Input();
    assert(Values.size() >= 2);
    TInt Profit = Values[1] - Values[0];
    TInt Min = std::min(Values[1], Values[0]);
    for(std::size_t i = 2; i < Values.size(); ++i){
        TInt V = Values[i];
        TInt P = V - Min;
        if(P > Profit){
            Profit = P;
        }
        if(V < Min){
            Min = V;
        }
    }
    std::cout << Profit << std::endl;
    return 0;
}

Measured memory_bytes: 1796
from itertools import permutations

n = int(input())
na = [i for i in range(1, n+1)]
nb = [i for i in range(1, n+1)]
x = [int(i) for i in input().strip().split(' ')]
y = [int(i) for i in input().strip().split(' ')]

a = list(permutations(na)).index(tuple(x))
b = list(permutations(nb)).index(tuple(y))

print(abs(a-b))




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

int main() {
  int n;
  cin >> n;
  vector<ll> h(n);
  rep(i,n) cin >> h.at(i);
  bool ans = true;
  for(int i = n-2; i >= 0; i--) {
    int a = h.at(i) - h.at(i+1);
    if(a <= 0) continue;
    if(a == 1) h.at(i)--;
    if(a >= 2) {
      ans = false;
      break;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0; 
}

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

NumberOfRotations = int(n/(a+b))
surplus = n%(a+b)

ans = 0

if NumberOfRotations == 0:
    if a > n:
        print(surplus)
        exit()
    else:
        print(a)
        exit()

ans = a*NumberOfRotations
if a > n - ((a+b)*NumberOfRotations):
    print(ans+surplus)
else:
    print(ans+a)

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A > B) {
    cout << 2 * A - 1 << endl;
  } else if (B > A){
    cout << 2 * B - 1 << endl;
  } else {
    cout << A + B << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C(I) cout<<(I)<<endl
ll n,m;


int main(){
    cin>>n>>m;
    cout<<(n+m)%24<<endl;
}

Measured memory_bytes: 256
<?php
list($n, $m) = ints();
$w[] = 0;
$v[] = 0;
for($i = 0; $i < $n; $i++)list($w[], $v[]) = ints();
$mv = array_sum($v)+1;
$dp = array_fill(0,$n+1,array_fill(0, $mv, 10**10));
$dp[0][0] = 0;
for($i = 1; $i <= $n; $i++){
    $vi = $v[$i];
    $wi = $w[$i];
    $dp0 = $dp[$i-1];
    $dp1 = &$dp[$i];
    for($j = 0; $j < $mv; $j++){
        $dp1[$j] = $dp0[$j];
        if($j-$v[$i] >= 0)chmin($dp1[$j], $dp0[$j-$vi] + $wi);
    }
}
$max = 0;
for($j = 0; $j < $mv; $j++){
    if($dp[$n][$j] <= $m){
        chmax($max, $j);
    }
}
echo $max;


function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 651768
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 100100
//#define NIL -1

int main() {
    LL n;
    LL ans=0;
    cin >> n;
    ans=ans+(n/11)*2;
    n=n%11;
    if(n>0){
        if(n<=6){
            ans++;
        }else{
            ans+=2;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  double r, S, l, pi;
  cin >> r ;
  pi = 3.141592653589;
  S = pi * r * r;
  l = 2 * pi * r;
  cout << setprecision(20)<< S << " " << l << endl;

  return 0;
}


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

int main(){
    int n; cin >> n;
    vector<int> A(n), B(n), C(n-1);
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int i = 0; i < n; i++) cin >> B[i];
    for (int i = 0; i < n - 1; i++) cin >> C[i];

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += B[A[i] - 1];
        if (i > 0) { if (A[i] - A[i - 1] == 1) ans += C[A[i - 1] - 1]; }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

const int MA = 100050;
Int sm[4 * MA];

void init(int x, int L, int R) {
  sm[x] = INFLL;
  if (R - L == 1) return;
  init(2 * x + 0, L, (L + R) / 2);
  init(2 * x + 1, (L + R) / 2, R);
}

void update(int x, int L, int R, int l, int r, Int v) {
  if (L == l && R == r) {
    chmin(sm[x], v);
    return;
  }
  const int M = (L + R) / 2;
  if (l < M) update(2 * x + 0, L, M, l, min(r, M), v);
  if (r > M) update(2 * x + 1, M, R, max(l, M), r, v);
}

Int query(int x, int L, int R, int k) {
  if (R - L == 1 && L == k) {
    return sm[x];
  }
  const int M = (L + R) / 2;
  if (k < M) return min(sm[x], query(2 * x + 0, L, M, k));
  else       return min(sm[x], query(2 * x + 1, M, R, k));
}

int N, M;
vector<int> RS[100050], CS[100050];

int main() {
  N = in();
  M = in();
  init(1, 0, N);
  update(1, 0, N, 0, 1, 0);

  for (int i = 0; i < M; ++i) {
    int l = in() - 1;
    int r = in() - 1;
    int c = in();
    RS[l].push_back(r);
    CS[l].push_back(c);
  }

  for (int i = 0; i < N; ++i) {
    const Int b = query(1, 0, N, i);
    for (int j = 0; j < (int)RS[i].size(); ++j) {
      const int r = RS[i][j], c = CS[i][j];
      update(1, 0, N, i, r + 1, b + c);
    }
  }

  const Int res = query(1, 0, N, N - 1);
  if (res == INFLL) {
    puts("-1");
  } else {
    printf("%lld\n", res);
  }

  return 0;
}


Measured memory_bytes: 13056
#include<stdio.h>

int main(void){
  int h , w;
  scanf("%d %d",&h ,&w);

  int c[11][11];
  for(int i = 0;i < 10;i ++){
    for(int j  = 0;j < 10;j ++){
      scanf("%d",&c[i][j]);
    }
  }

  int a[h][w];
  for(int i = 0;i < h;i ++){
    for(int j = 0;j < w;j ++){
      scanf("%d",&a[i][j]);
    }
  }


  int flag = 1;
  while(flag == 1){
    flag = 0;
    for(int i = 0;i < 10;i ++){
      for(int j = 0;j < 10;j ++){
        for(int k = 0;k < 10;k ++){
          if(c[i][j] > c[i][k] + c[k][j]){
            c[i][j] = c[i][k] + c[k][j];
            flag = 1;
          }
        }
      }
    }
  }

    int ans = 0;
    for(int i = 0;i < h;i ++){
      for(int j = 0;j < w;j ++){
        if(a[i][j] != -1){
          ans += c[a[i][j]][1];
        }
      }
    }

    printf("%d\n",ans);

    return 0;

}

Measured memory_bytes: 1848