akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INT_MAX
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
using namespace std;

const int N = 1e6 + 5;

const LL mod = 1e9 + 7;

LL ksm(LL a, LL b) { LL ans = 1LL; while(b) { if(b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; }  return ans; }

int a[N];

void solve() {
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);

    if(n < m) swap(n, m);

    int ans = k / n;
    if(k % n) ans++;
    printf("%d\n", ans);

}


int main() {
//    int _; scanf("%d", &_);
//    while(_--) solve();


    solve();

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> x = {-1, 0, 1, -1, 1, -1, 0, 1};
int INF = 10000000;
int main(){
  while (1){
    string S;
    cin >> S;
    if (S == "#"){
      break;
    }
    int N = S.size();
    if (N == 1){
      cout << 0 << endl;
    } else {
      vector<int> P(N);
      for (int i = 0; i < N; i++){
        if (S[i] < '5'){
          P[i] = S[i] - '1';
        } else {
          P[i] = S[i] - '2';
        }
      }
      vector<vector<vector<int>>> dp(8, vector<vector<int>>(8, vector<int>(2, INF)));
      dp[P[0]][P[1]][0] = 0;
      dp[P[0]][P[1]][1] = 0;
      dp[P[1]][P[0]][0] = 0;
      dp[P[1]][P[0]][1] = 0;
      for (int i = 0; i < N; i++){
        vector<vector<vector<int>>> dp2(8, vector<vector<int>>(8, vector<int>(2, INF)));
        for (int j = 0; j < 8; j++){
          for (int k = 0; k < 8; k++){
            if (dp[j][k][0] != INF){
              if (x[j] <= x[P[i]]){
                dp2[j][P[i]][1] = min(dp2[j][P[i]][1], dp[j][k][0]);
              }
              if (x[P[i]] <= x[k]){
                dp2[P[i]][k][0] = min(dp2[P[i]][k][0], dp[j][k][0] + 1);
              }
            }
            if (dp[j][k][1] != INF){
              if (x[P[i]] <= x[k]){
                dp2[P[i]][k][0] = min(dp2[P[i]][k][0], dp[j][k][1]);
              }
              if (x[j] <= x[P[i]]){
                dp2[j][P[i]][1] = min(dp2[j][P[i]][1], dp[j][k][1] + 1);
              }
            }
          }
        }
        swap(dp, dp2);
      }
      int ans = INF;
      for (int i = 0; i < 8; i++){
        for (int j = 0; j < 8; j++){
          for (int k = 0; k < 2; k++){
            ans = min(ans, dp[i][j][k]);
          }
        }
      }
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 3784
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 105, LEN = 1e5 + 5;
int n, m, A[N], B[LEN], cnt, deg[LEN], pp[LEN];
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		scanf("%d", &A[i]);
		if (A[i] & 1)
			++cnt;
	}
	if (((n & 1) && cnt >= 2) || ((!(n & 1)) && cnt >= 3)) {
		printf("Impossible\n");
		return 0;
	}
	if (m == 2 && A[1] == 1 && A[2] == 1) {
		printf("1 1\n1\n2\n");
		return 0;
	}
	if (m == 1) {
		if (n == 1) 
			printf("1\n1\n1\n");
//		else if (!(n & 1))
//			printf("%d\n2\n%d %d\n", A[1], n / 2 - 1, n - n / 2 + 1);
//		else
//			printf("%d\n2\n%d %d\n", A[1], n / 2, n - n / 2);
		else
			printf("%d\n2\n%d %d\n", n, 1, n - 1);
		return 0;
	}
	int p1 = 0, p2 = 0;
	for (int i = 1; i <= m; ++i) {
		if (A[i] & 1) {
			if (p1)
				p2 = i;
			else
				p1 = i;
		}
	}
	if (p1)
		swap(A[p1], A[1]);
	if (p2)
		swap(A[p2], A[m]);
	for (int i = 1; i <= m; ++i) {
		printf("%d ", A[i]);
	}
	printf("\n");
	if (A[m] != 1)
		printf("%d\n", m);
	else
		printf("%d\n", m - 1);
	printf("%d ", A[1] + 1);
	for (int i = 2; i <= m - 1; ++i)
		printf("%d ", A[i]);
	if (A[m] != 1)
		printf("%d\n", A[m] - 1);
	return 0;
}

Measured memory_bytes: 128
using ll=long long;using ull=unsigned long long;
#include<limits>
namespace pcl{template<typename T>constexpr T TNF=std::numeric_limits<T>::max()/2;constexpr int INF=TNF<int>;constexpr ll LNF=TNF<ll>;constexpr double DNF=TNF<double>;constexpr double EPS=1e-8;constexpr int P7=1'000'000'007;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
#include<iostream>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}template<typename T,typename U,typename V>bool in_range_strict(T const&begin,std::initializer_list<U>list,V const&end){if(!std::is_sorted(list.begin(),list.end()))return false;return in_range(begin,list,end);}template<typename T>inline T cget(){T x;std::cin>>x;return x;}}
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;int main(){int N;cin>>N;vector<pair<ll,ll>>lr;ll lmax=0;ll rmin=LNF;ll max_range=0;lr.reserve(N);for(int i=0;i<N;i++){ll L,R;cin>>L>>R;R++;updmax(lmax,L);updmin(rmin,R);updmax(max_range,R-L);lr.push_back(make_pair(L,R));}ll ans1=max(0ll,rmin-lmax)+max_range;vector<tuple<ll,ll,bool>>ab(N);for(int i=0;i<N;i++){get<0>(ab[i])=max(0ll,lr[i].second-lmax);get<1>(ab[i])=max(0ll,rmin-lr[i].first);get<2>(ab[i])=lr[i].first==lmax;}sort(ab.begin(),ab.end(),[](auto const&a,auto const&b){return get<0>(a)==get<0>(b)?get<1>(a)>get<1>(b):get<0>(a)<get<0>(b);});int lmaxidx=-1;for(int i=0;i<N;i++){if(get<2>(ab[i]))lmaxidx=i;}assert(lmaxidx!=-1);ll ans2=0;ll bmin=LNF;for(int i=1;i<=lmaxidx;i++){updmin(bmin,get<1>(ab[i-1]));updmax(ans2,get<0>(ab[i])+bmin);}cout<<max(ans1,ans2)<<endl;}


Measured memory_bytes: 4096
from collections import deque
def bfs():
    move=[[1,0],[0,1],[-1,0],[0,-1]]
    
    queue=deque()
    queue.append([sy,sx]) #queue=deque([[sy,sx]])でもよい
    visited[sy][sx]=0 #スタート地点の距離は0
    while queue:
        y,x=queue.popleft()
        cnt=visited[y][x]
        
        for dy,dx in move:
            my,mx=y+dy,x+dx 
            if my<0 or my>=tate:
                continue
            if mx<0 or mx>=yoko:
                continue
            if maze[my][mx]=="#":
                continue
            if visited[my][mx]>cnt:
                queue.appendleft([my,mx])
                visited[my][mx]=cnt # visitedは距離も兼ねてる
        for my in range(y-2,y+3):
            for mx in range(x-2,x+3):
                if my<0 or my>=tate:
                    continue
                if mx<0 or mx>=yoko:
                    continue
                if maze[my][mx]=="#":
                    continue
                if visited[my][mx]>cnt+1:
                    queue.append([my,mx])
                    visited[my][mx]=cnt+1
    if visited[gy][gx]==inf:
        print(-1)
    else:
        print(visited[gy][gx])


tate,yoko=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())
sy,sx,gy,gx=sy-1,sx-1,gy-1,gx-1
maze=[]
inf=float('inf')
visited=[[inf]*yoko for i in range(tate)]

for i in range(tate):
    line=list(input())
    maze.append(line)
bfs()




Measured memory_bytes: 152092
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#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 REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 1010000;
const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

typedef pair<int, int>P;



int cumA[100010], cumB[100010];
signed main() {
	string S; cin >> S;
	int N = S.size();
	int ans = 0;
	FOR(i,1,N) {
		if (S[i] == S[i - 1]) {
			if (S[i] == '1')S[i] = '0';
			else S[i] = '1';
			ans++;
		}
	}
	print(ans);
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

void solve2(){
  int a, b; cin >> a >> b;
  if(a >= b * 2) cout << a - b * 2 << endl;
  else cout << 0 << endl;

  return;
}

int main(){
  solve2();
  return 0;
}


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

using namespace std;

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

    int P[N];
    for(int i=0; i<N; i++){
        cin >> P[i];
    }

    int Q[N];
    for(int i=0; i<N; i++){
        cin >> Q[i];
    }

    int T[N];
    for(int i=0; i<N; i++){
        T[i] = i+1;
    }

    int a;
    int b;
    int cnt = 0;
    do{
        cnt++;
        bool fl = true;
        for(int i=0; i<N; i++){
            if(P[i] != T[i]){
                fl = false;
                break;
            }
        }
        if(fl) a = cnt; 

        fl = true;
        for(int i=0; i<N; i++){
            if(Q[i] != T[i]){
                fl = false;
                break;
            }
        }
        if(fl) b = cnt; 

    }while(next_permutation(T, T+N));

    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cstring>
 
using namespace std;
 
#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
 
#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))
 
#define pb push_back
#define mp make_pair
 
#define ALL(a) (a).begin(), (a).end()
 
#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
 
#define INF 1001001001
#define LLINF 1001001001001001001LL
 
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
 
#define PQ priority_queue
 
#define FST first
#define SEC second
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 


int dp[300][300];

int w[300];
//------------------HEAD---------------------
int main(){
    while(1){
        int n;cin>>n;
        if(n==0)break;
        rep(i,n){
            cin>>w[i];
        }//cerr<<w[200]<<" "<<w[201]<<endl;
        rep(i,n)rep(j,n){/*cerr<<w[200]<<" "<<w[201]<<endl;*/dp[i][j]=0;}
        //cerr<<dp[0][n-1]<<endl;
        //cerr<<w[200]<<" "<<w[201]<<endl;
        FOR(i,1,n){
            rep(j,n-i){
                FOR(k,j,j+i){
                    dp[j][j+i]=max(dp[j][j+i],dp[j][k]+dp[k+1][j+i]);
                }
                if(dp[j+1][j+i-1]==i-1&&abs(w[j]-w[j+i])<2){
                    //cerr<<j<<" "<<j+i<<" "<<dp[j+1][j+i-1]<< " "<<w[j]<<" "<<w[j+i]<<" "<<w[j]-w[j+1]<<endl;
                    dp[j][j+i]=i+1;
                }
            }
        }
        /*rep(i,n){
            rep(j,n){
                cout<<dp[i][j]<<" ";
            }cout<<endl;
        }*/
        cout<<dp[0][n-1]<<endl;

    }

    

    return 0;
}


Measured memory_bytes: 3432
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    multiset<int> ms;
    rep(i,N){
        multiset<int>::iterator itr = ms.upper_bound(vec[i] * -1);
        if (itr == ms.end()){
            ms.insert(vec[i] * -1);
        }
        else{
            ms.erase(itr);
            ms.insert(vec[i] * -1);
        }
    }
    int ans = 0;
    for (multiset<int>::iterator itr = ms.begin(); itr != ms.end(); itr++){
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8120
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

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

// ---- コーディングはここから！ ('-')7

void solve(){
	int h,w; cin>>h>>w;
	int x,y; cin>>x>>y;
	int tx,ty; cin>>tx>>ty;
	x--,y--,tx--,ty--;
	vector<string>s(h); fore(i,0,h)cin>>s[i];
	queue<ii>q;

	vvl vis(h,vl(w,0)), dfs(h,vl(w,0));
	auto valid=[&](int a, int b){
		return a>=0 and a<h and b>=0 and b<w and s[a][b]=='.' and !vis[a][b];
	};
	if(valid(x,y)){
			q.push({x,y});
			vis[x][y]=1;
	}

	auto f=[&](auto f, int a, int b, int d)->void{
		vis[a][b]=d;
		dfs[a][b]=1;
		bool mark=0;
		fore(i,0,4){
			int aa=a+dx[i], bb=b+dy[i];
			if(valid(aa,bb))f(f,aa,bb,d);
			else mark=1;
		}
		if(mark)q.push({a,b});
	};
	while(!q.empty()){
		auto [a,b]=q.front(); q.pop();
		auto d=vis[a][b];
		if(!dfs[a][b])f(f,a,b,d);
		fore(i,-2,3)
			fore(j,-2,3){
			int aa=a+i, bb=b+j;
			if(valid(aa,bb))f(f,aa,bb,d+1);
		}
	}
	cout<<vis[tx][ty]-1<<ENDL;
}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 20652
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define MOD 998244353LL
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}

bool prime[1000001];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}

int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    int n,m;
    cin >> n >> m;
    int cnt[m+1] = {0};
    rep(i, 0, n){
    	int k;
    	cin >> k;
    	rep(j, 0, k){
    		int a;
    		cin >> a;
    		cnt[a]++;
    	}
    }
    int ans = 0;
    rep(i, 1, m+1){
    	if(cnt[i]==n){
    		ans++;
    	}
    }
    
    cout << ans;
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a;
    int sum = 0;
    cin >> a;
    for (int i = 0 ; i < 3 ; i++){
        int y = a % 10;
        if (i == 0){
            if (y == 9){
                sum += 1;
                a /= 10;
            }else if (y == 1){
                sum += 9;
                a /= 10;
            }
        }else if (i == 1){
            if (y == 9){
                sum += 10;
                a /= 10;
            }else if (y == 1){
                sum += 90;
                a /= 10;
            }
        }else if (i == 2){
            if (y == 9){
                sum += 100;
                a /= 10;
            }else if (y == 1){
                sum += 900;
                a /= 10;
            }
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
 #include <queue>
 #include <iostream>
 #include <string.h> 
 #include <algorithm>
 using namespace std;
 char s[5001];
 char s1[5001][10];
 struct node{
 char w[10]; 
 }a[30000];
 int cmp(node x,node y){
 return strcmp(x.w,y.w)<0;
 }
int main(){
	int i,j,k,l,m=0,n;
	scanf("%s",s);
	scanf("%d",&k);
	l=strlen(s);
	for(i=1;i<=k;i++){
	for(j=0;j<=l-i;j++){
    s1[j][i-1]=s[j+i-1];
    s1[j][i]='\0';
    strcpy(a[m++].w,s1[j]);
	}
	}
sort(a,a+m,cmp);
i=0;
j=1;
while(j<k){
while(!(strcmp(a[i].w,a[i+1].w)))i++;
j++;
i++;
}
printf("%s",a[i].w);
	return 0;
}
	
	

 	
 	
 	
 	
 	
 	
 	
 

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll w[100+10], v[100+10],n,W;
const ll V=1e5;
ll dp[V+1]; 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n >> W;
    for (int i = 1; i <= n; i++) cin >> w[i] >> v[i];
    dp[0]=0;
    for (int i = 1; i <= V; i++) dp[i]=1e9+7;
    for (int i = 1; i <= n; i++) {
        for (ll val = V; val >= v[i]; val--) {
            dp[val] = min(dp[val], dp[val-v[i]]+w[i]);
        }
    }
    int i;
    for (i = V; i >= 0; i--) {
        if (dp[i] <= W) break;
    }
    cout << i << endl;
    
    return 0;
}

Measured memory_bytes: 4428
# coding: utf-8
def get_ln_inputs():
    return input().split()


def get_ln_int_inputs():
    return list(map(int, get_ln_inputs()))


def main():
    N = get_ln_int_inputs()[0]
    if N % 10 == 9 or N >= 90:
        print("Yes")
    else:
        print("No")
    return


main()

Measured memory_bytes: 3316
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define MAX_N 200005
#define LL long long
int n;
LL va[MAX_N];
LL num[MAX_N];
LL ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>va[i];
	for(int i=1;i<=n;i++)num[va[i]]++;
	for(int i=1;i<=n;i++)if(num[i])ans+= num[i]*(num[i]-1)/2;
	for(int i=1;i<=n;i++)
		printf("%lld\n",ans- num[va[i]]+1);
}

Measured memory_bytes: 4736
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}
const int mod = 1000000007;
template <typename T1, typename T2>
void modadd(T1 &a, const T2 &b) {
    a += b;

    if (a >= mod)
        a -= mod;
}

mt19937 rng(20010709);
const int INF = 1000000001;
const int N = 1 << 21;

int n, dp[100005][2];
vector <int> e[100005];

void dfs(int v, int p);

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

    cin >> n;

    for (int i = 1; i < n; i++) {
        int x, y;
        cin >> x >> y;

        e[x].push_back(y);
        e[y].push_back(x);
    }

    dfs(1, -1);

    modadd(dp[1][0], dp[1][1]);

    cout << dp[1][0] << endl;

    return 0;
}

void dfs(int v, int p) {
    dp[v][0] = dp[v][1] = 1;

    for (auto it : e[v]) {
        if (it == p) continue;

        dfs(it, v);
        dp[v][0] = (1LL * dp[v][0] * (dp[it][0] + dp[it][1])) % mod;
        dp[v][1] = (1LL * dp[v][1] * dp[it][0]) % mod;
    }
}

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

long long k, ans=0;

int main(){
	cin >> k;
	for (int i=1;i<=k;i++){
		for (int j=1;j<=k;j++){
			for (int l=1;l<=k;l++){
				ans+=__gcd(__gcd(i,j),l);
			}
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3624
n, m, x = map(int, input().split())
inp=[]

# 入力をすべて受け取る
for i in range(n):
  tmp = list(map(int, input().split()))
  inp.append(tmp)

# bit全探索を行うための箱づくり
sum = 0
min = 10**10
for i in range(2**n):
  tmp = [0]*m
  flg = 0
  
  # ある買う買わないのケースに対して、フラグが立ってたらスキルポイントを増やす
  for j in range(n):
    if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
      sum += inp[j][0]
      for k in range(1,m+1):
        #print(n,j, k, tmp, inp)
        tmp[k-1] += inp[j][k]
  for ii, k in enumerate(tmp):
    if k < x: # x未満ならflgをたててNGとする
      flg = 1
      break
  #print(tmp, flg)
  if sum < min and flg == 0: min = sum
  sum = 0
  
if min == 10**10: min = -1
print(min)


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

int main() {
    bool col[101];
    for (int i = 1; i <= 100; i++) col[i] = false;
    for (int i = 0; i < 3; i++) {
        int a;
        cin >> a;
        col[a] = true;
    }
    int ans = 0;
    for (int i = 1; i <= 100; i++) {
        if (col[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cmath>
using namespace std;

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  printf("%.6f", sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)));

  return 0;
}



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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
	llong X;
	cin >> X;

	llong many = X/100;

	cout << ((X%100) <= many*5) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 200005;

ll n, tot, sum, xor_sum, l, A[MAXN];

int main() {
    scanf("%lld", &n);

    for (int i = 0; i < n; i++) {
        scanf("%lld", &A[i]);
    }

    for (int i = 0; i < n; i++) {
        sum = sum + A[i];
        xor_sum = xor_sum ^ A[i];

        while (sum != xor_sum) {
            sum -= A[l];
            xor_sum = xor_sum ^ A[l];
            l++;
        }

        tot += i - l + 1;
    }

    printf("%lld\n", tot);
    
    return 0;
}

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

const int N = 2e5 + 10;

int n , Max;
string name[N];
map <string , int> num , vis;

int main(){
	scanf("%d" , &n);
	for(int i = 1; i <= n; i++)
		cin >> name[i] , num[name[i]]++ , Max = max(Max , num[name[i]]);
	sort(name + 1 , name + n + 1);
	for(int i = 1; i <= n; i++)
		if(!vis[name[i]] && num[name[i]] == Max)
			cout << name[i] << endl , vis[name[i]]++;
	return 0;
}

Measured memory_bytes: 39296
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int N;
string c;

int main(void) {

	cin >> N;

	cin >> c;

	c = "#" + c + "#";

	int p = 1; int q = N;

	int ans = 0;

	for (p = 1; p <= N; p++) {
		if (c[p] == 'R') { continue; }
		
		while (c[q] == 'W') { q--; }

		if (p > q) { break; }

		c[p] = 'R'; c[q] = 'W'; ans++;
		q--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3932
#include <iostream>
#define llint long long

using namespace std;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	llint a, b, c;
	
	cin >> a >> b >> c;
	if(a+b+c >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
	
	return 0;
}

Measured memory_bytes: 764
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(len(B)):
  if A[i] - B[i] >= 0:
    A[i] = A[i] - B[i]
    ans += B[i]
  else:
    ans += A[i]
    if A[i+1] - (B[i] - A[i]) >= 0:
      A[i+1] = A[i+1] - (B[i] - A[i])
      ans += (B[i] - A[i])
    else:
      ans += A[i+1]
      A[i+1] = 0
    A[i] = 0
  #print(ans, A)
print(ans)

Measured memory_bytes: 18752
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back

using namespace std;

using ll = long long;

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1){
            res = (res * a)%mod;
        }
        a = (a * a)%mod;
        b >>= 1;
    }
    return (res%mod);
}

signed main(){
	ll n;
    cin >> n;

    map<ll,ll>mp;
    while(n % 2 == 0){
        mp[2]++;
        n = n/2;  
    }  
    for(int i = 3; i <= sqrt(n); i = i + 2){    
        while(n % i == 0){  
            mp[i]++;  
            n = n/i;  
        }  
    }  
  
    if(n > 2){  
        mp[n]++;
    }

    ll max = 0;
    for(auto i=mp.begin();i!=mp.end();i++){
        //cout << i->first << " " << i->second << "\n";
        max = max + i->second;
    } 

    vector<ll>a;
    for(ll i=0;i<=100;i++){
        a.pb((i==0)?1:a[i-1]+(i+1));
    }

    // for(ll i=0;i<a.size();i++){
    //     cout << a[i] << " ";
    // }
    // cout << "\n";

    ll ans = 0;
    for(auto i=mp.begin();i!=mp.end();i++){
        if(binary_search(a.begin(),a.end(),i->second) == 1){
            ans = ans + lower_bound(a.begin(),a.end(),i->second)-a.begin()+1;
        }
        else{
            ans = ans + lower_bound(a.begin(),a.end(),i->second)-a.begin();   
        }
    } 
    cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3724
n = gets.to_i
w_max = -2*(10**9)
w_min = 2*(10**9)
z_max = -2*(10**9)
z_min = 2*(10**9)
n.times do
  x,y = gets.chomp.split(' ').map(&:to_i)
  w = x + y
  z = x - y
  if w_max <= w
    w_max = w
  end
  if w_min >= w
    w_min = w
  end
  if z_max <= z
    z_max = z
  end
  if z_min >= z
    z_min = z
  end
end
puts [w_max-w_min,z_max-z_min].max

Measured memory_bytes: 14272
#include <stdio.h>

int main(){
  int N,K;
  int count=0;
  scanf("%d %d", &N, &K)+1;
  int tmp;
  for (int i=0; i<N; i++){
    scanf("%d", &tmp)+1;
    if (tmp >= K) count++;
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<queue>
#include<functional>
#include<vector>
using namespace std;

priority_queue<long long,vector<long long>,greater<long long>>Q;
long long N,L,a[1000000],ok[1000000],p,q,maxn;

int main(){
	cin>>N>>L;
	for(int i=1;i<=N;i++){
		cin>>a[i];
	}
	for(int i=1;i<=N;i++){
		if(a[i]>a[i-1] && a[i]>a[i+1]){
			Q.push((L-a[i])*1000000+i);
			ok[i]=1;
		}
	}
	while(!Q.empty()){
		p=Q.top()/1000000;
		q=Q.top()%1000000;
		a[q]=0;
		maxn=p;
		if(q!=1){
			if(a[q-1]>a[q-2] && ok[q-1]==0){
				Q.push((p+L-a[q-1])*1000000+q-1);
				ok[q-1]=1;
			}
		}
		if(a[q+1]>a[q+2] && ok[q+1]==0){
			Q.push((p+L-a[q+1])*1000000+q+1);
			ok[q+1]=1;
		}
		Q.pop();
	}
	cout<<maxn<<endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    ll n=s.size();
    bool flag=true;
    if(s[0]==s[n-1]){
        if((n-3)%2==0) flag=false;
    }
    else{
        if((n-2)%2==0) flag=false;
    }
    if(flag) cout << "First" << endl;
    else cout << "Second" << endl;
}


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

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

	if (n % 3 == 0)
	{
		cout << n / 3 << endl;
	}
	else
	{
		cout << n / 3 - 1 + (n % 3 + 3) / 3 << endl;
	}
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  ll r, D, x[11];
  cin >> r >> D >> x[0];

  for(int i=1;i<=10;i++){
    x[i] = r * x[i - 1] - D;
  }

  for(int i=1;i<=10;i++){
    cout << x[i] << endl;
  }

  return 0;

}


Measured memory_bytes: 256
/*
 * B_frog2.h
 *
 *  Created on: 05-Feb-2019
 *      Author: abhimanyu
 */

#ifndef B_FROG2_H_
#define B_FROG2_H_

#include <bits/stdc++.h>
#define SUBMIT_A_FROG2 1
#define fo(i,a,b) for(int i=a;i<b;i++)
#define foi(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
using namespace std;

typedef vector<int> vi;

class Frog2{
private:
	int n,k;
	vi  stoneHeight;
public:
	Frog2(void);
	void takeInput(void);
	void solve(void);
	~Frog2(void);
};

/**
 * Constructor
 */
Frog2::Frog2(void){
	n = 0;
	k = 0;
}

/**
 * Read input from stdin
 */
void Frog2::takeInput(void){
	cin>>n>>k;
	stoneHeight.resize(n);
	fo(i,0,n){
		cin>>stoneHeight[i];
	}
}

/**
 * Solve problems
 */
void Frog2::solve(void){
	this->takeInput();
	int dp[n];
	dp[0] = 0;
	fo(i,1,n){
		dp[i] = INT_MAX;
		foi(j,i-1,max(0,i-k)){
			dp[i] = min(dp[i], dp[j] + abs(stoneHeight[i] - stoneHeight[j]));
		}
	}
	cout<<dp[n-1]<<endl;
}

/**
 * Desctructor
 */
Frog2::~Frog2(void){

}

#if SUBMIT_A_FROG2
int main(){
	Frog2 b_frog2_obj; b_frog2_obj.solve();
	return 0;
}
#endif




#endif /* B_FROG2_H_ */


Measured memory_bytes: 1024
from networkx import*
(N,),*t=[s.split()for s in open(0)]
G=Graph()
G.add_edges_from(t)
s=shortest_path_length
x=s(G,'1')
y=s(G,N)
print('FSennunkeec'[sum(x[k]>y[k]for k in x)*2>=int(N)::2])

Measured memory_bytes: 192112
inp = input()
a,b,c,d = [int(x) for x in list(inp)]

def add(a,b):
    return a+b
def sub(a,b):
    return a-b
lis = [0,0,0]
count = 0
while True:
    sum = 0
    if lis[0] == 0:
        sum = add(a,b)
    else:
        sum = sub(a,b)
    if lis[1] == 0:
        sum = add(sum,c)
    else:
        sum = sub(sum,c)
    if lis[2] == 0:
        sum = add(sum, d)
    else:
        sum = sub(sum, d)
    if sum == 7:
        break
    count += 1
    lis[0] = count % 2
    lis[1] = (count // 2) % 2
    lis[2] = (count// 4) % 2

if lis[0] == 0:
    x = '+'
else:
    x = '-'
if lis[1] == 0:
    y = '+'
else:
    y = '-'
if lis[2] == 0:
    z = '+'
else:
    z = '-'
print('{}{}{}{}{}{}{}=7'.format(a,x,b,y,c,z,d))

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
    
  int a,b;

  cin >> a >> b;

  int out1 = (int)a/b;
  int out2 = a%b;
  double out3 = (double)a/b;


  // cout << a << b << endl;
  // cout << out1 << "  "<< out2 << "  "<< out3 << "  " << endl;
  printf("%d %d %.5f", out1, out2, out3);

}



Measured memory_bytes: 3244
import sys
# K:blue　回収
# N-K:red 残り
# i 回で操作
N,K = map(int,input().split())

if K == 1:
    print(1)
    sys.exit()

# nCr = C[n][r]
# 1C0 = C[1][0], 1C1C[1][1]
MOD = 10**9 + 7
C = [[0]*2001 for _ in range(2001)]
C[1][0] = 1
C[1][1] = 1
for n in range(2,2001):
    for r in range(0,n+1):
        if r == 0:
            C[n][0] = 1
        elif r == n:
            C[n][n] = 1
        else:
            C[n][r] = (C[n-1][r-1]+C[n-1][r]) % MOD

for i in range(1,K+1):
    #p1 = combination(N-K+1,i)
    p1 = C[N-K+1][i]
    #p2 = combination(K-1,i-1)
    p2 = C[K-1][i-1]
    ans = p1 * p2 % MOD
    print(ans)


Measured memory_bytes: 75740
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
double dis(int x, int y) {
	return (double)sqrt(double(pow(x, 2)) + double(pow(y, 2)));
}
int main(){
	int d; double e;
	while (cin >> d >> e) {
		if (d == 0)break;
		double mi = (double)1000;
		for (int i = 0; i <= d; i++) {
			mi = min(mi, (double)abs(e - dis(i, d - i)));
		}
		cout << fixed << setprecision(5) << mi<<endl;
	}
	return 0;
}


Measured memory_bytes: 3172
// AOJ 0372: Three Meals
// 2017.11.14 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

typedef struct { long long b; int n, t; } T;
T tbl[3][1440]; int sz[3];
long long a[3][1440];

int bitcount64(long long x)
{
	x = ((x & 0xAAAAAAAAAAAAAALL) >>  1) + (x & 0x55555555555555LL);
	x = ((x & 0xCCCCCCCCCCCCCCLL) >>  2) + (x & 0x33333333333333LL);
	x = ((x & 0xF0F0F0F0F0F0F0LL) >>  4) + (x & 0x0F0F0F0F0F0F0FLL);
	x = ((x & 0x00FF00FF00FF00LL) >>  8) + (x & 0xFF00FF00FF00FFLL);
	x = ((x & 0xFF0000FFFF0000LL) >> 16) + (x & 0x00FFFF0000FFFFLL);
	x = ((x & 0xFFFFFF00000000LL) >> 32) + (x & 0x000000FFFFFFFFLL);
	return (int)x;
}

int cmp(T *a, T *b) { if (b->n - a->n) return b->n - a->n; return b->t - a->t; }

int main()
{
	int n, i, j, k, at, ht, f, ans;
	long long b, bb;
	
	scanf("%d", &n);
	for (b = 1, i = 0; i < n; i++, b <<= 1) for (j = 0; j < 3; j++) {
		int sh, sm, eh, em, t;
		scanf("%d%d%d%d", &sh, &sm, &eh, &em);
		sh = sh*60+sm, eh = eh*60+em;
		for (t = sh; t <= eh; t++) a[j][t] |= b;
	}
	for (j = 0; j < 3; j++) {
		T *tp;
		for (tp = tbl[j], i = 0; i < 1440; i++) if ((b = a[j][i]) > 0) {
			tp->b = b, tp->n = bitcount64(b), tp->t = i, tp++;
		}
		sz[j] = tp - tbl[j];
		qsort(tbl[j], sz[j], sizeof(T), cmp);
	}

	ans = 0;
	b  = tbl[0][0].b, n = tbl[0][0].n;
	b &= tbl[1][0].b; if (tbl[1][0].n < n) n = tbl[1][0].n;
	b &= tbl[2][0].b; if (tbl[2][0].n < n) n = tbl[2][0].n;
	if (bitcount64(b) == n && tbl[0][0].t < tbl[1][0].t && tbl[1][0].t < tbl[2][0].t) {
		ans = n; goto done;
	}

	for (i = 0; i < sz[0]; i++) {
		if (tbl[0][i].n <= ans) goto done;
		at = tbl[0][i].t, b = tbl[0][i].b;
		for (j = 0; j < sz[1]; j++) {
			if (tbl[1][j].n <= ans) break;
			if ((ht = tbl[1][j].t) <= at) continue;
			bb = tbl[1][j].b & b;
			if (bitcount64(bb) <= ans) continue;
			for (k = 0; k < sz[2]; k++) {
				if (tbl[2][k].n <= ans) break;
				if (tbl[2][k].t <= ht) continue;
				if ((f = bitcount64(bb & tbl[2][k].b)) > ans) {
					ans = f;
					if (ans == n) goto done;
				}
			}
		}
	}
done:
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1956
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

string s;
int n, dp[1000009][2], dat[1000009];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s;
	n = s.length();
	for (int i = 0; i < n; i++) dat[i] = s[i] - '0';
	reverse(dat, dat + n);
	dp[0][0] = dat[0];
	dp[0][1] = 10 - dat[0];
	for (int i = 1; i <= n; i++) {
		dp[i][0] = dp[i - 1][0] + dat[i];
		dp[i][0] = min(dp[i][0], dp[i - 1][1] + dat[i] + 1);
		dp[i][1] = dp[i - 1][0] + 10 - dat[i];
		dp[i][1] = min(dp[i][1], dp[i - 1][1] + (10 - dat[i] - 1));
	}
	cout << dp[n][0] << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 13084
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>


using namespace std;

int main() {
    size_t w;
    scanf("%zu", &w);
    vector<size_t> dlots(w);
    iota(dlots.begin(), dlots.end(), 1);

    int n;
    scanf("%d", &n);
    for (int i=0; i<n; ++i) {
        size_t a, b;
        scanf("%zu, %zu", &a, &b);
        --a, --b;
        swap(dlots[a], dlots[b]);
    }

    for (size_t i=0; i<w; ++i)
        printf("%zu\n", dlots[i]);

    return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<vector<int>> vec(n);
  rep(i,m){
    int x,y;
    cin >> x >> y;
    vec[x-1].push_back(y-1);
    vec[y-1].push_back(x-1);
  }
  vector<int> hav(n,-1);
  vector<int> ans(n,0);
  queue<int> que;
  
  hav[0]=0;
  que.push(0);
  while(!que.empty()){
    int v = que.front(); // キューから先頭頂点を取り出す
    que.pop();
     for (int nv : vec[v]) {
       if (hav[nv] != -1) continue;
       hav[nv] = hav[v] + 1;
       ans[nv]=v;
       que.push(nv);
     }
  }
  rep(i,n){
    if(i==0) cout << "Yes" << endl;
    else cout << ans[i]+1 << endl;
  }
}

Measured memory_bytes: 10568
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		
		int memory;
		
		int[] numbers = new int[3];
		numbers[0] = in.nextInt();
		numbers[1] = in.nextInt();
		numbers[2] = in.nextInt();
		
		if(numbers[0] >= numbers[1]){
			memory = numbers[0];
			numbers[0] = numbers[1];
			numbers[1] = memory;
		}
		if(numbers[1] >= numbers[2]){
			memory = numbers[1];
			numbers[1] = numbers[2];
			numbers[2] = memory;
		}
		if(numbers[0] >= numbers[1]){
			memory = numbers[0];
			numbers[0] = numbers[1];
			numbers[1] = memory;
		}
		
		System.out.println(numbers[0] + " " + numbers[1] + " "  + numbers[2]);
	}
}

Measured memory_bytes: 17320
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    auto N = readLong();
    foreach(n; iota(1, 3501)) {
        foreach(w; iota(1, 3501)) {
            if(4*n*w - (n+w)*N == 0) {
                continue;
            }
            long h = n*w*N/(4*n*w-(n+w)*N);
            if(h > 0 && 4*h*n*w == (n*w + w*h + h*n)*N) {
                writeln(h, " ", n, " ", w);
                return;
            }
        }
    }

}



Measured memory_bytes: 380
def run(x1, y1, x2, y2):
    dx = x2 - x1
    dy = y2 - y1
    x3 = x2 - dy
    y3 = y2 + dx
    x4 = x3 - dx
    y4 = y3 - dy
    return '{} {} {} {}'.format(x3, y3, x4, y4)


def read_line():
    x1, y1, x2, y2 = map(int, input().split())
    return (x1, y1, x2, y2)


def main():
    x1, y1, x2, y2 = read_line()
    ret = run(x1, y1, x2, y2)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

n,m = map(int,raw_input().split())

x = map(int, raw_input().split())
y = map(int, raw_input().split())

mod = 10**9+7
xsum = 0
ysum = 0
for i in range(n):
    xsum += (2*(i+1)-n-1)*x[i]

for i in range(m):
    ysum += (2*(i+1)-m-1)*y[i]
area = xsum*ysum%mod
print(area)

Measured memory_bytes: 14504
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>


using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(std::string X){
  char c = *X.begin();
  ll s_num = 0;
  ll t_num = 0;
  ll ans = 0;
  if(c == 'S')
    s_num++;
  else
    t_num++;

  for(auto i = X.begin()+1; i!=X.end(); i++) {
    if(*i=='S' and c == 'S') {
      s_num++;
    } else if (*i=='T' and c == 'S'){
      t_num = 1;
      c = 'T';
    } else if(*i == 'T' and c == 'T') {
      t_num++;
    } else if(*i == 'S' and c == 'T') {
      if(s_num > t_num) {
	ans += t_num;
	s_num-=t_num;
      } else if(t_num > s_num) {
	ans += s_num;
	t_num -= s_num;
	s_num = 0;
      } else {
	ans += s_num;
	s_num = 0;
	t_num = 0;
      }
      s_num++;
      t_num = 0;
      c = 'S';
    }
  }
  ans+=min(s_num, t_num);
  std::cout << X.size()-ans*2 << std::endl;
}

int main(){
  std::string X;
  std::cin >> X;
  solve(X);
  return 0;
}



Measured memory_bytes: 772
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,m,c;
    cin>>n>>m>>c;
    vector<int>b(m);
    rep(i,m)cin>>b[i];
    int ans=0;
    rep(i,n){
        int cnt=c;
        rep(j,m){
            int a; cin>>a;
            cnt+=a*b[j];
        }
        if(cnt>0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 998244353;

int64_t pow(int64_t a, int64_t b) {
    int64_t res = 1;
    for (int i = 0; i < b; i++) {
        res *= a;
        res %= MOD;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    int d[n];
    for (int i = 0; i < n; i++) cin >> d[i];

    int a[n+1];
    for (int i = 0; i < n+1; i++) a[i] = 0;

    for (int i = 0; i < n; i++) a[d[i]]++;

    if (d[0] != 0) cout << 0 << endl;
    else if (a[0] != 1) cout << 0 << endl;

    else {
        int zerofirst, nonzerolast;

        for (int i = 0; i < n+1; i++) {
            if (a[i] == 0) {
                zerofirst = i;
                break;
            }
        }

        for (int i = n; i > -1; i--) {
            if (a[i] != 0) {
                nonzerolast = i;
                break;
            }
        }

        if (zerofirst < nonzerolast) cout << 0 << endl;

        else {
            int64_t res = 1;
            for (int i = 1; i < nonzerolast+1; i++) {
                res *= pow((int64_t)a[i-1], (int64_t)a[i]);
                res %= MOD;
            }
            cout << res << endl;
        }
    }
}


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

using i64 = long long;
using P   = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()

void solve(std::string S, std::string T) {
    i64 ans = T.length();
    rep(i, S.length() - T.length() + 1) {
        i64 cost = 0;
        rep(j, T.length()) {
            if(S[i + j] != T[j]) ++cost;
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main() {
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    string st;
    cin >> st;
    int a = stoi(st);
    int cnt = 0;
    rep(i, st.size()) {
        cnt += st[i] - '0';
    }

    cout << ((a % cnt) ? "No" : "Yes") << endl;

    return 0;
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))

# a[0] > 0
ans = 0
if a[0] <= 0:
    ans += -a[0] + 1
    s = 1
else:
    s = a[0]
for i in range(1, n):
    if s > 0:
        s += a[i]
        if s >= 0:
            ans += s + 1
            s = -1
    else:
        s += a[i]
        if s <= 0:
            ans += -s + 1
            s = 1
ans1 = ans

# a[0] < 0
ans = 0
if a[0] >= 0:
    ans += a[0] + 1
    s = -1
else:
    s = a[0]
for i in range(1, n):
    if s > 0:
        s += a[i]
        if s >= 0:
            ans += s + 1
            s = -1
    else:
        s += a[i]
        if s <= 0:
            ans += -s + 1
            s = 1

print(min([ans1, ans]))

Measured memory_bytes: 85352
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

bool IsSquaredValue(int32_t n) {
  const int32_t a = static_cast<int32_t>(sqrt(n));
  return (a * a == n);
}

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

  int32_t A, B;
  cin >> A >> B;
  int32_t found = -1;
  for (int32_t i = 1; i <= max(A * 16, B * 12); ++i) {
    if ((i * 8) / 100 == A && (i * 10) / 100 == B) {
      found = i;
      break;
    }
  }
  cout << found << endl;
  return 0;
}


Measured memory_bytes: 256