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

#define pii pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of template

const int maxn = 3e5+5;
int n,t;

int main(){
	scanf("%d%d",&n,&t);
	
	ll ret = t;
	int last = 0;
	rep(k,0,n){
		int a;
		scanf("%d",&a);
		
		if(last+t<=a)ret+= t,last = a;
		else ret += a-last,last = a;
	}
	cout<<ret<<endl;
	
	
}


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

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int k;
    cin >> k;
    int a, b;
    cin >> a >> b;
    int x = a / k;
    int y = b / k;
    if(y > x) {
        cout << "OK";
    }
    else {
        if(a%k == 0 || b%k == 0) {
            cout << "OK";
        }
        else {
            cout << "NG";
        }
    }
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    //debug_map();
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cmath>
#include <stdlib.h>
using namespace std;
typedef long long ll;
int a[200010];
int ans[200010];
int disx[200010];
int disy[200010];
int main()
{
    int i, j, k;
    int n, t, m;
    cin >> n;
    int x, y;
    cin >> x >> y;
    for(i = 1; i <= n; i++) {
        for(j = i+1; j <= n; j++) {
            int xx = j-i;
            xx = min(xx, abs(x-i)+1+abs(y-j));
            xx = min(xx, abs(y-i)+1+abs(x-j));
            ans[xx]++;
        }
    }
    for(i = 1; i < n; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string s;
    cin >>s;
    s[3]= '8';
    
    cout << s << endl;
    
    return 0;
}



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

int main(){
    string S;
    cin >> S;
    if(S=="A") cout << "T" << endl;
    if(S=="T") cout << "A" << endl;
    if(S=="C") cout << "G" << endl;
    if(S=="G") cout << "C" << endl;
}

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

int f(vector<int>&v,int cou,int n){
    vector<int> v2(n);
    int min=101;
    int c=0;
    int d=0;
    int e=0;
    for(int i=0;i<n;i++){
        if(v.at(i)!=0){
            if(min>v.at(i)&&v.at(i)>0)
                min=v.at(i);
        }
        
        if(v.at(i)==0|i==n-1){
            if(min==101)
               min=0;
            for(int j=d;j<i+1;j++){
                v2.at(j)=v.at(j)-min;
            }
            if(v.at(i)==0)
                v2.at(i)=0;
            cou+=min;
            c++;
            min=101;
            d=i+1;
        }
    }
    if(c==n){
        cout<<cou<<endl;
        return cou;}
    else
        f(v2,cou,n);

}

int main(){
    int n;
    int ans=0;

    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
       cin>>v.at(i);
    ans=f(v,0,n);

}

Measured memory_bytes: 256
#line 1 "test/aoj/GRL_1_C.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C"
#line 1 "test/aoj/../../graph/template.cpp"
#include <vector>

template< typename T >
struct Edge {
  int from, to;
  T cost;
  Edge() {}
  Edge(int f, int t) : from(f), to(t), cost(1) {}
  Edge(int f, int t, T c) : from(f), to(t), cost(c) {}
  friend bool operator < (const Edge& lhs, const Edge& rhs) { return lhs.cost < rhs.cost; };
  friend bool operator > (const Edge& lhs, const Edge& rhs) { return rhs < lhs; };
  friend bool operator <= (const Edge& lhs, const Edge& rhs) { return !(lhs > rhs); };
  friend bool operator >= (const Edge& lhs, const Edge& rhs) { return !(lhs < rhs); };
};

template< typename T >
using Edges = std::vector< Edge< T > >;
template< typename T >
using Graph = std::vector< Edges< T > >;
#line 2 "test/aoj/../../graph/warshall-floyd.cpp"

#include <limits>
#include <vector>
// #include <iostream>

template < typename T >
struct WarshallFloyd {
  const T INF; // 十分に大きいがoverflowしない値として、型Tの最大値の半分を使う
  const int V; // 頂点数
  Graph<T> g;
  std::vector<std::vector<T>> dist;
  WarshallFloyd(Graph<T> &g): INF(std::numeric_limits<T>::max()/2), V(g.size()), g(g), dist(V, std::vector<T>(V, INF)) { init(); }
  WarshallFloyd(Graph<T> &g, int V): INF(std::numeric_limits<T>::max()/2), V(V), g(g), dist(V, std::vector<T>(V, INF)) { init(); }
  void init() {
    for (int i = 0; i < V; ++i) {
      dist[i][i] = 0;
      for (auto &e: g[i]) dist[i][e.to] = e.cost;
    }
    for (int k = 0; k < V; ++k) {
      for (int i = 0; i < V; ++i) {
        for (int j = 0; j < V; ++j) {
          if (dist[i][k] == INF || dist[k][j] == INF) continue;
          T d = dist[i][k]+dist[k][j];
          if (dist[i][j] > d) {
            // std::cout << i << j << k << " " << d << std::endl;
            dist[i][j] = d;
          }
        }
      }
    }
  }
  bool has_negative_cycle() {
    for (int i = 0; i < V; ++i) {
      if (dist[i][i] < 0) return true;
    }
    return false;
  }
};
#line 3 "test/aoj/GRL_1_C.test.cpp"

#include <iostream>
using namespace std;

typedef long long ll;

int main() {
  int V, E;
  cin >> V >> E;
  Graph<ll> g(V);
  for (int i = 0; i < E; ++i) {
    int x, y; ll d;
    cin >> x >> y >> d;
    g[x].emplace_back(x, y, d);
  }
  WarshallFloyd<ll> wf(g);
  if (wf.has_negative_cycle()) {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }
  for (int i = 0; i < V; ++i) {
    for (int j = 0; j < V; ++j) {
      if (j > 0) cout << " ";
      if (wf.dist[i][j] == wf.INF) cout << "INF";
      else cout << wf.dist[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3424
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n;
	long long int d,x,y,sum=0;
	double z;
	cin>>n>>d;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		z=sqrt(x*x+y*y);
		if(z<=d)
		{
			sum++;
		}
	}
	cout<<sum;
	return 0;
} 

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
using ll = long long;
ll f(ll n,ll d, ll & ans)
{
	ll rem ;
    if(d!=0)
    rem = n%d;
    else return 0;
    n = rem;
    
   ans++;
    if(n==0) return 0;
    
    d = __builtin_popcount(n);
    return f(n,d,ans);
    
}
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll remender(ll arr[],ll n,ll d)
{
    reverse(arr,arr+n);
    ll sum = 0;
    ll f = 1;
    for(ll i=0;i<n;i++)
    {
        sum = (sum + (arr[i] * f)%d)%d;
        f = (f * 2)%d;
    }
    return sum;
}
int main()
{
	ll n;
    cin >> n;
	ll arr[n];
    char brr[n];
    ll cnt1 = 0;
    for(ll i=0;i<n;i++)
    {
        cin >> brr[i];
        arr[i] = brr[i] - '0';
        if(arr[i] == 1)
        	cnt1++;
    }
    int g= 0;
    ll rem0  = 0,rem1 = 0,rem2 = 0;
    if(cnt1 > 1)
    rem0 = remender(arr,n,cnt1 - 1) , g++;
    if(cnt1 > 0)
    rem1 = remender(arr,n,cnt1),g++;
    
    if(cnt1 + 1 >0)
     rem2 = remender(arr,n,cnt1 + 1),g++;
    if(g%2==1)
    reverse(arr,arr+n);
    for(ll i=0;i<n;i++)
    {
        ll ans = 0;
        if(arr[i] == 0)
        {
            ll d= cnt1 + 1;
            
         //   cout << "f " << rem2 << endl;
         //  cout <<"g " << i << " " << ( rem2 + binpow(2,n - i - 1,d))%d << endl;
            if(d>0)
             f((rem2 + binpow(2,n - i - 1,d))%d ,d,ans) ;
            //cout << ans << endl;
        }
        else
        {
            ll d = cnt1 - 1;
            if(d>0)
              f((rem0 + d -  binpow(2,n - i - 1,d))%d ,d,ans) ;
           // cout << ans << endl;
        }
       cout << ans << endl;
    }
    
	return 0;
}


Measured memory_bytes: 5388
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

int main(){
lli a,b,c;
cin >> a >> b >> c;
cout << ((a-b == b-c) ? "YES" : "NO") << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  bool bP=false,bW=false,bG=false,bY=false;
  cin >> N;
  
  for(int n = 0; n < N; n++){
  	cin >> S;
    if(S=="P"){
    	bP=true;
    }else if(S=="W"){
    	bW=true;
    }else if(S=="G"){
    	bG=true;
    }else if(S=="Y"){
    	bY=true;
    }
  }
  
  if(bP && bW && bG && bY){
  	cout << "Four" << endl;
  }else{
  	cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
e = [(pi + 1) / 2 for pi in p]

tmp = 0
for i in range(n):
    tmp += e[i]
    if i >= k:
        tmp -= e[i - k]
    ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 25060
def B():
    a = [list(map(int,input().split())) for i in range(3)]
    n = int(input())
    b = [int(input()) for i in range(n)]
    for bingo in b:
        for i in range(3):
            for j in range(3):
                if a[i][j] == bingo:
                    a[i][j] = 0
    if (a[0][0] == a[1][1] == a[2][2] == 0) or (a[0][2] == a[1][1] == a[2][0] == 0):
        print("Yes")
        return
    for i in range(3):
        if all(a[i][j] == 0 for j in range(3)) or all(a[j][i] == 0 for j in range(3)):
            print("Yes")
            return
    print("No")

B()

Measured memory_bytes: 3064
import math

a, b, n = list(map(int, input().split()))

def calc(a,b,x):
    return math.floor(a*x/b) - a*math.floor(x/b)

if b==1:
    print(0)
elif b-1 <= n:
    print(a-math.ceil(a/b))
else:
    print(calc(a,b,n))


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

#define EPS 1e-10

class point {
public:
	double x, y;
	point() {}
	point( double x_, double y_ ) : x(x_), y(y_) {}
	point operator -( point p ) { return point( x - p.x, y - p.y ); }
	point operator +( point p ) { return point( x + p.x, y + p.y ); }
	point operator *( int a ) { return point( x * a, y * a ); }
};

class segment {
public:
	point p1, p2;
	segment() {}
};

double dot( point a, point b ) { return a.x * b.x + a.y * b.y; }
double cross( point a, point b ) { return a.x * b.y - a.y * b.x; }
double norm( point a ) { return a.x * a.x + a.y * a.y; }

double distance( segment s, point p )
{
	if( dot( s.p2 - s.p1, p - s.p1 ) < 0 ) return sqrt( norm( p - s.p1 ) );
	if( dot( s.p1 - s.p2, p - s.p2 ) < 0 ) return sqrt( norm( p - s.p2 ) );;
	return fabs( cross( s.p2 - s.p1, p - s.p1 ) / sqrt( norm( s.p2 - s.p1 ) ) );
}

int ccw( point p0, point p1, point p2 )
{
	point v1 = p1 - p0;
	point v2 = p2 - p0;
	if( cross( v1, v2 ) > EPS ) return 1;
	if( cross( v1, v2 ) < -EPS ) return -1;
	if( dot( v1, v2 ) < -EPS ) return 2;
	if( norm( v1 ) < norm( v2 ) ) return -2;
	return 0;
}

bool intersect( segment s1, segment s2 )
{
	return ccw( s1.p1, s1.p2, s2.p1 ) * ccw( s1.p1, s1.p2, s2.p2 ) <= 0 &&
			ccw( s2.p1, s2.p2, s1.p1 ) * ccw( s2.p1, s2.p2, s1.p2 ) <= 0;
}

double distance( segment s1, segment s2 )
{
	if( intersect( s1, s2 ) ) return 0;
	return min( { distance( s1, s2.p1 ), distance( s1, s2.p2 ),
					distance( s2, s1.p1 ), distance( s2, s1.p2 ) } );
}

int main()
{
	int q;
	cin >> q;
	for( int i = 0; i < q; i++ ) {
		segment s1, s2;
		cin >> s1.p1.x >> s1.p1.y >> s1.p2.x >> s1.p2.y >> s2.p1.x >> s2.p1.y >> s2.p2.x >> s2.p2.y;
		int ans = intersect( s1, s2 );

		cout << ans << endl;
	}
}



Measured memory_bytes: 3224
import math
N = int(input())
ARR = [int(s) for s in input().split(" ")]
ARR.insert(0,0)
ARR.append(0)


def calculate(arr):
    S = 0
    for i in range(len(arr)-1):
        S = S + int(math.fabs(arr[i+1]-arr[i]))

    for i in range(1,len(arr)-1):
        print(int(S + math.fabs(arr[i-1]-arr[i+1]) - (math.fabs(arr[i-1]-arr[i]) + math.fabs(arr[i]-arr[i+1]))))



calculate(ARR)


Measured memory_bytes: 14048
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
  ll N;
  cin >> N;
  vector<ll> div = divisor(N);
  ll ans = 100;
  for (ll x : div) {
    ll y = N / x;
    ll t1 = 0;
    while (x > 0) {
      x /= 10;
      t1++;
    }
    ll t2 = 0;
    while (y > 0) {
      y /= 10;
      t2++;
    }
    ans = min(ans, max(t1, t2));
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
vector<int> E[200000];
int in[200000];
int dp[200000];
int main(){
	int n,m;
	cin>>n>>m;
	rep(i,m){
		int x,y;
		cin>>x>>y;
		x--;y--;
		E[x].push_back(y);
		in[y]++;
	}
	queue<int>que;
	rep(i,n){
		if(!in[i]){
			que.push(i);
		}
	}
	while(!que.empty()){
		int p=que.front();que.pop();
		for(int u=0;u<E[p].size();u++){
			dp[E[p][u]]=max(dp[E[p][u]],dp[p]+1);
			in[E[p][u]]--;
			if(!in[E[p][u]])que.push(E[p][u]);
		}
	}
	cout<<*max_element(dp,dp+n)<<endl;
	return 0;
}

Measured memory_bytes: 8832
fun main(args: Array<String>) {
    val s = readLine() ?: return
    val target = 753
    0.until(s.length - 2).map {
        Math.abs(target - "${s[it]}${s[it + 1]}${s[it + 2]}".toInt())
    }.min()?.let {
        println(it.toString())
    }
}

Measured memory_bytes: 31804
n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
tento=0
for i in 0...n-1 do
  for j in i...n do
    tento+=1 if a[i]>a[j]
  end
end
ento=0
for i in 0...n do
  for j in 0...n do
    ento+=1 if a[i]>a[j]
  end
end
ans=tento*k
ans+=ento*(k*(k-1)/2)
p ans%1000000007

Measured memory_bytes: 1916
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
  
        int array[] = new int[n];
 
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();         
        }

        int ans = 0;
 
        for (int i = 0; i < n; i++) {
            if (array[array[i] - 1] == i + 1) {
                ans++;
            }
        }
 
        System.out.println(ans / 2);
 
        sc.close();
 
        }
 
    }

Measured memory_bytes: 59404
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
//#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector <int> siz; // 素集合のサイズを表す配列(1 で初期化)

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	void init(int N) {
		par.resize(N);
		siz.assign(N, 1);  // resize だとなぜか初期化されなかった
		for (int i = 0; i < N; ++i) par[i] = i; // 初期では親は自分自身
	}


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

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

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

	int size(int x) { return siz[root(x)]; }
};

signed main(void) {
	int n, m,k;
	cin >> n >> m>>k;
	UnionFind tree(n+1);
	tree.init(n + 1);
	vector<int>fri(n+1, 0);
	vector<vector<int>>blo(n + 1);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		tree.unite(a, b);
		fri[a]++;
		fri[b]++;
	}
	rep(i, k) {
		int a, b;
		cin >> a >> b;
		blo[a].pb(b);
		blo[b].pb(a);
	}
	rep1(i, n+1) {
		int ans = tree.size(i)-fri[i]- 1;
		rep(j, blo[i].size()) {
			if (tree.same(i, blo[i][j])) ans--;
		}
		print(ans);
	}
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i,n,ans=0;
    string s,t;
    cin>>s>>t;
    n=s.size();
    for(i=0;i<n;i++)if(s[i]!=t[i])ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3916
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: isize = read();
    let mut sides: Vec<Vec<(isize, isize)>> = (0..n).map(|_| Vec::new()).collect();
    for _ in 0..n-1 {
        let u: isize = read();
        let v: isize = read();
        let w: isize = read();
        sides[(u-1) as usize].push((v-1, w));
        sides[(v-1) as usize].push((u-1, w));
    }
    let mut seen: Vec<i8> = (0..n).map(|_| -1).collect();
    dfs(&sides, &mut seen, 0, -1, 1);
    for i in seen {
        println!("{}", i);
    }
}

fn dfs(sides: &Vec<Vec<(isize, isize)>>, seen: &mut Vec<i8>, i: isize, p: isize, color: i8) {
    if seen[i as usize] != -1 {
        return;
    }
    seen[i as usize] = color;
    for side in &sides[i as usize] {
        if side.0 == p {
            continue;
        }
        if side.1 % 2 != 0 {
            dfs(sides, seen, side.0, i, 1-color);
        } else {
            dfs(sides, seen, side.0, i, color);
        }
    }
}



Measured memory_bytes: 17788
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF = 10**9


def dfs(cur, a, b, c):
  if cur == N:
    if min(a, b, c) > 0:
      return abs(a-A) + abs(b-B) + abs(c-C) - 30
    else:
      return INF
  ret0 = dfs(cur+1, a, b, c) # 初動
  ret1 = dfs(cur+1, a+l[cur], b, c) + 10 # 合成時コスト10MP
  ret2 = dfs(cur+1, a, b+l[cur], c) + 10 # 合成時コスト10MP
  ret3 = dfs(cur+1, a, b, c+l[cur]) + 10 # 合成時コスト10MP
  return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 1000000000
    #define MOD 1000000007
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;

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

    int dy[]={0, 0, 1, -1, 0};
    int dx[]={1, -1, 0, 0, 0};


    int main()
    {
        int a,b,c,d;
        string s;
        cin>>s;
        a=s[0]-'0';
        b=s[1]-'0';
        c=s[2]-'0';
        d=s[3]-'0';
        if(a-b-c-d==7) cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;

        else if(a-b-c+d==7) cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
        else if(a-b+c-d==7) cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
        else if(a+b-c-d==7) cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;

        else if(a-b+c+d==7) cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
        else if(a+b-c+d==7) cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
        else if(a+b+c-d==7) cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;

        else if(a+b+c+d==7) cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    }

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {


	int a, b, c;
	cin >> a >> b;
	cout << 6 - a - b << endl;





	return 0;
}

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

int sa(int a,int b){
    return max(a,b)-min(a,b);
}

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

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int K; std::cin >> K;
	int S; std::cin >> S;
	int ans = 0;
	for(int X=0; X<=K; X++)
		for(int Y=0; Y<=K; Y++)
		{
			int Z = S - X - Y;
			if(Z>=0 && Z<=K) ans++;
		}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
/* 	* In the name of GOD 
 	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long
const int N = 201234;
int pow21[N], pow22[N], pow23[N];

int calc (int x){
	int a[60];
	int y = x;
	int num = 0;
	for (int i = 0; i < 60; i++){
		a[i] = y % 2;
		y /= 2;
		if (a[i])
			num ++;
	}
	if (num == 0){
		return 0;
	}
	if (x % num == 0){
		return 1;
	}
	return 1 + calc (x % num);
}

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	int x = 0;
	for (int i = 0; i < n; i++)
		if (s[i] == '1')
			x ++;
	if (x == 0){
		for (int i = 0; i < n; i++)
			cout << 1 << endl;
		return 0;
	}
	int y;
	y = 1;
	for (int i = 0; i < n; i++){
		if (x == 1)
			continue;
		pow21[i] = y;
		pow21[i] %= (x - 1);
		y *= 2;
		y %= (x - 1);
	}
	y = 1;
	for (int i = 0; i < n; i++){
		pow22[i] = y;
		pow22[i] %= (x);
		y *= 2;
		y %= (x);
	}
	y = 1;
	for (int i = 0; i < n; i++){
		pow23[i] = y;
		pow23[i] %= (x + 1);
		y *= 2;
		y %= (x + 1);
	}
	int num1 = 0;
	for (int i = 0; i < n; i++){
		if (x == 1)
			continue;
		if (s[i] == '1')
			num1 += pow21[n - i - 1], num1 %= (x - 1);
	}
	int num2 = 0;
	for (int i = 0; i < n; i++){
		if (s[i] == '1')
			num2 += pow22[n - i - 1], num2 %= (x);
	}
	int num3 = 0;
	for (int i = 0; i < n; i++){
		if (s[i] == '1')
			num3 += pow23[n - i - 1], num3 %= (x + 1);
	}
	for (int i = 0; i < n; i++){
		if (s[i] == '0'){
			int z = num3 + pow23[n - i - 1];
			z %= (x + 1);
			cout << 1 + calc(z) << endl;
		}else{
			int z = num1 - pow21[n - i - 1];
			if (x - 1 == 0){
				cout << 0 << endl;
				continue;
			}
			z %= (x - 1);
			if (z < 0)
				z = (x - 1) + z;
			cout << 1 + calc(z) << endl;
		}
	}
}


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

struct Restaurant{
  int id, p;
  string s;
};

bool compare(Restaurant i, Restaurant j){
  if(i.s != j.s) return (i.s < j.s);
  else return (i.p > j.p);
}

int main(){
  int n;
  cin >> n;
  Restaurant arr[n];
  rep(i,n){
    cin >> arr[i].s >> arr[i].p;
    arr[i].id = i;
  }
  
  sort(arr,arr+n,compare);
  
  rep(i,n){
    cout << (arr[i].id+1) << endl;
  }
  return 0;
}


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


int keta(ll x)
{
    int count = 0;
    while(x)
    {
        x/=10;
        count++;
    }
    return count;
}

int main()
{
    /*ABC144 B
    int x;
    cin>>x;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(x==i*j)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    */
    /*ABC150 B
    int n;
    string s;
    cin>>n>>s;
    int count = 0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A')
        {
           if(s[i+1]=='B')
           {
               if(s[i+2]=='C')
               {
                   count++;
               }
           }
        }
    }
    cout<<count<<endl;
    */

    /*ABC136 B
    int n;
    cin>>n;
    int count = 0;
    for(int i=1;i<=n;i++)
    {
        int even=0;
        int num = i;
        while(num)
        {
            num/=10;
            even++;
        }
        if(even%2!=0)
        {
            count++;
        }
    }
    cout<<count<<endl;
    */
    /*ABC106 B
    int n;
    cin>>n;
    int count=0;
    for(int i=10;i<=n;i++)
    {
        int num = i;
        int yakusu=0;
        for(int j=1;j<=num;j++)
        {
            if(j%2==0)
            {
                continue;
            }
            if(num%j==0)
            {
                yakusu++;
            }    
        }
        if(yakusu==8)
        {
            count++;
        }
    }    
    cout<<count<<endl;
    */
    /*ABC120 B
    int a,b,k;
    cin>>a>>b>>k;
    int count=0;
    for(int i=100;i>=1;i--)
    {
        if(a%i==0 && b%i==0)
        {
           count++;
        }
        if(count==k)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    */

    ll n;
    cin>>n;
    int ans = keta(n);
    for(ll i=1;i*i<=n;i++)
    {
        int cur=0;
        if(n%i==0)
        {
            ll b = n/i;
            cur = max(keta(i),keta(b));
        }
        else continue;

        if(cur<ans)
        {
            ans = cur;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int n;
int fib[100];
int main()
{
    cin >> n;
    fib[0] = 1; fib[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        fib[i] = fib[i - 1] + fib[i- 2];
    }
    cout << fib[n] << endl;
}


Measured memory_bytes: 3112
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	io_init;
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for (int i = 0; i < H; i++)cin >> S[i];
	vector<vector<pair<int, int>>> A(H, vector<pair<int, int>>(W, { 0,0 })), B(H, vector<pair<int, int>>(W, { 0,0 }));
	for (int i = 0; i < H; i++) {
		int cnt = 0;
		for (int j = W - 1; j >= 0; j--) {
			if (S[i][j] == '.') {
				cnt++;
				A[i][j].first = cnt;
			}
			else {
				cnt = 0;
			}
		}
	}
	for (int i = 0; i < W; i++) {
		int cnt = 0;
		for (int j = H - 1; j >= 0; j--) {
			if (S[j][i] == '.') {
				cnt++;
				A[j][i].second = cnt;
			}
			else {
				cnt = 0;
			}
		}
	}
	for (int i = 0; i < H; i++) {
		B[i][0].first = A[i][0].first;
		for (int j = 1; j < W; j++) {
			if (A[i][j].first != 0)B[i][j].first = max(A[i][j].first, B[i][j-1].first);
		}
	}
	for (int i = 0; i < W; i++) {
		B[0][i].second = A[0][i].second;
		for (int j = 1; j < H; j++) {
			if (A[j][i].second != 0)B[j][i].second = max(A[j][i].second, B[j-1][i].second);
		}
	}

	int ans = 0;
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++) {
		ans = max(ans, B[i][j].first + B[i][j].second - 1);
	}
	cout << ans << endl;
}


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

int main() {
	int N, count=0;
	const int MAX_N = 100;
	int a[MAX_N];
	
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> a[i];
	}
	
	int tmp;
	for(int i=0; i<N-1; i++){
		for(int j=N-1; j>=i+1; j--){
			if(a[j-1]>a[j]){
				tmp = a[j];
				a[j] = a[j-1];
				a[j-1] = tmp;
				count++;
			}
		}
	}
	
	if(N==1){
		cout << a[0] <<endl;
		cout << 0 << endl;
		return 0;
	}
	
	for(int i=0; i<N-1; i++){
		cout << a[i] << " ";
	}
	cout << a[N-1] << endl;
	cout << count << endl;
}

Measured memory_bytes: 1160
gets
max_val = 10 ** 18

nums = gets.split.map(&:to_i)
if nums.any?{|it| it == 0}
    puts 0
    exit
end

val = 1
nums.each{|it|
    val *= it
    if val > max_val
        puts -1
        exit
    end
}
puts val


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


int main()
{
  string A;
  cin >> A;
  int a=0,b=0;
  for(int i=0; i<A.size(); i++)
  {
    if(A.at(i)=='0')
    {
      a++;
    }
    else
    {
      b++;
    }
  }
  cout << A.size()-abs(a-b) << endl;
}

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

int main() {

    while(true){

        int n,r;
        cin >> n >> r;

        if(n == 0){
            break;
        }

        int a[n];
        for(int i=0; i<n; i++){
            a[i] = n-i;
        }

        for(int loop=0; loop<r; loop++){

            int p,c;

            cin >> p >> c;

            int tmp[n];

            for(int i=0; i<n; i++){
                tmp[i] = a[i];
            }

            int count = 0;

            for(int i=0; i<c; i++){
                a[count] = tmp[i+p-1];
                count++;
            }
            for(int i=0; i<p-1; i++){
                a[count] = tmp[i];
                count++;
            }

        }

        cout << a[0] << endl;

    }

    return 0;
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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

int n, f[105][15], p[105][15], cnt, ans=-(1<<30), c;


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

    cin>>n;
	for (int i = 0;i < n; i++){
		for(int j = 0; j < 10 ;j++) cin >> f[i][j];
	}
	for (int i = 0;i < n; i++){
		for (int j = 0; j < 11; j++) cin >> p[i][j];
	}

	for (int i = 1; i < (1<<10); i++) {
		cnt = 0;
		for (int j = 0; j < n; j++) {
			c = 0;
			for (int k = 0; k < 10; k++) {
				if ((i>>k&1) && f[j][k]) c++;
			}
			cnt += p[j][c];
		}
		ans = max(ans, cnt);
	}
	COUT(ans);
}

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

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

    int ans = 0;

    int a = 0, b = 100005;
    while(m--){
        int x, y;
        cin >> x >> y;
        a = max(a, x);
        b = min(b, y);
    }
    for(int i = 1; i <= n; i++){
        if(i >= a && i <= b) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, k; cin >> n >> k;
    vll v(n, 0);

    rep(i, k) {
        ll d; cin >> d;
        rep(j, d) {
            ll a; cin >> a; a--;
            v[a]++;
        } 
    }

    ll c = 0;
    rep(i, n) {
        if (v[i] == 0) c++;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 3628
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
k = int(input())
s = 0
for i in range(1,k-1):
  for j in range(i+1,k):
    for l in range(j+1,k+1):
      s += 6*gcd(i,j,l)
s += k*(k+1)//2
for i in range(1,k):
  for j in range(i+1,k+1):
    s += 6*gcd(i,j)
print(s)
  
      

Measured memory_bytes: 69692
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

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

    int ans = 0;
    if (N < 10) {
        ans = R+100*(10-N);
    } else {
        ans = R;
    }

    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

ll dp[111][2][10];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string N; cin>>N;
  int NN=N.length();
  int K; cin>>K;
  dp[0][0][0]=1;
  rep(i,NN) rep(j,2) rep(k,K+1){
    int n=N[i]-'0';
    if(j==0){
      if(n){
        dp[i+1][0][k+1]+=dp[i][j][k];
        dp[i+1][1][k]+=dp[i][j][k];
        dp[i+1][1][k+1]+=max(0,n-1)*dp[i][j][k];
      }else{
        dp[i+1][0][k]+=dp[i][j][k];
      }
    }else{
      dp[i+1][1][k]+=dp[i][j][k];
      dp[i+1][1][k+1]+=9*dp[i][j][k];
    }
  }

  cout<<dp[NN][0][K]+dp[NN][1][K]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f(int x){
  string S = to_string(x);
  int N = S.size();
  int ans = 0;
  for (int i = 1; i < N; i++){
    ans = max(ans, stoi(S.substr(0, i)) * stoi(S.substr(i)));
  }
  return ans;
}
int main(){
  vector<int> r(1000001, 0);
  for (int i = 10; i <= 1000000; i++){
    r[i] = r[f(i)] + 1;
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++){
    int N;
    cin >> N;
    cout << r[N] << endl;
  }
}


Measured memory_bytes: 6624
from itertools import combinations_with_replacement
n, m, q = map(int, input().split())
ans = 0
L = [list(map(int, input().split())) for _ in range(q)]
Comb = combinations_with_replacement(range(1, m+1), n)
for C in Comb:
    s = 0
    for a, b, c, d in L:
        if C[b-1] - C[a-1] == c:
            s += d
    if ans < s:
        ans = s
print(ans)

Measured memory_bytes: 9208
import sys
import math
import bisect

def main():
    a, b, c = map(int, input().split())
    #a, b = (b, a)
    a, b = b, a
    a, c = c, a
    print('%d %d %d' % (a, b, c))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define maxn 112345

using namespace std;
int a[maxn],n,p,k;

int main(){
    cin >> n >> k;
    for (int i=1;i<=n;i++){
        cin >> a[i];
        if (a[i]==1) p=i;
    }
    n--; k--;
    cout << (n+k-1)/k << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>

using namespace std;

typedef long long ll;

int main()
{

  string s;
  cin >> s;

  if(s=="SUN")
    {
      cout << 7 << endl;
      return 0;
    }
  else if(s=="MON")
    {
      cout << 6 << endl;
      return 0;
    }
  else if(s=="TUE")
    {
      cout << 5 << endl;
      return 0;
    }
  else if (s=="WED")
    {
      cout << 4 << endl;
      return 0;
    }
  else if(s=="THU")
    {
      cout << 3 << endl;
      return 0;
    }
  else if (s=="FRI")
     {
       cout << 2 << endl;
      return 0;
    }
  else
  {
    cout << 1 << endl;
      return 0;
    }
      

  


  return 0;
}



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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

using pii = pair<ll, ll>;

int n;
ll a[111111];

int main() {
   cin >> n;
   rep (i, n) {
      cin >> a[i];
   }
   sort(a, a+n);
   ll x = a[n-1];

   ll dif = 1e15;
   vector<pii> V;
   rep (i, n-1) {
      V.push_back({abs(x - a[i] - x/2), a[i]});
   }
   sort(all(V));
   // cout << V[0].second << " " << x << endl;
   cout << x << " " << V[0].second << endl;

   // rep (i, n) {
   //    cout << a[i] << " ";
   // }
   // cout << endl;

   return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const MAXN = 3e5;
int N, m[MAXN], d[MAXN+1];

int main() {
  std::cin >> N;
  std::fill_n(m, N, 0);
  for(int i = 0; i < N; ++i) { int A; std::cin >> A; ++m[A-1]; }
  std::fill_n(d, N+1, 0);
  for(int i = 0; i < N; ++i) ++d[m[i]];
 
  int sum_D = 0, sum_iD = N, k = 1;
  for(int ans = N; ans >= 1; --ans) {
    sum_D += d[ans];
    sum_iD -= d[ans]*ans;
    int next_k = sum_iD/ans + sum_D + 1;
    for(int i = k; i < next_k; ++i) std::cout << ans << "\n";
    k = next_k;
  }
  while(k <= N) { std::cout << 0 << std::endl; ++k; }
  return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] happy = new int[n][3];
        for (int i = 0; i < n; i++) {
            happy[i][0] = sc.nextInt();
            happy[i][1] = sc.nextInt();
            happy[i][2] = sc.nextInt();
        }

        int[][] dp = new int[n][3];
        for(int i=0; i<3; i++){
            dp[0][i] = happy[0][i];
        }

        for(int i=1; i<n; i++){
            for(int j=0; j<3; j++){
                dp[i][j] = happy[i][j]
                        + Math.max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]);
            }
        }

        int result = 0;
        for(int i : dp[n-1]){
            if(i>result) result = i;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 100348
n = int(input())
s = [input() for i in range(n)]
c = [0] * 4

for i in range(n):
    if s[i] == "AC":
        c[0] += 1
        
    elif s[i] == "WA":
        c[1] += 1
        
    elif s[i] == "TLE":
        c[2] += 1
        
    elif s[i] == "RE":
        c[3] += 1
        
print("AC x " + str(c[0]))
print("WA x " + str(c[1]))
print("TLE x " + str(c[2]))
print("RE x " + str(c[3]))
        

Measured memory_bytes: 16264
import java.util.Scanner;

public class Main{    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int sum;
                
        while(true){
            int m=sc.nextInt();
            int f=sc.nextInt();
            int r=sc.nextInt();
            if(m==-1&&f==-1&&r==-1){
                break;
            }

            sum = m+f;

            if(m==-1 || f==-1){
                System.out.printf("F");
            }else if(sum<30){
                System.out.printf("F");
            }else if(sum<50){
                if(r<50){
                    System.out.printf("D");
                }else{
                    System.out.printf("C");
                }
            }else if(sum<65){
                System.out.printf("C");
            }else if(sum<80){
                System.out.printf("B");
            }else{
                System.out.printf("A");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 26336
#include <iostream>

using namespace std;

int main() {
    int a , b , c , i , ans = 0;
    cin >> a >> b >> c ;
    
    for(i=a; i<=b ; i++)
    {
        if (c % i == 0)
            ans = ans + 1 ;
        
        
    }
    cout << ans << endl;
}


Measured memory_bytes: 3100
s = input()
dp = [0 for i in range(len(s)+1)]
dp[0] = 1
words = ['eraser', 'erase', 'dreamer', 'dream']

for i in range(len(s)):
  i += 1
  for sent in words:
    before = i - len(sent)
    if before < 0:
      continue
    if dp[before] == 1 and s[before:i] == sent:
      dp[i] = 1
print('YES' if dp[-1] else 'NO')

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    string S; cin >> S;
    vi A(4);
    rep(i, S.size()) {
        A[i] = S.at(i) - '0';
    }

    for (int i = 0; i < 1<<3; i++) {
        int ans = A[0];
        string tmp = to_string(A[0]);
        for (int j = 0; j < 3; j++) {
            // +
            if (i & 1<<j) {
                tmp += '+';
                tmp += to_string(A[j + 1]);
                ans += A[j + 1];
            }
            // -
            else {
                tmp += '-';
                tmp += to_string(A[j + 1]);
                ans -= A[j + 1];
            }
        }

        if (ans == 7) {
            cout << tmp << "=7" << endl;
            break;
        }
    }
}


Measured memory_bytes: 3688
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(void) {
	string s;
	cin >> s;
	int K;
	cin >> K;
	vector<string> ss;
	for (int i = 0; i < s.length(); i++) {
		for (int l = 1; i + l <= s.length() && l <= K; l++) {
			ss.push_back(s.substr(i, l));
		}
	}
	sort(ss.begin(), ss.end());
	unique(ss.begin(), ss.end());
	cout << ss[K - 1] << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 1908
#include <iostream>

using namespace std;

int sum[105];

int main() {
    int r, c, e, s;
    cin >> r >> c;
    for (int i = 0; i < r; ++i) {
        s = 0;
        for (int j = 0; j < c; ++j) {
            cin >> e;
            s += e;
            sum[j] += e;
            cout << e << ' ';
        }
        sum[c]+=s;
        cout << s << endl;
    }
    int i = 0;
    cout << sum[i++];
    while (i <= c) {
        cout << ' ' << sum[i++];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3112
//Dictionary//
#include<stdio.h>
#include<string.h>
#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];
int getChar(char ch){
  if(ch=='A') return 1;
  else if(ch=='C') return 2;
  else if(ch=='G') return 3;
  else if(ch=='T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum=0,p=1,i;
  for (i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){return key%M; }
int h2(int key){return 1+(key%(M-1)); }

int find(char str[]){
  long long k,i,hash;
  k=getKey(str);
  for(i=0;;i++){
    hash=(h1(k)+i*h2(k))%M;
    if(strcmp(H[hash],str)==0)return 1;
    else if(strlen(H[hash])==0)return 0;
    }
  return 0;
}

int insert(char str[]){
  long long k,i,h;
  k=getKey(str);
  for(i=0;;i++){
    h =(h1(k)+i*h2(k))%M;
    if(strcmp(H[h],str)==0){return 1;}
    else if(strlen(H[h])==0){
    strcpy(H[h],str);
    return 0;
    }
  }
  return 0;
}

int main(){
    int i,n,h;
    char str[L],com[9];
    for(i=0;i<M;i++) H[i][0]='\0';
    scanf("%d",&n);
    for(i=0;i<n;i++){
    scanf("%s %s",com,str);
    if(com[0]=='i' ){
      insert(str);
    }
    else {
      if (find(str)){
      printf("yes\n");
      }
      else {
        printf("no\n");
      }
    }
  }
    return 0;
}



Measured memory_bytes: 16048