akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#define MAX 120000
using namespace std;

int matrix[105][105],n,closest[105],close[105];

void djst(){
    int i,j,k;
    for(i=1;i<n;i++){
        if(matrix[0][i]!=-1)close[i]=matrix[0][i];
    }
    while(1){
        int mi=MAX,rec=-1;
        for(i=1;i<n;i++){
            if(close[i]!=-1&&close[i]<mi&&closest[i]==-1){
                mi=close[i];
                rec=i;
            }
        }
        if(rec==-1)break;
        closest[rec]=mi;
        close[rec]=MAX;
        for(j=1;j<n;j++){
            if(closest[j]==-1&&matrix[rec][j]!=-1){
                if(mi+matrix[rec][j]<close[j]||close[j]==-1)close[j]=mi+matrix[rec][j];
            }
        }
    }
}
int main(){
    memset(close,-1,sizeof(close));//memset??????????????¨0???-1???????????°???????§????
    memset(closest,-1,sizeof(closest));
    memset(matrix,-1,sizeof(matrix));
    int i,j;
    cin>>n;
    for(i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        for(j=0;j<b;j++){
            int c,d;
            cin>>c>>d;
            matrix[a][c]=d;
        }
    }
    closest[0]=0;
    djst();
    for(i=0;i<n;i++){
        cout<<i<<" "<<closest[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3112
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<map>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<vector>
using namespace std;
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
AdjList getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

long long Manhattan_dist(long long x1, long long y1, long long x2, long long y2){return abs(x1-x2) + abs(y1-y2);}

void out(bool ans){
	if(ans == true) cout << "yes" << endl;
	else cout << "no" << endl;
}
void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}
unsigned long long gcd(const unsigned long long a, const unsigned long long b){
	return (b==0) ? a : gcd(b,a%b);
}
int main(){
	long long mod = 1e9+7;
	int N;
	cin >> N;
	string S;
	cin >> S;
	map<char,int> cntr;
	for(auto c:S) cntr[c]++;
	long long ans = 1;
	for(auto x:cntr){
		// cout << x.second << endl;
		ans = (ans*(x.second+1))%mod;

	}
	cout << ans-1 << endl;


}



Measured memory_bytes: 512
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(void)
{
  char s[1024];
  int i;

  while (fgets(s, sizeof(s), stdin), strlen(s) != 0){
    for (i = 0; s[i] != '\0'; i++){
      if (islower(s[i])){
        s[i] = toupper(s[i]);
      }
    }
    printf("%s", s);
    s[0] = '\0';
  }

  return (0);
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define F first
#define S second
#define INF 1000000000000000000
#define int long long
using namespace std;
typedef pair< int,int > point;;
vector< point > graph[100001];
int v[100001];
void dijkstra(int s){
    priority_queue< point,vector< point >,greater< point > > pq;
    fill(v,v+100001,INF);
    pq.push(point(0,s));
    v[s]=0;
    while(!pq.empty()){
        point p=pq.top();pq.pop();
        int now=p.S,cost=p.F;
        for(int i=0;i<graph[now].size();++i){
            int next=graph[now][i].S;
            int ncos=graph[now][i].F+cost;
            if(ncos<v[next]){
                v[next]=ncos;
                pq.push(point(ncos,next));
            }
        }
    }
}
signed main(){
    int n;
    int a,b,c;
    scanf("%lld",&n);
    for(int i=1;i<n;++i){
        scanf("%lld%lld%lld",&a,&b,&c);
        graph[a].push_back(point(c,b));
        graph[b].push_back(point(c,a));
    }
    int query,key;
    int x,y;
    scanf("%lld%lld",&query,&key);
    dijkstra(key);
    for(int i=0;i<query;++i){
        scanf("%lld%lld",&x,&y);
        printf("%lld\n",v[x]+v[y]);
    }
    return 0;
}



Measured memory_bytes: 11120
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Integer[] Ms = new Integer[M];
        int[] checks = new int[N+1];
        List<Integer> MsList = Arrays.asList(Ms);

        for (int m = 0; m < M; m++){
            Ms[m] = sc.nextInt();
            checks[Ms[m]] = 1;
        }
        long[] memo = new long[N+1];
        for (int n = 1; n <= N; n++){
            if (n == 1) {
                if (checks[1] == 1){memo[1] = 0;}
                else {memo[1] = 1;}
                continue;
            }
            if (n == 2){
                if (checks[2] == 1){memo[2] = 0;}
                else if (checks[1] == 1){memo[2] = 1;}
                else {memo[2] = 2;}
                continue;
            }
            boolean inN = (checks[n] == 1);
            if ((inN) && (checks[n-1] == 1)) {
                break;
            }
            if (inN) {
                continue;
            }
            memo[n] = (memo[n-2] + memo[n-1])%1000000007;
        }
        System.out.println(memo[N]%1000000007);
      }
}


Measured memory_bytes: 60476
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N;long long K;
  cin>>N>>K;
  vector<ll>A(N);
  for(ll i=0;i<N;i++){
    cin>>A[i];
  }
  ll v=1;
  vector<ll> s;//辿る辺の順番
  vector<ll> ord(N+1,-1);//点vに何番目に来たか
  while(ord[v]==-1){
    ord[v]=s.size();
    s.push_back(v);
    v=A[v-1];
    // cout<<"v:"<<v<<endl;
  }
  ll cir=s.size()-ord[v];//周期のサイズ
  // cout<<s.size()<<endl;
  // cout<<ord[v]<<endl;
  // cout<<"cir:"<<cir<<endl;
  ll re=ord[v];//例外のサイズ
  // cout<<re<<endl;
  if(K<re)cout<<s[K]<<endl;
  else{
    K-=re;
    K%=cir;
    // cout<<tmp<<endl;
    // cout<<re<<endl;
    cout<<s[re+K]<<endl;
  }


}

Measured memory_bytes: 8504
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long n = Integer.parseInt(in.next());
            long k = Integer.parseInt(in.next());
            double ans = 0.0;

            for (long i = 1; i <= n; i++) {
                double tmp = 1.0;
                long nn = i;
                while (nn < k) {
                    nn *= 2;
                    tmp /= 2.0;
                }
                ans += tmp;
            }
            ans /= n;

            // 出力
            out.printf("%.12f\n", ans);

        }

    }
}



Measured memory_bytes: 23892
import java.util.Scanner;

public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);

int w = sc.nextInt();
int n = sc.nextInt();
int[] values = new int[w];
for (int i = 0; i < values.length; i++) {
values[i] = i + 1;
}

for (int i = 0; i < n; i++) {
String str = sc.next();
String[] ab = str.split(",");//文字列を,で分割
int a = Integer.parseInt(ab[0]) - 1;//intに変換
int b = Integer.parseInt(ab[1]) - 1;//分割されているから三文字目だけど二番目になった

int change;

change=values[a];
values[a]=values[b];
values[b]=change;

}

for(int i=0;i<values.length;i++){
System.out.printf("%d\n",values[i]);

}
sc.close();

}

}


Measured memory_bytes: 26284
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int N, A, B, C;
struct abc {
    int a, b, c, cost;
};

vector<abc> V;
vector<int> L;

void dfs(int i, int a, int b, int c, int cost){
    if(i==N){
        
        abc r;
        r.a = a;
        r.b = b;
        r.c = c;
        if(min(min(a,b), c) == 0) r.cost = INF;
        else r.cost = cost-30;
        V.push_back(r);
        return;
    }
    
    dfs(i+1, a, b, c, cost);
    dfs(i+1, a+L[i], b, c, cost + 10);
    dfs(i+1, a, b+L[i], c, cost + 10);
    dfs(i+1, a, b, c+L[i], cost + 10);
    return;
}

int main(){
    cin >> N >> A >> B >> C;
    L.resize(N);
    for(int&i:L)
        cin >> i;
    
    dfs(0, 0, 0, 0, 0);

    int ans = INF;
    for(int i=0; i<V.size(); i++){
        ans = min(ans, abs(A-V[i].a)+abs(B-V[i].b)+abs(C-V[i].c) + V[i].cost);
    }
    
    cout << ans << endl;
    return 0;
}


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

void Main() {
    // input
    string S, T;
    cin >> S;
    cin >> T;


    // translate
    u_int32_t ans = 0;
    for (u_int32_t i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) {
            ans++;
        }
    }


    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

#define INF 2e9

int M, D;


int main(){

    scanf("%d %d",&M,&D);

    int d,d_1,d_10;

    int i = 0;

    FOR(d, 1, D+1){
        d_1 = d - (d / 10)*10;
        d_10 = d / 10;
        //printf("%d / %d %d\n", d_10 * d_1 , d_10, d_1);
        if(d_10 >= 2 && d_1 >= 2 && (d_10 * d_1) <= M){
            //printf("%d / %d %d\n", d_10 * d_1 , d_10, d_1);
            i++;
        }
    }

    printf("%d", i);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int POW(int a,int n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return (int)ans;}
int icmp(const void* a,const void* b){return *(int*)a-*(int*)b;}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL fac[NUM],finv[NUM],inv[NUM];
void comi(){int i;fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fac[i]=fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
int com(int n,int k){if(n<k||n<0||k<0)return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  int N,K,R,S,P,i,ans=0;
  scanf("%d%d%d%d%d",&N,&K,&R,&S,&P);
  char T[N+1];
  int flag[N];
  FOR(i,0,N)flag[i]=0;
  scanf("%s",T);
  FOR(i,0,N){
    if(flag[i]==0){
      if(T[i]=='s')ans+=R;
      if(T[i]=='p')ans+=S;
      if(T[i]=='r')ans+=P;
      if(i+K<N)if(T[i+K]==T[i])flag[i+K]=1;
    }
  }

  printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=1<<29;
ll mod=1000000007;

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

	int N;
	cin>>N;
	vector<int> A(N);
	for(int i=0;i<N;i++) cin>>A[i];
	if(N==1){
		cout<<"Yes\n";
		return 0;
	}
	for(int i=N-1;i>=1;i--){
		if(A[i]>=A[i-1]) continue;
		else if(A[i]+1==A[i-1]) A[i-1]--;
		else{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";

	return 0;
}

Measured memory_bytes: 640
void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>
#include <limits.h>
#include <iomanip>
#include <stack>

using namespace std;
using namespace boost::multiprecision;

int N, K;
void solve() {
	cin >> N >> K;
	long double p = 0;
	for (int n = 1; n <= N; n++) {
		int t = N;
		int tn = n;
		while (tn < K) {
			t *= 2;
			tn *= 2;
		}
		p += 1 / (long double)t;
	}
	cout << setprecision(10) << showpoint << p;
}

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

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define REP(i,n) FOR(i,0,n)

class DisjointSet {
public:
  DisjointSet(int size): size(size) {
    id.resize(size, -1);
  }

  void unite(int x, int y) {
    x = getId(x);
    y = getId(y);

    if (x != y) {
      if (id[x] > id[y]) swap(x,y);
      id[x] += id[y];
      id[y] = x;
      --size;
    }
  }

  int getId(int x) {
    return id[x] < 0 ? x : id[x] = getId(id[x]);
  }

  void show() {
    printf("\n");
    REP(i,id.size()) printf("%d ", id[i]);
    printf("\n");
  }

private:
  vector<int> id;
  int size;
};

int N, M;
int p[100000];

int main() {
  scanf("%d%d", &N, &M);
  REP(i,N) {
    scanf("%d", &p[i]);
    --p[i];
  }

  DisjointSet ds(N);
  int x, y;
  REP(i,M) {
    scanf("%d%d", &x, &y);
    --x, --y;
    ds.unite(x,y);
    //ds.show();
  }

  int count = 0;
  REP(i,N) if (ds.getId(i) == ds.getId(p[i])) ++count;

  printf("%d\n", count);
  return 0;
}

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

int ans = 0;
std::string s;

int main() {
    std::cin >> s;
    for (int i = 0; i < 4; i++) {
        if (s[i] == '+')
            ans++;
        else
            ans--;
    }
    std::cout << ans << std::endl;
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1)/b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }

int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vec x(n),y(n);
    rep(i,n) cin>>x[i]>>y[i];
    pvec h;
    rep(i,n) h.eb(x[i],y[i]);
    sort(all(h));
    rep(i,n) tie(x[i],y[i])=h[i];
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    map<P,int> mp;
    rep(i,n-1){
        for(int j=i+1;j<n;j++){
            mp[P(x[i]-x[j],y[i]-y[j])]++;
        }
    }
    int ans=n;
    for(auto x:mp){
        chmin(ans,n-x.sc);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,a[10000],cnt,dig[10000],i,j,ans[10000],g,flg;
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for(i=0;i<n;i++) dig[i]=log10(a[i])+1;
	cnt=0; flg=0;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(i!=j){
				g=pow(10,dig[j]);
				ans[cnt]=a[i]*g+a[j];
				cnt++;
			}
			if(cnt==10000){
				flg=1;
				break;
			}
		}
		if(flg==1)break;
	}
	sort(ans,ans+cnt);
	cout<<ans[2]<<endl;
	return 0;
}

Measured memory_bytes: 3428
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Train {
    class Class2 {
        const string mark = "*";

        static void Main(string[] args) {
            new Class2().solve();
        }
        void solve() {
            int size_Data = int.Parse(Console.ReadLine());

            string[] result = new string[6];
            for (int i = 0; i < size_Data; i++) {
                double data = double.Parse(Console.ReadLine());
                if (data < 165.0) {
                    result[0] += mark;
                } else if (data >= 165.0 && data < 170.0) {
                    result[1] += mark;
                } else if (data >= 170.0 && data < 175.0) {
                    result[2] += mark;
                } else if (data >= 175.0 && data < 180.0) {
                    result[3] += mark;
                } else if (data >= 180.0 && data < 185.0) {
                    result[4] += mark;
                } else {
                    result[5] += mark;
                }
            }

            for (int i = 0; i < result.Length; i++) {
                Console.WriteLine((i+1)+":"+result[i]);
            }
        }
    }
}

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
const int N=1000005;
int vis[N];
vector<int>e[N],path,path2;
void dfs(int x)
{
	vis[x]=1;
	path.push_back(x);
	for(int i=0;i<e[x].size();i++)
	{
		if(!vis[e[x][i]])
		{
			dfs(e[x][i]);
			return;
		}
	}
}
int main()
{
	int n,m,a,b;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&a,&b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	dfs(1);
	swap(path,path2);
	dfs(1);
	printf("%d\n",path.size()+path2.size()-1);
	for(int i=(int)path2.size()-1;i>=0;i--)
		printf("%d ",path2[i]);
	for(int i=1;i<path.size();i++)
		printf("%d ",path[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 31864
def get_input():
    data_list = input().split()
    for i in range(len(data_list)):
        data_list[i] = int(data_list[i])
    return data_list

def get_score_list(student_num):
    score_list = [None] * student_num
    for i in range(student_num):
        score_data = int(input())
        score_list[i] = score_data
    score_list = sorted(score_list, reverse=True)
    return score_list

def decide_success_student_num(score_list, min_num, max_num):
    max_diff = -float('inf')
    for i in range(min_num - 1, max_num):
        tmp_num = score_list[i] - score_list[i+1]
        if tmp_num >= max_diff:
            max_diff = tmp_num
            success_student_num = i + 1
    return success_student_num


if __name__ == "__main__":
    while True:
        student_num, min_num, max_num = get_input()
        if student_num == 0:
            break
        score_list = get_score_list(student_num)
        success_student_num = decide_success_student_num(score_list, min_num, max_num)
        print(success_student_num)



Measured memory_bytes: 5624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
#include <atcoder/all>
using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

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

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

int encode (int i, int j, int w) { return i * w + j; }
P decode (int k, int w) { return P{k / w, k % w}; }
const ll BIG = (ll)1e9, MED = (ll)1e5;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w; cin >> h >> w;
    vector<string> s(h); rep (i, h) cin >> s[i];
    int start = h * w, goal = h * w + 1;
    mcf_graph<ll, ll> mcf(h * w + 2);    
    int pins = 0;
    rep (i, h) {
        rep (j, w) {
            int p = encode(i, j, w);
            if (s[i][j] == 'o') {
                mcf.add_edge(start, p, 1, 0);
                pins++;
            }
            if (s[i][j] == '#') continue;
            mcf.add_edge(p, goal, 1, (h + w - i - j) * BIG);
            rep (d, 2) {
                int y = i + dy[d], x = j + dx[d];
                if (y < 0 || x < 0 || y >= h || x >= w) continue;
                if (s[y][x] != '#') {
                    int q = encode(y, x, w);
                    // mcf.add_edge(p, q, 1, BIG - 1);
                    mcf.add_edge(p, q, h * w, BIG - 1);
                }
            }
        }
    }
    auto res = mcf.flow(start, goal, pins);
    // eprintf("flow:%lld cost:%lld\n", res.first, res.second);
    auto edges = mcf.edges();
    ll ans = 0;
    for (auto &e : edges) {
        // eprintf("%d->%d %lld/%lld %lld\n", e.from, e.to, e.flow, e.cap, e.cost);
        if (e.from != start && e.to != goal) ans += e.flow;
    }
    cout << ans << "\n";

    /***************************************************/
    /* Submit this code from the browser if using ACL! */
    /***************************************************/
    return 0;
}

Measured memory_bytes: 4432
#include <iostream>
using namespace std;
int main() {
  string p, s;
  cin >> p;
  p += p;
  cin >> s;
  if((int)p.find(s) != -1) {
	cout << "Yes" << endl;
  }
  else {
	cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3220
n,h=map(int,input().split())
p,x,y=[],[],[]
z=float("inf")
for i in range(n):
  a,b=map(int,input().split())
  p.append((a,b))
  x.append(a)
  y.append(b)
x.sort()
y.sort()
for i in range(n-1):
  for j in range(i,n):
    for k in range(n-1):
      lx,rx,dy=x[i],x[j],y[k]
      c=0
      t=[]
      for a,b in p:
        if x[i]<=a<=x[j] and y[k]<=b:c+=1;t.append(b)
      if h<=c:z=min(z,(x[j]-x[i])*(sorted(t)[h-1]-y[k]))
print(z)


Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] L = new int[N];
        for(int n=0; n<N; n++) L[n]=sc.nextInt();

        int ans=1;
        int pos = 0;
        for(int n=0; n<N; n++){
            pos+=L[n];
            if(pos<=X) ans++;
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 21716
// https://atcoder.jp/contests/abc138/tasks/abc138_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> G(N + 1);
  REP(i, N - 1) {
    int a, b;
    cin >> a >> b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  vector<int> ans(N + 1);
  while (Q--) {
    int p, q;
    cin >> p >> q;
    ans[p] += q;
  }

  queue<int> que;
  que.push(1);
  // 後戻りしないようにする
  bitset<200001> bs;
  bs.set(1);
  while (!que.empty()) {
    int t = que.front();
    que.pop();
    for (auto &x : G[t]) {
      if (!bs[x]) {
        bs.set(x);
        ans[x] += ans[t];
        que.push(x);
      }
    }
  }
  FOR(i, 1, N + 1) { cout << ans[i] << (i == N ? "\n" : " "); }

  return 0;
}


Measured memory_bytes: 19004
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
using namespace std;
const int mod = 1e9+7;
const int N = 2e5+5;
vector<int> x,y;
int F[N],I[N];
int pw(int a,int n) {
    int y = 1;
    for (;n;n/=2) {
        if (n&1) y = (ll)y*a%mod;
        a = (ll)a*a%mod;
    }
    return y;
}
int C(int n,int m) {
    if (m > n) return 0;
    return (ll)F[n]*I[m]%mod*I[n-m]%mod;
}
int ans[9500000];
main() {
    ios::sync_with_stdio(0);
    F[0] = I[0] = 1;
    for (int i = 1; i < N; i++) {
        F[i] = (ll)i*F[i-1]%mod;
        I[i] = pw(F[i],mod-2);
    }

    int n,m;

    int r,c;
    cin >> r >> c >> n;
    vector<pii> A;
    A.pb({1,1});
    for (int i = 1;i <= n; i++) {
        int a,b; cin >> a >> b;
        A.pb({a,b});
    }
    A.pb({r,c});
    sort(A.begin(),A.end());
    ans[0] = 1;
    for (int i = 1; i < A.size(); i++) {
        int x = A[i].fi;
        int y = A[i].se;
       // for (int j = 0; j < )
        ans[i] = C(x-1+y-1,y-1);
       // cout << ans[i] << ' ';
        for (int j = 1; j < i; j++)
        if (A[i].se >= A[j].se)
            (ans[i] -= (ll)ans[j]*C(x - A[j].fi + y - A[j].se,x - A[j].fi)%mod)%=mod;
    }
   // cout << ans[1];return 0;
    cout << (ans[A.size()-1]%mod+mod)%mod;



/*
    for (int i = 1;i <= r; i++)
    for (int j = 1; j <= c; j++)  {
        char c;
        cin >> c;
        if (c == '#') A.pb({i,j});
    }
    A.pb({r,c});

*/


}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 cnt(13);
  cnt[0] = 1;
  rep(i, n) {
    int d;
    cin >> d;
    cnt[d]++;
  }
  if (cnt[0] >= 2) {
    cout << 0 << endl;
    return;
  }
  reps(i, 12) {
    if (cnt[i] >= 3) {
      cout << 0 << endl;
      return;
    }
  }
  vi32 lst;
  repc(i, 12) {
    rep(j, cnt[i]) lst.push_back(i);
  }
  int l = lst.size();
  int ans = 0;
  rep(i, bit32(l)) {
    bitset<25> c;
    c[24] = 1;
    bool ok = true;
    rep(j, l) {
      int d;
      if (i & bit32(j)) {
        d = (24 - lst[j]) % 24;
      } else {
        d = lst[j];
      }
      if (c[d]) ok = false;
      else c[d] = 1;
    }
    if (!ok) continue;

    int mi = 1e9;
    int cn = 1;
    vi32 ls;
    reps(j, 25) {
      if (!c[j]) {
        cn++;
      } else {
        amin(mi, cn);
        cn = 1;
      }
    }
    amax(ans, mi);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
  long long ans;
  ans = accumulate(A.begin(), A.end(), 0LL);
  ans = min(ans, accumulate(B.begin(), B.end(), 0LL));
  vector< pair<long long, int> > s;
  for (int i = 0; i < N; i++) {
    s.emplace_back(A[i], i);
    s.emplace_back(B[i], i);
  }
  sort(s.begin(), s.end());

  vector<int> d(N, 0);
  bool flag = false;

  long long t = 0;
  for (int i = 0; i < N; i++) {
    t += s[i].first;
    ++d[s[i].second];
    if (d[s[i].second] == 2) {
      flag = true;
    }
  }

  if (flag) {
    ans = min(ans, t);
  } else {
    int n1 = s[N].second;
    for (int i = 0; i < N; i++) {
      if (s[i].second == n1) {
        ans = min(ans, t - s[i].first + s[N+1].first);
      } else {
        ans = min(ans, t - s[i].first + s[N].first);
      }
    }
  }

  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
    scanf("%lld",&B[i]);
  }
  solve(N, std::move(A), std::move(B));
  return 0;
}


Measured memory_bytes: 8048
#include<stdio.h>

int main()
{
    int r,g,b, results;
    scanf("%d %d %d",&r ,&g, &b);

    results = 100*r + 10*g +b;
    if( results%4==0 )
    {
         printf("YES");
    }
    else
    {
         printf("NO");
    }

    return 0;
}

Measured memory_bytes: 1700
// clang-format off
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using G = vector<vector<ll>>;
#define G(i, j) i, vector<ll>(j)
#define Gv(i, j, k) i, vector<ll>(j, k)
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
#define END(ans) ANS(ans); return
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(long long N, std::vector<std::string> S) {
  ll ac = 0, wa = 0, tle = 0, re = 0;
  rep(i, N) {
    switch (S[i][0]) {
    case 'A':
      ac++;
      break;
    case 'W':
      wa++;
      break;
    case 'T':
      tle++;
      break;
    case 'R':
      re++;
      break;
    }
  }
  ANS("AC x " << ac);
  ANS("WA x " << wa);
  ANS("TLE x " << tle);
  ANS("RE x " << re);
}

// clang-format off
int main() {
  long long N;
  scanf("%lld",&N);
  std::vector<std::string> S(N);
  for(int i = 0 ; i < N ; i++){
    std::cin >> S[i];
  }
  solve(N, std::move(S));
  return 0;
}


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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define int long long
int A[500][500];
bool solve() {
    REP(i, 500) REP(j, 500) A[i][j] = 0;
    int n, m, t, p;
    cin >> n >> m >> t >> p;
    if (n == 0) return false;
    REP(i, n) {
        REP(j, m) { A[i][j] = 1; }
    }
    int l = 0, u = 0;
    REP(_, t) {
        int d, c;
        cin >> d >> c;
        if (d == 2) {
            REP(i, 500) {
                REP(j, c) {
                    int dif = 2 * c - 2 * j - 1;
                    A[i][l + j + dif] += A[i][l + j];
                    A[i][l + j] = 0;
                }
            }
            l = l + c;
        } else {
            REP(j, 500) {
                REP(i, c) {
                    int dif = 2 * c - 2 * i - 1;
                    A[u + i + dif][j] += A[u + i][j];
                }
            }
            u += c;
        }
    }
    REP(_, p) {
        int x, y;
        cin >> x >> y;
        cout << A[u + x][l + y] << endl;
    }
    return true;
}
signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 5024
#include <bits/stdc++.h> 
#define ll long long int
#define DEBUG(x) cerr<<"> "<< #x << ':' <<x<<endl;
using namespace std;
ll INF = 1e15;
ll MOD = 1e9 + 7;
vector <ll> prime;
vector <bool> vis;

ll quick_expo( ll x, ll y )
{
    ll ans = 1;
    while(y!=0)
    {
        if((y&1) == 1)
            ans = (ans*x)%MOD;
        x = (x*x)%MOD;
        y = y>>1;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    for(int i=0;i<(1e6 + 6);i++)
    {
        vis.push_back(false);
    }
    for(int i=2;i<(1e6 + 6);i++)
    {
        if(vis[i] == false)
        {
            vis[i] = true;
            prime.push_back(i);
            for(int j=i;j<(1e6 + 6);j+=i)
            {
                vis[i] = false;
            }
        }        
    }
    ll c = 0;

    for(auto i:prime)
    {
        if(i>n)
        {
            break;
        }
        if(n%i == 0)
        {
            ll e = 0;
            while(n%i ==0 && n!=0 )
            {
                e++;
                n = n/i;
            }
            ll sum = e;
            if(sum == 1)
            {
                c++;
            }
            else
            {
                for(int j=1;j<=e;j++)
                {
                    if(sum<j)
                    {
                        break;
                    }
                    c++;
                    sum -= j;
                }
            }
        }
    }
    if(n>1)
        c++;
    cout<<c<<"\n";
}

Measured memory_bytes: 11732
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		System.out.printf("%d %d %f\n", a/b, a%b, (double)a/b);
	}
}

Measured memory_bytes: 26416
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int X, Y, Z;
	scanf("%d %d %d", &X, &Y, &Z);
	printf("%d\n", (X - Z) / (Y + Z));
	return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    LL x,y;
    cin >> x >> y;
    cout << min(max(y-x,x-y+2),abs(x+y)+1) << endl;
    return 0;
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll k; cin >> k;
    ll m = 0, bit = 1;
    frep(i, 1, k) {
        m = (m+bit*7)%k;
        if(m == 0) {
            cout << i << endl;
            return 0;
        }
        bit = (bit*10)%k;
        // cout << m << endl;
    }
    cout << -1 << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        int k=Integer.parseInt(st.nextToken());
        int s=Integer.parseInt(st.nextToken());
        int count=0;
        for(int i=0;i<=k;i++){
            if(i>s) break;
            for(int j=0;j<=k;j++){
                if(i+j>s) break;
                if((s-(i+j))<=k) count+=1;
            }
        }System.out.println(count);
    }
    
}


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

int main(){
 int a , b , c;
 cin >> a >> b >> c;
 if(a != b && b != c && a != c){
     cout << 3 << endl;
 }
 else if(a == b && a == c){
     cout << 1 << endl;
 }
 else cout << 2 << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    static int MOD = 1000000007;
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] abcd = new int[4];

        for(int i=0;i<4;i++)abcd[i]=Integer.parseInt(s.substring(i,i+1));

        for(int i=0;i<Math.pow(2,3+1);i++){
            int  temp = i;
            boolean[] bit = new boolean[3];
            for(int j=0;j<3;j++){
                bit[j]=temp%2==1;
                temp=temp>>1;
            }
            

            int fugou = 1;
            int ans=abcd[0];

            for(int j=0;j<3;j++){
                if(!bit[j])fugou=-1;
                else fugou = 1;
                ans+=fugou*abcd[j+1];

            }

            if(ans==7){

                for(int j=0;j<3;j++){
                    System.out.print(abcd[j]);
                    System.out.print(bit[j]?"+":"-");
                }
                System.out.println(abcd[3]+"=7");
                return;
            }


        }
    }

}


Measured memory_bytes: 21972
#include <iostream>


using namespace std;

int main(){
    int a, b, tmp = 0, i, diff;

    cin >> a >> b;
    diff = b - a;
    for(i = 1; i <= diff; i++){
        tmp += i;
    }
    
    cout << (tmp*2 - diff - a - b) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		int ans = 0;
		for(int i = a; i <= b; ++i) {
			if(c % i == 0) {
				++ans;
			}
		}
		System.out.println(ans);
	}
}


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

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

int w[101], v[101];

ll solve(int n, int m, vector<vector<ll>> dp){
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			if(w[i] <= j)
				dp[i][j] = max(v[i] + dp[i-1][j-w[i]], dp[i-1][j]);
			else
				dp[i][j] = dp[i-1][j];
		}
	}
	return dp[n][m];
}

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	
/*	int t;
	cin >> t;
	while(t--){
		//cout << "Case #" << t  << ": ";
        
	} */
	int n, m;
	cin >> n >> m;
	
	for(int i = 1; i <= n; i++)
		cin >> w[i] >> v[i];
	
	vector<vector<ll>> dp(n+1, vector<ll>(m+1, 0));
	ll ans = solve(n, m, dp);
	cout << ans;
	return 0;
}


Measured memory_bytes: 161172
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
#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 RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(){

  int n, l;

  cin >> n >> l;

  vector<string> v(n);

  REP(i, n) cin >> v[i];

  sort(v.begin(), v.end());

  REP(i, n) cout << v[i];

  cout << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define N (ll)(1e9+7)
#define T int
#define P pair<T,T>
#define umap unordered_map<T,T>
#define uset unordered_set<T>
#define rep(i,n) for(i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define print(v) for(auto x:v) cout<<x<< " "
#define pb push_back
using namespace std;


int main()
{
    
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int a=h1*60+m1;
    int b=h2*60+m2;
    cout<<b-a-k<<endl;
}


Measured memory_bytes: 3636
#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;
    cin >> N;
    vector<int> counter(4, 0);
    rep(i, N) {
        char s[30];
        cin >> s;
        // cout << s << endl;
        if(s[0]=='A'){
            counter[0]++;
        }else if(s[0]=='W'){
            counter[1]++;
        }else if(s[0]=='T'){
            counter[2]++;
        }else if(s[0]=='R'){
            counter[3]++;
        }
    }
    cout << "AC x " << counter[0] << endl;
    cout << "WA x " << counter[1] << endl;
    cout << "TLE x " << counter[2] << endl;
    cout << "RE x " << counter[3] << endl;

    return 0;
}

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

int main() {
	ll n,x,a,ans=0;
	cin>>n>>x;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a>=x)ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    double d = in.nextDouble();
    double t = in.nextDouble();
    double s = in.nextDouble();
    double last = d/s;
    if(last <= t) {
      System.out.print("Yes");
    }else {
    System.out.print("No");
    }
  }
}

Measured memory_bytes: 37152
#include <bits/stdc++.h>
using namespace std;
int kind[5] = {' ','A','C','G','T'};
typedef struct{
  vector<int>data;
}H;
H hash[5000000];

int convertion(string s){
  int d = 1;
  int sum = 0;
  for(int i = s.size() - 1;i >= 0;i--){
    for(int j = 1;j < 5;j++){
      if(kind[j] == s[i]){sum += d * j;break;}
    }
    d *= 5;
  }
  return sum;
}

int main(){
  string q,s;
  int n;
  cin >> n;
  while(n--){
    cin >> q >> s;
    if(q == "insert"){
      int sum = convertion(s);
      hash[sum / 60].data.push_back(sum);
    }
    if(q == "find"){
      int sum = convertion(s);
      bool flag = false;
      for(int i = 0;i < hash[sum / 60].data.size();i++){
	if(hash[sum / 60].data[i] == sum){cout << "yes" << endl;flag = true;break;}
      }
      if(!flag)cout << "no" << endl;
    }
  }
  return 0;
}

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

int main(){
int H, W;
cin >> H >> W;

vector<string>S(H);
for(int i = 0; i < H; i++){ 
       cin >> S.at(i);
}

int left[H][W];

for(int i = 0; i < H; i++){ 
      int cnt = 0;
       for(int j = 0; j < W; j++){
              if(S[i][j] == '#') cnt = 0;
              else cnt++;
              left[i][j] = cnt;
       }
}

int right[H][W];

for(int i = 0; i < H; i++){ 
      int cnt = 0;
       for(int j = W - 1 ; j >= 0; j--){
              if(S[i][j] == '#') cnt = 0;
              else cnt++;
              right[i][j] = cnt;
       }
}

int up[H][W];

for(int i = 0; i < W; i++){
      int cnt = 0; 
       for(int j = 0; j < H; j++){
              if(S[j][i] == '#') cnt = 0;
              else cnt++;
              up[j][i] = cnt;
       }
}

int down[H][W];

for(int i = 0; i < W; i++){ 
      int cnt = 0;
       for(int j = H - 1 ; j >= 0; j--){
              if(S[j][i] == '#') cnt = 0;
              else cnt++;
              down[j][i] = cnt;
       }
}

int ans = -1;
for(int i = 0; i < H; i++){ 
       for(int j = 0; j < W; j++){ 
              
              ans = max(ans, left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3);
       }
}

cout << ans << endl; 
}

Measured memory_bytes: 66816