akhauriyash/Code-Regression huggingface dataset:
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main {
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		//InputStream in = new FileInputStream("src/input.txt");
		InputStream in = System.in;
		//PrintStream out = new PrintStream("src/output.txt");

		//System.setOut(out);

		sc = new Scanner(in);

		int N = sc.nextInt();
		int A = sc.nextInt();

		System.out.println((int)(Math.pow(N, 2))-A);

		//out.close();
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, k;
    cin >> n >> k;
    int x, sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (x > k - x) {
            sum += 2 * (k - x);
        }else{
            sum += 2 * x;
        }
    }
    cout << sum << endl;
    return 0;
}


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

int main() {
  int A,B,C;
  cin>>A>>B>>C;

  if(A<C&&C<B){
    cout<<"Yes"<<endl; 
  }else if(B<C&&C<A){
    cout<<"Yes"<<endl; 
  }else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1000020;
ll n,p,i,a,s[N],c[N],k,ans;
struct Uzi{
	ll val,id;
	bool operator<(const Uzi &k)const{
		if(k.val!=val)
			return k.val>val;
		return k.id>id;
	}
}x[N];
void init(){
	scanf("%lld%lld",&n,&k);
	n++;
	for(i=2;i<=n;i++){
		scanf("%lld",&a);
		a-=k;
		s[i]=s[i-1]+a;
	}
	for(i=1;i<=n;i++)
		x[i]=(Uzi){s[i],i};
	sort(x+1,x+n+1);
}
void work(){
	for(i=1;i<=n;i++){
		for(k=x[i].id;k;k-=k&-k)
			ans+=c[k];
		for(k=x[i].id;k<=n;k+=k&-k)
			c[k]++;
	}
	printf("%lld",ans);
	//while(1);
}
int main(){
	init();
	work();
	return 0;
}

Measured memory_bytes: 12416
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <unordered_map>
//#include <bits/stdc++.h>
#include <cassert>
#include <map>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;


int main()
{
  map<int, int> ma;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    {
      int x;
      scanf("%d", &x);
      ma[x] += 1;
    }
  int ans = n;
  for (auto pr : ma)
    if (pr.second >= pr.first)
      ans -= pr.first;
  printf("%d\n", ans);
}


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	long long n;
	cin>>n;
	int ans=0;
	for(long long i=1;i*i<=n-1;++i){
		if((n-1)%i==0){
			if(i!=(n-1)/i)
				ans+=2;
			else ans++;
		}
	}
	for(long long i=2;i*i<=n;++i){
		if(n%i==0){
			long long k=n;
			while(k%i==0){
				k/=i;
			}
			if(k%i==1) ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <string>
using namespace std;

int main(void){
    int n, m, max = 0, x = 0;
    string s[105], t[105]; 
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> s[i];
    cin >> m;
    for (int i = 1; i <= m; i++) cin >> t[i];
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (s[i] == s[j]) x++;
        }
        for (int j = 1; j <= m; j++) {
            if (s[i] == t[j]) x--;
        }
        if (x > max) max = x;
      	x = 0;
    }
    cout << max << endl;
    return 0;
}



Measured memory_bytes: 256
//****************************//
/**********  main *************/
//****************************//
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for(i = 0; i < n; i++)
#define FOR(i, a, b) for(i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())

double pi = 3.141592653589793;

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

int main() {

    std::cin.tie(0);

    int n;
    int tmp, res, cnt;
    int tmp_mod;
    bool flag = false;

    cin >> n ;

    tmp_mod = n%1000;

    res = 1000 - tmp_mod;

    if(tmp_mod == 0) res = 0;
    

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	long long int A = 0;
	cin >> N;
	for(int i = 0; i <= N; i++){
		if(i % 3 == 0){
			A = A;
        } else {
			if(i % 5 == 0){
				A = A;
            } else {
				A = A + i;
            }
        }
    }
	cout << A;
}

Measured memory_bytes: 3636
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

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

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using namespace std;

class AX {
public:
	void solve(std::istream& in, std::ostream& out) {
		int a,b;
		in >> a >> b;

		out << max(a+b, max(a-b, a*b));

	}
};

int main() {
	AX solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
(defun main ()
  (let ((s (read-line)))
    (cond ((string= s "A")
           (princ #\T))
          ((string= s "T")
           (princ #\A))
          ((string= s "C")
           (princ #\G))
          ((string= s "G")
           (princ #\C)))))

(main)

Measured memory_bytes: 9828
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N, M;
  while(scanf("%d %d", &N, &M) && N){
    vector<int> _H(N + 1, 0), _W(M + 1, 0);
    REP(i, N){
      scanf("%d", &_H[i + 1]);
      _H[i + 1] += _H[i];
    }
    REP(i, M){
      scanf("%d", &_W[i + 1]);
      _W[i + 1] += _W[i];
    }
    ++N; ++M;
    vector<int> H, W;
    REP(i, N) FOR(j, i + 1, N) H.push_back(_H[j] - _H[i]);
    REP(i, M) FOR(j, i + 1, M) W.push_back(_W[j] - _W[i]);
    SORT(H); SORT(W);
    int ans = 0;
    REP(i, H.size()) ans += upper_bound(W.begin(), W.end(), H[i]) - lower_bound(W.begin(), W.end(), H[i]);
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 25696
#include <iostream>

int main()
{
    int input;
    std::cin >> input;
    std::cout << input << ":";

    int number = input;//input????????????????????????number??????????????????
    for (int devide_number = 2; devide_number * devide_number <= number; devide_number++) {
        if (number % devide_number == 0) {
            std::cout << " " << devide_number;
            number /= devide_number;
            devide_number--;//????????°??§??????????????????????????§?????????????¬????decide_number++??¨????????????????????°??????????????????????????????
            continue;
        }
    }

    std::cout << " " << number << std::endl;//??????????????£????´???°?????¨??????????????????????????§??¨????????????

    return 0;
}

Measured memory_bytes: 1168
N = int(input())
P = list(map(int, input().split()))

min_list = [0 for i in range(N)]
min_list[0] = P[0]
for i, p in enumerate(P):
    if i == 0:
        continue
    if p < min_list[i-1]:
        min_list[i] = p
    else:
        min_list[i] = min_list[i-1]

ans = 0
for i, p  in enumerate(P):
    if p <= min_list[i]:
        ans += 1
print(ans)


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

long long GCD(long long a, long long b) {
    long long tmp;
    while (b) {
        tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

long long LCM(long long a, long long b) {
    return a * b / GCD(a, b);
}

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

    long long N, A[100], lcm = 1;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        lcm = LCM(lcm, A[i]);
    }

    long long tmp = 0;
    for (int i = 0; i < N; i++)
        tmp += lcm / A[i];
    cout << fixed << setprecision(6) << (double) lcm / tmp << '\n';

    return 0;
}

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

bool find(string a, char c) {
  for(int i = 0; i < a.length(); i++) {
    if(a[i] == c) return true;
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    string str;
    cin >> str;

    string ans = str.substr(0,1);
    for(int i = 1; i < (str.length()+2)/3; i++) {
      if(find(ans, str[i*3])) continue;
      if(str[i*3-2] == '-' && str[i*3-1] == '>') {
	ans += str[i*3];
      } else if(str[i*3-2] == '<' && str[i*3-1] == '-') {
	ans = str.substr(i*3,1) + ans;
      }
    }

    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int q;
  cin >> q;
  vector<set<int>> is(26);
  rep(i, n) is[s[i]-'a'].insert(i);
  rep(i, q){
    int type;
    cin >> type;
    if(type==1){
      int i;
      char c;
      cin >> i >> c;
      i--;
      is[s[i]-'a'].erase(i);
      s[i] = c;
      is[s[i]-'a'].insert(i);
    }else{
      int l, r;
      cin >> l >> r;
      l--;
      int ans = 0;
      rep(i, 26){
        auto it = is[i].lower_bound(l);
        if (it != is[i].end() && *it < r) ++ans;
      }
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 27232
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

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

count = 0

suma = sum(a)

for i in range(n):
    if a[i] >= suma/4/m:
        count+=1

if count >=m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#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 argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    map<int, pair<int, bool>> l;
    rep(i, m)
    {
        int p;
        string s;
        cin >> p >> s;
        auto t = l[p];
        if (t.second)
            continue;
        if (s == "WA")
        {
            l[p].first++;
        }
        else
        {
            l[p].second = true;
        }
    }
    int a(0), b(0);
    for (auto ip : l)
    {
        if (ip.second.second)
        {
            a++;
            b += ip.second.first;
        }
    }
    cout << a << " " << b;
    return 0;
}


Measured memory_bytes: 6528
#if defined(__GNUC__)
#include <bits/stdc++.h>
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

int indexDic(vector<int> v);
void digitFix(vector<int> &v, int num);

itn main() {
	std::ios::sync_with_stdio(false);

	int n;

	cin >> n;

	vector<int> p(n), q(n);

	REP(i, n) {
		cin >> p[i];
	}

	REP(i, n) {
		cin >> q[i];
	}

	int pdic = indexDic(p);
	int qdic = indexDic(q);

	cout << abs(pdic - qdic);

	return 0;
}

int indexDic(vector<int> v) {
	int r = 0;
	int fr;
	int c;

	while (v.size()) {
		c = v.size() - 1;
		fr = 1;
		while (c) {
			fr *= c;
			--c;
		}

		r += (v[0] - 1) * fr;

		digitFix(v, v[0]);
		v.erase(v.begin());
	}

	return r + 1;
}

void digitFix(vector<int> &v, int num) {
	int s = v.size();

	REP(i, s) {
		if (v[i] >= num) {
			--v[i];
		}
	}
}

Measured memory_bytes: 256
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/
vector<vector<ll> > g;
vector<ll> vis;
ll values[10007];
ll c[10007];
ll curr=0;
void dfs(ll x)
{
    vis[x]=1;
    values[x]=c[curr];
    curr++;

    for(auto xx:g[x])
    {
        if(!vis[xx]) dfs(xx);
    }
}
void solve()
{
    ll n;
    cin>>n;

    if(n==2)
    {
        ll x,y;
        cin>>x>>y;
        cin>>x>>y;
        cout<<min(x,y)<<"\n";
        cout<<x<<" "<<y<<"\n";
        return;
    }

    g.resize(n);
    vis.resize(n);
    mem(values,0);
    ll a[n];
    mem(a,0);

    pair<ll,ll> pq[n-1];
    f(i,n-1)
    {
        ll x,y;
        cin>>x>>y;
        x--,y--;
        g[x].pb(y);
        g[y].pb(x);

        a[x]++,a[y]++;

        pq[i]={x,y};
    }

    f(i,n) cin>>c[i];
    sort(c,c+n,greater<ll>());

    ll root=-1;

    f(i,n)
    {
        if(a[i]>1)
        {
            root=i;
            break;
        }
    }
    curr=0;
    dfs(root);
    ll ans=0;
    f(i,n-1) ans+=min(values[pq[i].ff],values[pq[i].ss]);
    cout<<ans<<"\n";
    f(i,n) cout<<values[i]<<" ";
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;


int main(void) {
  int x,a;
  cin >> x >> a;
  if(x<a)cout << 0 <<endl;
  else cout << 10 << endl;
}


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

const int MAXN = 1e5 + 1;

int n, l, q, x[MAXN];

int f[MAXN][31];
void prework() {
	for (int i = 1; i <= n; ++i) {
		int pos = std :: upper_bound(x + 1, x + n + 1, x[i] + l) - x - 1;
		f[i][0] = x[i] + l >= x[n] ? n : pos;
	}
	for (int j = 1; j <= 30; ++j) for (int i = 1; i <= n; ++i) f[i][j] = f[f[i][j - 1]][j - 1];
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &x[i]);
	scanf("%d%d", &l, &q);
	prework();
	while (q--) {
		int a, b; scanf("%d%d", &a, &b);
		if (a > b) std :: swap(a, b);
		int p = a, ans = 0;
		for (int j = 30; ~j; --j) if (f[p][j] < b) ans += (1 << j), p = f[p][j];
		printf("%d\n", ans + 1);
	}
	return 0;
}

Measured memory_bytes: 13184
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erase(unique(all(v)),v.end());
#define pvec(v) rep(i,v.size()){ cout << v[i] << " ";}
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}





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

	ll a=0, b=0, c=0, ans = 0, n, ret = 0, m, d;
	string s,t;
	cin >> n;
	vi v(n);
	rep(i, n) cin >> v[i];
	rep(i, n) {
		ans += v[i] - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
MOD=10**9+7

N,_,*a = map(int, open(0).read().split())
A=set(a)
dp = [0 for _ in range(N+1)]
dp[:2] = 1, 0 if 1 in A else 1
for i in range(2,N+1):
    if i not in A:
        dp[i]=(dp[i-1]+dp[i-2])%MOD
    
print(dp[N])




Measured memory_bytes: 14180
#include <bits/stdc++.h>
#include <string>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const ll dx[4] = {0,1,0,-1};
const ll dy[4] = {1,0,-1,0};
using pii = pair<int,int>;
using pll = pair<ll, ll>;

namespace patch {
  template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
}
int main() {

	int h,w;
	cin >> h >> w;
	string s,grid[h];
	for(int i=0; i<h; i++) {
		cin >> s;
		grid[i] = s;
	}
	queue<pii> q1;
	q1.push(pii(0,0));
	int count_moves = 0;
	int count_white = 0;
	int moves[h][w];
	for(int i=0; i<h; i++) {
		for(int j=0; j<w; j++) {
			if(grid[i][j] == '.'){
				count_white++;
				moves[i][j] = -1;
			}
		}
	}
	moves[0][0] = 0;
	pii temp;
	pii temp2;
	while(1) {
		if(q1.empty() == 1){
			cout << -1 << endl;
			return 0;
		}
		temp = q1.front();
		if(temp == pii(h-1,w-1))
				break;
		count_moves = moves[temp.fi][temp.se];

		for(int i=0; i<4; i++) {
			temp2.fi = temp.fi+dx[i];
			if(temp2.fi < 0 || temp2.fi >= h) 
				continue;
			temp2.se = temp.se+dy[i];
			if(temp2.se < 0 || temp2.se >= w)
				continue;
			if(moves[temp2.fi][temp2.se] != -1 || grid[temp2.fi][temp2.se] == '#') 
				continue;
			moves[temp2.fi][temp2.se] = count_moves+1;
			q1.push(temp2);
		}
		q1.pop();
	}
	cout << count_white - moves[h-1][w-1] -1 << endl;
	return 0;
}
			



Measured memory_bytes: 256
n, a, b = map(int, input().split())

if (b-a) % 2 == 0:
    ans = (b-a)//2
else:
    if (a-1) < (n-b):
        ans = a+((b-a-1)//2)
    elif (a-1) == (n-b):
        ans = n/2
    else:
        ans = n-b+1+((b-a-1)//2)

print(int(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 1000000000

int main(){
   ll N,M,V,P;
   cin>>N>>M>>V>>P;
   vector<ll> A(N);
   for(int i=0;i<N;i++){
     cin>>A.at(i);
   }
   sort(A.begin(),A.end());

   ll base=A.at(N-P);
   vector<ll> sum(N+1,0);
   for(int i=0;i<N;i++){
     sum.at(i+1)=sum.at(i)+A.at(i);
   }

   int ans=P;
   for(ll i=0;i<N-P;i++){
     ll x=A.at(i)+M;
     if(x<base){
       continue;
     }
     if(V<=P){
       ans++;
       continue;
     }
     if(M*(V-P-i)<=(x-base)+x*(N-P-i-1)-(sum.at(N-P)-sum.at(i+1))){
       ans++;
     }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 1920
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N, K;
    scan(N, K);
    K = min(K, N - 1);
    long ans;
    auto mc = ModComb(N);
    foreach (i ; 0 .. K + 1) {
        debug {
            //writeln(mc.c(N, i) * mc.c(N - 1, i));
        }
        ans += mc.c(N, i) * mc.c(N - 1, i) % mod;
        ans %= mod;
    }
    writeln(ans);
}



struct ModComb {
    int _N;
    long[] _fact, _factinv;
    long _mod;

    this(int n, long mod = 1_000_000_007L) {
        _N = n;
        _fact = new long[](_N + 1);
        _factinv = new long[](_N + 1);
        _mod = mod;

        _fact[0] = 1;
        foreach (i ; 1 .. _N + 1) {
            _fact[i] = (_fact[i-1] * i) % mod;
        }

        _factinv[_N] = _powmod(_fact[_N], mod - 2);
        foreach_reverse (i ; 0 .. _N) {
            _factinv[i] = (_factinv[i+1] * (i+1)) % mod;
        }
    }

    long c(int n, int k) {
        if (k < 0 || k > n) return 0;
        return f(n) * finv(n - k) % _mod * finv(k) % _mod;
    }

    long p(int n, int r) {
        if (r < 0 || r > n) return 0;
        return f(n) * finv(n - r) % _mod;
    }

    long f(int n) {
        return _fact[n];
    }

    long finv(int n) {
        return _factinv[n];
    }

    long _powmod(long x, long y) {
        return y > 0 ? _powmod(x, y>>1)^^2 % _mod * x^^(y & 1) % _mod : 1;
    }
}

unittest {
    auto mc = ModComb(1_000_000);
    assert(mc.c(5, 2) == 10);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 3964
N, M = list(map(int, input().split()))
a = [int(input()) for i in range(M)] + [10**20]

dp = [1] + [0 for i in range(N+2)]

next_a = a.pop(0)

for i in range(N):
    if next_a == i:
        dp[i] = 0
        next_a = a.pop(0)
    else:
        dp[i+1] += dp[i]
        dp[i+2] += dp[i]
print(dp[N]%1000000007)

Measured memory_bytes: 462728
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int n;
           cin>>n;
           cout<<(n-2)*180<<endl;
}

Measured memory_bytes: 3592
n, k, c = map(int, input().split())
s = list(str(input()))

def getpos(s):
    l = []
    i = 0
    while i <= n-1 and len(l) < k:
        if s[i] == 'o':
            l.append(i)
            i += c+1
        else:
            i += 1
    return l

l = getpos(s)

s.reverse()
r = getpos(s)
for i in range(len(r)):
    r[i] = n-1-r[i]

#print(l)
#print(r)

lastl = [-1]*(n+1)
lastr = [-1]*(n+1)

for i in range(k):
    lastl[l[i]+1] = i

for i in range(n):
    if lastl[i+1] == -1:
        lastl[i+1] = lastl[i]

for i in range(k):
    lastr[r[i]] = i

for i in reversed(range(n)):
    if lastr[i] == -1:
        lastr[i] = lastr[i+1]

#print(lastl)
#print(lastr)

ans = []
s.reverse()
for i in range(n):
    if s[i] != 'o':
        continue
    cnt = 0
    cnt += lastl[i]+1
    cnt += lastr[i+1]+1
    if lastl[i] != -1 and lastr[i+1] != -1 and r[lastr[i+1]] - l[lastl[i]] <= c:
        cnt -= 1
    if cnt < k:
        ans.append(i+1)

for i in range(len(ans)):
    print(ans[i])

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll dp[111][111111];
ll sum[111][111111];
map<ll, ll> mp;

void mod_add(ll &a, ll b){
	a += b;
	a %= MOD;
}

void calSum(int n){
	REP(i, 111111 - 1){
		mod_add(sum[n][i], dp[n][i]);
		if(i > 0)mod_add(sum[n][i], sum[n][i-1]);
	}
}

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

	ll n, k;cin >> n >> k;
	vector<ll> v;

	for(int i = 1;i * i <= n;i++){
		v.PB(i);
		if(i != (n / i))v.PB(n / i);
	}
	ll m = v.size();
	sort(ALL(v));
	REP(i, m){
		mp[v[i]] = i;
	}

	REP(i, m){
		if(i == 0){
			dp[0][i] = 1;
		}
		else {
			dp[0][i] = v[i] - v[i-1];
		}
	}
	calSum(0);

	for(ll i = 1;i <= k - 1;i++){
		REP(j, m){
			if(j == 0){
				dp[i][j] = sum[i-1][m];
			}
			else {
				ll now = sum[i-1][mp[n / v[j]]];
				dp[i][j] = now * (v[j] - v[j-1]) % MOD;
			}
		}
		calSum(i);
	}

	cout << sum[k - 1][m] << endl;

	return 0;
}


Measured memory_bytes: 180856
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) (*find_by_order(i))
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
// #define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/


void solve(){
    int x;
    cin >> x;
    int c = x, ans = 1;
    while(c%360 != 0)c += x, ans++;
    cout << ans;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3608
#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[i];
	}

	int ans = 0;
	int dirh[4] = { 1, -1, 0, 0 };
	int dirv[4] = { 0, 0, 1, -1 };
	for( int sti = 0; sti < H; sti++ ) {
		for( int stj = 0; stj < W; stj++ ) {
			if( S[sti][stj] == '#' ) continue;
			for( int ti = 0; ti < H; ti++ ) {
				for( int tj = 0; tj < W; tj++ ) {
					if( S[ti][tj] == '#' ) continue;
					queue<tuple<int, int, int>> que;
					que.push( make_tuple( sti, stj, 0 ) );
					vector<vector<int>> visit( H, vector<int>( W ) );
					int len = 0;
					while( !que.empty() ) {
						int i, j, d;
						tie( i, j, d ) = que.front();
						que.pop();
						if( i == ti && j == tj ) {
							len = d;
							break;
						}
						for( int ii = 0; ii < 4; ii++ ) {
							int ni = i + dirv[ii];
							int nj = j + dirh[ii];
							if( ni < 0 || H <= ni || nj < 0 || W <= nj || S[ni][nj] == '#' || visit[ni][nj] ) continue;
							visit[ni][nj] = 1;
							que.push( make_tuple( ni, nj, d + 1 ) );
						}
					}
					ans = max( ans, len );
				}
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)

int main() {
	ll W, a, b; cin >> W >> a >> b;
	if (b - (a + W) > 0) {
		cout << b - (a + W) << endl;
	}
	else if (a - (b + W) > 0) {
		cout << a - (b + W) << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
bool isPrime(ll N){
    if(N<2)return false;
    if(N<4)return true;
    if((N&1)==0)return false;
    if(N%3==0)return false;
    ll curr=5,s=sqrt(N);
    while(curr<=s){
        if(N%curr==0)return false;
        curr+=2;
        if(N%curr==0)return false;
        curr+=4;
    }
    return true;
}
void solve(){
    ll n;
    cin>>n;
    while(isPrime(n)!=true){
        n++;
    }
    cout<<n;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

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

signed main(void)
{
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	sort(p.rbegin(), p.rend());
	p[0] /= 2;
	int sum = 0;
	rep(i, n) sum += p[i];
	cout << sum << endl;
	return 0;
}


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

using namespace std;

namespace jumpmelon
{
	typedef long long big;

	const int P = 998244353;

	vector<int> operator*(const vector<int> &A, const vector<int> &B)
	{
		int n = (int)A.size(), m = (int)B.size();
		vector<int> R(n + m - 1);
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				R[i + j] = int((R[i + j] + (big)A[i] * B[j]) % P);
		return R;
	}

	vector<int> operator+(const vector<int> &A, const vector<int> &B)
	{
		int n = (int)A.size(), m = (int)B.size();
		vector<int> R(max(n, m));
		for (int i = 0; i < n; i++)
			R[i] = A[i];
		for (int i = 0; i < m; i++)
			R[i] = (R[i] + B[i]) % P;
		return R;
	}

	int inv(int x) { return x == 1 ? 1 : int(big(P - P / x) * inv(P % x) % P); }

	const int MAXN = 400;
	int A[MAXN], B[MAXN];
	int Fac[MAXN + 1], InvFac[MAXN + 1];
	int S[MAXN + 1][MAXN + 1];
	int L[MAXN + 1];
	vector<int> G[MAXN + 1];

	int C(int n, int m) { return int((big)Fac[n] * InvFac[m] % P * InvFac[n - m] % P); }

	void work()
	{
		int n, s = 0;
		scanf("%d", &n);
		for (int i = 0; i < n; i++)
		{
			scanf("%d%d", &A[i], &B[i]);
			s += A[i];
		}
		Fac[0] = 1;
		for (int i = 1; i <= MAXN; i++)
			Fac[i] = int((big)Fac[i - 1] * i % P);
		InvFac[MAXN] = inv(Fac[MAXN]);
		for (int i = MAXN; i >= 1; i--)
			InvFac[i - 1] = int((big)InvFac[i] * i % P);
		G[0] = {1};
		int inv_s = inv(s);
		for (int i = 0, t = 0; i < n; i++)
		{
			int c = int((big)A[i] * inv_s % P);
			vector<int> V(B[i]);
			for (int j = 0, v = 1; j < B[i]; j++, v = int((big)v * c % P))
				V[j] = int(big(P - v) * InvFac[j] % P);
			t += A[i];
			for (int j = t; j >= 0; j--)
			{
				if (!G[j].empty())
					G[j] = G[j] * V;
				if (j >= A[i])
					G[j] = G[j] + G[j - A[i]];
			}
		}
		S[0][0] = 1;
		for (int i = 1; i <= MAXN; i++)
			for (int j = 1; j <= i; j++)
				S[i][j] = int((S[i - 1][j - 1] + big(i - 1) * S[i - 1][j]) % P);
		int ans = 0;
		for (int k = 0; k < (int)G[0].size(); k++)
			ans = int((ans + (big)G[0][k] * Fac[k]) % P);
		for (int d = 1; d < s; d++)
		{
			int c = int((big)d * inv_s % P), inv_c = inv(c);
			int vr = inv((1 + P - c) % P), vv = int((big)c * vr % P);
			L[0] = vr;
			for (int i = 1; i < (int)G[d].size(); i++)
			{
				L[i] = 0;
				for (int j = 0; j < i; j++)
					L[i] = int((L[i] + (big)vv * C(i, j) % P * L[j]) % P);
			}
			for (int k = 0, v = 1; k < (int)G[d].size(); k++, v = int((big)v * inv_c % P))
				for (int i = k, u = 1; i >= 0; i--, u = P - u)
					ans = int(
						(ans + (big)G[d][k] * v % P * S[k][i] % P * u % P * L[i]) % P);
		}
		printf("%d\n", (P - ans) % P);
	}
}

int main()
{
	jumpmelon::work();
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

class UnionFind
{
private:
    vector<ll> p;
    vector<ll> rank;
public:
    UnionFind(ll n){
        p.resize(n,-1);
        rank.resize(n,1);
    }
    ll find(ll x){
        if(p[x]<0)return x;
        return p[x]=find(p[x]);
    }
    void unite(ll x,ll y){
        x=find(x);
        y=find(y);
		if(x==y)return;
        if(rank[x]>rank[y])swap(x,y);
        if(rank[x]==rank[y])rank[y]++;
        p[y]+=p[x];
        p[x]=y;
    }
    ll size(ll x){
        return -p[find(x)];
    }
	bool same(ll a, ll b){
		return find(a) == find(b);
	}
};

signed main(){
	//cout << fixed << setprecision(10);
	int n; cin >> n;
	vl a(n);
	map<int,int> mp;
	rep(i,0,n){
		cin >> a[i];
		mp[a[i]]++;
	}
	ll cnt = 0;
	ll ans = mp.size();
	for(auto c:mp){
		//cout << c.first << " " << c.second << endl;
		cnt += (c.second - 1);
	}
	if(cnt % 2 == 1)ans--;
	cout << ans << endl;
}



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

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;

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

  int n; cin >> n;
  ll t = 1, a = 1;
  ll p, q, m;
  rep(i, n) {
    cin >> p >> q;
    m = max((t+p-1)/p,(a+q-1)/q);
    t = m*p, a = m*q;
  }

  cout << t+a << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int sec;
	int ssec[4];
	scanf("%d%d%d%d",ssec,ssec+1,ssec+2,ssec+3);
	sec = ssec[0]+ssec[1]+ssec[2]+ssec[3];
	printf("%d\n%d\n",sec / 60,sec % 60);
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d\n",max(a+b,max(a+a-1,b+b-1)));
    return 0;
}


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

using namespace std;

#define ll long long

template< typename flow_t >
struct FordFulkerson {
  struct edge {
    int to;
    flow_t cap;
    int rev;
    bool isrev;
    int idx;
  };

  vector< vector< edge > > graph;
  vector< int > used;
  const flow_t INF;
  int timestamp;

  FordFulkerson(int n) : INF(numeric_limits< flow_t >::max()), timestamp(0) {
    graph.resize(n);
    used.assign(n, -1);
  }

  void add_edge(int from, int to, flow_t cap, int idx = -1) {
    graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false, idx});
    graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true, idx});
  }

  flow_t dfs(int idx, const int t, flow_t flow) {
    if(idx == t) return flow;
    used[idx] = timestamp;
    for(auto &e : graph[idx]) {
      if(e.cap > 0 && used[e.to] != timestamp) {
        flow_t d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  flow_t max_flow(int s, int t) {
    flow_t flow = 0;
    for(flow_t f; (f = dfs(s, t, INF)) > 0; timestamp++) {
      flow += f;
    }
    return flow;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      for(auto &e : graph[i]) {
        if(e.isrev) continue;
        auto &rev_e = graph[e.to][e.rev];
        cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
      }
    }
  }
};

signed main(){
    int h, w; cin >> h >> w;
    // 0 : 始点
    // 1〜h : 縦
    // h+1〜h+w : 横
    // h+w+1 : 終点
    FordFulkerson<int> f(h + w + 2);
    for (int i = 1; i <= h; ++i){
        string s; cin >> s;
        for (int j = 0; j < w; ++j){
            if (s[j] == '.') continue;
            if (s[j] == 'o'){ 
              f.add_edge(i, h + j + 1, 1);
              f.add_edge(h + j + 1, i, 1);
            }
            if (s[j] == 'S'){
                f.add_edge(0, i, 1000000000);
                f.add_edge(0, h + j + 1, 1000000000);
                f.add_edge(i, 0, 1000000000);
                f.add_edge(h + j + 1, 0, 1000000000);
            }
            if (s[j] == 'T'){
                f.add_edge(h + w + 1, i, 1000000000);
                f.add_edge(h + w + 1, h + j + 1, 1000000000);
                f.add_edge(i, h + w + 1, 1000000000);
                f.add_edge(h + j + 1, h + w + 1, 1000000000);
            }
        }
    }
    int ans = f.max_flow(0, h + w + 1);
    cout << (ans >= 1000000000 ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <cmath>
using namespace std; 
#define pb push_back 
#define M 998244353
#define ff first
#define ss second 
#define deb(x) cout< #x< " "< x< endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<=n;i++)
#define FORR(a,b,c) for(int a= b;a>=c;a--)
#define nl endl
#define fa(arrr) for(auto x:arrr)
#define sz size()
#define mp make_pair
#define mxm3(a,b,c) max(a, max(b,c))
#define mi3(a,b,c) min(a, min(b,c))
#define MAX 100005
#define PII pair<ll,ll>
#define all(v) v.begin(), v.end()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
typedef long long ll;
typedef vector<ll>vl;
vector<ll> prime(1100,-1);
//126271
// 107897

int main(){

	fast;
	ll t;
	// string s;
	// cin >> s;
	// cin >>t;
	t = 1;
	// int tc = 1;
	while(t--){
		int x,y,z; cin >> x >> y >> z;
		cout << z << " " <<  x << " "<<  y  << endl;

	}	
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {

    ll N;

    cin >> N;

    vector<ll> ans(4);

    rep(i, 4) {
        ans[i] = 0;
    }

    string tmp;

    rep(i, N) {
        cin >> tmp;
        if (tmp == "AC") {
            ans[0]++;
        }
        if (tmp == "WA") {
            ans[1]++;
        }
        if (tmp == "TLE") {
            ans[2]++;
        }
        if (tmp == "RE") {
            ans[3]++;
        }
    }

    cout << "AC x " << ans[0] << endl;
    cout << "WA x " << ans[1] << endl;
    cout << "TLE x " << ans[2] << endl;
    cout << "RE x " << ans[3] << endl;

    return 0;
}

Measured memory_bytes: 3636
a, b, c = map(int, raw_input().split())
k = input()
mx = max(a, b, c)
if a == mx:
	print a *(2 ** k) + b + c
elif b == mx:
	print b *(2 ** k) + a + c
else :
	print c *(2 ** k) + a + b

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;
const ll MOD=1e9+7;

int n;
ll dp[102][4][4][4];
int flag[102][4][4][4];

ll ddpp(int x,int y,int z,int w){
    if (flag[x][y][z][w]){
        return dp[x][y][z][w];
    }
    else{
        flag[x][y][z][w]=1;
        if (x==n){
            dp[x][y][z][w]=1;
        }
        else{
            if (z==1 && w==2){//末尾AG
                dp[x][y][z][w]=ddpp(x+1,z,w,1)+ddpp(x+1,z,w,2)+ddpp(x+1,z,w,0);
            }
            else if (z==2 && w==1){//末尾GA
                dp[x][y][z][w]=ddpp(x+1,z,w,0)+ddpp(x+1,z,w,1)+ddpp(x+1,z,w,2);
            }
            else if (z==1 && w==3){
                dp[x][y][z][w]=ddpp(x+1,1,3,1)+ddpp(x+1,1,3,0)+ddpp(x+1,1,3,3);
            }
            else if (y==1 && w==2){//AC
                dp[x][y][z][w]=ddpp(x+1,z,w,0)+ddpp(x+1,z,w,1)+ddpp(x+1,z,w,2);
                
            }
            else if (y==1 && z==2){
                dp[x][y][z][w]=ddpp(x+1,z,w,0)+ddpp(x+1,z,w,1)+ddpp(x+1,z,w,2);
            }
            else{
                dp[x][y][z][w]=ddpp(x+1,z,w,0)+ddpp(x+1,z,w,1)+ddpp(x+1,z,w,2)+ddpp(x+1,z,w,3);
            }
        }
        dp[x][y][z][w]%=MOD;
        return dp[x][y][z][w];
    }
}

int main() {
    cin>>n;
    ddpp(0,0,0,0);
    cout<<dp[0][0][0][0]<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
	int a,b,x=0,num=0;;
	while(cin>>a>>b){
		if(a==0&&b==0)break;
		if(num!=0)cout<<endl;
		for(int i=a;i<=b;i++){
			if(i%400==0){
				cout<<i<<endl;
				x=1;
			}else if(i%100==0){

			}else if(i%4==0){
				cout<<i<<endl;
				x=1;
			}
		}
		if(x==0)cout<<"NA"<<endl;
		x=0;
		num=1;
	}
	return 0;
}

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

class Point_class():
    def __init__(self, x, y):
        self.x = x
        self.y = y

import sys

for line in sys.stdin:
    A = map(float, line.split())
    p = []
    for i in range(4):
        p.append(Point_class(A[2*i], A[2*i+1]))
    if p[0].x > p[3].x or p[1].x < p[2].x or p[0].y > p[3].y or p[1].y < p[2].y:
        print "NO"
    else:
        print "YES"

Measured memory_bytes: 6444
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int n = sc.nextInt();
		
		int[] S = new int[n];
		for(int i=0; i<n; i++) {
			S[i] = sc.nextInt();
		}
		
		int q = sc.nextInt();
		
		int cnt = 0;
		for(int i=0; i<q; i++) {
			int T = sc.nextInt();
			for(int j=0; j<n; j++) {
				if(T == S[j]) {
					cnt++;
					break;
				}
			}
		}
		
		System.out.println(cnt);
	}
	
	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	    public int nextInt(){
	    	return Integer.parseInt(next());
	    }
	}

}

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

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;

    ll total = 0;
    for (ll i = 1; i <= n; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
            total += i;
        }
    }

    cout << total << "\n";
}



Measured memory_bytes: 3648