akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  cout<<A+B+C-max({A,B,C});
return 0;}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,b,a)     for(int i=b;i>=a;i--)
#define endl '\n'

#define ll long long int

long long int n,ans=0;
int gcd(int a ,int b)
{
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}

int main()
{
    
    
    cin>>n;
    rep(i,1,n)
 		rep(j,1,n)
 			rep(k,1,n)
 				ans+=gcd(i,gcd(j,k));
 	cout<<ans;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    set<ll> s;
    REP(i, 3) {
        ll x; cin >> x;
        s.insert(x);
    }
    cout << s.size() << endl;
}


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


int main(){
    string str;
    getline(cin,str);
    for(int i=0; i<str.size(); i++){
        if(str[i]>='a' && str[i]<='z'){
            str[i]-=32;
        }
        else if(str[i]>='A' && str[i]<='Z'){
            str[i]+=32;
        }
    }
    cout << str << endl;


}


Measured memory_bytes: 3164
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

char s[300][20];
char t[20];
int main(){
	ll n,m;
	ll st=0;
	scanf("%lld",&n);
	rep(i,0,n)scanf(" %s",s[i]);
	scanf("%lld",&m);
	rep(i,0,m){
		scanf(" %s",t);
		int flag=0;
		rep(j,0,n)if(!strcmp(s[j],t))flag=1;
		if(flag){
			if(st)printf("Closed by %s\n",t);
			else printf("Opened by %s\n",t);
			st^=1;
		}else printf("Unknown %s\n",t);
	}
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n,m,x,y;cin>>n>>m>>x>>y;
    int maxi=x+1,mini=y;
    rep(i,n){
        int X;cin>>X;
        chmax(maxi,X);
    }
    rep(i,n){
        int Y;cin>>Y;
        chmin(mini,Y);
    }
    //cout<<maxi<<" "<<mini<<endl;
    if(maxi>=mini)cout<<"War"<<endl;
    else cout<<"No War"<<endl;
}

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

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    double squ, ans=0;
    squ = w*h/2;
    if(w/2==x && h/2==y){
        ans = 1;
    }
    cout << squ << " " << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int N, i, l, r, sum=0;
  scanf("%d", &N);
  for (i=0; i<N; i++) {
    scanf("%d %d", &l, &r);
    sum+=r-l+1;
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

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

	vector<int> primes;
	primes.push_back(2);
	for(int i = 3; i <= 999999; i += 2){
		bool ok = true;
		for(int j = 2; j * j <= i; j++){
			if(i % j == 0)ok = false;
		}
		if(ok)primes.push_back(i);
	}
	int n;
	while(cin >> n){
		int ans = 0;
		for(auto i:primes)if(i <= n)ans++;
		cout << ans << '\n';
	}
	return 0;
}
// Write Here



Measured memory_bytes: 3408
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    for (i in s.indices) {
        if (i % 2 == 1 && s[i] == 'R' ||
                i % 2 == 0 && s[i] == 'L') {
            println("No")
            return
        }
    }
    println("Yes")
}

Measured memory_bytes: 31404
H, W, A, B = gets.split.map(&:to_i)

d = 1

B.times {
	A.times { print d }
	d ^= 1
	(W-A).times { print d }
	d ^= 1
	puts
}
(H-B).times {
	d ^= 1
	A.times { print d }
	d ^= 1
	(W-A).times { print d }
	puts
}


Measured memory_bytes: 2812
unittest
{
	assert( [ "4 3", "1 2", "2 3", "3 4" ].solve == 6 );
	assert( [ "5 4", "1 2", "1 3", "1 4", "4 5" ].solve == 48 );
	assert( [ "16 22", "12 1", "3 1", "4 16", "7 12", "6 2", "2 15", "5 16", "14 16", "10 11", "3 10", "3 13", "8 6", "16 8", "9 12", "4 3" ].solve == 271414432 );
	
	assert( [ "4 3", "1 2", "1 3", "1 4" ].solve == 0 );		// 追加ケース
}



import std.container;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s"( n, k );
	auto abs = new long[ 2 ][ n - 1 ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
		ab[] -= 1;
	}
	
	// dfsで塗り方を探索
	const M = 10L ^^ 9 + 7;
	auto ans = ModWorld!M( k );
	auto nss = toAdjacencyList!true( n, abs );
	auto cs = new long[ n ];
	cs[] = k;
	cs[ 0 ]--;
	auto stack = make!SList( 0L );
	while( !stack.empty )
	{
		auto f = stack.front;
		stack.removeFront;
		
		foreach( t; nss[ f ] )
		{
			if( cs[ t ] < k ) continue;
			ans *= cs[ f ];
			cs[ f ]--;				// 自分を塗り済なので-1する
			cs[ t ] = k - 2;		// 自分と親を塗り済なので-2する
			stack.insert( t );
		}
	}
	return ans;
}

// 辺配列から隣接リストを作成
auto toAdjacencyList( bool undirected = false )( long n, long[ 2 ][] es )
{
	auto nss = new long[][ n ];
	foreach( e; es )
	{
		nss[ e[ 0 ] ] ~= e[ 1 ];
		static if( undirected ) nss[ e[ 1 ] ] ~= e[ 0 ];
	}
	return nss;
}

// モジュラ整数型（n mod M）
struct ModWorld( long M )
{
	long n;
	
	void opUnary( string OP )() if( OP == "++" ){ this.n = ( this.n + 1 ) % M; }
	void opUnary( string OP )() if( OP == "--" ){ this.n = ( this.n + M - 1 ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "+"  ){ this.n = ( this.n + r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "-"  ){ this.n = ( this.n + M - r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "*"  ){ this.n = ( this.n * r.n ) % M; }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "/"  ){ this *= r ^^ ModWorld( M - 2 ); }
	void opOpAssign( string OP )( ModWorld r ) if( OP == "^^" )
	{
		auto a = this.n;
		this.n = 1L;
		for( auto i = r.n; 0 < i; i >>= 1 )
		{
			if( i & 1 ) this.n = ( this.n * a ) % M;
			a = ( a * a ) % M;
		}
	}
	auto opBinary( string OP )( ModWorld r ){ auto l = this; l.opOpAssign!OP( r ); return l; }
	
	void opAssign( long r ){ this.n = r; }
	void opOpAssign( string OP )( long r ){ this.opOpAssign!OP( ModWorld( r ) ); }
	auto opBinary( string OP )( long r ){ return this.opBinary!OP( ModWorld( r ) ); }
	auto opBinaryRight( string OP )( long l ){ return ModWorld( l ).opBinary!OP( this ); }
	auto opEquals( long r ){ return this.n == r; }
	
	auto toString(){ return this.n.to!string; }
}


Measured memory_bytes: 13072
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
void no(){
  cout<<"No"<<endl;
  exit(0);
}
VVI egs;
VI ff,tmn,tmx,tpar;
const in una=1e15;
tuple<in,in,in> dfs(in u, in pr){
  in cpar=-1;
  in cmn=-una;
  in cmx=una;
  in imn,imx,ipr;
  forv(i,egs[u]){
    if(egs[u][i]==pr)
      continue;
    tie(imn,imx,ipr)=dfs(egs[u][i],u);
    if(ipr!=-1){
      if(cpar==ipr)
	no();
      cpar=!ipr;
    }
    cmn=max(cmn,imn-1);
    cmx=min(cmx,imx+1);
  }
  if(cmn>cmx)
    no();
  if(cmn==cmx && (cmn%2+2)%2!=cpar)
    no();
  if(ff[u]!=una){
    if(cpar!=-1 && ff[u]!=una && cpar!=ff[u]%2)
      no();
    if(ff[u]!=una && (ff[u]>cmx || ff[u]<cmn))
      no();
    if(ff[u]!=una){
      cpar=ff[u]%2;
      cmn=cmx=ff[u];
    }
  }
  tmn[u]=cmn;
  tmx[u]=cmx;
  tpar[u]=cpar;
  return tie(cmn,cmx,cpar);
}
void writ(in u, in pr, in cc){
  --cc;
  if(cc<tmn[u])
    cc+=2;
  ff[u]=cc;
  forv(i,egs[u]){
    if(egs[u][i]==pr)
      continue;
    writ(egs[u][i],u,cc);
  }
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  egs.resize(n);
  in ta,tb;
  forn(z,n-1){
    cin>>ta>>tb;
    --ta;
    --tb;
    egs[ta].PB(tb);
    egs[tb].PB(ta);
  }
  in k;
  cin>>k;
  ff.resize(n,una);
  in v;
  forn(z,k){
    cin>>v;
    cin>>ff[v-1];
  }
  in cmn,cmx,cp;
  tmn.resize(n);
  tmx.resize(n);
  tpar.resize(n);
  tie(cmn,cmx,cp)=dfs(0,-1);
  assert(cp!=-1);
  in cc=cmn;
  while((cc%2+2)%2!=cp)
    ++cc;
  assert(cc<=cmx);
  writ(0,-1,cc+1);
  cout<<"Yes\n";
  forn(i,n)
    cout<<ff[i]<<"\n";
  return 0;
}


Measured memory_bytes: 20608
#include <iostream>
#include <string>
#include <utility>
#include <map>
#include <vector>
#include <cmath>
using namespace std;
using ll = long long;

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

int main()
{
    ll x,y;
    cin >> x >> y;
    if(abs(x-y) <= 1)cout << "Brown" << endl;
    else cout << "Alice" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
typedef long long ll;

int main()
{
	ll N,K;
	cin >> N >> K;
	ll ans = 0;
	ll cnt = 0;
	for (ll i = K; i < N+1; i+=K) {
		cnt++;
	}
	ans = pow(cnt,3);
	if (K % 2 == 0) {
		cnt = 0;
		for (ll i = 1; i < N + 1; i++) {
			if (i%K == (K / 2))cnt++;
		}
		ans += pow(cnt,3);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;


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();
        int x = sc.nextInt();

        int count = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b && i * 500 + j * 100 <= x; j++) {
                int tmp = i * 500 + j * 100;
                int rest = x - tmp;
                if (rest >= 0 && rest % 50 == 0 && rest / 50 <= c) count++;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ii> P;
typedef unsigned long long int ull;
const int MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;

int main(){
    int n;cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end(),greater<int>());
    ll ans=a[0];
    for(int i=1;i<=(n-2)/2;i++){
        ans+=a[i]*2;
    }
    if(n%2==1) ans+=a[(n-2)/2+1];
    cout<<ans<<endl;
}

Measured memory_bytes: 4788
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

struct Edge{
	int to,cap,rev;
	Edge(){}
	Edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
};

vector<Edge> G[1100];
bool used[1100];

void add_edge(int from,int to,int cap){
	G[from].push_back(Edge(to,cap,G[to].size()));
	G[to].push_back(Edge(from,0,G[from].size()-1));
}

int dfs(int v,int t,int f){
	if(v==t) return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		Edge &e =G[v][i];
		if(!used[e.to]&&e.cap>0){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow=0;
	for(;;){
		for(int i=0;i<1100;i++){
			used[i]=0;
		}
		int f=dfs(s,t,1e9);
		if(f==0)return flow;
		flow+=f;
	}
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
	while(1){
		int n,m; cin >> n >> m;
		if(n==0&&m==0)break;
		vector<ll> b(n),r(m);
		for(int i=0;i<1100;i++){
			G[i].clear();
			used[i]=0;
		}
		int sv=0; int tv=1001;
		for(int i=0;i<n;i++){
			cin >> b[i];
			add_edge(sv,i+1,1);
		}
		for(int i=0;i<m;i++){
			cin >> r[i];
			add_edge(501+i,tv,1);
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(GCD(b[i],r[j])!=1){
					add_edge(i+1,j+501,1);
				}
			}
		}
		cout << max_flow(sv,tv) << endl;
	}
	return 0;
}


Measured memory_bytes: 9332
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	bool yes = false;
	for (int i = 1; i < 10; ++i) {
		for (int j = 1; j < 10; ++j) {
			if (i * j == N) { yes = true; }
		}
	}

	cout << (yes ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
X, N = [int(i) for i in input().split(' ')]
if N>0:
  p = [int(i) for i in input().split(' ')]
  abs_list = {}

  for i in range(-100,200):
    if(i in p):
      continue
    abs_list[i] = abs(X - i)
  min_k = min(abs_list, key=abs_list.get)
  print(min_k)
else:
  print(X)




Measured memory_bytes: 61844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <set>
#include <vector>

using namespace std;

int main() {

  while( true ) {
    int n, h;
    cin >> n >> h;
    if ( n == 0 and h == 0 ) break;
    
    set<tuple<int, int, int>> s;
    for ( int i = 0; i < h; i++ ) {
      string c;
      int a, b;
      cin >> c >> a >> b;
      a--;b--;
      if ( "xy" == c ) {
	for ( int j = 0; j < n; j++ ) {
	  s.insert( make_tuple( a, b, j ) );
	}
      }	else if ( "xz" == c ) {
	for ( int j = 0; j < n; j++ ) {
	  s.insert( make_tuple( a, j, b ) );
	}
      } else {
	for ( int j = 0; j < n; j++ ) {
	  s.insert( make_tuple( j, a, b ) );
	}
      }
    }
    cout << n * n * n - s.size() << endl;
  }
}

Measured memory_bytes: 4336
n = int(input())
ans = 1
m = 1000000000000000000
a = map(int, input().strip().split(" "))
a = list(a)

for i in range(n):
    if a[i]==0:
        ans = 0

for i in range(n):
    ans *= a[i]
    if ans > m:
        ans = -1
        break 

print(ans)

Measured memory_bytes: 21704
class Queue
  def initialize
    @arr = []
    @head = 0
    @tail = 0
  end

  def enque(x)
    @arr[@tail] = x
    @tail = @tail + 1
  end

  def deque
    x = @arr[@head]
    @head = @head + 1
    x
  end

  def size
    @tail - @head
  end
end

def roundrobin(q, queue)
  finished = []
  t = 0
  while queue.size != 0
    process = queue.deque
    if (process[1].to_i <= q)
      t = t + process[1].to_i
      process[1] = 0
      finished.push("#{process[0]} #{t}")
    else
      t = t + q
      process[1] = process[1].to_i - q
      queue.enque(process)
    end
  end

  puts finished.join("\n")
end



as = STDIN.gets.split(' ')

n = as[0].to_i
q = as[1].to_i

queue = Queue.new
n.times.each {
  queue.enque(STDIN.gets.split(' '))
}

roundrobin(q, queue)

Measured memory_bytes: 20420
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;

ll k;

ll f(ll x){
  return ((10 * x) % k + 7) % k;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> k;
  ll tmp  = 7;
  for (int i = 0; i < 5000000; ++i) {
    if(tmp % k == 0){
      cout << i+1 << endl;
      exit(0);
    }
    tmp = f(tmp);
  }

  cout << -1 << endl;


}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int N , X, sum;
    sum = 0;
    cin >> N >> X;
    vector<int> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec[i];
        sum += vec[i];
    }
    sort(vec.begin(),vec.end());
    cout << N + ((X - sum) / vec[0]) << endl;
}

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

int main()
{
    int N;
    scanf("%d", &N);
    int xN, yN, tN;
    xN = yN = tN = 0;

    bool flg = true;

    for (int i = 0; i < N; i++) {
        int t, x, y;
        scanf("%d %d %d", &t, &x, &y);

        int sum = abs(xN - x) + abs(yN - y);
        int sumt = abs(tN - t);

        if (sum > sumt) flg = false;
        if (sum % 2 == 1 && sumt % 2 != 1) flg = false;
        if (sum % 2 == 0 && sumt % 2 != 0) flg = false;

        xN = x, yN = y, tN = t;
    }

    if (!flg) printf("No\n");
    else printf("Yes\n");
}


Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

global_max = max(a)
count = 0
for i in range(n):
    if a[i] == global_max:
        count += 1
    if count == 2:
        break

for i in range(n):
    if a[i] == global_max:
        if count == 1:
            print(max(a[:i] + a[i + 1:]))
        else:
            print(global_max)
    else:
        print(global_max)


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S;
    ll K;
    cin >> S;
    cin >> K;
    ll N = S.size();
    unordered_set<ll> set;
    rep(i, N) {
        set.insert(S[i] - 'a');
    }
    if (set.size() == 1) {
        cout << (ll) N * K / 2 << '\n';
    } else {
        string T = S;
        ll cnt = 0;
        rep2(i, 1, N) {
            if (T[i] == T[i - 1]) {
                cnt++;
                T[i] = '1';
            }
        }
        if (S[0] == S[N - 1] && T[N - 1] != '1') {
            ll cnt2 = 1;
            S[0] = '1';
            rep2(i, 1, N) {
                if (S[i] == S[i - 1]) {
                    cnt2++;
                    S[i] = '1';
                }
            }
            cout << (ll) cnt + (ll) cnt2 * (K - 1) << '\n';
        } else {
            cout << (ll) cnt * K << '\n';
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    APoisonousCookies solver = new APoisonousCookies();
    solver.solve(1, in, out);
    out.close();
  }

  static class APoisonousCookies {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int a = in.nextInt();
      int b = in.nextInt();
      int c = in.nextInt();
      long d = c - a > 0 ? c - a : 0;
      long f = d - b > 0 ? d - b : 0;
      long res = Math.min(a, c) + Math.min(d, b) + Math.min(f, 1) + b;
      out.println(res);
    }

  }

  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

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

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

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

    public void close() {
    }

  }
}



Measured memory_bytes: 21076
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let mut d: Vec<i32> = readn(n);
    d.sort();
    let mut cnt = 1;
    for i in 1..n {
        if d[i-1] < d[i] {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
n = int(input())
xy = []
for _ in range(n):
    xy.append(list(map(int,input().split())))
a,b=xy[0]
m1=a+b
p1=xy[0]
m2=a-b
p2=xy[0]
p3=xy[0]
p4=xy[0]
m3=-a-b
m4=-a+b

for x,y in xy:
    if x+y > m1:
        m1=x+y
        p1 = [x,y]
    if x-y > m2:
        m2=x-y
        p2 = [x,y]
    if -x-y > m3:
        m3 = -x-y
        p3 = [x,y]
    if -x+y > m4:
        m4 = -x+y
        p4 = [x,y]
m = 0
for x0,y0 in [p1,p2,p3,p4]:
    for x1,y1 in [p1,p2,p3,p4]:
        dis=abs(x0-x1) + abs(y0-y1)
        if dis > m:
            m = dis
print(m)

Measured memory_bytes: 45292
#include <bits/stdc++.h>
        using namespace std;
		typedef long long int ll;
			int main(){	
			 
			 int A, B, Q;
			 cin >> A >> B >> Q;
			 vector<ll> s(A);
			 vector<ll> t(B);
			 vector<ll> x(Q);
			 ll INF = 5000000000000;
			 
			 for(int i=0; i<A; i++){
			     cin >> s.at(i);  
			 }
			 for(int i=0; i<B; i++){
			     cin >> t.at(i); 
			 }
			 for(int i=0; i<Q; i++){
			     cin >> x.at(i); 
			 }
			 
			 for(int i=0; i<Q; i++){
			        ll xx= x.at(i); 
			        ll left=0;
			        ll right=A-1;
			        while(right-left>1){
			            ll middle = (left + right)/2;
			            if( xx < s.at(middle) ){
			                right = middle; 
			            }else{
			                left= middle; 
			            }
			        }
			        ll sl, sr;
			        if( xx < s.at(0) ){
			            sl = -INF;
			            sr = s.at(0);
			        }else if(xx >s.at(A-1)){
			            sl = s.at(A-1);
			            sr = INF;
			        }else{
			            sl = s.at(left);
			            sr = s.at(right); 
			        }
			        
			        //cout<< i <<" "<<sl <<" "<< sr << endl;
			        
			        left=0;
			        right=B-1;
			        while(right-left>1){
			            ll middle = (left + right)/2;
			            if( xx < t.at(middle) ){
			                right = middle; 
			            }else{
			                left= middle; 
			            }
			        }
			        ll tl, tr;
			        if( xx < t.at(0) ){
			            tl = -INF;
			            tr = t.at(0);
			        }else if(xx >t.at(B-1)){
			            tl = t.at(B-1);
			            tr = INF;
			        }else{
			            tl = t.at(left);
			            tr = t.at(right); 
			        }
			        
			        //cout<< i <<" "<<tl <<" "<< tr << endl;
			        
			        ll ans_1 = xx - min(sl,tl); 
			        ll ans_2 = max(sr,tr) -xx; 
			        ll ans_3 = tr-sl + min(tr-xx, xx-sl);
			        ll ans_4 = sr-tl + min(sr-xx, xx-tl); 
			        cout<< min(min(ans_1,ans_2), min(ans_3,ans_4))<< endl;
			 }
             
              
              
        	}

Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
//サイコロオブジェクトでコンストラクタを作成し、転がしてTOPを表示する。
public class Main {

    public static void main(String[] args) throws IOException {
        // TODO 自動生成されたメソッド・スタ
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split(" ");
        int[] a = new int[6];

       for(int i = 0;i < s.length;i++ ){
           a[i] = Integer.parseInt(s[i]);
       }
       Dice dice = new Dice(a);

       String order = br.readLine();

       for(int i = 0;i < order.length();i++){
           char c = order.charAt(i);
           switch(c){
           case 'S':
               dice.turnS();
               break;
           case 'N':
               dice.turnN();
               break;
           case 'W':
               dice.turnW();
               break;
           case 'E':
               dice.turnE();
               break;
           }

       }
       System.out.println(dice.TOP);
    }

}
class Dice{
    int TOP,BOTTOM,LEFT,RIGHT,FRONT,BACK;

    Dice(int[] a){
        this.TOP = a[0];
        this.FRONT = a[1];
        this.RIGHT = a[2];
        this.LEFT = a[3];
        this.BACK = a[4];
        this.BOTTOM = a[5];
    }

    void turnS(){
        int tmp = this.TOP;
        this.TOP = this.BACK;
        this.BACK = this.BOTTOM;
        this.BOTTOM = this.FRONT;
        this.FRONT = tmp;
    }

    void turnN(){
        int tmp = this.TOP;
        this.TOP = this.FRONT;
        this.FRONT = this.BOTTOM;
        this.BOTTOM = this.BACK;
        this.BACK = tmp;
    }

    void turnW(){
        int tmp = this.TOP;
        this.TOP = this.RIGHT;
        this.RIGHT = this.BOTTOM;
        this.BOTTOM = this.LEFT;
        this.LEFT = tmp;
    }

    void turnE(){
        int tmp = this.TOP;
        this.TOP = this.LEFT;
        this.LEFT = this.BOTTOM;
        this.BOTTOM = this.RIGHT;
        this.RIGHT = tmp;
    }
}


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

int main() {
  int H,W;
  string s;
  cin>>H;
  cin>>W;
  for(int i=0;i<W+2;i++)
    cout << '#';
  cout << endl;
  
  for(int i=0;i<H;i++){
    cout << '#';
    vector<char> vec(W);
    cin>>s;
    for(int j=0;j<W;j++)
      cout << s.at(j);
    cout << '#'<<endl;
  }
  
  for(int i=0;i<W+2;i++)
    cout << '#';
  cout << endl;
}
    
      

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <vector>
using namespace std;
typedef int64_t int64;
#define print(x) cout << (x) << '\n'

inline void fastin(int &num) {
    bool neg = false;
    int c;
    num = 0;
    c = getchar();
    if (c == '-') {
        neg = true;
        c = getchar();
    }
    for (; (c > 47 && c < 58); c = getchar()) num = num * 10 + c - 48;
    if (neg) num *= -1;
}
 
int main(){
 int n, k; fastin(n); fastin(k);
 int a[n];
 for (int i = 0; i < n; ++i) fastin(a[i]);
 
 int64 s[n]; s[0] = a[0];
 for (int i = 1; i < n; ++i) s[i] = s[i - 1] + (int64) a[i];
 vector<int64> v;
 
 for (int i = 0; i < n; ++i) v.push_back(s[i]);
 for (int i = 0; i < n; ++i){
   for (int j = i + 1; j < n; ++j) v.push_back(s[j] - s[i]);
 }
 
 int64 ans = 0;
 for (int bit = 38; bit >= 0; --bit){
   int64 p = ((int64)1<<bit);
   int cnt = 0;
   
   for (int i = 0; i < (int) v.size(); ++i){
     if (((ans + p) & v[i]) == ans + p) ++cnt;
   }
   if (cnt >= k) ans += p;
 }
 print(ans);
 
 return 0;
}

Measured memory_bytes: 6384
N = int(input())
st = {}
for i in range(N):
    S = list(input())
    S.sort()
    w = "".join(S)
    if w in st:
        st[w] += 1
    else:
        st[w] = 1
ans = 0
for v in st.values():
    if v > 1:
        ans += (v * (v - 1) // 2)

print(ans)


Measured memory_bytes: 17808
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N;int D;cin>>N>>D;
    vector<vector<int>>X(N,vector<int>(D));
    rep(i,N)rep(j,D){
        cin>>X.at(i).at(j);
    }
    double l=0;
    int sum=0;
    int ans=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            for(int k=0;k<D;k++){
                sum+=(X.at(i).at(k)-X.at(j).at(k))*(X.at(i).at(k)-X.at(j).at(k));
            }
            l=sqrt(sum);
            if(l==(int)l){
                ans++;
            }
            sum=0;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
using namespace std;
typedef long long ll;

int arr[5001];
int points[5001];
pair<int, ll> memo[5001]; // {횟수,총점수}

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

	for (int i = 1; i <= N; i++) {
		cin >> arr[i];
	}
	for (int i = 1; i <= N; i++) {
		cin >> points[i];
	}

	for (int i = 1; i <= N; i++) {
		vector<int> nodes;
		int initIdx = i;
		if (memo[i].first != 0) continue;

		int currIdx = i;
		ll point_sum = 0;
		int cnt = 0;
		do {
			cnt++;
			currIdx = arr[currIdx];
			point_sum += points[currIdx];
			nodes.push_back(currIdx);
		} while (currIdx != initIdx);
		
		for (int i = 0; i < nodes.size(); i++) {
			memo[nodes[i]] = { cnt, point_sum };
		}
	}

	ll maxim = -10e20;
	for (int i = 1; i <= N; i++) {
		int tempK = K;
		ll sum = 0;
		double multiple = (double)tempK /memo[i].first;
		if (multiple>2) {
			if (memo[i].second > 0) {
				sum += ((int)multiple - 1) * memo[i].second;
			}
			tempK -= ((int)multiple - 1)*memo[i].first;
		}

		int currIdx = i;
		for (int j = 0; j < tempK; j++) {
			currIdx = arr[currIdx];
			sum += points[currIdx];
			maxim = max(maxim, sum);
		}
	}
		
	cout << maxim << endl;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)
int gcd(int x, int y){
    if(x % y == 0){
        return x;
    }else{
        return gcd(x, x%y);
    }
}
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,0,n) cin >> a[i];
    ll sum = 0;
    rep(i,0,n) sum+=a[i];
    set<ll> s;
    for(int i = 1; i * i < sum; i++){
        if(sum % i == 0){
            s.insert(i);
            s.insert(sum/i);
        }
    }
    ll ans = 1;
    for(ll x: s){
        ll need = 1e18;
        vector<ll> r(n);
        rep(i,0,n) r[i] = a[i]%x;
        sort(r.begin(), r.end());
        ll B = 0;
        rep(i,0,n) B += x - r[i];
        ll A = 0;
        rep(i,0,n){
            A += r[i];
            B -= x - r[i];
            need = min(need, max(A,B));
        }
        if(need <= k ) ans = max(ans, x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

S = input()

a = [0]*(len(S)+1)

for i in range(len(S)):
    if S[i] == '<':
        a[i+1] = max(a[i+1], a[i]+1)

for i in range(len(S)):
    if S[-i-1] == '>':
        a[-i-2] = max(a[-i-1]+1, a[-i-2])

count = 0
for i in a:
    count += i
print(count)



Measured memory_bytes: 28976
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int n, res = 0;
  scanf("%d", &n);
  if(n % 3 == 0 && n % 2) res--;
  while(n > 0){
    n /= 3;
    res++;
  }
  printf("%d\n", res);
  return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdio>
using namespace std;
int x1,y1,x2,y2,x3,y3,x4,y4;
int main(int argc, char const *argv[])
{
	scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
	int xwaarde = x2-x1, ywaarde = y2-y1;
	int x3 = x2-ywaarde, y3 = y2+xwaarde;
	int x4 = x3-xwaarde, y4 = y3-ywaarde;
	printf("%d %d %d %d\n",x3,y3,x4,y4);
	return 0;
}

Measured memory_bytes: 256
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>

using namespace std;

int main() {

	long long X, Y;
	cin >> X >> Y; // 10^18

	vector<long long> array;

	array.push_back(X);
	long long array_last = X;
	while (array_last * 2 <= Y) {
		array_last *= 2;
		array.push_back(array_last);
	}

	cout << array.size() << endl;

	return 0;

}


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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;

/*
	int N;
	std::cin >> N;
	std::vector<int> vec(N);
	for (auto& v : vec)
	{
		std::cin >> v;
	}
*/

void Main()
{
	int A;
	cin >> A;

	if (A >= 30) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

ll pow_mod(ll a, ll n, ll MOD){
  ll m[60]; m[0]=a; // m[i] : a^(2^i)をMODで割った余り
  rep(i,59) m[i+1] = (m[i]*m[i])%MOD;

  ll retval = 1;
  bitset<60> s(n);
  rep(i,60) if (s.test(i)) (retval *= m[i]) %= MOD;

  return retval; 
}

int main(){
  int N; cin >> N;
  map<int, int> A; 
  rep(i,N) {
    int a; cin >> a;
    A[a]++;
  }
  bool check = true;
  int n = N/2;
  if (N%2) {
    for (int i=0;i<=n;i++){
      if (i==0 && A[2*i]!=1) check = false;
      else if (i>0 && A[2*i]!=2) check = false;
    }
  }
  else {
    for (int i=0;i<n;i++){
      if (A[2*i+1]!=2) check = false;
    }
  }
  if (check==false) cout << 0 << endl;
  else {
    ll MOD = 1000000007;
    ll ans = pow_mod(2,n,MOD);
    cout << ans << endl;
  }

    

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 7452
from itertools import permutations
from math import factorial

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

cnt = 0
for i in permutations(range(n)):
    for j in range(n - 1):
        cnt += ((xy[i[j]][0] - xy[i[j + 1]][0]) ** 2 +
                (xy[i[j]][1] - xy[i[j + 1]][1]) ** 2) ** 0.5
print(cnt/factorial(n))

Measured memory_bytes: 3064
inf=10**9
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
dp=[[inf]*(2**n) for _ in range(m+1)]
def two(i):
	return "0"*(n-len(bin(i)[2:]))+bin(i)[2:]
for i in range(m+1):
	dp[i][0]=0
for i in range(m):
	a,b=map(int,input().split())
	r=0
	c=list(map(int,input().split()))
	for p in c:
		r+=2**(p-1)
	for j in range(2**n):
		x=j|r
		dp[i+1][x]=min(dp[i][j]+a,dp[i][x],dp[i+1][x])
	for j in range(2**n):
		dp[i+1][j]=min(dp[i+1][j],dp[i][j])
print(dp[-1][-1]) if dp[-1][-1]!=inf else print(-1)

Measured memory_bytes: 76252
// ※※※ 解答不能 ※※※
// 正答者の解答を勉強する.
// pekempey氏.
// https://atcoder.jp/contests/abc137/submissions/6839042
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
using namespace std;
using ll = long long;

int main(){
    
    // 1. 入力情報取得.
    int N, M, P;
    scanf("%d %d %d", &N, &M, &P);
    vector<int> us(M), vs(M), ws(M);
    rep(i, M){
        scanf("%d %d %d", &us[i], &vs[i], &ws[i]);
        us[i]--; vs[i]--; ws[i] -= P;
    }
    
    // 2. ベルマン–フォード法の適用.
    const ll inf = 1e18;
    vector<ll> dist(N, -inf);
    dist[0] = 0;
    rep(k, N * 2){
        rep(i, M){
            if(dist[us[i]] != -inf){
                if(dist[vs[i]] < dist[us[i]] + ws[i]){
                    if(k < N - 1) dist[vs[i]] = dist[us[i]] + ws[i];
                    else          dist[vs[i]] = inf;
                }
            }
        }
    }
    
    // 3. 出力 ～ 後処理.
    if(dist[N - 1] >= inf){
        printf("%d\n", -1);
    }else{
        printf("%lld\n", max(0LL, dist[N - 1]));
    }
    return 0;
    
}

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

using namespace std;

int main(){
  long long  l,r;
  cin >> l >> r;
  if(r-l>=2019){
   cout << 0 << endl;
  }
  else{
    int L=l%2019;
    int R=r%2019;
    if(L<=R){
      int m=2020*2020;
      for(int i=L;i<R;i++){
        for(int j=i+1;j<=R;j++){
          int M=i*j%2019;
          m=min(m,M);
        }
      }
      cout << m << endl;
    }
    else if(L>R){
      int m=2020*2020;
      for(int i=0;i<2020;i++){
        for(int j=i+1;j<2020;j++){
          if((i<R || L<i)&&(j<R || L<j)){
            int M=i*j%2019;
            m=min(m,M);
          }
        }
      }
      cout << m << endl;
    }
  }
}


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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

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

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ld n;
    ld p = 3.14159265358979323846;
    cin >> n;
    cout << fixed << setprecision(30) << p*n*2.0 << endl;
}


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

void solve() {
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            cout << "No";
            return;
        }
    }
    cout << "Yes";
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1; 
    //cin >> T;
    while(T--) solve();
}

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

int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;

	for (int i = 0; i < h; i++) {
	 	for (int j = 0; j < w; j++) {
			int x = (i < b ? 0 : 1);
			int y = (j < a ? 0 : 1);
			cout << (x ^ y);
	 	}
	 	cout << endl;
	}

 	return 0;
}

Measured memory_bytes: 1280
n = int(input())
a = list(map(int, input().split()))
q = int(input())
for i in range(q):
  b, e = list(map(int, input().split()))
  if b==0:
    a = a[e-1::-1]+a[e:]
  else:
    a = a[:b]+a[e-1:b-1:-1]+a[e:]
print(" ".join(map(str, a)))


Measured memory_bytes: 5632
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int space = 0;
    int width = 0;
    int between = 0;
    
    cin >> space;
    cin >> width;
    cin >> between;
    
    space -= between;
    
    cout << space / (width + between) << endl;
    
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N; cin >> N;
  vector<int> a(N); REP(i, N) cin >> a[i];

  map<int, int> m;

  REP(i, N) {
    m[i + 1] = a[i];
  }

  int cnt = 0;
  REP(i, N) {
    if(m[a[i]] == i + 1) {
      cnt++;
    }
  }

  cout << cnt / 2 << endl;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
int main(){
    int M;
    cin >> M;
    cout << (24 - M) + 24 << endl;

}






Measured memory_bytes: 256
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from bisect import bisect_left
def resolve():
    N = ir()
    S = list(sr())
    a = [[] for _ in range(26)]
    for i, s in enumerate(S):
        a[ord(s)-ord('a')].append(i)
    Q = ir()
    for i in range(Q):
        x, y, z = sr().split()
        if x == '1':
            y = int(y)-1
            if S[y] == z:
                continue
            u = ord(S[y])-ord('a')
            l = bisect_left(a[u], y)
            a[u].pop(l)
            v = ord(z)-ord('a')
            l = bisect_left(a[v], y)
            a[v].insert(l, y)
            S[y] = z
        else:
            y = int(y)-1
            z = int(z)-1
            ans = 0
            for i in range(26):
                l = bisect_left(a[i], y)
                if l == len(a[i]):
                    continue
                elif a[i][l] <= z:
                    ans += 1
            print(ans)
resolve()

Measured memory_bytes: 29320
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    deque<char> s;

    for(int i = 0; i < n; i++){
        char tmp;
        cin >> tmp;
        s.push_back(tmp);
    }

    int lcnt = 0;
    int rcnt = 0;

    int ansr = 0;
    int ansl = 0;

    for(int i = 0; i < n; i++){
        if(s[i] == '('){
            lcnt++;
        } else {
            if(lcnt > 0){
                lcnt--;
            } else {
                rcnt++;
            }
        }
    }

    ansr = lcnt;
    ansl = rcnt;

    for(int i = 0; i < ansr; i++){
        s.push_back(')');
    }
    for(int i = 0; i < ansl; i++){
        s.push_front('(');
    }

    for(int i = 0; i < s.size(); i++){
        cout << s[i];
    }

    cout << endl;


}

Measured memory_bytes: 256