akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 100000000000007;
    public static void Main()
    {
        int N = NextInt();
        Node[] node = new Node[N];
        for (int i = 0; i < N; i++) node[i] = new Node(i);
        int[] a = new int[N - 1];
        int[] b = new int[N - 1];
        long[] c = new long[N - 1];
        for (int i = 0; i < N - 1; i++)
        {
            int A = NextInt() - 1;
            int B = NextInt() - 1;
            int C = NextInt();
            Edge e = new Edge();
            e.to = B;
            e.cost = C;
            node[A].relate.Add(e);
            e = new Edge();
            e.to = A;
            e.cost = C;
            node[B].relate.Add(e);
        }
        int Q = NextInt();
        int K = NextInt() - 1;
        Stack<Node> stack = new Stack<Node>();
        stack.Push(node[K]);
        while (stack.Count() != 0)
        {
            Node now = stack.Pop();
            now.visit = true;
            foreach (var e in now.relate)
            {
                if (!node[e.to].visit)
                {
                    node[e.to].cost = now.cost + e.cost;
                    stack.Push(node[e.to]);
                }
            }
        }
        for(int i = 0;i < Q; i++)
        {
            Console.WriteLine(node[NextInt()-1].cost + node[NextInt() - 1].cost);
        }
    }
}
public class Node
{
    public List<Edge> relate = new List<Edge>();
    public int name = 0;
    public bool visit = false;
    public long cost = 0;
    public Node(int name) { this.name = name; }
}
public class Edge
{
    public int to;
    public long cost;
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

Measured memory_bytes: 46876
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define endl '\n'

void solvetask(){
    int n; cin >> n;
    int ok = 0, cnt = 0;
    for (int i=0; i<n; i++){
        int a,b; cin >> a >> b;
        if (a == b) cnt++;
        else cnt = 0;
        if (cnt == 3) ok = 1;
    }
    if (ok) cout << "Yes\n";
    else cout << "No\n";
}
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solvetask();
}

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

int main()
{
    int n, t[101], v[101];
    int *points = new int[41000], *points_limit = new int[41000];
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", t + i);
    for (int i = 0; i < n; i++)
        scanf("%d", v + i);
    t[n] = v[n] = 0;
    for (int i = 1; i < n; i++)
        t[i] += t[i - 1];
    std::fill(points_limit, points_limit + t[n - 1] * 2 + 1, 1000);
    for (int i = 0; i <= t[0] * 2; i++)
        points_limit[i] = std::min(v[0] * 2, points_limit[i]);
    for (int i = 1; i < n; i++)
        for (int j = t[i - 1] * 2; j <= t[i] * 2; j++)
            points_limit[j] = std::min(v[i] * 2, points_limit[j]);
    points_limit[0] = points_limit[t[n - 1] * 2] = 0;
    for (int i = t[n - 1] * 2 - 1; i >= 0; i--)
    {
        points_limit[i] = std::min(points_limit[i], points_limit[i + 1] + 1);
    }
    for (int i = 1; i <= t[n - 1] * 2 - 1; i++)
    {
        points_limit[i] = std::min(points_limit[i], points_limit[i - 1] + 1);
    }
    long long sum{};
    for (int i = 0; i < t[n - 1] * 2; i++)
        sum += points_limit[i] + points_limit[i + 1];
    printf("%lf\n", (double)sum / 8);
    

    delete[] points;
    delete[] points_limit;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll x,y;
  cin >> x >> y;
  if(x*2<=y&&y<=x*4&&y%2==0) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

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

using namespace std;

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

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int main()
{
    int n, m;

    cin >> n >> m;

    map <int, pair<int, bool>> mapa;

    for(int i = 0; i < m; i++)
    {
        int p;
        string s;
        cin >> p >> s;

        bool jelTacno = ((s == "AC") ? (true) : (false));

        if(mapa.find(p) == mapa.end())
        {
            mapa[p].fi = ((jelTacno == true) ? (0) : (1));
            mapa[p].se = jelTacno;
        }

        else if(mapa[p].se == false)
        {
            if(jelTacno == true)
            {
                mapa[p].se = true;
            }

            else
            {
                mapa[p].fi++;
            }
        }
    }

    int kolikoJeUspeo = 0, kazna = 0;

    for(map <int, pair <int, bool>>::iterator it = mapa.begin(); it != mapa.end(); ++it)
    {
        if(it->second.se)
        {
            kazna += it->second.fi;
            kolikoJeUspeo += it->second.se;
        }
    }

    cout << kolikoJeUspeo << ' ' << kazna << '\n';

    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
 
using namespace std;
 
int n,e,i,j;
vector<vector<pair<int,int> > > graph;
vector<int> color;
bool vis[100001];
set<int> st;
 
void colour(int node)
{
	queue<int> q;
	int c=0;
	set<int> already_colored;
	if(vis[node])
		return;
	vis[node]=1;
 
	for(i=0;i<graph[node].size();i++)
	{
		if(color[graph[node][i].second]!=-1)
		{
			already_colored.insert(color[graph[node][i].second]);
		}
	}
 
	for(i=0;i<graph[node].size();i++)
	{
		if(!vis[graph[node][i].first])
		{
			q.push(graph[node][i].first);
		}
		if(color[graph[node][i].second]==-1)
		{
			while(already_colored.find(c)!=already_colored.end())
			c++;
			color[graph[node][i].second]=c;
			st.insert(color[graph[node][i].second]);
			already_colored.insert(c);
			c++;
		}
	}
	while(!q.empty())
	{
		int temp=q.front();
		q.pop();
		colour(temp);
	}
	return;
}
 
int main()
{
	int x,y;
	set<int> empty;
	cin>>n;
	graph.resize(n);
	color.resize(n,-1);
	memset(vis,0,sizeof(vis));
	for(i=0;i<n-1;i++)
	{
		cin>>x>>y;
		x--; y--;
		graph[x].push_back(make_pair(y,i));
		graph[y].push_back(make_pair(x,i));
	}
	colour(0);
	cout << st.size() << endl;
	for(i=0;i<n-1;i++) {
	    cout << color[i]+1<<endl;
	}
}

Measured memory_bytes: 57600
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 1e6 + 111;
        
using namespace std;          

int n, p, a[maxn], m;
string s;

void solve(){             
	cin >> n >> m;

	int mx = 0;

	for (int i = 1; i <= n; i++){
		cin >> a[i];
		p += a[i];
		mx = max(mx, a[i]);
	}
    int cnt = 0;

    for (int i = 1; i <= n; i++){
    	if (a[i] * 4 * m >= p)
    		cnt++;
    }

    if (cnt >= m)
    	cout << "Yes";
    else
    	cout << "No";
}                              
      
main(){
    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
using namespace std;
using ll = unsigned long long;
using p = pair<int, int>;

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

    N %= 10;

    if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9)
    {
        cout << "hon" << endl;
    }
    else if (N == 0 || N == 1 || N == 6 || N == 8)
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "bon" << endl;
    }

    return 0;
}


Measured memory_bytes: 3552
//ABC066A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <numeric>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int ans = min({a+b,b+c,c+a});
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

const ll MOD = 1e9 + 7;

int main() {
    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<ll> A(N), s(N + 1, 0);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    if (P >= V) {
        rep(i, N) {
            //cout << i << " " << A[i] << endl;
            if (A[P - 1] - A[i] > M) {
                cout << i << endl;
                return 0;
            }
        }
        cout << N << endl;
        return 0;
    }
    rep(i, N) s[i + 1] = s[i] + A[i];
    ll ok = P - 1, ng = N;
    while (ok + 1 < ng) {
        //cout << ok << " " << ng << endl;
        ll x = (ok + ng) / 2;
        if (A[P - 1] > A[x] + M) {
            ng = x;
            continue;
        }
        if (s[x] - s[P - 1] - A[x] * (x - P + 1) <= (N - V) * M) ok = x;
        else ng = x;
    }
    cout << ok + 1 << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
#include <string>

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define REP(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  u64 A, B = 0;
  cin >> A >> B;
  cout << A * B;
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long int MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};


int Knapsack_01(int N,int W,vector<int> v,vector<int> w) {

  int dp[N+1][W+1];
//std::vector<std::vector<int> > dp(N + 1, std::vector<int>(W + 1, 0));
  for (int i = 0; i <= N; i++) dp[i][0] = 0;
  for (int j = 0; j <= W; j++) dp[0][j] = 0;

  REP(i, N) REPS(j, 1, W+1){
      if (j < w[i]) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j], dp[i+1][j - w[i]] + v[i]);
  }
  return dp[N][W];
}

int Knapsack_eco(int N,int W, vector<int> v,vector<int> w) {

    vector<int> dp(W+1, 0);

    REP(i, N) REPS(j, w[i], W+1) dp[j] = max(dp[j], dp[j-w[i]]+v[i]);

    return dp[W];
}

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

  int N, W;
  cin >> N >> W;

  vvint(v, w, N);

  cout << Knapsack_eco(N, W, v, w) << endl;

}

Measured memory_bytes: 3200
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>

#define ll long long
#define pll pair<ll, ll>

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

const int INF = 1111111111;
const double EPS = 1e-9;

using namespace std;

void init()
{
}

void solve()
{
	const int N = 1111;
	int n, k;
	cin >> n >> k;

	int p[N];
	rep(i, n)
	{
		cin >> p[i];
	}

	sort(p, p + n);

	int sum = 0;
	rep(i, k)
	{
		sum += p[i];
	}
	cout << sum << endl;
}

int main()
{
	init();
	solve();
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int n;
double ans = 0;
double dp[3005][3005];
double p[3005];
int main()
{
  cin >> n;

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

  dp[0][0] = 1.0;
  for(int i=0; i<n; i++){
    dp[i+1][0] = dp[i][0] * (1 - p[i]);
    for(int j=0; j<=n; j++){
      dp[i+1][j+1] = dp[i][j] * p[i] + dp[i][j+1] * (1 - p[i]);
    }
  }

  for(int i=n/2+1; i<=n; i++){
    ans += dp[n][i];
  }

  printf("%.15f\n",ans);

  return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
const int N(3333);
int a[N], deg[N], ans[N];
vector<int> adj[N];
int main() {
	int n;
	cin >> n;
	for(int i(1); i <= n; i++)
		cin >> a[i];
	for(int i(1); i < n; i++) {
		int x, y;
		cin >> x >> y;
		if(a[x] > a[y]) {
			adj[x].push_back(y);
			deg[y]++;
		}
		if(a[y] > a[x]) {
			adj[y].push_back(x);
			deg[x]++;
		}
	}
	vector<int> q;
	for(int i(1); i <= n; i++) {
		if(deg[i] == 0) {
			q.push_back(i);
		}
	}
	for(int i(0); i < (int)q.size(); i++) {
		int v(q[i]);
		for(int j(0); j < (int)adj[v].size(); j++) {
			if(!--deg[adj[v][j]]) {
				q.push_back(adj[v][j]);
			}
		}
	}
	vector<int> vec;
	for(int i((int)q.size() - 1); i >= 0; i--) {
		int v(q[i]);
		for(int j(0); j < (int)adj[v].size(); j++) {
			if(ans[adj[v][j]] == 0) {
				ans[v] = 1;
				vec.push_back(v);
				break;
			}
		}
	}
	if(vec.empty()) {
		printf("\n");
	}else {
		sort(vec.begin(), vec.end());
		for(int i(0); i < (int)vec.size(); i++) {
			printf("%d%c", vec[i], i == (int)vec.size() - 1 ? '\n' : ' ');
		}
	}
}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; ++i) cin >> p[i];

    int res = 0;
    for(int i=1; i+1<n; ++i) {
        if(p[i - 1] < p[i] && p[i] < p[i + 1]) ++res;
        else if(p[i - 1] > p[i] && p[i] > p[i + 1]) ++res;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
A_dict = {}

cnt = 1
for i in A:
    A_dict[cnt] = i
    cnt += 1

A_dict_sorted = sorted(A_dict.items(),key= lambda x:x[1])

for i in range(n):
    print(A_dict_sorted[i][0], end=" ")


Measured memory_bytes: 26296
import java.util.*;
class Main{
  public static void main(String args[]){
    StringBuilder bl = new StringBuilder();
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int A[] = new int[n];
    for(int i = 0; i<n; i++){
      A[i] = sc.nextInt();
    }
    int i = partition(A,0,A.length-1);
    if(0==i)bl.append('[').append(A[0]).append(']');
    else bl.append(A[0]);
    for(int j = 1; j<A.length; j++){
      if(j==i)bl.append(' ').append('[').append(A[j]).append(']');
      else bl.append(' ').append(A[j]);
    }
    System.out.println(bl);

  }
  static int partition(int A[], int p, int r){
    int x = A[r];
    int i = p-1;
    int tmp;
    for(int j =p; j<r; j++){
      if(A[j]<=x){
        i = i+1;
        tmp = A[i];
        A[i] = A[j];
        A[j] = tmp;
      }
    }
    tmp = A[i+1];
    A[i+1] = A[r];
    A[r] = tmp;
    return i+1;
  }
}


Measured memory_bytes: 67400
#include<bits/stdc++.h>
using namespace std;
int n;
int ans;
int k;
int main()
{
	cin>>n>>k;
	ans=0;
	while(n--)
	{
		int num;
		cin>>num;
		ans+=(num>=k)?1:0;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
import java.io.*;
class Main {
  public static void main(String[] args) {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    br.lines()
      .parallel()
      .map(Integer::parseInt)
      // .boxed()
      .sorted(Comparator.reverseOrder())
      .sequential()
      .limit(3)
      .forEach(System.out::println);
  }
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int w,h;

int table[35][35];
int c[4];
int dist[35][35][4];

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

typedef tuple<int,int,int,int> state;
void dijkstra(){
	rep(i,h)rep(j,w)rep(k,4)dist[i][j][k]=inf;
	dist[0][0][1]=0;
	state s=make_tuple(0,0,0,1);
	priority_queue<state,vector<state>,greater<state>> q;
	q.push(s);
	while(!q.empty()){
		state cur=q.top();q.pop();
		int x,y,d,costs;
		tie(costs,y,x,d)=cur;
		if(dist[y][x][d]<costs)
			continue;
		rep(i,4){
			int nx=x,ny=y,nd=d,ncosts=costs;
			nd=(nd+i)%4;
			nx+=dx[nd],ny+=dy[nd];
			if(table[y][x]!=i)
				ncosts+=c[i];
			if(0<=nx&&nx<w&&0<=ny&&ny<h){
				if(dist[ny][nx][nd]>ncosts){
					dist[ny][nx][nd]=ncosts;
					q.push(make_tuple(ncosts,ny,nx,nd));
				}
			}
		}
	}
	return;
}

int main(void){
	while(1){
		scanf("%d %d",&w,&h);
		if(w==0)
			break;
		rep(i,h)rep(j,w) scanf("%d",&table[i][j]);
		rep(i,4) scanf("%d",&c[i]);
		dijkstra();
		int ans=inf;
		rep(i,4) ans=min(ans,dist[h-1][w-1][i]);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1308
import Data.Set( Set, null, fromList, deleteAt, lookupIndex, minView)
import qualified Data.Set as S
import Data.Maybe( fromJust)
main = do
    n <- readLn
    as <- return . map (read::String->Int) . words =<< getLine
    let ps = zip [1..n] as
	pairs = fromList ps
	process::Set (Int,Int) -> Int -> Maybe Int
	process set n
	  | S.null set = Just n
	  | otherwise = do
	    ((a,b), remain) <- minView set
	    case lookupIndex (b,a) remain of
		Nothing -> process remain n
		Just ix -> process (deleteAt ix remain) (n+1)
    print . fromJust $ process pairs 0

Measured memory_bytes: 50044
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                cnt +=1

print(cnt)

Measured memory_bytes: 39536
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

ll M;

ll iv(ll i) {
	if (i == 1) { return 1; }
	return M - iv(M%i)*(M / i) % M;
}


vector<ll> frac;

ll p(ll n, ll m) {
	if (m == 0) { return 1; }
	ll x = p(n, m / 2);

	if (m % 2 == 1) { return x * x*n%M; }
	return x * x%M;
}

ll query1(ll x, ll n) {
	if (x == 0) { return 0; }

	ll y = x + (n - 1);

	//cout << x << " " << n <<y<< endl;


	if (y >= M) { return 0; }

	ll ret= frac[y] * iv(frac[x - 1]) % M;

	
	return ret;
}

ll query(ll x, ll d, ll n) {
	if (d == 0) { return p(x, n) % M; }

	ll t = x * iv(d) % M;

	return query1(t, n)*p(d, n) % M;
}


int main() {
	M = 1000003;

	frac.assign(M + 1,0);
	frac[0] = 1;
	repn(i, M) {
		frac[i] = frac[i - 1] * i%M;
	}

	ll Q;
	cin >> Q;
	rep(i, Q) {
		ll x, d, n;
		cin >> x >> d >> n;
		cout << query(x, d, n)<<endl;
	}


	system("PAUSE");
}


Measured memory_bytes: 8952
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
using namespace std;
int n,m;
map<string,int>M;
vector<int>a[100];
bool flag;
int cal(int x,int y,char c)
{
	if(c=='+')return(x+y)%256;
	else if(c=='-')return(x-y+256)%256;
	else if(c=='*')return x*y%256;
	else
	{
		if(y)return x/y%256;
		else return flag=true;
	}
}
main()
{
	cin>>m;
	for(int i=0;i<m;i++)
	{
		string s;int L,R;
		cin>>s>>L>>R;
		M[s]=i;
		for(int j=L;j<=R;j++)a[i].push_back(j);
	}
	cin>>n;
	stack<int>S;
	for(;n--;)
	{
		string s;cin>>s;
		if(s[0]>='0'&&s[0]<='9')
		{
			int now=0;
			for(int i=0;i<s.size();i++)now=(now*10+s[i]-48)%256;
			S.push(now);
		}
		else if(M.find(s)!=M.end())
		{
			S.push(~M[s]);
		}
		else
		{
			int x,y;
			y=S.top();S.pop();
			x=S.top();S.pop();
			if(x>=0&&y>=0)S.push(cal(x,y,s[0]));
			else
			{
				vector<int>tmp;
				if(x>=0)
				{
					for(int Y:a[~y])tmp.push_back(cal(x,Y,s[0]));
					sort(tmp.begin(),tmp.end());
					tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
					a[~y]=tmp;
					S.push(y);
				}
				else if(y>=0)
				{
					for(int X:a[~x])tmp.push_back(cal(X,y,s[0]));
					sort(tmp.begin(),tmp.end());
					tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
					a[~x]=tmp;
					S.push(x);
				}
				else
				{
					for(int X:a[~x])for(int Y:a[~y])tmp.push_back(cal(X,Y,s[0]));
					sort(tmp.begin(),tmp.end());
					tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
					a[~x]=tmp;
					S.push(x);
				}
			}
		}
	}
	cout<<(flag?"error":"correct")<<endl;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;

ll rep_square(ll a, ll b) {
    // return a^b
    ll ans = 1;
    ll base = a;
    while (b != 0) {
        if (b & 1) {
            ans *= base;
        }
        base *= base;
        b >>= 1;
    }
    return ans;
}

int main() {
    ll n;
    cin >> n;
    ll length = 0;
    while (true) {
        length++;
        if (n <= rep_square(26, length)) {
            break;
        } else {
            n -= rep_square(26, length);
        }
    }
    n--;
    int num[length];
    rep(i, length) {
        num[i] = n % 26;
        n /= 26;
    }

    repb(i, length) { cout << char('a' + num[i]); }
    cout << endl;
    return 0;
}



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

const int MAX_N = 21;
const int MAX_MASK = 1 << (MAX_N + 1);
const ull MOD = 1e9 + 7;
ull dp[MAX_N + 1][MAX_MASK];
ull inp[MAX_N + 1];

int main() {
	ios_base::sync_with_stdio(false);
	for (size_t i = 0; i <= MAX_N; i++) {
		for (size_t j = 0; j < MAX_MASK; j++) {
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;

	int N; cin >> N;
	for (size_t i = 1; i <= N; i++) {
		ull mask = 0;
		for (size_t j = 0; j < N; j++) {
			ull val; cin >> val;
			mask |= val << j;
		}
		inp[i] = mask;
	}

	ull MASK = 1 << N;
	for (size_t i = 1; i <= N; i++) {
		for (size_t mask = 0; mask < MASK; mask++) {
			if (__builtin_popcount(mask) == i - 1) {
				for (size_t bit = 0; bit <= N; bit++) {
					if ((1 << bit) & inp[i] && !((1 << bit) & mask)) {
						dp[i][(1 << bit) | mask] = (dp[i][(1 << bit) | mask] + dp[i - 1][mask]) % MOD;
					}
				}
			}
		}
	}
	cout << dp[N][(1 << N) - 1] << endl;
	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll H,W;
char S[111][111];
ll dp[111][111];

ll i, j, k;
int main(){
    scanf("%lld%lld", &H, &W);
    fornum(i,0,H){
        scanf("%s", S[i]);
    }
    fornum(i,0,H){
        fornum(j,0,W){
            dp[i][j] = 1e9;
        }
    }
    dp[0][0] = (S[0][0] == '#');
    fornum(i,0,H){
        fornum(j,0,W){
            if(i+1<H){
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (S[i][j] == '.' && S[i + 1][j] == '#'));
            }
            if(j+1<W){
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (S[i][j] == '.' && S[i][j + 1] == '#'));
            }
            //cout << dp[i][j] << " ";
        }
        //cout << endl;
    }
    printf("%lld", dp[H - 1][W - 1]);
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int partition(int *A, int p, int r){
	int i, j = p-1, tmp;

	for(i = p; i < r; i++){
		if(A[i] <= A[r]){
			j++;
			tmp = A[j];
			A[j] = A[i];
			A[i] = tmp;
		}
	}
	tmp = A[j+1];
	A[j+1] = A[r];
	A[r] = tmp;

	return j+1;
}

int main(){
	int n, q, i;
	int *A;

	scanf("%d", &n);
	A = (int *)malloc(sizeof(int) * n);
	for(i = 0; i < n; i++)
		scanf("%d", &A[i]);

	q = partition(A, 0, n-1);

	for(i = 0; i < n; i++){
		if(i == q)
			printf("[%d]", A[q]);
		else
			printf("%d", A[i]);
		if(i < n-1)
			printf(" ");
	}
	printf("\n");

	free(A);
	return 0;
}


Measured memory_bytes: 2052
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a = sc.nextInt
  val b = sc.nextInt
  val c = sc.nextInt
  val d = sc.nextInt

  val train = if (a > b) b else a
  val bus = if (c > d) d else c

  println(train + bus)
}

Measured memory_bytes: 25408
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int n,t[100],a=0,b=0;
  string s[100],x;
  cin>>n;
  for(int i=1;i<=n;i++){
	cin>>s[i]>>t[i];
  }
  cin>>x;
  for(int i=1;i<=n;i++){
	if(s[i]==x){
      b=i+1;
    }  
  }
 for(int i=b;i<=n;i++){
    a+=t[i];
 }
   cout<<a<<"\n";
}

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

using namespace std;

int main( )
{	
    int n;
    int maxProfit = 1-1000000000;
    int Ri = 2000000000;
	ios::sync_with_stdio( false );
    cin>>n;
    
    vector<int> R(n);
    vector<int>::iterator itr = R.begin( );
    vector<int>::iterator itrE = R.end( );
    
    for( ; itr!=itrE; itr++ ) {
    	cin>>*itr;
    }
    itr = R.begin( );
    for( ; itr!=itrE; itr++ ) {
        if( maxProfit < *itr - Ri ) {
       		maxProfit = *itr - Ri;
       	}
       	if( *itr < Ri ) {
    		Ri = *itr;
    	}
    }    

    cout<<maxProfit<<endl;
	
	return 0;
}

Measured memory_bytes: 1796
r, c = map(int, input().split())
table = [[0 for j in range(c+1)] for i in range(r+1)]
for i in range(r):
  a = list(map(int, input().split()))
  sumr = 0
  for j in range(c):
    table[i][j] = a[j]
    sumr += a[j]
  table[i][c] = sumr
for j in range(c+1):
  sumc = 0
  for i in range(r):
    sumc += table[i][j]
  table[r][j] = sumc
for i in range(r+1):
  for j in range(c+1):
    if j == 0:
      print(table[i][j], end = "")
    else:
      print("", table[i][j], end = "")
  print()


Measured memory_bytes: 6744
H,W=map(int,input().split())
flg=0
flg2=0
bef=[];aft=[]
ans=[]
N=0
for i in range(H):
  flg+=1;flg%=2
  A=list(map(int,input().split()))
  if flg==1:
    for j in range(W):
      a=A[j]
      aft=[i+1,j+1]
      if a%2==0:
        if flg2==0:
          pass
        else:
          ans.append(bef+aft)
          N+=1
      else:
        if flg2==0:
          flg2=1
        else:
          ans.append(bef+aft)
          N+=1
          flg2=0
      bef=[i+1,j+1]
          
  else:
    for j in range(W-1,-1,-1):
      a=A[j]
      aft=[i+1,j+1]
      if a%2==0:
        if flg2==0:
          pass
        else:
          ans.append(bef+aft)
          N+=1
      else:
        if flg2==0:
          flg2=1
        else:
          ans.append(bef+aft)
          N+=1
          flg2=0
      bef=[i+1,j+1]
print(N)
for i in ans:
  print(*i)

Measured memory_bytes: 84500
/// Bismillahir Rahmanir Rahim
/* Author: Mohammad Morsalin 
    Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define PI acos(-1)
#define IOS ios::sync_with_stdio(false);
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
int main()
{
    IOS
    int a,b;
    cin>>a>>b;
    cout << a*b << endl;
    return 0;
}
///Alhamdulillah

Measured memory_bytes: 3668
import java.io.*;
import java.util.*;

public class Main {
	
	public static int n = 0, s = 0, ans = 0;
	
	@SuppressWarnings("unchecked")
	public static void solve (boolean[] check, ArrayList<Integer> list, int cnt) {
		
		ArrayList<Integer> temp = (ArrayList<Integer>) list.clone();
		
		if (cnt == n) {
			int sum = 0;
			for (int i = 0; i < list.size(); i++) {
				sum += list.get(i);
			}
			if (sum == s) ans++;
			return;
		}
		
		main:
		for (int i = 0; i < check.length; i++) {
			
			if (check[i]) continue;
			for (int j = 0; j < list.size(); j++) {
				if (list.get(j) >= i) continue main;
			}
			
			temp.add(i);
			check[i] = true;
			solve(check,temp,cnt + 1);
			check[i] = false;
			temp.remove(temp.size() - 1);
			
		}
		
	}
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		while (true) {
			String ss = br.readLine();
			StringTokenizer st = new StringTokenizer(ss, " ");
			n = Integer.parseInt(st.nextToken());
			s = Integer.parseInt(st.nextToken());
			if (n == 0 && s == 0) break;
			solve(new boolean[10], new ArrayList<Integer>(), 0);
			
			System.out.println(ans);
			ans = 0;
		}
		
	}
	
}

Measured memory_bytes: 9888
#include <iostream>
#include <list>
using namespace std;
int main(){
	int  l=0;
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n=0,bandera=0;
	list<int>lista;
	string accion;
	int a=0;
	cin>>a;
	l=a;
	while(l>0){
		l--;
		cin>>accion;
		if(accion[0]=='i'){
			cin>>n;
			lista.push_front(n);
		}else{
			if(accion.size()==6){
				cin>>n;
						for(list<int>::iterator it3=lista.begin();it3!=lista.end();it3++){
						  
							if(*it3==n){
								lista.erase(it3); 
								break;	
							}
					
						}
	 
			}else{
				if(accion[6]=='F'){
					    if(!lista.empty())
						lista.pop_front();
				 		
				}else{
						if(!lista.empty())
						lista.pop_back();
					}
			}
		}
	}						a=lista.size();
	 						for(list<int>::iterator it3=lista.begin();it3!=lista.end();it3++){
						  		if(a!=1){
						  			cout<<*it3<<" ";
								  }else cout<<*it3;
								  a--;
						  		
						}
						cout<<"\n";
 
	return 0;
}


Measured memory_bytes: 34472
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int n;
    int k;
    int ans=0;
    cin >> n >> k;
    vector<int> a(n,0);
    for(int i=0; i<k; i++){
        int d;
        int tmp;
        cin >> d;
        for(int j=0; j<d; j++){
            cin >> tmp;
            tmp--;
            a[tmp]++;
        }
    }

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

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
import math
import collections
import sys

#input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

a,b,c=MI()
print(min(int(b/a),c))

Measured memory_bytes: 3316
from collections import Counter


class BIT():
    """一点加算、区間取得クエリをそれぞれO(logN)で答える
    add: i番目にvalを加える
    get_sum: 区間[l, r)の和を求める
    i, l, rは0-indexed
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, val):
        """i番目にvalを加える"""
        i = i + 1
        while i <= self.n:
            self.bit[i] += val
            i += i & -i

    def get_sum(self, l, r):
        """区間[l, r)の和を求める"""
        return self._sum(r) - self._sum(l)


def min_swap_times(s, t):
    if Counter(s) != Counter(t):
        return -1

    n = len(s)
    memo = {}
    for i in range(n):
        if s[i] not in memo:
            memo[s[i]] = [i]
        else:
            memo[s[i]].append(i)
    for i in memo:
        memo[i] = memo[i][::-1]

    array = [0] * n
    for i in range(n):
        array[i] = memo[t[i]][-1]
        del(memo[t[i]][-1])    

    memo = {}
    for i in range(n):
        memo[i] = array[i]
    bit = BIT(n)
    res = 0

    for i in range(n):
        bit.add(memo[i], 1)
        res += bit.get_sum(memo[i] + 1, n)
    return res


import copy

s = input()
n = len(s)
memo = {}
for i in range(n):
    if s[i] not in memo:
        memo[s[i]] = 1
    else:
        memo[s[i]] += 1

odd_cnt = 0
for i in memo:
    odd_cnt += memo[i] % 2
if odd_cnt > 1:
    print(-1)
    exit()

left = []
right = []

memo2 = copy.deepcopy(memo)
ans_cnt = 0
word = ""
for i in range(n):
    if memo2[s[i]]*2 > memo[s[i]] + 1:
        memo2[s[i]] -= 1
        ans_cnt += i - len(left)
        left.append(s[i])
    elif memo2[s[i]]*2 == memo[s[i]] + 1:
        word = s[i]
        memo2[s[i]] -= 1
        right.append(s[i])
    else:
        memo2[s[i]] -= 1
        right.append(s[i])
 
if word != "":
    for i in range(len(right)):
        if right[i] == word:
            ans_cnt += i
            del(right[i])
            break
right = right[::-1]
tmp = min_swap_times(left, right)
if tmp == -1:
    print(-1)
else:
    print(ans_cnt + tmp)

Measured memory_bytes: 70220
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
const int maxn=300005;
char s[maxn];
char a[maxn];
int n;
char change(char a)
{
    if(a=='S') return 'W';
    if(a=='W') return 'S';
}
int dfs()
{
    for(int x=2;x<n;x++)
    {
        if(s[x]=='o')
        {
            if(a[x]=='S')
            {
                a[x+1]=a[x-1];
            }
            else
            {
                a[x+1]=change(a[x-1]);
            }
        }
        else
        {
            if(a[x]=='W')
            {
                a[x+1]=a[x-1];
            }
            else
            {
                a[x+1]=change(a[x-1]);
            }
        }
    }
    int flag1=0,flag2=0;
    if(a[1]=='S')
    {
        if(s[1]=='o'&&a[2]==a[n]) flag1=1;
        else if(s[1]=='x'&&a[2]==change(a[n])) flag1=1;
    }
    else
    {
        if(s[1]=='o'&&a[2]!=a[n]) flag1=1;
        else if(s[1]=='x'&&a[2]!=change(a[n])) flag1=1;
    }
    if(a[n]=='S')
    {
        if(s[n]=='o'&&a[1]==a[n-1]) flag2=1;
        else if(s[n]=='x'&&a[1]==change(a[n-1])) flag2=1;
    }
    else
    {
        if(s[n]=='o'&&a[1]==change(a[n-1])) flag2=1;
        else if(s[n]=='x'&&a[1]==a[n-1]) flag2=1;
    }
    if(flag1&&flag2) return 1;
    return 0;
}
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    a[1]='S';a[2]='S';
    if(dfs())
    {
        printf("%s\n",a+1);
        return 0;
    }
    a[1]='S';a[2]='W';
    if(dfs())
    {
        printf("%s\n",a+1);
        return 0;
    }
    a[2]='S';a[1]='W';//WS
    if(dfs())
    {
        printf("%s\n",a+1);
        return 0;
    }
    a[1]='W';a[2]='W';//WW
    if(dfs())
    {
        printf("%s\n",a+1);
        return 0;
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 512
a, b = map(int, input().split())
s = input()
num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
count = 0

for i in range(len(s)):
    if 0 <= i and i <= a-1:
        if s[i] not in num:
            print('No')
            count += 1
            break
    elif i == a:
        if s[i] != '-':
            print('No')
            count += 1
            break
    else:
        if s[i] not in num:
            print('No')
            count += 1
            break

if count == 0:
    print('Yes')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define rep(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;

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

const ll mod=1e9+7;
const ll inf=1ll<<60;

/*---------------------*/

ll t,a,b,c,d;

int main(){
    cin>>t;
    while(t--){
        cin>>a>>b>>c>>d;
        if(a<b||d<b){
            cout<<"No\n";
            continue;
        }if(c>=b){
            cout<<"Yes\n";
            continue;
        }
        ll g=__gcd(b,d);
        if(b+a%g-g>c)cout<<"No\n";
        else cout<<"Yes\n";
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int A, B, X,q;
	cin >> X;
	cin >> A;
	cin >> B;
	q = (X - A) / B;
	int x = X - A - B*q;
	cout << x << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        System.out.println("" + a.charAt(0) + b.charAt(1) + c.charAt(2));
        sc.close();
    }
}

Measured memory_bytes: 38980
package main

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

func main() {
	nextReader = newScanner()

	a := nextInt()
	b := nextInt()
	c := nextInt()
	if a < b && b < c {
		fmt.Printf("Yes\n")
	} else {
		fmt.Printf("No\n")
	}
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}



Measured memory_bytes: 1068
#include<stdio.h>
int main()
{
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    //printf("%d %d %d ",n,a,b);
    int ans=0;
    int s,j;
/*    if(a>b)
        {
            int temp=a;
            a=b;
            b=temp;
        }
*/    for(int i=1;i<=n;i++)
    {
        s=0;
        j=i;
        while(j)
        {
            s+=j%10;
            j/=10;
        }
        //printf("i==%d s==%d\n",i,s);
        if(s>=a&&s<=b)
            ans+=i;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class DPowerfulDiscountTickets
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            long n = nm[0];
            long m = nm[1];

            var pQueue = new PriorityQueue<long>(Compare);
            Console.ReadLine().Split(' ').ToList().ForEach(x => pQueue.Enqueue(long.Parse(x)));

            for (int i = 0; i < m; i++)
            {
                pQueue.Enqueue(pQueue.Dequeue() / 2);
            }

            long answer = 0;
            while (pQueue.Count > 0)
            {
                answer += pQueue.Dequeue();
            }

            Console.WriteLine(answer);
            Console.ReadLine();
        }

        static int Compare(long a, long b) { return (int)(b - a); }
    }

    class PriorityQueue<T>
    {
        private readonly List<T> m_list;
        private readonly Comparison<T> m_compare;
        public int Count { get; private set; }
        public PriorityQueue(Comparison<T> compare)
        {
            m_list = new List<T>();
            m_compare = compare;
            Count = 0;
        }
        private int Add(T value)
        {
            if (Count == m_list.Count)
            {
                m_list.Add(value);
            }
            else
            {
                m_list[Count] = value;
            }
            return Count++;
        }
        private void Swap(int a, int b)
        {
            T tmp = m_list[a];
            m_list[a] = m_list[b];
            m_list[b] = tmp;
        }
        public void Enqueue(T value)
        {
            int c = Add(value);
            while (c > 0)
            {
                int p = (c - 1) / 2;
                if (m_compare(m_list[c], m_list[p]) < 0) { Swap(p, c); } else { break; }
                c = p;
            }
        }
        public T Dequeue()
        {
            T value = m_list[0];
            m_list[0] = m_list[--Count];
            int p = 0;
            while (true)
            {
                int c1 = p * 2 + 1;
                int c2 = p * 2 + 2;
                if (c1 >= Count) { break; }
                int c = (c2 >= Count || m_compare(m_list[c1], m_list[c2]) < 0) ? c1 : c2;
                if (m_compare(m_list[c], m_list[p]) < 0) { Swap(p, c); } else { break; }
                p = c;
            }
            return value;
        }
    }
}

Measured memory_bytes: 27484
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

constexpr int mod = 1000000007;

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

  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];

  priority_queue<pair<ll, int>> pq;
  rep(i, n) {
    pq.push({a[i] + b[i], i});
  }

  ll tak = 0, ao = 0;

  while (!pq.empty()) {
    auto p = pq.top(); pq.pop();
    tak += a[p.second];
    if (pq.empty()) break;
    p = pq.top(); pq.pop();
    ao += b[p.second];
  }

  cout << tak - ao << endl;

  return 0;
}


Measured memory_bytes: 6908
#include<bits/stdc++.h>
#define LL long long
int N, T;
LL sum=0;
int main() {
	scanf("%d%d",&N,&T);
	int cur=0;
	for(int i=0;i<N;i++)
	{
		int t;
		scanf("%d",&t);
		if(t>cur)
			{
			    sum+=(LL)T;
			    cur=t+T;
			}
		else
			{
			    sum+=(LL)(T-(cur-t));
			    cur+=(T-(cur-t));
			}
	}
	printf("%lld",sum);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
using namespace std;
int main() {

    string S;
    cin >> S;
    
    int ans = 0;
    int count = 0;
    for(int i = 0; i < S.size(); i++){
        
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'T' || S[i] == 'G'){
            count++;
            ans = max(ans, count);
        }
        else {
            ans = max(ans, count);
            count = 0;
        }
    }
    
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
n,m=map(int, input().split())
al=[]
for i in range(m):
    a=list(map(str, input().split()))
    al.append(a)
l_all=[[] for i in range(n)]
for i in range(m):
    l_all[int(al[i][0])-1].append(al[i][1])
ac=0
pn=0
for j in range(n):
    if l_all[j].count('AC')!=0:
        pn+=l_all[j].index('AC')
        ac+=1
print('{} {}'.format(ac,pn))

Measured memory_bytes: 39344
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
x = int(raw_input())

n = 0
i = 0
while i * 500 <= x and i <= a:
    if i * 500 == x:
        n += 1
#        print 10
    else:
        y = x - i * 500
        j = 0
        while j * 100 <= y and j <= b:
            if j * 100 == y:
                n += 1
#                print 20
            else:
                z = y - j * 100
                if z / 50 <= c:
                    n += 1
#                    print 30
            j += 1
    i += 1

print n

Measured memory_bytes: 2568