akhauriyash/Code-Regression huggingface dataset:
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	vector<pair<ll, ll>> v(n);
	rep(i, n)
	{
		ll x, y; cin >> x >> y;
		v[i] = make_pair(x, y);
	}
	sort(all(v));
	ll res = 5e18;
	rep(i, n - k + 1)for (int j = i + k - 1; j < n; ++j)
	{
		ll x = v[j].first - v[i].first;
		vector<ll> z;
		for (int a = i; a <= j; ++a)
		{
			z.push_back(v[a].second);
		}
		sort(all(z));
		ll y = 1e10;
		rep(a, z.size() - k + 1)
		{
			y = min(y, z[a + k - 1] - z[a]);
		}
		res = min(res, x*y);
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n;
    cin >> n;
    cout << 800*n - 200*(n/15) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var k = int.Parse(Console.ReadLine().Trim());
        var s = int.Parse(Console.ReadLine().Trim());
        var k0 = int.Parse(Console.ReadLine().Trim());
        var s0 = int.Parse(Console.ReadLine().Trim());
        int k1;   int s1;
        if (k % k0 == 0) k1 = k / k0;
        else k1 = k / k0 + 1;
        if (s % s0 == 0) s1 = s / s0;
        else s1 = s / s0 + 1;
        Console.WriteLine( n - Math.Max(k1, s1));
    }
}

Measured memory_bytes: 9164
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  std::cout << n/2 + n % 2 << '\n';
  return 0;
}


Measured memory_bytes: 888
/*  ex5_4
    Stuartyg    */
    
#include<stdio.h>

int main(void){
    char str[11], *ptr; //最大10文字
    int len = 0, max_len = 0;

    scanf("%s",str);
    ptr = str;

    while(*ptr != '\0'){ //最後の文字まで
        while (*ptr == 'A' || *ptr == 'C'||*ptr == 'G' || *ptr == 'T'){
            len++; //部分文字列の長さに1たす
            *ptr++; //次の文字を見る
        }
        if(max_len<len){ //前に見つかった部分文字列より長さが長いものが見つかった
            max_len = len;
        }
        len = 0;
        *ptr++; //次の文字へ
    }

    printf("%d\n",max_len);
    return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll h, w, k;
    cin >> h >> w >> k;

    ll coe[w][3] = {};

    rep(i, 1 << (w - 1)) {
        bool temp[w - 1];
        rep(j, w - 1) { temp[j] = i & (1 << j); }
        bool flag = false;
        rep(j, w - 2) {
            if (temp[j] && temp[j + 1]) {
                flag = true;
            }
        }
        if (flag) {
            continue;
        }
        rep(j, w) {
            if (j == 0) {
                if (temp[j]) {
                    coe[j][2]++;
                } else {
                    coe[j][1]++;
                }
            } else if (j == w - 1) {
                if (temp[j - 1]) {
                    coe[j][0]++;
                } else {
                    coe[j][1]++;
                }
            } else {
                if (temp[j - 1]) {
                    coe[j][0]++;
                } else if (temp[j]) {
                    coe[j][2]++;
                } else {
                    coe[j][1]++;
                }
            }
        }
    }

    ll dp[h + 1][w] = {};
    dp[0][0] = 1;

    repd(i, 1, h + 1) {
        rep(j, w) {
            rep(index, 3) {
                if (coe[j][index] == 0) {
                    continue;
                }
                dp[i][j] += coe[j][index] * dp[i - 1][j + index - 1] % mod;
                dp[i][j] %= mod;
            }
        }
    }

    cout << dp[h][k - 1] << endl;

    return 0;
}



Measured memory_bytes: 3596
N, A, B = map(int, input().split())
X = list(map(int, input().split()))

S = 0
for i in range(1, N):
    if A * (X[i] - X[i - 1]) <= B:
        S += A * (X[i] - X[i - 1])
    else:
        S += B
print(S)

Measured memory_bytes: 20064
#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>;
const int MOD=1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(j,k) {
    vector<int> b(n+1);
    rep(i,n) {
      int l=max(0,i-a[i]);
      int r=min(n,i+a[i]+1);
      b[l]++;  b[r]--;
    }
    rep(i,n) b[i+1]+=b[i];
    b.pop_back();
    if(a==b) break;
    a=b;
  }
  rep(i,n) cout << a[i] << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 4828
N, K = map(int, input().split())
A = list(map(int, input().split()))

x = 0
for l in range(N - 1):
  for r in range(l + 1, N):
    if A[l] > A[r]:
      x += 1
# print(x)
      
AA = A + A
y = 0
for l in range(2 * N - 1):
  for r in range(l + 1, 2 * N):
    if AA[l] > AA[r]:
      y += 1
y -= 2 * x
# print(y)
  
print(int((K * x + K * (K - 1) * y // 2) % (10 ** 9 + 7)))


Measured memory_bytes: 3188
def show(A):
    N = len(A)
    for i in range(N):
        if i :
            print(' ', end = '')
        print(A[i], end = '')
    print()

def bubleSort(A, N):
    flag = 1
    exchange = 0
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                exchange += 1
                flag = 1
    show(A)
    print(exchange)

N = int(input())
A = [int(i) for i in input().split()]

bubleSort(A, N)


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

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

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && a!=c) cout<<"Yes"<<endl;
  else if(b==c && a!=c) cout<<"Yes"<<endl;
  else if(a==c && a!=b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int n;
ll a[100001];
ll b[100001];
ll ans=0;
int main(){
    cin>>n;
    for(int i=0;i<n-1;i++)
        cin>>a[i],ans=2*a[i]-ans;
    cin>>a[n-1];
    b[0]=(2*a[n-1]-ans)/2;
    cout<<b[0]<<" ";
    for(int i=1;i<n;i++)
        b[i]=a[i-1]*2-b[i-1],cout<<b[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  while(1){
    getline(cin,s);
    if(s[0]=='.')break;
    stack<char> sta;
    for(int i=0;i<s.size();i++){
      if(s[i]=='(') sta.push('(');
      else if(s[i]=='[') sta.push('[');
      else if(s[i]==')'){
	if(sta.empty()){
	  sta.push('1');
	  break;
	}
	if(sta.top()=='('){
	  sta.pop();
	}
	else break;
      }
      else if(s[i]==']'){
	if(sta.empty()){
	  sta.push('1');
	  break;
	}
	if(sta.top()=='['){
	  sta.pop();
	}
	else break;
      }
    }
    if(sta.empty()){
      cout<<"yes"<<endl;
    }
    else cout<<"no"<<endl;
    
  }

  return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b:i--)

int main() {
    // your code goes here
    ll a,b,c;
    cin >> a >> b >> c;
    if(a==b&&b!=c) cout << "Yes" << endl;
    else if(b==c&&c!=a) cout << "Yes" << endl;
    else if(c==a&&a!=b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
pa = 1000
ans=0
for i in range(N):
  ans += B[A[i]-1]
  if pa == A[i]-1-1:
    ans += C[pa]
  pa = A[i]-1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int main()
{
  while (true)
  {
    int h, w;
    cin >> h >> w;
    if (h == 0 && w == 0)
    {
      break;
    }
    REP(i, h)
    {
      REP(j, w)
      {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
}



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

using namespace std;

#define int long long
int const maxn = 1e5 + 5;
int mod = 1e9 + 7, ans = 1, k;
vector < int > g[maxn];

void dfs(int v, int p, int f) {
    if (f <= 0) {
        cout << 0;
        exit(0);
    }
    ans = ans * f % mod;
    int cnt = k - 1;
    if (p != 0) cnt--;
    for (auto u : g[v]) {
        if (u != p) {
            dfs(u, v, cnt);
            cnt--;
        }
    }
}

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, u, v;
    cin >> n >> k;
    for (int i = 1; i < n; ++i) {
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1, 0, k);
    cout << ans << '\n';
    return 0;
}



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

using int32 = int32_t;
using int64 = int64_t;
int main(void ){
  int64 A, B, C;
  cin >> A >> B >> C;
  int64 res = 0, cnt = 0;
  while (C > 0) {
    cnt++;
    if (cnt > 0 && cnt % 7 == 0) {
      C -= B;
    }
    C -= A;
    res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 3100
import java.io.InputStreamReader;
import java.io.LineNumberReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_C
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));
            
            String inputStr = null;
            double x1 = 0;
            double x2 = 0;
            double y1 = 0;
            double y2 = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {
                
                // ??????????????????????????????.
                if (lineNumReader.getLineNumber() == 1) {
                    String[] points = inputStr.split(" ");
                    x1 = Double.parseDouble(points[0]);
                    y1 = Double.parseDouble(points[1]);
                    x2 = Double.parseDouble(points[2]);
                    y2 = Double.parseDouble(points[3]);
                    
                    // ?????¢????¨????.
                    double dist = Math.sqrt(Math.pow(x1-x2, 2) + Math.pow(y1-y2, 2));
                    
                    // ????????????.
                    System.out.println(String.format("%.8f", dist));
                }
                
                if (lineNumReader.getLineNumber() > 1) {
                    break;
                }
            }
            
            lineNumReader.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
        
    }
    
    public static String shuffle(String original, int h) {
        StringBuilder shuffledStr = new StringBuilder(original);
        String temp = shuffledStr.substring(0, h);
        shuffledStr.delete(0, h);
        shuffledStr.append(temp);
        return shuffledStr.toString();
        
    }
}

Measured memory_bytes: 24536
r,c,n=map(int,input().split())
def po(x,y):
  if y==0:return x
  if x==r:return r+y
  if y==c:return r+c+(r-x)
  if x==0:return r+c+r+(c-y)
q=[]
for i in range(n):
  x1,y1,x2,y2=map(int,input().split())
  if (x1 in [0,r] or y1 in [0,c])and(x2 in [0,r] or y2 in [0,c]):
    q.append((po(x1,y1),i))
    q.append((po(x2,y2),i))
if len(q)==0:exit(print("YES"))
q.sort()
d=[]
for _,i in q:
  if len(d)==0:d.append(i)
  elif d[-1]==i:del d[-1]
  else:d.append(i)
if len(d)==0:print('YES')
else:print('NO')

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++ ) cin >> d.at(i);
  
  sort(d.begin(), d.end());
  
  int ans = d.at(N/2) - d.at(N/2 -1);
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	std::ios::sync_with_stdio(false);
	int t = 1;
	// cin>>t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> arr(n);
		int ctr = 0;
		for (int i = 0; i < n; i++) {
			cin >> arr[i];
			if ((i + 1) & 1 && arr[i] & 1)ctr++;
		}
		cout << ctr;
	}
	return 0;
}

Measured memory_bytes: 3632
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        System.out.println(execute(sc.nextLine()));

    }

    public static int execute(String base) {

        EvenString evenString = new EvenString(base);
        do{
            evenString.cut();
        }while (!evenString.isEvenString());

        return evenString.length();
    }

    public static List<String> splitByLength(String s, int length) {
        List<String> list = new ArrayList<>();
        if (s != null && !s.isEmpty()) {
            Matcher m = Pattern.compile("[\\s\\S]{1," + length + "}").matcher(s);
            while (m.find()) {
                list.add(m.group());
            }
        }
        return list;
    }

    private static class EvenString {
        String base;
        String first;
        String second;
        public EvenString(String base){
            this.split(base);
        }

        private void split(String base){
            this.base = base;
            int length = base.length() / 2;
            List<String> separated = splitByLength(base,length);
            this.first = separated.get(0);
            this.second = separated.get(1);
        }

        public boolean isEvenString(){
            return first.equals(second);
        }

        public int length(){
            return base.length();
        }

        public void cut() {
            String newBase = base.substring(0,base.length()-2);
            this.split(newBase);
        }
    }
}

Measured memory_bytes: 23764
# Contest No.: ABC167
# Problem No.: D
# Solver:      JEMINI
# Date:        20200510

import sys

def main():
    n, k = map(int, sys.stdin.readline().split())
    nums = [None]
    nums += list(map(int, sys.stdin.readline().split()))
    visited = [1]
    visitedSet = set([1])
    temp = nums[1]
    cnt = 0
    while temp not in visitedSet:
        if cnt == k:
            break
        visited.append(temp)
        visitedSet.add(temp)
        temp = nums[temp]
        cnt += 1
    if len(visited) > k:
        print(visited[-1])
        return
    frontCnt = visited.index(temp)
    k -= frontCnt
    cnt = k % (len(visited) - frontCnt)
    print(visited[frontCnt + cnt])
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 117184
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Integer a[] = new Integer[n];
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			
			Arrays.sort(a, Comparator.reverseOrder());
			int Alice = 0;
			int Bob = 0;
			for (int i = 0; i < n; i++) {
				if (i % 2 == 0) {
					Alice += a[i];
				} else {
					Bob += a[i];
				}
			}
			
			System.out.println(Alice - Bob);
		}

	}

}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x;
    cin>>a>>b>>c;
    x=a*c;
    if(x>b)
    {
        cout<<b/a;
    }
    else if(x<=b)
    {
        cout<<c;
    }
    else if(a<b)
    {
        cout<<0;
    }




     return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <cstdlib>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 40);
typedef pair<int, int> P;
const int MOD = 1000000007;

int main() {

	long double h, w;
	cin >> h >> w;

	if (h == 1 || w == 1) {
		cout << 1 << endl;
	
	}
	else {
		cout << (ll)roundl((long double)h*w / 2) << endl;
	}


	return 0;

}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;


int Max(int arr[],int ele){
    int a_max=0;
    for(int i=0;i<ele;i++) 
        a_max = max(a_max,arr[i]);
    return a_max;
}

int main(){
    int count[100]={0};
    int N,M;
    char s[100][20],t[100][20];
    cin >> N;
    for(int i=0;i<N;i++){
        scanf("%s",s[i]);
    }
    cin >> M;
     for(int j=0;j<M;j++){
        scanf("%s",t[j]);
    }
    for(int k=0;k<N;k++){
        for(int l=k;l<N;l++){
            if(!strcmp(s[k],s[l])){
                count[k]++;
            }
        }

    }
    for(int m=0;m<N;m++){
        for (int n=0;n<M;n++){
            if(!strcmp(s[m],t[n])) 
                count[m]--;
        }
    }
    cout << Max(count,N) << endl;
    return 0;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int n, a[51], b[51], trace[51];
ll dp[51][51], E[51];
bool use[51];
int main() {
	scanf("%d", &n);
	for(int i=1; i<=n; i++) scanf("%d", a+i);
	for(int i=1; i<=n; i++) scanf("%d", b+i);
	ll res = 0;
	for(int tt=51; tt>=1; tt--) {
		bool flag = 0;
		for(int i=1; i<=n; i++) {
			for(int j=0; j<=a[i]; j++) {
				if(j < b[i]) dp[i][j] = -1;
				else if(j == b[i]) dp[i][j] = 0;
				else {
					dp[i][j] = -1;
					for(int k=j; k>=1; k--) {
						if(k >= tt && !use[k]) continue;
						if(dp[i][j % k] != -1)
							dp[i][j] = k;
					}
				}
			}
			if(dp[i][a[i]] == -1)  { flag = 1; break; }
		}
		if(flag) {
			if(tt == 51) { puts("-1"); return 0; }
			use[tt] = 1;
			res += 1ll << tt;
		}
	}
	printf("%lld", res);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,a[10];
bool used[10];
int main()
{
	cin>>n>>k;
	for(int i=0;i<10;i++)
		used[i]=true;
	for(int i=0;i<k;i++)
	{
		cin>>a[i];
		used[a[i]]=false;
	}
	for(int i=n;;i++)
	{
		bool flag=true;
		int x=i;
		while(x)
		{
			int tmp=x%10;
			if(!used[tmp])
			{
				flag=false;
				break;
			}
			x/=10;
		}
		if(flag)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define BUFSIZE 1000000

int x,n,m;

char p[BUFSIZE];

int cnt = 0 ;

/*
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
*/
int a;
char s[BUFSIZE];
char t[BUFSIZE];
int main(void){
  scanf("%s",s);
  scanf("%s",t);
  for(int i = 0 ;i < strlen(s);i++){
    if(s[i] != t[i]) cnt++;
  }

/*
  for(int i = 0;i < ;i++){
    scanf("%",);

  }
/*  qsort(a, n, sizeof(int), compare_int);
*/
/*
for(int i = 0;i < ;i++){


}
*/
printf("%d",cnt);
return 0;

}


Measured memory_bytes: 2116
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

void generate(vector<int> vec, vector<vector<int>> &acc, const vector<int> P, const int selected, const int N) {
    if (selected == ((1 << N) - 1)) {
        acc.push_back(vec);
        return;
    }

    for (int i = 0; i < N; i++) {
        if ((selected | (1 << i)) != selected) {
            vec.push_back(P[i]);
            generate(vec, acc, P, selected | (1 << i), N);
            vec.pop_back();
        }
    }
}

int find(const vector<int> &xs, const vector<vector<int>> &acc) {
    for (int i = 0; i < (int) acc.size(); i++) {
        if (xs == acc[i]) {
            return i;
        }
    }

    return -1;
}

int main(void) {
    int N;
    cin >> N;

    vector<int> P(N), Q(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> Q[i];
    }

    vector<int> t;
    for (int i = 0; i < N; i++) {
        t.push_back(i+1);
    }

    vector<vector<int>> acc;
    vector<int> s;
    generate(s, acc, t, 0, N);

    // for (int i = 0; i < (int) acc.size(); i++) {
    //     for (int j = 0; j < N; j++) {
    //         cout << acc[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    int pi = find(P, acc);
    int qi = find(Q, acc);
    assert(pi >= 0 && qi >= 0);

    cout << abs(pi - qi) << endl;

    return 0;
}


Measured memory_bytes: 3384
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
const int maxn=2e5+5;
int h[maxn];
ll a[maxn];
struct node
{
    int l,r;
    ll maxx;
}tree[4*maxn];
void build(int l,int r,int cur)
{
    tree[cur].l=l;
    tree[cur].r=r;
    if(l==r) return;
    int mid=(l+r)>>1;
    build(l,mid,cur<<1);
    build(mid+1,r,cur<<1|1);
    return;
}
void push_up(int cur)
{
    tree[cur].maxx=max(tree[cur<<1].maxx,tree[cur<<1|1].maxx);
    return;
}
void add(int pos,ll val,int cur)
{
    if(tree[cur].l==pos&&tree[cur].r==pos)
    {
        tree[cur].maxx=val;
        return;
    }
    if(tree[cur].l>pos||tree[cur].r<pos)
        return;
    add(pos,val,cur<<1);
    add(pos,val,cur<<1|1);
    push_up(cur);
    return;
}
ll query(int l,int r,int cur)
{
    if(tree[cur].l>=l&&tree[cur].r<=r)
        return tree[cur].maxx;
    if(tree[cur].l>r||tree[cur].r<l)
        return (ll)0;
    return max(query(l,r,cur<<1),query(l,r,cur<<1|1));
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&h[i]);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    build(0,n,1);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        ll cur=query(0,h[i]-1,1)+a[i];
        ans=max(ans,cur);
        add(h[i],cur,1);
    }
    printf("%lld\n",ans);
    return 0;
}


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

long long W, H, x, y;

int main() {
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	cin >> W >> H >> x >> y;
	if(x * 2 == W && y * 2 == H)
		cout << 1.0 * W * H / 2 << ' ' << 1 << endl;
	else
		cout << 1.0 * W * H / 2 << ' ' << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
let () =
  let sa = read_line () in
  let sb = read_line () in
  let sc = read_line () in
  let la = String.length sa in
  let lb = String.length sb in
  let lc = String.length sc in
  let rec iter ia ib ic t =
    match t with
      0 -> if ia = la then "A" else begin
               match sa.[ia] with
                 'a' -> iter (ia+1) ib ic 0
               | 'b' -> iter (ia+1) ib ic 1
               | _ -> iter (ia+1) ib ic 2
             end
    | 1 -> if ib = lb then "B" else begin
               match sb.[ib] with
                 'a' -> iter ia (ib+1) ic 0
               | 'b' -> iter ia (ib+1) ic 1
               | _ -> iter ia (ib+1) ic 2
             end
    | _ -> if ic = lc then "C" else begin
               match sc.[ic] with
                 'a' -> iter ia ib (ic+1) 0
               | 'b' -> iter ia ib (ic+1) 1
               | _ -> iter ia ib (ic+1) 2
             end
  in
  iter 0 0 0 0 |> print_endline


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int a, b, c;
	
	scanf("%d%d%d", &a, &b, &c);
	
	if((a == b + c) || (b == a + c) || (c == a + b)){
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
n=int(input())
v=list(map(int,input().split()))

v_odd=[[i,0] for i in range(10**5+1)]
v_even=[[i,0] for i in range(10**5+1)]

for i in range(n):
    if i%2==0:
        v_even[v[i]][1] +=1
    else:
        v_odd[v[i]][1] +=1

v_even_s=sorted(v_even,key=lambda x:x[1],reverse=True)
v_odd_s=sorted(v_odd,key=lambda x:x[1],reverse=True)

sum1=0
sum2=0

i=0
f=True
ans=0
while f:
    if v_even_s[i][0]!=v_odd_s[i][0]:
        if v_even_s[i][1]>v_odd_s[i][1]:
            v_even_s.pop(i)
            v_odd_s.pop(0)
        else:
            v_even_s.pop(0)
            v_odd_s.pop(i)
        f=False
    else:
        ans+=v_even_s[i][1]
        if ans==n//2:
            v_even_s.pop(0)
            v_odd_s.pop(1)
            f=False
        i+=1

for i in range(n-1):
    sum1+=v_even_s[i][1]
    sum2+=v_odd_s[i][1]
ans=sum1+sum2
print(ans)




Measured memory_bytes: 36716
/*
        ####   ####
     ###    ###    ###
   ###    Bravery    ###
  ###  Determination  ###
   ##  Perseverance   ##
    ##   Integrity   ##
     ##  Patience   ##
      ## Kindness  ##
        ##Justice##
         ##     ##
           ## ##
             #
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
typedef long long ll;
using namespace std;
int n,b[105],a[105];
int main(){
	cin>>n;
	for (int i=1;i<n;i++) cin>>b[i];
	for (int i=1;i<=n;i++)  a[i]=1000000000;
	for (int i=1;i<n;i++){
		a[i]=min(a[i],b[i]);
		a[i+1]=min(a[i+1],b[i]);
	}
	int ans=0;
	for (int i=1;i<=n;i++) ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	void run() {
		Scanner sc = new Scanner(System.in);
		double s = 0;
		double[] x = new double[3];
		double[] y = new double[3];
		String[] str = sc.next().split(",");
		x[0] = Double.parseDouble(str[0]);
		y[0] = Double.parseDouble(str[1]);
		str = sc.next().split(",");
		x[2] = x[1] = Double.parseDouble(str[0]);
		y[2] = y[1] = Double.parseDouble(str[1]);
		
		while(sc.hasNext()) {
			x[1] = x[2];
			y[1] = y[2];
			str = sc.next().split(",");
			x[2] = Double.parseDouble(str[0]);
			y[2] = Double.parseDouble(str[1]);
			s += area( line(x, y) );
		}
		System.out.println(s);
	}
	double[] line(double[] x, double[] y) {
		double[] d = new double[3];
		for(int i=0;i<3;i++) {
			d[i] = sqrt( (x[i]-x[(i+1)%3])*(x[i]-x[(i+1)%3]) + (y[i]-y[(i+1)%3])*(y[i]-y[(i+1)%3]) );
		}
		return d;
	}
	
	double area(double[] d) {
		double len = (d[0] + d[1] + d[2])/2;
		return sqrt( len * (len-d[0]) * (len-d[1]) * (len-d[2]) );
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int a[m];
    for(int i=0; i<m; i++){
        cin >> a[i];
    }
    int left=0,right=0;
    for(int i=0; i<m; i++){
        if(a[i] <= x){
            left++;
        }else{
            right++;
        }
    }
    cout << min(left,right) << endl;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int a = in(), b = in();
  if (a + b == 15)
    cout << "+" << endl;
  else if (a * b == 15)
    cout << "*" << endl;
  else
    cout << "x" << endl;
}


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

using namespace std;

void solve(double A, double B, double H, double M) {
  double m = H * 60 + M;
  double theta = m * (24 - 2) * M_PI / (12 * 60);
  double C = sqrt(pow(A, 2) + pow(B, 2) - 2.0 * A * B * cos(theta));
  cout << fixed << setprecision(10);
  cout << C << endl;
}

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

  double A, B, H, M;
  cin >> A >> B >> H >> M;

  solve(A, B, H, M);

  return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Edge {
    ll a;
    ll b;
    ll c;
};

struct UnionFind {
    UnionFind(int n) {
        rank.assign(n, 0);
        parent.resize(n);
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
    }

    int find(int x) {
        if (x == parent[x])
            return x;
        return parent[x] = find(parent[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    void unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;

        if (rank[x] < rank[y]) {
            parent[x] = y;
        }
        else {
            parent[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }

    vector<int> rank;
    vector<int> parent;
};

int main() {
    ll N, M;
    cin >> N >> M;
    priority_queue<Edge, vector<Edge>, function<bool(Edge, Edge)>> q([](Edge a, Edge b) { return a.c > b.c; });
    REP(i, M) {
        Edge e;
        cin >> e.a >> e.b >> e.c;
        q.push(e);
    }

    UnionFind uf(N);
    ll ans = 0;
    while (!q.empty()) {
        auto t = q.top();
        q.pop();
        if (uf.same(t.a, t.b))
            continue;
        uf.unit(t.a, t.b);
        ans += t.c;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5980
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int A, B, C;
    vi a(3);
    rep(i, 0, 3) cin >> a[i];
    sort(a.begin(), a.end());
    string left = to_string(a[2]) + to_string(a[1]);
    int ans = stoi(left) + a[0];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define max 100005
#define nil -1

vector<vector<int>> g;
int t=0;
vector<int> d,f;
vector<bool> visited;

void dfs(int u){
    visited[u]=true;
    t++;
    d[u]=t;
    for(auto to:g[u]){
        if(!visited[to]){
            dfs(to);
        }
    }
    t++;
    f[u]=t;
}

int main() {
  int  n,u,k,v;
  cin>>n;
    g.resize(n);
    d.resize(n);
    f.resize(n);
    visited.resize(n, false);
  rep(i,n){
      cin>>u>>k;
      u--;
      for(int j=0;j<k;j++){
          cin>>v;
          v--;
          g[u].push_back(v);
        }
    }
    rep(i,n){
        if(!visited[i]){
            dfs(i);
        }
    }
    rep(i,n){
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
  return 0;
}



Measured memory_bytes: 3164
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

int main() {
    int n, m;
    cin >> n >> m;
    ll x[100000];
    rep(i, m)cin >> x[i];
    if (n > m)n = m;
    sort(x, x + m);
    priority_queue<ll> cnt;
    ll ans = 0;
    for (int i = 0; i < m - 1;i++) {
        cnt.push(abs(x[i] - x[i + 1]));
        ans += abs(x[i] - x[i + 1]);
    }
    rep(i, n - 1) {
        ans -= cnt.top();
        cnt.pop();
    }
    cout << ans << endl;
}

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

struct Edge{
    int to;
    string w;
};
using Edges=vector<Edge>;
using Graph=vector<Edges>;
const int SIZE=500;
int n,a,s,g;
int vertex(int v,int length){
    return length*n+v;
}
int solve();
int main(){
    while(cin>>n>>a>>s>>g,n){
        solve();
    }
}
int solve(){

    Graph graph(n*SIZE);
    for(int i=0;i<a;i++){
        int x,y;
        string lab;
        cin>>x>>y>>lab;
        for(int j=0;j+lab.size()<SIZE;j++){
            graph[vertex(x,j)].push_back(Edge{vertex(y,j+lab.size()),lab});
        }
    }
    string INF="";
    for(int i=0;i<100;i++) INF+="z";

    vector<string> d(n*SIZE,INF);
    d[vertex(s,0)]="";
    for(int i=0;i<n*SIZE;i++){
        for(int j=0;j<graph[i].size();j++){
            int to=graph[i][j].to;
            string tow=d[i]+graph[i][j].w;
            d[to]=min(d[to],tow);            
        }
    }
    string res=INF;    
    for(int i=0;i<SIZE;i++){
        if(i<SIZE/2){
            res=min(d[vertex(g,i)],res);
        }  
        else{
            if(res>d[vertex(g,i)]){
                cout<<"NO"<<endl;
                return 0;
            }
        }
    }
    cout<<(res==INF ? "NO" : res)<<endl;
    return 0;
}


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

ll x,y,tmp;

inline ll gcd(ll x,ll y){
	if(y==0)return x;
	return gcd(y,x%y);
}

int main(){

	cin >>x>>y;

	ll g = gcd(x,y);

	for(ll i=2; i<= g / i; i++)
		if(g%i==0)
			{
				tmp++;
				while(g%i == 0) g /= i;
			}

	if(g>1)tmp++;
	cout<<tmp+1<<endl;

	return 0;
}


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


auto solve(std::string S){
    auto bi = begin(S);
    auto ei = end(S);
    auto mi = bi + (S.size() / 2);

    while(bi != mi) {
        mi -= 1;
        ei -= 2;
        if(equal(bi, mi, mi)){
            break;
        }
    }
    return (bi == mi) ? -1 : distance(bi, ei);
}

int main(){
    std::string S;
    std::cin >> S;
    auto result = solve(S);
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
a = readl()
b = readl()
count = 0
for i in range(n):
    for j in range(2):
        t = min(a[i + j], b[i])
        count += t
        a[i + j] -= t
        b[i] -= t
print(count)


Measured memory_bytes: 21024
#include<iostream>
using namespace std;
typedef long long ll;

const ll mod = 998244353;

ll modpow(ll a, ll b, ll p = mod){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

int main(){
    ll m, n, k;
    cin >> m >> n >> k;
    ll ans = modpow(m, n);
    ll sub = 0, mcomb = 1;
    for(int i = 1; i < min(k, m+1); i++){
        ll tmp = 0, comb = 1;
        for(int j = 1; j <= i; j++){
            ll x = (i-j)%2 == 0 ? 1 : -1;
            comb = comb*modpow(j,mod-2)%mod*(i-j+1)%mod;
            tmp += x*(comb*modpow(j,n)%mod);
            tmp = (tmp + mod)%mod;
        }
        mcomb = mcomb*modpow(i,mod-2)%mod*((m-i+1)%mod)%mod;
        tmp = tmp*mcomb%mod;
        sub += tmp;
        sub %= mod;
    }
    cout << (ans-sub+mod)%mod << endl;
    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
                //to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	rapid_pleaseAC_fast;

	string s;
	cin >> s;
	rep(i, s.size() - 1) {
		if (s.substr(i, 2) == "AC") {
			cout << "Yes" << rt;
			return 0;
		}
	}
	cout << "No" << rt;

	please AC;
}
//参考：---

Measured memory_bytes: 256
n = int(input())
c = []
s = []
f = []
for i in range(n-1):
    cc,ss,ff = list(map(int,input().split()))
    c.append(cc)
    s.append(ss)
    f.append(ff)

for i in range(n):
    ans = 0
    for j in range(i, n-1):
        if ans <= s[j]:
            ans = s[j]
        else:
            ans = (ans + f[j] - 1)//f[j]*f[j]
        ans += c[j]
    print(ans)

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

using namespace std;

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template<class T>
void print(vector<T>& V, bool spaced = true) {
    string space;
    spaced ? space = " " : space = "";
    for(int i = 0; i < V.size(); i++) {
        cout<< V[i] << space;
    }cout<< '\n';
}

template<class T>
void printendl(vector<T>& V) {
    for(int i = 0; i < V.size(); i++) {
        cout<< V[i] << '\n';
    }
}

template<class T>
T gcd(T a, T b) {
    T r;
    while (b != 0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

template <class T>
T lcm (T a, T b) {
    return a / gcd(a, b) * b;
}

template<class T>
T Max(T a, T b) {
    return (a < b) ? b : a;
}

template<class T>
T Min(T a, T b) {
    return (a < b) ? a : b;
}

//str

bool isPalindrome(string str){
    
    int length = str.length();
 
    for (int i = 0; i < (length / 2); i++)
        if (str[i] != str[length - 1 - i])
            return false;
 
    return true;    
}

void reverseStr(string& str) 
{ 
    int n = str.length(); 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
}
 

//Read through the messages at the end when you're done

const int INF = 10e9;


int main() {

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

    int n; cin>> n;
    vector<int> v(n);
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) cin>> v[i];
    for(int i = 0; i < n; ++i) {
        for(int j: {i+1, i+2}) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(v[i]-v[j]));
            }
        }
    }

    cout << dp[n-1] << '\n';
    

    
    

    return 0;
}

    //Use long long da5eel rabbak!
    //Dont use endl;
    //DONT SUBMIT IZA UR NOT SURE WALLAHI BTENDAM
    //Dear Amine, just because it worked for the test cases doesnt necessarily mean it is correct.
    //Dear Amine, try it on ur own test cases iza ur not SURE
    //In case u didnt use long long, CHECK FOR POTENTIAL OVERFLOWS
    //DONT FORGET TO MOD EVERYTHING IZA U NEED TO MOD



Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {

	private static final String DORM_SEPARATOR = "####################";
	private static int DORM_COUNT = 4;
	private static int FLOOR_COUNT = 3;
	private static int ROOM_COUNT = 10;

	public static void main(String[] args) {

		int n;
		int b, f, r, v;

		List<int[][]> house = new ArrayList<>();
		for (int i = 1; i <= DORM_COUNT; i++) {
			house.add(new int[FLOOR_COUNT][ROOM_COUNT]);
		}

		Scanner stdIn = new Scanner(System.in);

		n = stdIn.nextInt();

		for (int i = 0; i < n; i++) {
			b = stdIn.nextInt();
			f = stdIn.nextInt();
			r = stdIn.nextInt();
			v = stdIn.nextInt();

			house.get(b-1)[f-1][r-1] += v;

		}

		int count = 0;
		for(int[][] floor : house) {
			for(int i = 0; i < FLOOR_COUNT; i++) {
				for(int j = 0; j < ROOM_COUNT; j++) {
					System.out.print(" " + floor[i][j]);
				}
				System.out.println();
			}
			count++;
			if(count == 4) {
				break;
			}
			System.out.println(DORM_SEPARATOR);
		}
	}

}

Measured memory_bytes: 29436