akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,ans,x;
inline void read(ll &x)
{
	ll f;char c;
	for (f=1,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for (x=0;c<='9'&&c>='0';c=getchar()) x=x*10+(c&15);x*=f;
}
inline ll gcd(ll a,ll b)
{
	if(b==0) return a;
	else return gcd(b,a%b);
}
inline ll lcm(ll a,ll b)
{
	return 1ll*a/gcd(a,b)*b;
}
int main()
{
	read(n);
	read(ans);n--;
	while(n--)
	{
		read(x);
		ans=lcm(ans,x);
	} 
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 384
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 1110031;

int n,ar[N],S[N];

long long cnt[N],le[N],opn[N],cls[N];

long long zero_solver(){
	long long res=0;
	int C=0;
	for (int i=1;i<=n;i++){
		if (S[i]==0)
			C++;
	}
	if (S[n])
		return 0;
	res=1;
	--C;
	for (int i=1;i<=C;i++){
		res=res*2%bs;
	}
	return res;
}

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    cin>>n;
    for (int i=1;i<=n;i++){
    	cin>>ar[i];
    	S[i]=(S[i-1]^ar[i]);
    	cnt[i]=cnt[i-1]+(S[i]==0);
    }

    for(int i=1;i<=n;i++){
    	int here=S[i];

    	int prv=le[here];
    	if (prv!=0){
    		cls[here]+=opn[here]*(cnt[i]-cnt[prv]);
    		cls[here]%=bs;

    		opn[here]+=cls[here];
    	}

    	le[here]=i;

    	// new one
    	opn[here]+=1;

    	opn[here]%=bs;
    	cls[here]%=bs;
    }

    /*for (int i=1;i<=100;i++){
    	if (opn[i]!=0||cls[i]!=0){
    		cout<<i<<" "<<opn[i]<<" "<<cls[i]<<endl;
    	}
    }*/

    long long ans=zero_solver();
    //cout<<ans<<endl;
	if (S[n]==0)
		for (int i=1;i<N;i++){
				ans=ans+opn[i];
			ans%=bs;
		}

    if (S[n]!=0)
    	ans=(cls[S[n]]+1)%bs;
    ans%=bs;

    cout<<ans<<endl;

//    cin.get(); cin.get();
    return 0;
}


Measured memory_bytes: 39168
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = False
show_flg = True

p = None
XY = None
N = None


def primes(n):
    is_prime = [1] * (n + 1)
    is_prime[0] = 0
    is_prime[1] = 0
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = 0
    return is_prime


def main():
    X = I()
    a = primes(10**5+1000)

    for i in range(0, 10**5+1000+1):
        if i >= X and a[i] == 1:
            print(i)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 67180
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var min = 100000000;

            for(var x=0; x<S.Length - 2 ; ++x)
            {
                var num = int.Parse(S[x].ToString()) * 100 + int.Parse(S[x + 1].ToString()) * 10 + int.Parse(S[x + 2].ToString());
                var dis = Math.Abs(753 - num);
                min = Math.Min(min, dis);
            }
            Console.WriteLine(min);
        }
        
    }
}


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

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  int gcd = B;
  if(B>A){
    int tmp = A;
    A = B;
    B = tmp;
  }
  vector<int> cnt;
  if(A%B == 0){
    cnt.push_back(B);
  }
  for(int i=B/2;i>0;i--){
    if(A%i == 0 && B%i == 0){
      cnt.push_back(i);
    }
  }
  cout << cnt[K-1] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static void solve(InputReader in, PrintWriter out) {
      int x = in.nextInt();
      int n = in.nextInt();
      int[] p = new int[n];
      HashSet<Integer> s = new HashSet();
      for (int i = 0; i < n; i++) {
         p[i] = in.nextInt();
         s.add(p[i]);
      }
      for (int dist = 0; ; dist++) {
         if (!s.contains(x - dist)) {
            out.println(x - dist);
            return;
         }
         if (!s.contains(x + dist)) {
            out.println(x + dist);
            return;
         }
      }
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

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

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

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

      public double nextDouble() {
         return Double.parseDouble(nextToken());
      }
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


Measured memory_bytes: 33064
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),sa,sb,sc,to="a";
bool fl;
struct edge{int to,cost;};
ll inda,indb,indc;

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>sa>>sb>>sc;
    while(1){
        if(to=="a"){
            if(inda==Size(sa)){
                Cout("A");
                return 0;
            }
            to=sa[inda++];
        }
        else if(to=="b"){
            if(indb==Size(sb)){
                Cout("B");
                return 0;
            }
            to=sb[indb++];
        }
        else{
            if(indc==Size(sc)){
                Cout("C");
                return 0;
            }
            to=sc[indc++];
        }
    }
    return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize ("Ofast")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll> 
#define vll vector<ll>
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e5+11,mod=998244353;
inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
ll tree[4*MAXN];
ll qfst(int l,int r)
{
    ll res=0;
    for(l+=n,r+=n;l<r;l>>=1,r>>=1)
    {
        if(l&1) res+=tree[l++];
        if(r&1) res+=tree[--r];
    }
    return res%mod;
}
void modify(int p, ll value) 
{ 
for (tree[p +=n] = value; p > 1; p >>= 1)
tree[p >> 1] = tree[p]+tree[p ^ 1];
}
void sol(void)
{
cin>>n>>k;
vector<pll> vp(k);
for(int i=0;i<k;i++)
cin>>vp[i].F>>vp[i].S;
sort(all(vp));
modify(n-1,1);
for(int i=n-2;i>=0;i--)
{
 ll calc=0;
 for(auto x:vp)
 {
     calc+=qfst(min(i+x.F,n),min(i+x.S+1,n));
     calc%=mod;
 }
 modify(i,calc);
}
cout<<qfst(0,1);
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    sol();
}


Measured memory_bytes: 6728
//こういう問題苦手…。和が同じグループを沢山作って異なるグループ間に辺を張ればOK。
//nが偶数なら自明で、nが奇数なら最大値だけ残して端からグループを作ってほげ。
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> P;

int n;
vector<int> g[60];
vector<P> ans;

signed main() {
	int i, j, k, l;
	int cnt = 0;
	
	cin >> n;
	
	if (n % 2 == 1) {
		g[cnt++].push_back(n);
		n--;
	}
	for (i = 1; i < n - i + 1; i++) {
		g[cnt].push_back(i);
		g[cnt].push_back(n - i + 1);
		cnt++;
	}
	
	for (i = 0; i < cnt; i++) {
		for (j = i + 1; j < cnt; j++) {
			for (k = 0; k < g[i].size(); k++)
				for (l = 0; l < g[j].size(); l++)
					ans.push_back(P(g[i][k], g[j][l]));
		}
	}
	
	int su[101] = {0};
	cout << ans.size() << endl;
	for (i = 0; i < ans.size(); i++) {
		cout << ans[i].first << " " << ans[i].second << endl;
		su[ans[i].first] += ans[i].second;
		su[ans[i].second] += ans[i].first;
	}
	
	//for (i = 1; i <= n; i++) cout << "su[" << i << "] = " << su[i] << endl;
	return 0;
}

Measured memory_bytes: 384
import itertools
n = int(input())
l = []
l.extend(list(itertools.product([3,5,7], repeat=i)) for i in range(3,10))
l = [int("".join(map(str,j))) for i in l for j in i if 7 in j and 5 in j and 3 in j]
print(sum([1 for i in l if n>=i]))

Measured memory_bytes: 7896
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N, M;
    cin >> N >> M;
    int k[M], s[M][N], p[M];
    rep(i,M) {
        cin >> k[i];
        rep(j,k[i]) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    rep(i,M) cin >> p[i];

    int count = 0;

    rep(i,1<<N) {
        int check = 0;
        rep(j,M) {
            int switches = 0;
            rep(l,k[j]) {
                if (i&(1<<s[j][l])) switches++;
            }
            if (switches % 2 == p[j]) check++;
        }
        if (check == M) count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define N 300009
#define inf 1e18
int mod=1e9+7;
int maxN=1e9;

#define PI 3.141596535

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r;cin>>r;
    cout.precision(10);
    cout<<fixed;
    double ans=2.0*PI*r;
    
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3816
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
import java.lang.Math.*


val MOD = 1_000_000_007L
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }

//val rd = debug.Reader("abc", "171", "d", "sample-1")
val rd = Reader()


fun solveD(N: Int, K: Long, A:Array<Int>): Int {
    var step = Array<Long>(N){-1}
    fun dfs(x: Int, sp:Long): Pair<Int, Long> {
        if (sp>=K) {
            return Pair(x, -1L);
        }

        if (step[x] >= 0L) {
            return Pair(x,sp)
        }

        step[x] = sp
        return dfs(A[x], sp + 1L)
    }

    var pos = dfs(0, 0L)
    if (pos.second < 0L) {
        return pos.first + 1;
    }

    val move = (K - step[pos.first]) % (pos.second - step[pos.first])

    fun dfs2(n: Long, x: Int): Int {
        if (n >= move) {
            return x
        }
        return dfs2(n + 1L, A[x])
    }

    return dfs2(0L, pos.first) + 1
}


fun main() {
    val (n,K) = rd.readListLong()
    val N = n.toInt()
    val a = rd.readListInt()
    var A = Array<Int>(N){0}
    for(i in 0 until N) {
        A[i] = a[i] - 1
    }

    val ans = solveD(N, K, A)

    println(ans)
}



class Main : Runnable {
    override fun run() { main() }
}
fun main(args: Array<String>) {
    Thread(null, Main(), "mainThread", 128 * 1024 * 1024).start()
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


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

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

class Sol{
	public void Solve(){
		var ca = S.ToCharArray();
		Array.Reverse(ca);
		int N= ca.Length;
		for(int i=0;i<N;i++) {
			if(ca[i] == 'd')ca[i] = 'b';
			else if(ca[i] == 'b')ca[i] = 'd';
			else if(ca[i] == 'p')ca[i] = 'q';
			else if(ca[i] == 'q')ca[i] = 'p';
		}
		var ns = new String(ca);
		Console.WriteLine(ns == S ?"Yes":"No");
		
	}
	String S;
	public Sol(){
		S = rs();
	}

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


Measured memory_bytes: 3416
N = int(input())
W = [input() for _ in range(N)]

if len(W) != len(set(W)):
    print("No")
    exit()

now = W[0][-1]
flag = True
for i in range(1, N):
    if now == W[i][0]:
        now = W[i][-1]
    else:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
using System;
using System.Globalization;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        var N = Scan();
        var K = ScanInt();
        var digits = N.Length;
        var dp = new long[digits + 1, 2, K + 1];
        dp[0, 0, 0] = 1;
        for (int d = 0; d < digits; d++) {
            var cur = N[d] - '0';
            for (int s = 0; s <= 1; s++) {
                for (int c = 0; c <= K; c++) {
                    var m = c == K ? 0 : s == 1 ? 9 : cur;
                    for (int n = 0; n <= m; n++) {
                        var isSmall = s == 1 || n < cur ? 1 : 0;
                        var count = c == K ? K : n != 0 ? c + 1 : c;
                        dp[d + 1, isSmall, count] += dp[d, s, c];
                    }
                }
            }
        }
        Console.WriteLine(dp[digits, 0, K] + dp[digits, 1, K]);
    }
}

public static class Scanner
{
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;

    private static byte ConsoleIn() {
        var stream = Console.OpenStandardInput();
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stream.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    private static char Char() {
        var let = ConsoleIn();
        while ((let < '!' || '~' < let) && !isEof) let = ConsoleIn();
        return (char) let;
    }
    public static string Scan() {
        var sb = new StringBuilder();
        for (var let = Char(); '!' <= let && let <= '~'; let = (char) ConsoleIn()) {
            sb.Append(let);
        }
        return sb.ToString();
    }
    public static int ScanInt() {
        var temp = 0;
        for (var let = Char(); '0' <= let && let <= '9'; let = (char) ConsoleIn()) {
            temp = temp * 10 + let - '0';
        }
        return temp;
    }
}

Measured memory_bytes: 23808
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)
using namespace std;

ll count (string s) {
    ll cnt = 0, d = 0;
    REP (i, s.size()) {
        if (s[i] == 'D') {
            d += i - cnt;
            cnt++;
        }
    }
    return d;
}

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

    string s;
    cin >> s;

    string t = "";

    REP (i, s.size()) {
        if (s[i] == 'B' && (i+1 < s.size() && s[i+1] == 'C')) {
            t += 'D';
            i++;
        }
        else t += s[i];
    }

    // cout << t << endl;

    ll start = 0;
    ll end = 0;
    ll ans = 0;
    while (start < t.size()) {
        if (t[start] == 'A') {
            end = start;
            while (end < t.size()) {
                if (t[end] == 'B' || t[end] == 'C') break;
                end++;
            }
            // cout << "start:" << start << " end:" << end << "\n";
            string u = t.substr(start, end - start);
            // cout << u << "\n";
            ans += count(u);
            start = end;
        }
        start++;
    }

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

Measured memory_bytes: 1044
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_map>

using namespace std;

const double pi=4*atan(1.0);

int mod=1000000007;

int main() {
	int N,W;
	cin>>N>>W;
	vector<pair<int,int>> items(N);
	for(auto& val:items)
		cin>>val.first>>val.second;

	vector<vector<int>> dp(W+1,vector<int>(N,-1));
	for(int i=0;i<N;++i)
		dp[0][i]=0;

	for(int i=0;i<W+1;++i){
		dp[i][0]=(i/items[0].second)*items[0].first;
	}

	for(int i=1;i<N;++i){
		for(int j=0;j<min(items[i].second,W+1);++j){
			dp[j][i]=dp[j][i-1];
		}
		for(int j=items[i].second;j<W+1;++j){
			dp[j][i]=max(dp[j][i-1],dp[j-items[i].second][i]+items[i].first);
		}
	}

	cout<<dp[W][N-1]<<endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 7128
#include <stdio.h>

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

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
const int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, int b, int _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll ans = 0;
  ans = n / (a + b) * a;
  n -= n / (a + b) * (a + b);
  ans += min(n, a);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)

int main() {
    int x;
    cin >> x;
    for (int i = 0; ; i++) {
        x -= i;
        if (x <= 0) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void calc(int weight) {
        ArrayList<Integer> arr = new ArrayList<Integer>();
        int count=0;
        int balanceWeight = 512;

        while (weight != 0) {
            if (weight >= balanceWeight) {
                weight -= balanceWeight;
                arr.add(balanceWeight);
                count++;
            }
            balanceWeight /= 2;
        }
        for (int i = count - 1; i >= 0; i--) {
            System.out.print(arr.get(i));
            if (i != 0) System.out.print(" ");
            else System.out.println();
        }
        arr.clear();
    }

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        while (in.hasNextInt()) {
            calc(in.nextInt());
        }
    }
}



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

using namespace std;

ifstream fin("jocul.in");
ofstream fout("jocul.out");

long long n,g;
long long v[105],w[105];
long long dp[10000005];

int main(){
    long long i,sum=0,answer=-1;

    cin>>n>>g;

    for(i=1;i<=n;i++)
        cin>>w[i]>>v[i];

    dp[0]=0;

    for(i=1;i<=n;i++){
        sum+=w[i];
        for(int j=sum;j>=w[i];j--)
            if(dp[j-w[i]]!=-1)
                dp[j]=max(dp[j],v[i]+dp[j-w[i]]);
    }

    for(i=0;i<=sum;i++){
        if(dp[i]>answer && i<=g)
            answer=dp[i];
    }

    cout<<answer;

    return 0;
}


Measured memory_bytes: 39168
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node{
  int key;
  struct Node *next;
  struct Node *prev;
};

struct Node *nil;

struct Node* listSearch(int key){
  
  struct Node *cur = nil->next;
  while (cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init() {
  
  nil = (struct Node *)malloc(sizeof(struct Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  
  struct Node *cur = nil->next;
  int isf = 0;
  
  while(1){
    if(cur == nil) break;
    if(isf++ > 0) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(struct Node *x){
  
  if(x == nil) return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
  free(x);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  struct Node *x = (struct Node *)malloc(sizeof(struct Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main() {

  int i;
  int n;
  int key;
  int np = 0;
  int nd = 0;
  int size = 0;
  char com[20];
  
  scanf("%d", &n);
  init();

  for(i=0; i<n; i++){
    scanf("%s", com);
    if(com[0] == 'i'){
      scanf("%d", &key);
      insert(key);
      np++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
	if(com[6] == 'L') deleteLast();
	else if(com[6] == 'F') deleteFirst();
      }
      else{
	 scanf("%d", &key);
	deleteKey(key);
	nd++;
      }
      size--;
    }
  }

  printList();
  
  return 0;
}



Measured memory_bytes: 32944
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n,m = MI()
graph = [[] for _ in range(n+1)]
for i in range(m):
    a,b = MI()
    graph[a].append(b)
    graph[b].append(a)
visited = [False]*(n+1)
visited[0] = True
visited[1] = True
def dfs(v,visited):
    if all(visited):
        return 1
    ans = 0
    for i in graph[v]:
        if visited[i]:
            continue
        visited[i] = True
        ans += dfs(i,visited)
        visited[i] = False
    return ans
print(dfs(1,visited))


Measured memory_bytes: 10032
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N; 
  
  int p = 0;
  int w = 0;
  int g = 0;
  int y = 0;

  for (int i = 0; i < N; i++) {
    string color;
    cin >> color;
    
    if (color == "P") {
      p++;
    }
    if (color == "W") {
      w++;
    }
    if (color == "G") {
      g++;
    }
    if (color == "Y") {
      y++;
    }
  }
  
  if (y > 0) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
long long x;
long long f(long long x){
	if(x==1)return x;
	return 2*f(x/2)+1;
}
int main(){
	cin>>x;
	cout<<f(x);
}


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


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

    vector<int> v ={a,b,c};
    sort(v.begin(),v.end());
    
    if(v[0] == v[1] && v[1] != v[2]) print("Yes");
    else if(v[0] != v[1] && v[1] == v[2]) print("Yes");
    else print("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,q;
	int box[1000];
	int i;
	int a,b,c;
	cin>>n;
	for(i=0;i<n;i++)	cin>>box[i];
	cin>>q;
	for(i=0;i<q;i++){
		cin>>a>>b>>c;
		rotate(box+a,box+b,box+c);
	}
	for(i=0;i<n;i++){
		if(i)	cout<<" ";
		cout<<box[i];
	}
	cout<<endl;
}


Measured memory_bytes: 3160
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define OK 200000

using namespace std;

int main(){

	long N, M;

	cin >> N >> M;

	if(N >= M) {
		cout << 0 << endl;
		return 0;
	}

	long A[M], B[M-1], sum;
	for(long ll = 0; ll < M; ll++){
		cin >> A[ll];
	}
	sort(A, A+M);

	for(long ll = 0; ll < M-1; ll++){
		B[ll] = abs(A[ll+1] - A[ll]);
	}

	sort(B, B+M-1);

	sum = abs(A[M-1] - A[0]);

	for(long l = 1; l < N; l++){
		sum -= B[M-2-l+1];
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        StringBuilder sb=new StringBuilder();
        HashSet<Character> set=new HashSet<>();
        sb.append('a');
        set.add('a');
        dfs(n-1,sb,set);
    }
    public static void dfs(int n, StringBuilder sb,HashSet<Character> set){
        if(n==0)
        {
            System.out.println(sb.toString());
            return;
        }
        int i=0;
        for(i=0;i<26;i++)
        {
            char c=(char)(i+'a');
            if(set.contains(c))
            {
                sb.append(c);
                dfs(n-1,sb,set);
                sb.deleteCharAt(sb.length()-1);
            }
            else{
                sb.append(c);
                set.add(c);
                dfs(n-1,sb,set);
                sb.deleteCharAt(sb.length()-1);
                set.remove(c);
                break;
            }
        }
    }
}


Measured memory_bytes: 54268
#include <iostream>
using namespace std;
int abs(int s){
	if(s<0) s=-s;
	return s;
}
int main(){
	int N,r[100],i=-1;
	cin >> N;
	if(N==0){
		cout << 0;
		return 0;
	}
	while (N != -1){
		i++;
		r[i] = abs(N)%(2);
		if(N<0 && abs(N)%2==1){
			N=N/(-2)+1;
		}else{
			N = N/(-2);
		}
		if(N==1){
			i++;
			r[i]=1;
			break;
		}
	}
	if(N==-1){
		i++;
		r[i]=1;
		i++;
		r[i]=1;
	}
	for(int j=i;j>=0;j--){
		cout << r[j];
	}
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n;cin>>n;
	while(n--){
		string str;cin>>str;
		int s=str.size();
		bool f0=1,f1=1;
		rep(i,s){
			if(i&1&&str[i]=='L')f1=0;
			if(i&1^1&&str[i]=='R')f0=0;
			if(i+1!=s&&str[i]==str[i+1])f1=f0=0;
			i++;
			if(i==s)break;
			if(i&1&&str[i]=='R')f1=0;
			if(i&1^1&&str[i]=='L')f0=0;
			if(i+1!=s&&str[i]==str[i+1])f1=f0=0;
		}
		cout<<(f0||f1?"Yes":"No")<<endl;
	}
	return 0;
}

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


struct UnionFind
{
  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }

  void init() {
    int n = par.size();
  	rep(i,n) {
      par[i] = i;
      sizes[i] = 1;
  	}
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (sizes[x] < sizes[y]) swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};


// 頂点a, bをつなぐコストcostの（無向）辺
struct Edge
{
  int a, b, cost;

  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};

// 頂点数と辺集合の組として定義したグラフ
struct Graph
{
  int n;  // 頂点数
  vector<Edge> es;  // 辺集合

  int getmin() {
    int m = es.size();
    if (m == 0) return -1;
    // コストが小さい順にソート
    sort(es.begin(), es.end());

    UnionFind uf(n);
    int cur_min_ind = 0;
    int ans = 100000000;

    while (true) {
      int min_cost = es[cur_min_ind].cost;
      int max_cost = min_cost;
      int num_edge = 0;

      uf.init();
      for(int ei = cur_min_ind; ei < m; ei++) {
        Edge& e = es[ei];
        if (!uf.same(e.a, e.b)) {
          // 辺を追加しても閉路ができないなら、その辺を採用する
          max_cost = e.cost;
          num_edge++;
          uf.unite(e.a, e.b);
        }
      }

      if (cur_min_ind == 0 && num_edge < n - 1) return -1;
      if (num_edge < n - 1) break;
      ans = min(ans, max_cost - min_cost);

      // calc next min ind
      cur_min_ind++;
      while (cur_min_ind < m && es[cur_min_ind].cost == es[cur_min_ind - 1].cost) cur_min_ind++;
      
      if (cur_min_ind == m) break;
    }


    return ans;
  }
};


void solve(int n, int m) {
  Graph g;
  g.n = n;
  rep(i, m) {
    Edge e;
    cin >> e.a >> e.b >> e.cost;
    e.a--;
    e.b--;
    g.es.push_back(e);
  }
  cout << g.getmin() << endl;
}

int main() {
  int n, m;
  while (cin >> n >> m, n||m) solve(n, m);
  return 0;
}

Measured memory_bytes: 1348
# encoding: utf-8                                                                      

def main
  while n = gets.chomp.to_i and n != 0
    nums = gets.chomp.split(/\s/).collect { |x| x.to_f}
    avg = nums.inject(0) { |s, e| s + e} / nums.size
    ans = 0.0
    nums.each do |num|
      ans += (num - avg) ** 2
    end
    puts ("%.6f" %  Math.sqrt((ans / nums.size)))
  end
end

main

Measured memory_bytes: 6184
N = int(input())
li = []
for i in range(N-1):
    c, s, f = map(int, input().split())
    li.append((c,s,f))
for i in range(N-1):
    t = 0
    for j in range(i, N-1):
        t = max(li[j][1], t)
        t += (li[j][2] - t)%li[j][2]
        t += li[j][0]
    print(t)
print(0)

Measured memory_bytes: 41964
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define int long long
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n,m,r;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
ll a[100005],b[105];
string s;
signed main()
{

    //ios_base::sync_with_stdio(0),cin.tie(0);
    while(cin>>n)
    {
        rep(i,n) cin>>a[i];
        bool flag=true;
        for(int i=n-1;i>0;i--)
        {
            if(a[i-1]==a[i]+1) a[i-1]--;
            else
            {
                if(a[i-1]>a[i]) flag=false;
            }
        }
        if(!flag) cout<<"No\n";
        else cout<<"Yes\n";
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;

int main(){
  ll N;cin>>N;
  vll A(N);rep(i,N)cin>>A[i];
  vll acum(N+1,0);
  rep(i,N) acum[i+1]=acum[i]+A[i];
  ll ans = 0;
  rep(i,N){
    ans += A[i] * ((acum[N] - acum[i+1]) % mod);
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
#define ll               long long int
#define F                first
#define S                second
#define pll              pair<ll,ll>
#define rep(i,a,b)       for(ll i=a; i<b; i++)

bool comp(pll a, pll b)
{
    return (a.F-a.S < b.F-b.S);
}

int main()
{
  ll n,sa=0,sb=0,cnt=0,b=-1; 
  cin>>n;
  pll a[n];
  rep(i,0,n){ cin>>a[i].F; sa+=a[i].F; }
  rep(i,0,n){ cin>>a[i].S; sb+=a[i].S; }
  if(sa<sb) { cout<<-1; return 0; }
  sort(a,a+n,comp);
  rep(i,0,n) if(a[i].F-a[i].S>=0) { b=i; break; }
  if(b==1) { cout<<0; return 0; }
  ll i=0,j=n-1;
  for(;j>=i && i<b;j--)
  {     
      cnt++;
      ll e=a[j].F-a[j].S;
      while(e>0 && i<b)
      {
          ll d=a[i].S-a[i].F; 
          if(e>=d)
          {
              e-=d; 
              i++;
              cnt++;
          }
          else
          {
              a[i].F+=e;
              e=0;
          }
      }
  }
  cout<<cnt;
  return 0; 
}












Measured memory_bytes: 1792
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  private static Scanner sc = new Scanner(System.in);

  private void run() {
    long N = Long.parseLong(sc.next());
    long base = 0;
    while (true) {
      long nextBase = base + 1;
      if (nextBase * nextBase > N) {
        break;
      }
      base++;
    }
    System.out.println(base * base);
  }
}


Measured memory_bytes: 35500
#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, k;
    cin >> n >> k;
    int d[k];
    rep(i,k) cin >> d[i];

    for(int i = n; ; i++) {
        bool isok = true;
        string s = to_string(i);
        rep(j,s.size()){
            rep(a,k){
                if(s[j] - '0' == d[a]){
                    isok = false;
                    goto loopend;
                }
            }
        }
        loopend:
        if(isok){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import heapq

N = int(input())
a = list(map(int, input().split()))

q1 = a[:N]
heapq.heapify(q1)
sum1 = sum(a[:N])
slist1 = [sum1]
for k in range(N, 2*N):
    sum1 += a[k] - heapq.heappushpop(q1, a[k])
    slist1.append(sum1)

q2 = [-i for i in a[2*N:]]
heapq.heapify(q2)
sum2 = (-1)*sum(a[2*N:])
slist2 = [sum2]
for k in range(2 * N - 1, N - 1, -1):
    sum2 += -1*a[k] - heapq.heappushpop(q2, -1*a[k])
    slist2.append(sum2)

ans = -1*float("inf")
for i in range(N+1):
    ans = max(ans, slist2[-1*(i+1)] + slist1[i])
print(ans)

Measured memory_bytes: 37212
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

// 試合するペア
alias P = Tuple!(int, int);

int calc(int[][] g) {
    int n = cast(int)g.length;

    // 後ろから popBack するので reverse しておく
    foreach (i; 0..n) g[i].reverse();

    // 対戦可能な試合を v に格納
    void putGame(int i, ref P[] v) {
        if (g[i].length == 0) return;
        int j = g[i][$-1];
        if (g[j].back == i) {
            v ~= P(min(i, j), max(i, j));
        }
    }

    P[] v;
    foreach (i; 0..n) putGame(i, v);

    int day = 0;
    while (v.length > 0) {
        day++;
        v.sort();
        v = v.uniq.array;

        P[] prevV;
        swap(prevV, v);

        foreach (x; prevV) {
            g[x[0]].popBack();
            g[x[1]].popBack();
        }
        foreach (x; prevV) {
            putGame(x[0], v);
            putGame(x[1], v);
        }
    }
    foreach (i; 0..n) {
        if (g[i].length > 0) return -1;
    }
    return day;
}

void main() {
    int n; scan(n);
    int[][] g;
    for (int i = 0; i < n; i++) {
        g ~= readints.map!(e => e - 1).array;
    }
    writeln(calc(g));
}


Measured memory_bytes: 12540
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };


// ────────────────────────────────────────────────────

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

	vvi a(n);
	rep(i, n) {
		int m; cin >> m;
		rep(j, m) {
			int c; cin >> c;
			a[i].push_back(c);
		}
	}

	priority_queue<int> pq;
	ll ans = 0;
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < a[i].size(); ++j) pq.push(a[i][j]);
		ans += pq.top(); pq.pop();
	}
	cout << ans << endl;
}



Measured memory_bytes: 19128
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;


void enqueue(P x){
  Q[tail]=x;
  tail = (tail+1)%LEN;

}

P dequeue(){
  P x=Q[head];
  head = (head+1)%LEN;
  return x;
}
int res(int x, int y){
  return x<y?x:y;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1;
  tail = n+1;

  while(head != tail){
    u= dequeue();
    c= res(q,u.t);
    u.t -=c;
    elaps +=c;
    if(u.t > 0) enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  
  return 0;
}
    



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

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

bool can = false;
rep(i,b) {
    if (((i+1)*a-c)%b==0) can=true;
}

if(can) cout << "YES" << endl;
else cout << "NO" << endl;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n;
int a[N], b[N], c[N], d[N];

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i] >> b[i];
		c[i] = a[i];
		d[i] = b[i];
	}
	sort(c + 1, c + n + 1);
	sort(d + 1, d + n + 1);
	if(n % 2 == 1)
	{
		int idx = (n + 1) / 2;
		cout << d[idx] - c[idx] + 1;
	}
	else
	{
		int idx = n / 2;
		cout << (d[idx] + d[idx + 1] - c[idx] - c[idx + 1] + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 9896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans=0;
  rep(i,n-2){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
    int A,B,C,K,i;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&K);
    for(i=1;i<=K;i++){
        if(C<=B||C<=A){
            C=C*2;
        }
        else if(B<=A){
            B=B*2;
        }
    }
    if(A<B&&B<C){
        printf("Yes");
    }
    else{
        printf("No");
    }


    return 0;
}

Measured memory_bytes: 1676
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

const Int INF = 1e15;

int main(){
    int N; cin >> N;
    vector<Int> A(N+1);
    rep1(i,N) cin >> A[i];

    // dp[i][0]: A[1]~A[i]からi/2個とるときの最大値
    // dp[i][1]: A[1]~A[i]からi/2+1個とるときの最大値(i:奇数)
    vector<vector<Int>> dp(200010, vector<Int>(2, -INF));

    dp[1][0] = 0;
    dp[1][1] = A[1];
    dp[2][0] = max(A[1], A[2]);

    for(int i=3; i<=N; i++){
        Int last = A[i];
        if(i % 2 == 0){
            dp[i][0] = max(dp[i-1][1], last + dp[i-2][0]);
        } else {
            dp[i][0] = max(dp[i-1][0], last + dp[i-2][0]);
            dp[i][1] = last + dp[i-2][1];
        }
    }

    cout << dp[N][0] << endl;
}

Measured memory_bytes: 15648
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#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++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, a; cin >> n >> a;
    vector<int> x(n);
    rep(i, n) {
        cin >> x[i];
        x[i] -= a;
    }
    int dp[55][5050];
    rep(i, 55) {
        rep(j, 5050) {
            dp[i][j] = 0;
        }
    }
    dp[0][2525] = 1;
    rep(i, n) {
        rep(j, 5050) {
            dp[i + 1][j] += dp[i][j];
            if(j + x[i] < 5050 && j + x[i] >= 0) dp[i + 1][j + x[i]] += dp[i][j];
        }
    }
    cout << dp[n][2525] - 1 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 2432