akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main() {
    int n; cin >> n;
    int A[100];
    for (int i=0; i<n; ++i) {
        cin >> A[i];
    }

    int cnt = 0;
    for (int i=1; i<n; ++i) {
        for (int j=n-1; j>=1; --j) {
            if (A[j-1] > A[j]) {
                swap(A[j-1], A[j]);
                cnt ++;
            }
        }
    }

    for (int i=0; i<n; ++i) {
        if (i==0)
            cout << A[i];
        else
            cout << " " << A[i];
    }
    cout << "\n";
    cout << cnt << "\n";

    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d[i];
	int sum, ans, p;
	sum = 0;
	p = 0;
	for(int i = 0; i < n ;i++)
	{
		sum += d[i];
		p += d[i] * d[i];
	}
	ans = (sum * sum - p) / 2;
	cout << ans << "\n";
	return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <sstream>
// #include <bits/stdc++.h>
#define req(i,h) for(int i = h; i > 0; i--)

using namespace std;


int main(void) {
    int r;
    cin >> r;
    if(r < 1200) {
        cout << "ABC" << endl;
    } else if(r < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,x,y,i,k,l,r,ll,rr,len,lena,lenb,aa[10001],bb[10001];
int main(){
    cin>>a;
	cin>>b;
	x=a;
	y=b;
    while(a){
		aa[++lena]=a&1;
		a>>=1;
	}
    while(b){
		bb[++lenb]=b&1;
		b>>=1;
	}
    for(i=max(lena,lenb);i;i--){
        if(aa[i]!=bb[i]){
			len=i;
			break;
		}
        x-=1ll*aa[i]<<(i-1);
        y-=1ll*bb[i]<<(i-1);
    }
    for(i=len-1;i;i--){
		if(bb[i]){
			k=i;
			break;
		}
	}
    l=x;
	r=(1ll<<(len-1))+(1ll<<k)-1;
    ll=(1ll<<(len-1))+x;
	rr=(1ll<<len)-1;
    if(ll>r){
		cout<<r-l+1+rr-ll+1<<endl;
	}
    else{
		cout<<rr-l+1<<endl;
	}
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;

#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vec vector <int>
#define rep(i,a,b) for (ll i=a;i<b;i++)
#define repD(i,a,b) for (ll i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define maa 1000000007
#define Eps 1e-9
#define PI 3.14159265359

typedef tree<pii,null_type,less <pii >,rb_tree_tag,tree_order_statistics_node_update>ind_set;
typedef gp_hash_table<int, int, hash<int> > ht1;   /// if clear is required
typedef cc_hash_table<int, int, hash<int> > ht2;

///*X.find_by_order("index")
///X.order_of_key("key")

///----------------------------------------------------------------------------------

string a,b;
int n,m;
int DP[5000][5000];
int fun(int i,int j)
{
    if (i>=n)return 0;
    if (j>=m)return 0;
    if (DP[i][j]!=0)return DP[i][j];

    DP[i][j]=max(fun(i+1,j),fun(i,j+1));
    if (a[i]==b[j])DP[i][j]=1+fun(i+1,j+1);
    return DP[i][j];
}
string ans;
void reconstruct(int i,int j)
{
    if (i>=n ||j>=m)return;



    if (DP[i+1][j+1]==DP[i][j]-1 &&DP[i][j]==DP[i+1][j]+1&&DP[i][j]==DP[i][j+1]+1)
        {ans+=a[i];reconstruct(i+1,j+1);}
    else if (DP[i][j+1]>DP[i+1][j])reconstruct(i,j+1);
    else reconstruct(i+1,j);


}

void solve()
{
    cin>>a>>b;n=a.length();m=b.length();
rep(i,0,3002)rep(j,0,3002)DP[i][j]=0;
    ///int L=fun(0,0);return;
/*rep(i,0,n)
{
    cout<<"\n";rep(j,0,m)cout<<DP[i][j]<<" ";
}*/
//cout<<L<<"\n";

    repD(i,n-1,-1)
    {
        repD(j,m-1,-1)
        {
            if (a[i]==b[j])DP[i][j]=1+DP[i+1][j+1];
            else DP[i][j]=max(DP[i+1][j],DP[i][j+1]);
        }
    }

    reconstruct(0,0);cout<<ans<<"\n";




}
signed main()
{

    srand(time(NULL));

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

///freopen("input.txt","r",stdin);
///freopen("output.txt","w",stdout);

    int t=1;
///cin>>t;
    rep(a,0,t)
    {
        ///cout<<"Case "<<a+1<<": ";
        solve();
    }
}


Measured memory_bytes: 118528
#include<iostream>
using namespace std; // 575

const int MAX = 100000;
int main() {
	static int N, a[MAX][3];
	cin >> N;
	for (int i = 0;i < N;++ i) cin >> a[i][0] >> a[i][1] >> a[i][2];
	static int dp[MAX][3];
	for (int i = 0;i < N;++ i) for (int j = 0;j < 3;++ j) dp[i][j] = 0;
	for (int i = 0;i < 3;++ i) dp[0][i] = a[0][i];
	for (int i = 1;i < N;++ i) for (int j = 0;j < 3;++ j) for (int k = 0;k < 3;++ k) if (j != k) dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
	cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2]));
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

3状態の遷移を考えるだけだね、O(N)
*/

Measured memory_bytes: 2560
s = input()
ans = 0
lb = 0
rb = len(s) - 1
while rb - lb > 0:
    if s[lb] == s[rb]:
        lb += 1
        rb -= 1
    elif s[lb] == 'x':
        lb += 1
        ans += 1
    elif s[rb] == 'x':
        rb -= 1
        ans += 1
    else:
        ans = -1
        break
print(ans)
# https://img.atcoder.jp/code-festival-2017-qualc/editorial.pdf


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

int main()
{
	unsigned long long int sum = 0;

	int n;

	cin >> n;

	vector<int> v(n);
	for (auto &x : v)
		cin >> x;
	sort(v.begin(), v.end());

	for (int i = 1; i < n; i++)
	{
		sum += v[n - i / 2 - 1];
	}

	cout << sum;

	return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	ll m;
	cin>>m;
	if(n==m)
	{
		cout<<"Yes"<<"\n";
	}
	else
	{
		cout<<"No"<<"\n";
	}
	return 0;
	
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){
    int a,b,c;cin >> a>>b>>c;
    if(a+b+c<=21)cout << "win"<<endl;
    else cout << "bust"<<endl;

    
    
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
void pre(){}
void solve(){
    ll l,r,d;cin>>l>>r>>d;
    cout<<(r)/d - (l-1)/d<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, K; cin >> n >> K;
  if (K > (n - 1) * (n - 2) / 2) {
    cout << -1 << '\n';
  }
  else {
    cout << n - 1 + (n - 1) * (n - 2) / 2 - K << '\n';
    for (int i = 1; i < n; ++i) {
      cout << 1 << ' ' << i + 1 << '\n';
    }
    int left = (n - 1) * (n - 2) / 2 - K;
    for (int i = 1; i < n; ++i) for (int j = 1; j < i and left; ++j) {
      cout << i + 1 << ' ' << j + 1 << '\n';
      --left;
    }
  }
}


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

typedef long long int ll;
typedef vector<int> vi;            
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int>     pii;
typedef vector<bool> vb;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#ifdef LOCAL
    #include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

void solve(){
    ll n; cin>>n;
    vl a(n); for(auto &e: a) cin>>e;
    ll curr = 0;
    ll answer = 0;
    for(auto &e: a){
        curr = max(curr, e);
        answer += curr - e;
    }
    cout<<answer<<endl;
}   

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen(".inp.txt", "r", stdin);
        freopen(".out.txt", "w", stdout);
        freopen(".err.txt", "w", stderr);
    #endif
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 4764
import java.util.*;
import java.io.*;
   class Main{

     public static void main(String []args) throws Exception{
      // System.out.println("Hello World");
        BufferedReader br =new BufferedReader (new InputStreamReader(System.in));
        String s;
        int N;
        s=br.readLine();
        N=Integer.parseInt(s);
        int pos=-1;
        int a=0,b=0,c=0;
        String ss[];
        long sum=0l;
        long dp[][]=new long[N][3];
        s=br.readLine();
        ss=s.split(" ");
            a=Integer.parseInt(ss[0]);
            b=Integer.parseInt(ss[1]);
            c=Integer.parseInt(ss[2]);
            int max=Math.max(a,b);
        dp[0][0]=a;
        dp[0][1]=b;
        dp[0][2]=c;
        // System.out.println("initial"+sum+"pos"+pos);
        for(int i=1;i<N;i++)
        {  
            s=br.readLine();
            ss=s.split(" ");
            a=Integer.parseInt(ss[0]);
            b=Integer.parseInt(ss[1]);
            c=Integer.parseInt(ss[2]);
           // max=Math.max(a,b);
            //max=Math.max(max,c);
            dp[i][0]=a*1l+Math.max(dp[i-1][1],dp[i-1][2])*1l;
           dp[i][1]=b*1l+Math.max(dp[i-1][0],dp[i-1][2])*1l;
           dp[i][2]=c*1l+Math.max(dp[i-1][1],dp[i-1][0])*1l;
           
        }
        System.out.println(Math.max(dp[N-1][0],Math.max(dp[N-1][1],dp[N-1][2])));
        
     }
}

Measured memory_bytes: 49616
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define vii vector<int,int>

using namespace std;


int main(){
    int a,b;
    cin >> a >> b;
    if(a+b == 15) cout << "+" << endl;
    else if(a*b == 15) cout << "*" << endl;
    else cout << "x"<< endl;
}


Measured memory_bytes: 256
c[1100000],n=1e6;main(i,j){for(i=2;i*i<n;i++)for(j=i;!c[i]&&j<n;c[j+=i]=1);for(i=2;i<n;i++)c[i]=c[i-1]+!c[i];for(;~scanf("%d",&n);printf("%d\n",c[n]));}

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


int main() {
  int N,M;
  cin >> N >> M;
  
  vector<int> Work(M);
  for (int i = 0;i < M;i++){
    cin >> Work.at(i);
  }
  
  int Sum = 0;

  for (int i = 0;i < M;i++){
    Sum += Work.at(i);
  }
  if (Sum > N){
    cout << -1 << endl;
  } else {
    cout << N - Sum << endl;
  }
  
}


Measured memory_bytes: 3672
#include <stdio.h>
int main(void) {
  int a, b;
  char op;

  while (scanf("%d %c %d", &a, &op, &b) == 3 && op != '?') {

    switch (op) {

      case '+': a += b; break;
      case '-': a -= b; break;
      case '*': a *= b; break;
      case '/': a /= b; break;

      default: continue;
    }
  printf("%d\n", a);
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef complex<ll> P;
#define real X
#define imag Y

bool check(ll a, ll b, ll c) {
  return (a + b > c) && (a + c > b) && (b + c > a) && a != b && a != c && b != c && a <= b && b <= c;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (j == i) continue;
      for (int k = 0; k < n; ++k) {
	if (k == i || k == j) continue;
	if (check(a[i], a[j], a[k])) {
	  ++ans;
	}
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int placeNum=sc.nextInt();
	int temp=sc.nextInt();
	int ideal=sc.nextInt();
	int ans=0;
	double dis=10000;
	int placeHigh[]=new int[placeNum];
	for(int i=0;i<placeHigh.length;i++) {
		placeHigh[i]=sc.nextInt();
		if(dis>Math.abs(ideal-(temp-placeHigh[i]*0.006))) {
			dis=Math.abs(ideal-(temp-placeHigh[i]*0.006));
			ans=i+1;
		}
	}
	System.out.println(ans);

}
}

Measured memory_bytes: 24276
N,T = map(int,input().split())
t = list(map(int,input().split()))
t.append(10**18)
ans = 0
for t1,t2 in zip(t[:-1],t[1:]):
    if t2-t1 < T:
        ans += t2-t1
    else:
        ans += T
print(ans)

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

int main(){
  long long n;
  cin>>n;
  vector<long long> l(100);
  for(long long i =0; i<n; i++){
    cin>>l.at(i);
  }
  long long ans =0;
  for(long long i =0; i<n-2; i++){
    for(long long j =i+1; j<n-1; j++){
      long long l1 = l.at(i);
      long long l2 = l.at(j);
      if(l1 != l2){
	      for(long long k=j+1; k<n; k++){
          long long l3 = l.at(k);
          if(l3 != l1 && l3 != l2){
            if(l1 + l2 >l3 && l2 + l3 > l1 && l3 + l1 > l2) ans++;
	        }
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14
int ans = INF;

void ri(vi va){
    if(va.size() == 2){
        if(va[0] == va[1])
            ans = va[0];
        else
            ans = abs(va[0] - va[1]);
        return;
    }
    vi sa;
    auto itr = va.begin();
    auto itrr = itr++;
    while(1){
        if(*itr == *itrr)
            sa.push_back(*itr);
        else
            sa.push_back(abs(*itr - *itrr));
        itr += 2;
        itrr += 2;
        if(itrr == va.end())break;
    }
    ri(sa);
}


signed main(){
    int n;
    cin >> n;
    vi va;
    rep(i, pow(2, n - 1)){
        int a, b;
        cin >> a >> b;
        if(a == b)va.push_back(a);
        else 
            va.push_back(abs(a - b));
    }
    ri(va);
    cout << ans << endl;    
}

Measured memory_bytes: 4340
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstring>
using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 0;i < n;i++){
        int x;
        cin >> x;
        v.push_back(x);
    }
    int ans = 0;
    sort(v.begin(), v.end());
    for(int i = 0;i < n-2;i++){
        for(int j = i+1;j < n-1;j++){
            ans += (int)(upper_bound(v.begin(), v.end(), v[i]+v[j]-1) - v.begin()) - j - 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
// https://misteer.hatenablog.com/entry/AGC005-Bs
int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) {
        cin >> a[i];
        a[i]--;
    }
    //ある値×その区間長さ
    vector<int> idx(N);
    REP(i, N) { idx[a[i]] = i; }
    set<int> s;
    ll ans = 0;
    REP(x, N) {
        int l, r;
        //小さいものから始める
        int i = idx[x];
        s.insert(i);
        auto iterator = s.find(i);
        if(iterator == s.begin()) {
            //自分より小さいものが存在しない
            l = -1;
        } else {
            iterator--;
            l = *iterator;
        }
        iterator = s.find(i);
        iterator++;
        if(iterator == s.end()) {
            //自分より小さいものが存在しない
            r = N;
        } else {
            r = *iterator;
        }
        // cout << (x + 1) * (i - l) * (r - i) << endl;
        // cout << i - l << " ::::" << r - i << endl;
        ans += (x + 1) * (i - l) * (r - i);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int MAX_N = 100000, INDEX = 1;
const int MAX_T = 1000000000, MAX_K = 1000000000, INF = MAX_T + MAX_K + 1;

int n, c, k, t[MAX_N + 1 + INDEX];

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

    cin >> n >> c >> k;

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

    t[n + 1] = INF;

    sort(t + INDEX, t + INDEX + n, less<int>());

    int ans = 0, last = n + 1;
    for (int i = n; i >= 1; i--) {
        if (last - i >= c || t[last] - t[i] > k) {
            ans++, last = i;
        }
    }

    cout << ans << endl;

    return 0;
}


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

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var g1 = new int[]{1,3,5,7,8,10,12};
            var g2 = new int[]{4,6,9,11};
            var g3 = new int[]{2};
            
            var _ = Console.ReadLine().Split();
            var x = int.Parse(_[0]);
            var y = int.Parse(_[1]);

            var flag = false;
            if(g1.Contains(x) && g1.Contains(y)){
                flag = true;
            }
            if(g2.Contains(x) && g2.Contains(y)){
                flag = true;
            }
            if(g3.Contains(x) && g3.Contains(y)){
                flag = true;
            }

            Console.WriteLine(flag ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11220
import sys

a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
n=int(input())
d=[int(input())for _ in range(n)]
lsa,lsb,lsc=[0]*3,[0]*3,[0]*3

for i in d:
  if i in a:
    lsa[a.index(i)]+=1
    
  elif i in b:
    lsb[b.index(i)]+=1
    
  elif i in c:
    lsc[c.index(i)]+=1
    
if all(i>=1 for i in lsa):
  print("Yes")
  sys.exit()
  
elif all(i>=1 for i in lsb):
  print("Yes")
  sys.exit()
  
elif all(i>=1 for i in lsc):
  print("Yes")
  sys.exit()
  
for i in range(3):
  if lsa[i]>=1 and lsb[i]>=1 and lsc[i]>=1:
    print("Yes")
    sys.exit()
    
if lsa[0]>=1 and lsb[1]>=1 and lsc[2]>=1 or lsa[2]>=1 and lsb[1]>=1 and lsc[0]>=1:
  print("Yes")
  sys.exit()
  
print("No")

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

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

using ll = int64_t;

using namespace std;


int64_t n,m;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n >> m;

    using P = pair<ll,ll>;

    int64_t ans = 0;

    priority_queue<P> p;
    priority_queue<int64_t> q;

    REP(i,n){
        int64_t a,b;cin >> a >> b;
        p.emplace(-a,b);
    }

    for(int64_t i = 1;i <= m;i++){
        while(p.size()){
            if(-p.top().first <= i){
                q.push(p.top().second);
                p.pop();
            }else break;
        }
        if(q.size()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << '\n';
}



Measured memory_bytes: 6524
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func frog2(n, steps int, heights []int) int {
	minInt := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}
	absInt := func(a int) int {
		if a < 0 {
			return -a
		}
		return a
	}
	costs := make([]int, n)
	costs[0] = 0
	costs[1] = absInt(heights[1] - heights[0])

	var curMin, minCost int
	for i := 2; i < n; i++ {
		minCost = absInt(heights[i]-heights[i-1]) + costs[i-1]
		for j := 2; j <= minInt(steps, i); j++ {
			curMin = absInt(heights[i]-heights[i-j]) + costs[i-j]
			if curMin < minCost {
				minCost = curMin
			}
		}
		costs[i] = minCost
	}
	return costs[n-1]
}

var inp *bufio.Scanner

func ScanInt() int {
	inp.Scan()
	res, _ := strconv.Atoi(inp.Text())
	return res
}

func ScanIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		inp.Scan()
		res[i], _ = strconv.Atoi(inp.Text())
	}
	return res
}

func main() {
	inp = bufio.NewScanner(os.Stdin)
	inp.Split(bufio.ScanWords)
	stones := ScanInt()
	steps := ScanInt()
	heights := ScanIntArray(stones)
	fmt.Println(frog2(stones, steps, heights))
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() {
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k>a){
        k = k-a;
        if(k>b){
            k=k-b;
            cout<<a-k;
        }
        else{
            cout<<a;
        }
    }
    else{
        cout<<k;
    }

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    string s;
    cin >> n >> s;
    using P = pair<string, string>;
    map<P, int> mp;
    rep(mask, 1<<n) {
        string x, y;
        rep(i, n) {
            if(mask&(1<<i)) x+= s[i];
            else y += s[i];
        }
        mp[make_pair(x, y)]++;
    }
    ll ans = 0LL;
    rep(mask, 1<<n) {
        string x, y;
        rep(i, n) {
            if(mask&(1<<i)) x+= s[i+n];
            else y += s[i+n];
        }
        reverse(all(x));
        reverse(all(y));
        ans += mp[make_pair(y, x)];
    }
    cout << ans << endl;
    return 0;
}

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

int N;
int sosu_t[55556] = {0};
vector<int> sosu;

main()
{
    cin >> N;
    for (int i = 2; i <= sqrt(55555); i++) {
        for (int j = 2*i; j <= 55555; j+=i) {
            sosu_t[j] = 1;
        }
    }
    for (int i = 2; i < 55555; i++) {
        if (sosu_t[i] == 0) {
            sosu.push_back(i);
        }
    }

    int cnt = 0;
    for (auto itr = sosu.begin(); itr != sosu.end(); itr++) {
        if (*itr%5 == 1) {
            if (cnt == 0) {
                cout << *itr;
            } else {
                cout << " " << *itr;
            }
            cnt++;
            if (cnt == N) {
                break;
            }
        }
    }
    cout << endl;
}

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

namespace _20200328_ABC160C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadStringList(2);

            //入力の変換
            string[] sp = input[0].Split(' ');
            int K = int.Parse(sp[0]);
            int N = int.Parse(sp[1]);

            sp = input[1].Split(' ');
            List<int> A = new List<int>();
            for (int i = 0; i < N; i++)
            {
                A.Add(int.Parse(sp[i]));
            }

            //処理
            List<int> dist = new List<int>();
            //各家の間の距離
            for (int i = 1; i < N; i++)
            {
                dist.Add(A[i] - A[i - 1]);
            }
            //1軒目とN軒目の間
            dist.Add(A[0] + (K - A[N - 1]));

            int max = dist.Max();

            int result = K - max;

            Console.WriteLine(result);
        }

        private static List<string> ReadStringList(int numberOfLines)
        {
            var stringList = new List<string>();

            for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++)
            {
                stringList.Add(Console.ReadLine().Trim());
            }

            return stringList;
        }

    }
}


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

int main(){
  long long n, k;
  cin >> n >> k;
  vector<long long> c(100010);
  for(int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    c.at(a) += b;
  }
  for(int i = 0; i < c.size(); i++){
    if(c.at(i) > 0){
      k -= c.at(i);
      if(k <= 0){
        cout << i << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164

int main(){
	int l,arg,theta;
	double x,y;

	x = y = 0.0;
	theta = 0;

	while(1){
		scanf("%d,%d",&l,&arg);
		if(l == 0 && arg == 0){
			break;
		}
		x += l*1.0*sin(theta*PI/180.0);
		y += l*1.0*cos(theta*PI/180.0);
		theta += arg;
	}

	printf("%d\n%d\n",(int)x,(int)y);

	return 0;
}

Measured memory_bytes: 604
import sys
sys.setrecursionlimit(10 ** 7)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def SI(): return input()


def main():
    N = int(input())
    W = LI()
    S12 = sum(W)
    ans = S12
    now = 0
    for i in range(N):
        now += W[i]
        ans = min(ans, abs(S12-now - now))

    print(ans)


main()


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

void solve(int N) {
  rep2(i, 1, 10) {
    rep2(j, 1, 10) {
      if (i * j == N) {
        cout << "Yes" << endl;
        return;
      }
    }
  }
  cout << "No" << endl;
}

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

  solve(N);
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int Mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void f()
{
  int n,l;
  string s;
  cin>>n;
  pair<string, pair<int ,int> > p[n];
  for(int i=0;i<n;i++)
  {
    cin>>s>>l;
    p[i]=mp(s,mp(-1*l,i+1));
  }
  sort(p,p+n);
  for(auto i:p)
  {
    cout<<i.S.S<<nl;
  }
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3604
import sys
nodes = ['OFFSET'] + [-1] * 4000000
_num_nodes = 0
outputs = [None] * 2000000
_num_outputs = 0

def max_heapify(idx):
    left_idx = idx * 2
    right_idx = left_idx + 1

    max_idx = idx

    if nodes[left_idx] > nodes[max_idx]:
        max_idx = left_idx
    if nodes[right_idx] > nodes[max_idx]:
        max_idx = right_idx

    if max_idx != idx:
        tmp = nodes[idx]
        nodes[idx] = nodes[max_idx]
        nodes[max_idx] = tmp
        max_heapify(max_idx)
    return


def insert(node_no):
    global _num_nodes
    nodes[_num_nodes+1] = node_no
    _num_nodes += 1
    idx = _num_nodes
    while idx > 1:
        parent_idx = idx // 2
        if nodes[idx] > nodes[parent_idx]:
            tmp = nodes[parent_idx]
            nodes[parent_idx] = nodes[idx]
            nodes[idx] = tmp
        else:
            break
        idx = parent_idx
    return


def extract():
    global _num_outputs
    outputs[_num_outputs] = nodes[1]
    _num_outputs += 1
    global _num_nodes
    nodes[1] = nodes[_num_nodes]
    nodes[_num_nodes] = -1
    _num_nodes -= 1
    max_heapify(1)
    return


def main():
    commands = sys.stdin.readlines()
    for command in commands:
        if command[0] == 'i':
            insert(int(command[7:]))
        elif command[1] == 'x':
            extract()
        elif command[1] == 'n':
            break

    for i in range(_num_outputs):
        print(outputs[i])
    return


main()



Measured memory_bytes: 246320
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 5;
ll a[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int x, y;
    cin >> x >> y;
    if(x == y)
        cout << string(y, (char)(y + '0'));
    else
        cout << string(max(x, y), (char)(min(x, y) + '0'));
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>   //AA06( 23/ 07/ 20) If u see my code, Have a Good Day! (^_^)

int main()
{
    int N, A, B, i, x = 0, y = 0;

    scanf("%d%d%d", &N, &A, &B);

    for(i = 0; ; ++i) {

        A++;
        x++;

        if(B - A == 1)
            break;

        else if(B - A == 0) {

            printf("Borys\n");

            return 0;
        }

        B--;
        y++;

    }

    if(x > y)
        printf("Alice\n");

    else
        printf("Borys\n");

    return 0;
}


Measured memory_bytes: 1640
program main
  implicit none
  integer :: N, K, Q
  integer, allocatable :: A(:)
  integer, allocatable :: people(:)
  integer :: i

  !
  read (*,*) N,K,Q
  allocate(A(Q))
  do i = 1,Q
     read(*,*) A(i)
  end do
  allocate(people(N))
  people = 0
  do i = 1,Q
     people(A(i))  = people(A(i)) + 1
  end do

  ! calc point
  people(:) = K+people(:)-Q
  do i = 1,N
     if (people(i) >0) then
        write(*,'(a)') 'Yes'
     else
        write(*,'(a)') 'No'
     end if
  end do
  stop
end program main

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int x; cin >> x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 3632
#include <algorithm>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF INT_MAX
#define P pair<int,int>
#define prique priority_queue
using namespace std;

signed main() {
	int x, a;
	cin >> x >> a;
	if (x < a)cout<<0<<endl;
	else cout << 10 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
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 (b<a) {a=b; return 1;} return 0;}

int next_combination(int sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}
// for (int bit = (1<<k)-1 ;bit < (1<<n); bit = next_combination(bit))

int n, m, ans;
vector<vector<int>> to;
vector<bool> seen;

void dfs(int v) {
    seen[v] = true;
    bool flag = true;
    rep(i, n) {
        if (!seen[i]) {
            flag = false;
            break;
        }
    }
    if (flag) ans++;
    for (auto nv : to[v]) {
        if (seen[nv]) continue;
        dfs(nv);
    }
    seen[v] = false;
}

int main(){
    cin >> n >> m;
    to.resize(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].emplace_back(b);
        to[b].emplace_back(a);
    }

    seen = vector<bool>(n, false);
    dfs(0);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a[8],i;
	for(i=0;i<8;i++) scanf("%d",&a[i]);
	for(i=0;i<8;i+=2){
		if(a[i]==1) printf("%d\n",a[i+1]*6000);
		if(a[i]==2) printf("%d\n",a[i+1]*4000);
		if(a[i]==3) printf("%d\n",a[i+1]*3000);
		if(a[i]==4) printf("%d\n",a[i+1]*2000);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());
//int randt(int l, int r){ return (rando() % (r - l + 1) + l); }

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5;
int mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
ll infll = 1e18 + 7;

int n, l;
string a[N];

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> l;
    ForE(i, 1, n){
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    ForE(i, 1, n){
        cout << a[i];
    }
    
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 6792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int k;cin >> k;
    vl con;
    queue<ll> q;
    for(int i=1;i<=9;i++) q.push(i);
    for(int i=1;i<=9;i++) con.emplace_back(i);
    while(con.size()<=100000){
        ll t = q.front();q.pop();
        int d = t%10;
        for(int i=-1;i<=1;i++){
            if((d==0 && i==-1) || (d==9 && i==1)) continue;
            ll ne = t*10 + d + i;
            con.emplace_back(ne);
            q.push(ne);
        } 
    }
    sort(con.begin(),con.end());
    cout << con[k-1] << endl;
}

Measured memory_bytes: 1620
N = int(input().strip())
A = [int(str) for str in input().strip().split()]
B = [int(str) for str in input().strip().split()]
C = [int(str) for str in input().strip().split()]

res = 0

for i in range(N):
    res += B[A[i] - 1]
    if i >= 1:
        if A[i] - A[i - 1] == 1:
            res += C[A[i] - 2]

print(res)

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

int main()
{
	int N, K;
	int cnt = 0;

	cin >> N >> K;

	int h;
	for (int i = 0; i < N; i++)
	{
		cin >> h;
		if (h >= K)
			cnt++;
	}

	cout << cnt;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const int INF = INT_MAX / 2;

int main(){
    ll s; cin >> s;
    set<ll> m;
    while(1){
        if(m.count(s)>0) break;
        m.insert(s);
        if(s%2==0){
            s = s/2;
        } else {
            s = 3*s+1;
        }
    }
    cout << m.size() + 1 << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
E = [list(map(int, input().split())) for i in range(M)]
C = [-float("inf")] * (N+1)
C[1] = 0
for i in range(N-1):
    for e in E:
        a, b, c = e
        C[b] = max(C[b], C[a]+c)
ans = C[N]
for i in range(N):
    for e in E:
        a, b, c = e
        C[b] = max(C[b], C[a]+c)
if C[N] == ans:
    print(ans)
else:
    print("inf")


Measured memory_bytes: 3572
N = int(input())
S = input()

L = S.count('(')
R = S.count(')')

if L > R:
    S = S + (')' * (L - R))
if R > L:
    S = ('(' * (R - L)) + S

d = 0
mx = 0
for s in S:
    if s == ')':
        d += 1
    else:
        d -= 1
    mx = max(mx, d)

S = '(' * mx + S + ')' * mx
print(S)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define reep(i,a,b) for(int i=(a);i<(b);++i)

int main(){
	int n;
	cin>>n;
	reep(i,0,n){
		int a,b;
		cin>>a>>b;
		a%=b;
		if(a==0){
			cout<<b<<endl;
		}
		else{
			cout<<a<<endl;
		}
	}
}

Measured memory_bytes: 1160
use itertools::Itertools;
use proconio::fastout;
use proconio::input;
use proconio::marker::Usize1;

#[fastout]
fn main() {
    input!(n: usize, town: [(Usize1, Usize1); n]);

    let mut id = vec![0; n];
    for i in 0..n {
        id[town[i].0] = i
    }

    let mut col = vec![0; n];
    let mut siz = vec![0; n];
    let mut cnt = 0;
    let mut min = n + 1;
    for i in 0..n {
        let (_, y) = town[id[i]];
        if min == n - i {
            cnt += 1;
        }
        min = min.min(y);
        col[id[i]] = cnt;
        siz[cnt] += 1;
    }

    for i in 0..n {
        println!("{}", siz[col[i]])
    }
}


Measured memory_bytes: 10972
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <stdio.h>
#include <functional>
#include <chrono>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MAX_INF = 9223372036854775807;
constexpr ll MOD = (1e9 + 7);
//constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init, ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

template<class T>
T maxVec(vector<T>& v) {
	T ans = -INF;
	rep(i, 0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}


template <class C>
void print(const C & c, std::ostream & os = std::cout)
{
	std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, ", "));
	os << std::endl;
}
/*
ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}
*/
bool sortreverse(ll a, ll b) {
	return a > b;
}

ll kiriage(ll a, ll b) {
	if (a % b == 0)return a / b;
	return a / b + 1;
}

ll n, m, x, y, t, q, s,k,h,w;

class UnionFind {
public:
	vl parent;
	UnionFind(ll n) {
		parent = vl(n, -1);
	}

	ll root(ll n) {
		if (parent.at(n) < 0)return n;
		parent.at(n) = root(parent.at(n));
		return parent.at(n);
	}

	ll size(ll n) {
		return -parent.at(root(n));
	}

	bool connect(ll a, ll b) {
		if (root(a) == root(b))return false;
		a = root(a); b = root(b);
		if (size(a) < size(b))swap(a, b);
		parent[a] += parent[b];
		parent[b] = a;
		return true;
	}
};

int main() {
	cin >> n >> m;
	unordered_map<ll, vl> lang;
	rep(i, 1, m + 1) {
		lang[i] = vl{};
	}
	UnionFind uni(n);
	rep(i, 0, n) {
		cin >> k;
		rep(j, 0, k) {
			cin >> x;
			lang.at(x).push_back(i);
		}
	}
	rep(i, 1, m + 1) {
		if (lang[i].size() == 0)continue;
		rep(j, 0, lang.at(i).size() - 1) {
			uni.connect(lang[i][j], lang[i][j + 1]);
		}
	}
	if (uni.size(0) == n) {
		printf("YES");
	}
	else {
		printf("NO");
	}
}

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

int main() {
  ll n; cin >> n;
  
  vector<ll> nums(n);
  vector<ll> sums(n);
  for(int i = 0; i < n; i++) {
    ll temp; cin >> temp;
    nums.at(i) = temp;
    if(i == 0) {
      sums.at(i) = temp;
    } else {
      sums.at(i) = sums.at(i-1) + temp;
    }
  }
  ll ans = 0;
  ll mod = 1000000007;
  for(int i = n-1; i > 0; i--) {
    ll a = nums.at(i);
    ll b = sums.at(i-1) % mod;
    ans += a * b % mod;
    ans %= mod;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 6344
N,Y=map(int,input().split())
from itertools import product

for x,y in product(range(0,N+1),repeat=2):
    z=N-x-y
    if z>=0 and 10000*x+5000*y+1000*z==Y:
        print(x,y,z)
        exit()
print(-1,-1,-1)


Measured memory_bytes: 40812
import java.util.Scanner;

public class Main {

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

		if (a == b) {
			System.out.println(c);
		} else if (a == c) {
			System.out.println(b);
		} else {
			System.out.println(a);
		}

	}

}


Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>

using namespace std;

#define N 100000

pair<int, char> Left[N],Right[N];

void merge(pair<int,char> cards[],int left,int mid,int right){
    int n1 = mid - left;
    int n2 = right - mid;
    
    for(int i = 0;i < n1;++i){
        Left[i] = cards[left + i];
    }
    for(int i = 0;i < n2;++i){
        Right[i] = cards[mid + i];
    }
    Left[n1].first = Right[n2].first = __INT_MAX__;
    int i = 0;
    int j = 0;
    for(int k = left;k < right;++k){
        if(Left[i].first <= Right[j].first){
            cards[k] = Left[i++];
        }else{
            cards[k] = Right[j++];
        }
    }
}

void mergeSort(pair<int,char> cards[],int left,int right){
    int mid;
    if(left + 1 < right){
        mid = (left + right) / 2;
        mergeSort(cards,  left, mid);
        mergeSort(cards,  mid, right);
        merge(cards,left,mid,right);
    }
}

int partition(pair<int,char> cards[],int p,int r){
    // 末端
    int x = cards[r].first;
    int i = p - 1;
    for(int j = p;j < r;++j){
        if(cards[j].first <= x){
            ++i;
            swap(cards[i],cards[j]);
        }
    }
    swap(cards[i + 1],cards[r]);
    return i + 1;
}

void quickSort(pair<int,char> A[],int p,int r){
    if(p < r){
        int q = partition(A,p, r);
        quickSort(A,p, q - 1);
        quickSort(A,q+1, r);
    }
}

int main(void){
    int n;
    pair<int,char> cards1[N];
    pair<int,char> cards2[N];

    cin >> n;
    for(int i = 0;i < n;++i){
        cin >> cards1[i].second >> cards1[i].first;
        cards2[i].second = cards1[i].second;
        cards2[i].first = cards1[i].first;
    }
    
    quickSort(cards1,0, n - 1);
    mergeSort(cards2, 0, n);
    
    string stable = "Stable";
    
    for(int i = 0;i < n;++i){
        if(cards1[i].second != cards2[i].second){
            stable = "Not stable";
            break;
        }
    }
    
    // output
    cout << stable << endl;
    for(int i = 0;i < n;++i){
        cout << cards1[i].second << " " << cards1[i].first << endl;
    }
}



Measured memory_bytes: 6288