akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

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

    vector<int> ans(n,-1);
    queue<int> q;
    q.push(0);
    while(q.empty() == false){
        int v = q.front(); q.pop();
        for(int adjacent_v : graph[v]){
            if(ans[adjacent_v] == -1){
                ans[adjacent_v] = v;
                q.push(adjacent_v);
            }
        }
    }
    cout << "Yes" << endl;
    for(int i=1; i<n; i++) cout << ans[i] + 1 << endl;
    return 0;
}

Measured memory_bytes: 9988
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli a, b;
    cin>>a>>b;
    out((b%a==0?a+b:b-a));
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    int a[n+1];
    bool visited[n+1];
    int light=1;
    a[0] = 0;

    int answer = 0;
    FOR(i,1,n+1){
        cin >> a[i];
        visited[i] = false;
    }
    while(true){
        if(visited[light]==true){
            cout << -1 << endl;
            return 0;
        }
        else{
            visited[light] = true;
            light = a[light];
            answer++;
            if(light ==2)break;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 768
def resolve():
    '''
    code here
    '''
    import collections
    N = int(input())
    A_list = [int(item) for item in input().split()]

    A_list.sort()


    dp = [0 for item in range(A_list[-1]+1)]
    for item in A_list:

        temp = item
        while temp <= A_list[-1]:
            dp[temp] += 1
            temp += item

    cnt = 0
    for item in A_list:
        if dp[item] == 1:
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 34104
#include<stdio.h>
int main(void){
int i;
int n;
int max;
int min;
long int sum=0;
int a[10000];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
max=min=a[0];
for(i=0;i<n;i++){
if(a[i]>max){
max=a[i];
}
else if(a[i]<min){
min=a[i];
}
sum+=a[i];
}
printf("%d %d %ld\n",min,max,sum);
return 0;
}

Measured memory_bytes: 636
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
void read(int &x){
	char ch = getchar();x = 0;
	for (; ch < '0' || ch > '9'; ch = getchar());
	for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
int main(){
	int a,b;
	read(a);read(b);
	if(b%a==0){
		cout<<a+b<<endl;
	} 
	else cout<<b-a<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//typedef long long ll
//#define inf 1e18


//int find_last_zero(int n){int cnt=0;for(int i=5; n/i>=1; i=i*5){cnt=cnt+n/i;}return cnt;}
//ll number_of_zero(int n)
//{
//    ll p=5;, x;
//    ll cnt=0;
//    while(1)
//    {
//        x=n/p;
//        p=p*5;
//        cnt=cnt+x;
//        if(!x)return cnt;
//    }
//}
void solve()
{
    int n;
    cin >> n;
    vector<int>p(n);
    for(int i=0; i<n; i++)
    {
        cin >> p.at(i);
    }
    int cnt=0;
    for(int i=0; i<n; i++)
    {
        if(p.at(i)!=i+1)
        cnt++;
    }
    if(cnt<=2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}
int main ()
{
   // FasterIO;
    #ifdef _online
    input
    //output
    #endif // _online
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

void solve(){
    ll L, R;
    cin >> L >> R;

    if(R - L + 1 >= 2019){
        cout << 0 << endl;
        return;
    }
    L %= 2019, R %= 2019;
    int mi = INF;
    if(L > R) swap(L, R);
    for(int i=L;i<R;i++){
        for(int j=i+1;j<=R;j++){
            chmin(mi, (i*j)%2019);
        }
    }
    cout << mi << endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll bigmod(ll a,ll p,ll m)
{
    if(p==0)
        return 1%m;
    if(p%2!=0)
    {
        return (a*(bigmod(a,p-1,m)))%m;
    }
    else
    {
        ll x=(bigmod(a,p/2,m))%m;
        return (x*x)%m;
    }
}
vector<ll> sum;
int bin(ll req)
{
    int low=0;
    int high=sum.size()-1;
    int ans=-1;
    while(low<=high)
    {
        int mid=(low+high)/2;
        if(sum[mid]<=req)
        {
            ans=mid;
            low=mid+1;
        }
        else high=mid-1;
    }
    return ans+1;
}
int main()
{
    int n,m;
    ll t;
    cin>>n>>m>>t;
    ll arr[n+2];
    ll brr[m+2];
    ll res=0;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        res +=arr[i];
        sum.push_back(res);
    }
    ll req=bin(t);
    res=0;
    for(int j=0; j<m; j++)
    {
        cin>>brr[j];
        res += brr[j];
        if((t-res)>=0)
        {
            int id=bin(t-res);
            id +=(j+1);
            req=max(req,(ll)id);
        }
    }
    cout<<req<<endl;

    return 0;
}


Measured memory_bytes: 7916
# maをi-1番目までにでてる最大値としてi番目との差分を足していく

def main():
    # INF = 10 ** 9
    N = int(input())
    A = list(map(int, input().split()))

    # initialize
    ma = A[0]

    res = 0
    for i in range(1, N):
        if A[i] <= ma:
            res += ma - A[i]
        else:
            ma = A[i]
    print(res)

if __name__ == "__main__":
    main()

Measured memory_bytes: 32140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int cnt , sum , c ;
int const N = 100 , m = 1e6+6 , OO = 0x3f3f3f3f;
map<string , int > p;
std::map<string,int>::iterator it =p.begin();
int main(){
int n ,m ;
string s ;
cin >> n ;
for(int i = 0 ; i < n ; ++i ){
    cin >> s ;
    p[s]++;
}
cin >> m ;
for(int i = 0 ; i < m ; ++i ){
    cin >> s ;
    p[s]--;
}
for(auto it = p.begin() ; it != p.end() ; it++)
 c = max(c , it->second);
   cout << c <<endl;
     }




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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int main(){
	cin.sync_with_stdio(false);
	int a, b;
	char op;

	cin >> a >> op >> b;

	if (op == '+') {
		cout << a + b << endl;
	} else {
		cout << a - b << endl;
	}

	return 0;
}


Measured memory_bytes: 256
hand = "11111112222222221111211121"
#       abcdefghijklmnopqrstuvwxyz

while True:
    s = input()
    if s == "#":
        break

    num = [ord(c) - ord('a') for c in s]
    cnt = 0
    for i in range(len(num) - 1):
        if hand[num[i]] != hand[num[i + 1]]:
            cnt += 1
    print(cnt)


Measured memory_bytes: 5572
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
#include <cctype>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if(a < b  &&  b < c)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1156
import sys
N = int(raw_input())
T = [0]
X = [0]
Y = [0]
for n in xrange(N):
    t, x, y = [int(val) for val in raw_input().split(" ")]
    T.append(t)
    X.append(x)
    Y.append(y)
for i in xrange(N):
    dt = T[i+1] - T[i]
    dx = X[i+1] - X[i]
    dy = Y[i+1] - Y[i]
    target = dt - abs(dx) - abs(dy)
    if (target%2==1) or (target<0):
        print "No"
        sys.exit()
print "Yes"

Measured memory_bytes: 9732
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int c[1000005];

int main()
{ios_base::sync_with_stdio(false);
int n,k;
cin>>n>>k;
rep(i,1,n)
{
	int x;
	cin>>x;
	c[x]++;
}
sort(c,c+1000005);
int cnt=0;
rep(i,0,1000004)
{
	if(c[i])cnt++;
}
int ans=0;
if(cnt<=k)
{
	ol("0");
	return 0;
}
int x=cnt-k;
rep(i,0,1000004)
{
	if(x)
	{
		if(c[i])
		{
			ans+=c[i];
			x--;
		}
	}
}
ol(ans);
return 0;
}



Measured memory_bytes: 4224
//Copyright(c)2017 Mstdream
#include<bits/stdc++.h>
using namespace std;

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
const int N=305;
int n,a[N][N],t[N],vis[N],num[N],ans=N,m;
int main(){
	splay(n),splay(m);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			splay(a[i][j]);
		}
		t[i]=1;
	}
	for(int i=1;i<=m;i++){
		memset(num,0,sizeof num);
		for(int j=1;j<=n;j++){
			while(vis[a[j][t[j]]])t[j]++;
			num[a[j][t[j]]]++;
		}
		int mx=0;
		for(int j=1;j<=m;j++){
			mx=max(mx,num[j]);
		}
		ans=min(ans,mx);
		int p=0;
		for(int j=1;j<=m;j++){
			if(num[j]==mx){
				p=j;break;
			}
		}
		vis[p]=1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
while gets
  puts case $_.to_f.ceil
  when 0..48
    "light fly"
  when 48..51
    "fly"
  when 51..54
    "bantam"
  when 54..57
    "feather"
  when 57..60
    "light"
  when 60..64
    "light welter"
  when 64..69
    "welter"
  when 69..75
    "light middle"
  when 75..81
    "middle"
  when 81..91
    "light heavy"
  else
    "heavy"
  end
end

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

using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b && b == c && a == c){
		cout << "No";
	} else if(a == b || a == c || b == c){
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}



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

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

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

		
		sc.close();
	}
}

Measured memory_bytes: 25936
#include<bits/stdc++.h>
using namespace std;
signed main(){
long long n,b=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
		b++;
    }
  }
  cout<<b<<"\n";
}

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

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

	int start = 0, end, t=c;
	bool flag = false;
	while (start <= 3600+c) {
		end = start + a;
		if (start <= t && t <= end) {
			flag = true;
			break;
		}

		start = end + b;
		t = 60 * (start/60) + c;
	}
	if(flag) cout << t << endl;
	else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, count = 0, f_count = 0;
  cin >> N;
  for(int i = 0; i < N; i++) {
    int A;
    cin >> A;
    for(int j = A; j % 2 == 0; j /= 2) {
      f_count++;
    }
    if(count == 0 && f_count == 0) {
      count = 0;
      break;
    }
    else if(count == 0 && f_count != 0) {
      count = f_count;
      f_count = 0;
    }
    else if(count > f_count) {
      count = f_count;
      f_count = 0;
    }
    else if(count <= f_count) {
      f_count = 0;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
if a % 2 or b % 2 or c % 2:
   print(0)
   exit()
if a == b == c:
   print(-1)
   exit()

cnt = 0
while True:
   if a % 2 or b % 2 or c % 2:
      break
   cnt += 1
   next_a = b // 2 + c // 2
   next_b = a // 2 + c // 2
   next_c = a // 2 + b // 2
   a = next_a; b = next_b; c = next_c
print(cnt)

Measured memory_bytes: 61864
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int[] hills = new int[10];
		Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		for (int i = 0; i < 10; i++) {
			hills[i] = scanner.nextInt();
		}
		Arrays.sort(hills);
		printListOfTop3Hills(hills);
	}

	public static void printListOfTop3Hills(int[] hills) {
		for (int i = 9; i > 6; i--) {
			System.out.println(hills[i]);
		}
	}
}

Measured memory_bytes: 17188
#include<iostream>
#include<string>
#include<cctype>
using namespace std;

int mcxitoint(string mcxi){
	int ret=0;
	for(string::iterator it=mcxi.begin();it!=mcxi.end();++it){
		int cur=1;
		if(isdigit(*it)){
			cur=(*it)-'0';
			++it;
		}
		switch (*it){
		case 'm':
			ret+=1000*cur;
			break;
		case 'c':
			ret+=100*cur;
			break;
		case 'x':
			ret+=10*cur;
			break;
		case 'i':
			ret+=cur;
			break;
		}
	}
	return ret;
}


string inttomcxi(int in){
	string ret="";
	if(in%10!=0){
		ret='i'+ret;
		if(in%10!=1)ret=static_cast<char>(in%10+'0')+ret;
	}
	in=in/10;
	if(in%10!=0){
		ret='x'+ret;
		if(in%10!=1)ret=static_cast<char>(in%10+'0')+ret;
	}
	in=in/10;
	if(in%10!=0){
		ret='c'+ret;
		if(in%10!=1)ret=static_cast<char>(in%10+'0')+ret;
	}
		in=in/10;
	if(in%10!=0){
		ret='m'+ret;
		if(in%10!=1)ret=static_cast<char>(in%10+'0')+ret;
	}
	return ret;
}



int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string mcxi[2];
		cin>>mcxi[0]>>mcxi[1];
		cout<<inttomcxi(mcxitoint(mcxi[0])+mcxitoint(mcxi[1]))<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
from collections import Counter
s = list(map(int,list(input())))

t = 0
cusum = []
for i in range(len(s))[::-1]:
  t += s[i]*pow(10,len(s)-i-1,2019)
  t %= 2019
  cusum.append(t)
  
counter = Counter(cusum)

ans = counter[0]
for v in counter.values():
  ans+=v*(v-1)//2

print(ans)

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

int main(){
  int a;
  cin >>a;
  ll ans = 0;
  for(int i = 1; i<=a; i++){
    ans += i;
    if(i%3==0 || i%5==0) ans -= i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main(){
  char c,cans[29]={'X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W'};
  int n;
  while(cin>>c){
    n = c - '@' - 1;
    cout << cans[n];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1132
import java.util.Scanner;
 
public class Main{
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int pre = 0, curr = 1, ans = 0;
		boolean flag = false;
		while (num > 0) {
			curr = num % 10;
			if (pre == curr) {
				ans++;
				pre = curr;
			} else {
				ans = 1;
				pre = curr;
			}
			if (ans >= 3) {
				flag = true;
				break;
			}
			num /= 10;
 
		}
		System.out.println(flag == true ? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
using System;
using System.Linq;

namespace Aizu {
    public class OnlineJudge {
        static void Main() {
            var name = "kogakubu10gokan";
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();

            for (var i = 0; i < input[0]; ++i) {
                var year = Console.ReadLine().Split();
                if (int.Parse(year[0]) > input[1]) {
                    for (Console.WriteLine(name); ++i < input[0]; Console.ReadLine());
                    return;
                }

                name = year[1];
            }

            Console.WriteLine(name);
        }
    }
}



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

int N,K;

int main(){
    cin >> N >> K;
    long long H[N];
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    sort(H, H+N);
    long long sum=0;
    for(int i=0;i<N-K;i++){
        sum+=H[i];
    }
    cout << sum << endl;
    return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define inf (1ll<<56)
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int n,l,r,tl,tr,L,R,len,ans;
priority_queue <ll> q1;
priority_queue <ll, vector<ll>, greater<ll> > q2;
signed main()
{
	n=read(); while(n--)
	{
		l=read(); r=read(); len=r-l;
		tr+=len;
		q1.push(r-tl); q2.push(r-tr);
		while((L=q1.top()+tl)>(R=q2.top()+tr))
		{
			ans+=L-R;
			q1.pop(); q2.pop();
			q1.push(R-tl); q2.push(L-tr);
		}
		tl-=len;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;




int32_t main()
{


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


    int k;
    cin >> k;

    string s = "ACL";


    while(k--)
    {
    	cout << s;
    }


    return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
class Program
{
	//static long[,] dp;
	//static	Dictionary<string, long> dp;
	//static int[] weight, value;
    //static List<string> str = new List<string>();
	static void Main(string[] args)
	{
		// 入力フェーズ
		string S = Console.ReadLine();
		string T = Console.ReadLine();

		int slen = S.Length;
		int tlen = T.Length;
		int[,] dp = new int[slen + 1, tlen + 1];
		// Sのi文字目までと、Tのj文字目までの最大の長さになる部分文字列の長さを格納する
//Console.WriteLine(S + " " + T);
		for(int i= 1; i<=slen; i++)
		{
			//Console.Write(i + "slength ");
			for(int j= 1; j<=tlen; j++)
			{
					//Console.Write(j + "tlength ");
				int newlen;
				if(S[i-1] == T[j-1])
				{
					newlen = dp[i-1,j-1] + 1;
					//Console.Write(S[i-1] + " = " + T[j-1]);
				}
				else
				{
					newlen = dp[i-1,j-1]; // 変わらず
				}
				dp[i,j] = Math.Max(newlen , Math.Max(dp[i-1, j], dp[i, j-1]));
			}
			//Console.WriteLine(" end");
		}

		// dp[slen, tlen]に最大の長さの部分文字列の長さが求まっているので復元する
		// 最後の文字から
		string ret = "";

		for(int i=slen, j=tlen; i>0 || j>0; )
		{
			if(j > 0 && dp[i,j] == dp[i,j-1])
			{
				j--; //一つ上にうつる
			}
			else if(i > 0 && dp[i,j] == dp[i-1,j])
			{
				i--;
			}
			else
			{
				if(dp[i,j] != dp[i-1, j-1])
				{
					ret = S[i-1] + ret;
				}

				i--;
				j--;
			}
		}

		Console.WriteLine(ret);

    }
}


Measured memory_bytes: 52184
sx,sy,tx,ty = map(int, input().split())

ans = []
for i in range(tx-sx):
    ans.append('R')
for i in range(ty-sy):
    ans.append('U')

for i in range(tx-sx):
    ans.append('L')
for i in range(ty-sy):
    ans.append('D')
    
ans.append('D')
ans.append('R')
for i in range(tx-sx):
    ans.append('R')
for i in range(ty-sy):
    ans.append('U')
ans.append('U')
ans.append('L')

ans.append('U')
ans.append('L')
for i in range(tx-sx):
    ans.append('L')
for i in range(ty-sy):
    ans.append('D')
ans.append('D')
ans.append('R')

print(''.join(ans))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int mini=INT_MAX,maxi=0,mini1=INT_MAX,maxi1=INT_MIN,n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    long long int c,d;
    cin>>c>>d;
    mini=min(mini,c+d);
    maxi=max(maxi,c+d);
    mini1=min(mini1,c-d);
    maxi1=max(maxi1,c-d);
  }
  cout<<max(maxi-mini,maxi1-mini1);

	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int a[1000003],b[1000003];
vector<long long>res1;
long long ans=0,res=0;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i],ans+=a[i];
	for(int i=0;i<n;i++){cin>>b[i],ans-=b[i];if(a[i]>=b[i])res1.push_back(a[i]-b[i]);else res+=b[i]-a[i];}
	sort(res1.begin(),res1.end());
	if(ans<0)
		cout<<-1;
	else{
		long long cnt=0,i=res1.size()-1;
		while(cnt<res)
			cnt+=res1[i],
			i--;
		cout<<-i+n-1;
	}
}

Measured memory_bytes: 5752
a, b = map(int, input().split())
def gcd(l, m):
    x = min(l, m)
    y = max(l, m)
    if y % x == 0:
        return x
    else:
        while y % x != 0:
            z = y % x
            y = x
            x = z
        else:
            return z

def lcm(s, t):
    ans = s * t // (gcd(s, t))
    return ans

print(lcm(a, b))

Measured memory_bytes: 3060
// ~/SolverToBe/Developers/Corvus
// ~/sudo apt-get verdict Accpeted

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <functional>
#include <assert.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 100005, M = 1000005;
const ll MOD = 1e9 + 7;
const double eps = 1e-9;

int n,m,dp[N],ind[N],idx[N];
vector<vector<int> > g;
vector<int> ord;

void topologicalSort() {
    queue<int> q;
    for(int i=0; i<n; i++)
        if(ind[i]==0)
            q.push(i);
    while(q.size()) {
        int u = q.front();
        q.pop();
        ord.push_back(u);
        for(int i=0; i<g[u].size(); i++) {
            ind[g[u][i]]--;
            if(ind[g[u][i]]==0)
                q.push(g[u][i]);
        }
    } 
}

int main() {
    scanf("%d%d",&n,&m);
    g.resize(n);
    for(int i=0,a,b; i<m; i++) {
        scanf("%d%d",&a,&b);
        a--,b--;
        g[a].push_back(b);
        ind[b]++;
    }
    topologicalSort();
    for(int i=0; i<n; i++) {
        dp[i] = 0;
        ind[ord[i]] = i;
    }
    int ans = 0;
    for(int i=n-2; i>=0; i--) {
        int u = ord[i];
        for(int v : g[u])
            if(ind[v] > i)
                dp[i] = max(dp[i], dp[ind[v]] + 1);
        ans = max(ans, dp[i]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;

int top;
const int MAX = 110;
int s[MAX];
string c;

void initialize() { top = 0; }

bool isEmpty() { return top == 0; }

bool isFull() { return top >= MAX - 1; }

void push(int x)
{
    s[++top] = x;
}

int pop()
{
    top--;
    return s[top + 1];
}

int main()
{
    initialize();
    int a, b;
    while (cin >> c) {
        if (c == "+") {
            a = pop();
            b = pop();
            push(a + b);
        } else if (c == "-") {
            a = pop();
            b = pop();
            push(b - a);
        } else if (c == "*") {
            a = pop();
            b = pop();
            push(a * b);
        } else {
            push(stoi(c));
        }
    }
    cout << pop() << endl;

    return 0;
}


Measured memory_bytes: 3136
"""
- Nを素因数分解する
- N = p[i]^1*p[i]^2...*p[k]^1*p[k]^2...
"""
from collections import Counter
N = int(input())
factors = []
i = 2

while N > 1:
  if N < i * i:
    factors.append(N)
    break
  while N % i == 0:
    factors.append(i)
    N //= i
  i += 1
# N == 1
ans = 0
# print(factors)
# Counter() ->{key:count}
for count in Counter(factors).values():
  i = 1
  while count >= i:
    count -= i
    i += 1
    ans += 1
print(ans)

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

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	vector<int> adj[n];
	int v[n];
	memset(v,0,sizeof(v));
	int i,x,y;
	unordered_map<string,int> ma;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		x--;
		y--;
		string s=to_string(x)+" "+to_string(y);
		if(ma[s]==1)
			continue;
		s=to_string(y)+" "+to_string(x);
		if(ma[s]==1)
			continue;
		adj[x].push_back(y);
		adj[y].push_back(x);
		ma[s]=1;
	}
	int ans=0;
	int cnt=0;
	for(i=0;i<n;i++)
	{
		if(v[i]==0)
		{
			cnt=0;
			queue<int> q;
			v[i]=1;
			q.push(i);
			while(q.size())
			{
				int x=q.front();
				q.pop();
				cnt++;
				for(int j:adj[x])
				{
					if(v[j]==0)
					{
						v[j]=1;
						q.push(j);
					}
				}
			}
			ans=max(ans,cnt);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 44192
w, h, n = map(int, input().split())

d = 0
u = h
r = w
l = 0

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        if l <= x:
            l = x
    elif a == 2:
        if r >= x:
            r = x
    elif a == 3:
        if d <= y:
            d = y
    elif a == 4:
        if u >= y:
            u = y
    if u-d <= 0 or r-l <= 0:
        break
ans = (r-l) * (u-d)
if ans <= 0:
    print(0)
else:
    print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<math.h>

using namespace std;

int n[2], result[100];

int main()
{
	scanf("%d", &n[0]);

	n[1] = n[0];

	int a = 2;
	int b = 0;

	while (n[1] > 1)
	{
		if (n[1] % a == 0)
		{
			result[b] = a;
			n[1] /= a;
			b++;
		}
		else
		{
			a++;
		}

		if (result[b] == 0 && a > sqrt(n[1]))
		{
			result[b] = n[1];
			b++;
			break;
		}
	}

		printf("%d:", n[0]);
		for (int x = 0; x < b - 1; x++)
		{
			printf(" %d", result[x]);
		}
		printf(" %d\n", result[b - 1]);

	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

class Graph{
	private:
	vvi Gpro,Gd;
	vvp Glist;
	int GV,GE;
	public:
	Graph(int x,int y,bool z){
		GV=x;
		GE=y;
//		Gd=vvi(x,vi(x,inf));
		if(z) Gpro=vvi(x,vi(x,inf));
		else Glist=vvp(x);
	}
	void Gpro_add(int x,int y,int z){
		Gpro[x][y]=z;
		Gpro[y][x]=z;
	}
	void Glist_add(int x,int y,int z){
		Glist[x].push_back(P(y,z));
		Glist[y].push_back(P(x,z));
	}
	void Gd_add(int x,int y,int z){
		Gd[x][y]=z;
	}
	int open(int x,int y){
		return Gd[x][y];
	}
	void DIJplus(int x){
		priority_queue<P> que;
		Gd[x][x]=0;
		que.push(P(0,x));
		while(!que.empty()){
			P p=que.top();
			p.first*=-1;
			que.pop();
			int v=p.second;
			if(Gd[x][v]<p.first) continue;
			for(int i=0;i<Glist[v].size();i++){
				P e=Glist[v][i];
				if(Gd[x][e.first]>Gd[x][v]+e.second){
					Gd[x][e.first]=Gd[x][v]+e.second;
					que.push(P(-1*Gd[x][e.first],e.first));
				}
			}
		}
	}
	void BELLMAN(int x){
		Gd[x][x]=0;
		while(1){
			bool update=1;
			for(int i=0;i<GV;i++){
				for(int j=0;j<Glist[i].size();j++){
					P e=P(Glist[i][j].first,Glist[i][j].second);
					if(Gd[x][i]!=inf&&Gd[x][e.first]>Gd[x][i]+e.second){
						Gd[x][e.first]=Gd[x][i]+e.second;
						update=0;
					}
				}
			}
			if(update) break;
		}
	}
	bool FNL(int x){
		Gd[x][x]=0;
		for(int i=0;i<GV;i++){
			for(int j=0;j<GV;j++){
				for(int k=0;k<Glist[j].size();k++){
					P e=P(Glist[j][k].first,Glist[j][k].second);
					if(Gd[x][j]!=inf&&Gd[x][e.first]>Gd[x][j]+e.second){
						Gd[x][e.first]=Gd[x][j]+e.second;
						if(i==GV-1) return 1;
					}
				}
			}
		}
		Gd=vvi(GV,vi(GV,inf));
		return 0;
	}
	void WARSHALL(){
		for(int i=0;i<GV;i++){
			for(int j=0;j<GV;j++){
				for(int k=0;k<GV;k++) Gd[i][j]=min(Gd[i][j],Gd[i][k]+Gd[k][j]);
			}
		}
	}
	int PRIM(){
		int Gans=0;
		vi mincost(GV,inf);
		vector<bool> used(GV,1);
		mincost[0]=0;
		while(1){
			int v=-1;
			for(int i=0;i<GV;i++){
				if(used[i]&&(v==-1||mincost[i]<mincost[v])) v=i;
			}
			if(v==-1) break;
			used[v]=0;
			Gans+=mincost[v];
			for(int i=0;i<Glist[v].size();i++){
				mincost[Glist[v][i].first]=min(mincost[Glist[v][i].first],Glist[v][i].second);
			}
		}
		return Gans;
	}
};


int V,E;

int main(){
	cin>>V>>E;
	Graph gra(V,E,0);
	for(int i=0;i<E;i++){
		int s,t,d;
		cin>>s>>t>>d;
		gra.Glist_add(s,t,d);
	}
	cout<<gra.PRIM()<<endl;
}

Measured memory_bytes: 3996
#ライブラリインポート
from collections import defaultdict
import bisect

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	S = list(input())
	nibu = []
	for i in range(N + 1):
		if S[i] == "0":
			nibu.append(i)

	prev = [None] * (N + 1)
	for i in range(1, N + 1):
		if S[i] == "0":
			s = bisect.bisect_left(nibu, i - M)
			x = nibu[s]
			if x != i:
				prev[i] = x
	# print(nibu)
	# print(prev)
	if prev[N] == None:
		print(-1)
	else:
		ans = []
		x = N
		while True:
			ans.append(x - prev[x])
			x = prev[x]
			if prev[x] == None:
				break
		if x == 0:
			ans = ans[::-1]
			print(" ".join(list(map(str, ans))))
		else:
			print(-1)

if __name__ == '__main__':
	main()

Measured memory_bytes: 58632
def main():
    import sys
    input = sys.stdin.readline
    X, N = map(int, input().split())
    P = list(map(int, input().split()))
    ans = float("inf")
    ans_m = float("inf")
    for i in range(-10, 110):
        if i not in P:
            if abs(X-i) < ans_m:
                ans_m = abs(X-i)
                ans = i
    print(ans)


if __name__ == '__main__':
    main()

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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

int main()
{
    ll n,m;
    cin>>n>>m;

    ll a[2009];
    ll votes = 0;

    FOR(i,0,n)
    {
        cin>>a[i];
        votes += a[i];
    }
    ll x = 4*m;

    ll limit = ceil(votes/(double)x);

    int count = 0;

    FOR (i,0,n)
    {
        if (a[i] >= limit)
        {
            count++;
        }
    }

    if (count >= m)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}

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

int main() {
  long k,n,ans;
  cin >> k >> n;
  ans=k;
  vector<int> a(n+1);
  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  a[n]=a[0]+k;
  for(int i=0;i<n;i++) {
    ans=min(ans,k-(a[i+1]-a[i]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int quant = sc.nextInt();
 
        Queue<TimeTask> que = new ArrayDeque<>();
        for (int i = 0; i < n; i++) {
            que.add(new TimeTask(sc.next(), sc.nextInt()));
        }
         
        int timePoint = 0;
        while (!que.isEmpty()) {
            TimeTask head = que.poll();
 
            if (head.time > quant) {
                timePoint += quant;
                head.addTime(-quant);
                que.add(head);
                 
            } else {
                timePoint += head.time;
                System.out.println(head.task + " " + timePoint);
            }
        }
    }
     
    static class TimeTask {
        String task;
        int time;
        TimeTask (String task, int time) {
            this.task = task;
            this.time = time;
        }
         
        void addTime(int add) {
            time += add;
        }
    }
}


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

struct fastio {
	char s[100000];
	int it, len;
	fastio(): it(0), len(0) {}
	char get() {
		if (it >= len)
			len = fread(s, 1, 100000, stdin), it = 0;
		return s[it++];
	}
} _buff;

struct node {
	int val;
	char id;
	node *fa, *son[26];
} tr[1000010], *root, *tl[200010];

int n, idx;
char s[1000000], vis[26];
int readint();

int main() {
	root = &tr[idx++];
	n = readint();
	for (int i = 0; i < n; ++i) {
		s[0] = _buff.get();
		while (!isalpha(s[0]))
			s[0] = _buff.get();
		int len;
		for (len = 0; isalpha(s[len]); ++len)
			s[len + 1] = _buff.get();
		s[len] = '\0';
		node *p = root;
		for (int j = len - 1; j >= 0; --j) {
			if (p->son[s[j] - 'a'] == NULL)
				tr[idx].fa = p, tr[idx].id = s[j] - 'a',
					p->son[s[j] - 'a'] = &tr[idx++];
			p = p->son[s[j] - 'a'];
		}
		++p->val;
		tl[i] = p;
	}

	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		memset(vis, 0, sizeof(vis));
		for (node *p = tl[i]; p != root; p = p->fa) {
			vis[p->id] = 1;
			for (int j = 0; j < 26; ++j)
				if (vis[j] && p->fa->son[j] != NULL)
					ans += p->fa->son[j]->val;
		}
		--ans;
	}
	printf("%lld\n", ans);
	return 0;
}

int readint() {
	int ret = 0;
	char c = _buff.get();
	while (!isdigit(c))
		c = _buff.get();
	while (isdigit(c)) {
		ret = ret * 10 + c - '0';
		c = _buff.get();
	}
	return ret;
}



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

using namespace std;

typedef long long ll;

int main()
{
  string s;
  cin >> s;
  if (s.size() < 4) {
    cout << "No" << endl;
    return 0;
  }
  if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin >> n;
  	int a3 = n / 100;
  	int a2 = (n % 100) / 10;
    int a1 = ((n % 10) % 10);
  	cout << a3 + a2 + a1 << endl;
      
}

Measured memory_bytes: 3512
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string t;
  cin>>t;
  fr(i,t.size()){
    if(t[i]=='?'){
      t[i]='D';
    }
  }
  cout<<t;

}

Measured memory_bytes: 3772
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val a = read().toCharArray().toSet()
    println(if(a.size == 1) "No" else "Yes")
}

fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}

Measured memory_bytes: 34168
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
U = [input() for i in range(0,N)]
M = int(input())
door = False
for i in range(M):
    T = input()
    if T in U:
        if door == True:
            print("Closed by " + T)
            door = False
        else:
            print("Opened by " + T)
            door = True
    else:
        print("Unknown " + T)

Measured memory_bytes: 6728
#include "bits/stdc++.h"
#define long int64_t
using namespace std;

struct Solver {
	void solve() {
		int K;
		cin >> K;

		vector<int> A( K+1 );
		A[1] = 7 % K;
		for( int i = 2; i <= K; ++i ) {
			A[i] = (10 * A[i-1] + 7) % K;
		}

		for( int i = 1; i <= K; ++i ) {
			if( A[i] == 0 ) {
				cout << i << endl;
				return;
			}
		}

		cout << -1 << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 7036
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("test.txt","r",stdin);
	ll n;
	cin>>n;
	ll a[n],b[n],c[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	ll dp1[n],dp2[n],dp3[n];
	dp1[0]=a[0];
	dp2[0]=b[0];
	dp3[0]=c[0];
	for(ll i=1;i<n;i++)
	{
		dp1[i]=max(dp2[i-1],dp3[i-1])+a[i];
		dp2[i]=max(dp1[i-1],dp3[i-1])+b[i];
		dp3[i]=max(dp1[i-1],dp2[i-1])+c[i];
	}
	ll ans=max(max(dp1[n-1],dp2[n-1]),dp3[n-1]);
	cout<<ans<<endl;
	

}

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

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 59;


void solve()
{
  int V, E;
  int64 v[100][100];
  fill_n(*v, 100 * 100, INF);
  for(int i = 0; i < 100; i++) v[i][i] = 0;

  cin >> V >> E;
  while(E--) {
    int a, b, c;
    cin >> a >> b >> c;
    v[a][b] = c;
  }
  for(int k = 0; k < V; k++) {
    for(int i = 0; i < V; i++) {
      for(int j = 0; j < V; j++) {
        v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
      }
      if(v[i][i] < 0) {
        cout << "NEGATIVE CYCLE" << endl;
        return;
      }
    }
  }
  for(int i = 0; i < V; i++) {
    for(int j = 0; j < V; j++) {
      if(j) cout << " ";
      if(v[i][j] >= INF / 2) cout << "INF";
      else cout << v[i][j];
    }
    cout << endl;
  }
}

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

Measured memory_bytes: 3296
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
typedef long long ll;
const ll MAX=510000;
const ll mod = 1e9 + 7;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll h[101010];
ll y[101010];
ll a[201010];
ll c[101010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
bool IsOK(ll len){
        map<string,ll> m;
        rep(i,0,N){
            if(m[S.substr(i,len)]==0){
                m[S.substr(i,len)]=i+len;
            }else{
                if(i>=m[S.substr(i,len)]){
                    return true;
                }
            }
        }
        return false;
}
int main(){
    cin>>A>>B;
    if(A>=10 || B >= 10){
        cout<<-1<<endl;
    }else{
        cout<<A*B<<endl;
    }
    return 0;
}


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

int main(void)
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; s[i] != '\0'; i++)
    {
        if(s[i]!=t[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3796
N=int(input())
alist=list(map(int,input().split()))

a2list=[]
for i in range(N):
  a2list.append((alist[i],i))
a2list.sort(reverse=True)
#print(a2list)

dp=[]
for i in range(N+1):
  dp.append([0]*(N+1))
#print(dp)

for i in range(1,N+1):
  aa,ii=a2list[i-1]
  for j1 in range(i+1):
    j2=i-j1
    if j1==0:
      dp[j1][j2]=dp[j1][j2-1]+aa*abs((N-1)-(j2-1)-ii)
    elif j2==0:
      dp[j1][j2]=dp[j1-1][j2]+aa*abs(ii-(j1-1))
    else:
      dp[j1][j2]=max(dp[j1][j2-1]+aa*abs((N-1)-(j2-1)-ii),dp[j1-1][j2]+aa*abs(ii-(j1-1)))

#print(dp)
answer=0
for i in range(N):
  answer=max(answer,dp[i][N-i])
  #print(dp[i][N-i])
print(answer)

Measured memory_bytes: 100528
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




















class RollingHash {
private:
    using ull = unsigned long long;
    const ull base1;
    const ull base2;
    const ull mod1;
    const ull mod2;
    vector<ull> hash1;
    vector<ull> hash2;
    vector<ull> pow1;
    vector<ull> pow2;
    
    string s;
    
public:
    RollingHash(string &s) : s(s), base1(1009), base2(2009), mod1(1000000007), mod2(1000000009),
                             hash1(s.size() + 1), hash2(s.size() + 1), pow1(s.size() + 1, 1), pow2(s.size() + 1, 1) {
        for(int i = 0; i < s.size(); i++){
            hash1[i + 1] = (hash1[i] * base1 + s[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + s[i]) % mod2;
            pow1[i + 1] = (pow1[i] * base1) % mod1;
            pow2[i + 1] = (pow2[i] * base2) % mod2;
        }
    }
    
    // s の [l, r) のハッシュ値を返す
    ull get(int l, int r){
        return (hash1[r] - ((hash1[l] * pow1[r - l]) % mod1) + mod1) % mod1;
    }
    
    ull get(){
        return get(0, s.size());
    }
    
    ull operator () (){
        return get(0, s.size());
    }
    
    ull operator () (int l, int r){
        return get(l, r);
    }
};

int main(){
    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    string ss;
    ll tmp = ((m % n == 0)? m / n : m / n + 1);
    REP(i, max(tmp, 50LL)){
        ss += s;
    }
    RollingHash roli1(ss), roli2(t);
    vector<bool> match(n);
    REP(i, n){
        if(roli1(i, i + m) == roli2()){
            match[i] = true;
        }
    }
    vector<ll> d(n);
    set<ll> st;
    auto f = [dfs = [&](auto &&dfs, ll now) -> ll {
        if(st.find(now) != st.end()){
            cout << -1 << endl;
            exit(0);
        }
        if(d[now] != 0){
            return d[now];
        }
        st.insert(now);
        if(match[now]){
            d[now] = dfs(dfs, (now + m) % n) + 1;
        }
        st.erase(now);
        return d[now];
    }](ll start){ dfs(dfs, start); };
    REP(i, n){
        f(i);
    }
    cout << *max_element(d.begin(), d.end()) << endl;
}

Measured memory_bytes: 895948
#include <iostream>
#include <string>

using namespace std;

int main(){

        int gameNum = 0,Hanako = 0,Taro = 0;
        string HCard,TCard;
        cin >> gameNum;
        for(int i = 0; i < gameNum; i++){
                cin >> HCard >> TCard;
                if(HCard.compare(TCard) == 0){
                        Hanako++;
                        Taro++;
                }
                else if(HCard.compare(TCard) < 0) Taro += 3;
                else Hanako += 3;
        }

        cout << Hanako << " " << Taro << endl;

        return 0;
}

Measured memory_bytes: 1208
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        Arrays.sort(a);
        boolean arrangeable = true;
        for (int i = 0; i < n; i++) {
            if (a[i] != ((i + n % 2) / 2 * 2 + 1 - n % 2)) {
                arrangeable = false;
                break;
            }
        }

        if (arrangeable) {
            int answer = 1;
            for (int i = 0; i < n / 2; i++) {
                answer = (answer * 2) % 1_000_000_007;
            }
            System.out.println(answer);
        } else {
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 50752