akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AOnTheWay solver = new AOnTheWay();
        solver.solve(1, in, out);
        out.close();
    }

    static class AOnTheWay {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            if ((a <= c && c <= b) || (b <= c && a >= c)) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}



Measured memory_bytes: 21972
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stack>
using namespace std;

struct Point {
    Point() {x=0,y=0;}
    Point(int _x,int _y){x  =_x,y=_y;}

    int x,y;
};

// 重载相应的比较运算符
bool operator < (Point a, Point b)
{
    return a.x == b.x ? a.y < b.y : a.x < b.x;
}
long long gcd(long a, long b) {
    return b ? gcd(b, a % b) : a;
}

int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};
char dc[] = {'R', 'L', 'D', 'U'};
char dcc[] = {'L', 'R', 'U', 'D'};

int k,n,m;

void solvee(){
    cin >> n >> m;
    vector<long long> c(n+1);
    vector<long long> res(n+1);
    vector<vector<long long> > nxt(n+1);
    for(int i = 1; i <= n; i++) scanf("%lld", &c[i]);
    for(int i = 0; i < m; i++) {
        int u,v;
        scanf("%d%d", &u,&v);
        res[u] += c[v];
        nxt[v].push_back(u);
    }
    long long ans = res[1];
    for(int i = 1; i <= n; i++) {

        for(int j = 1; j < (1<<nxt[i].size()); j++) {
            cout << i<< ' '<< j<<endl;
            long long sum = c[i];
            for(int k = 0; k < nxt[i].size(); k++) {
                if(j&(1<<k)) {
                    sum += res[nxt[i][k]]-c[i];
                }
            }
            cout << "sum = " <<sum<<endl;
            ans = gcd(ans, sum);
        }
    }

    cout << ans <<endl;
}

char s[1000000+10];

int main() {
    int a,b;
    cin >>a>>b;
    for(int i = 0; i <= 2000; i++) {
        if(int(i*0.1) ==b && int(i*0.08)  ==a){
            cout << i<<endl;
            return 0;
        }
    }
    puts("-1");
    return 0;
}




Measured memory_bytes: 256
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

const ll sz = 1e7+5;
ll cnt[sz];

void PreCompute() {
	for (int i = 1; i < sz; ++i) {
		for (int j = i; j < sz; j += i) {
			++cnt[j];
		}
	}
}

int main() {
	PreCompute();
	ll N;
	scll(N);
	ll ans = 0;
	++N;
	for (ll i = 1; i < N; ++i) {
		ans += i * cnt[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 81960
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m=map(int,input().split())
    num=[tuple(map(int,input().split())) for i in range(m)]
    num.sort()
    min_num=[0,0,0]
    flag=[True,True,True]
    for i in range(m):
        if flag[num[i][0]-1]:
            min_num[num[i][0]-1]=num[i][1]
            flag[num[i][0]-1]=False
        else:
            if min_num[num[i][0]-1]!=num[i][1]:
                print(-1)
                break
    else:
        if n==3:
            if min_num[0]==0:
                if flag[0]==True:
                    print(100+10*min_num[1]+min_num[2])
                else:print(-1)
            else:
                print(100*min_num[0]+10*min_num[1]+min_num[2])

        elif n==2:
            if min_num[0]==0:
                if flag[0]==True:
                    print(10+min_num[1])
                else:print(-1)
            else:
                print(10*min_num[0]+min_num[1]) 
        else:print(min_num[0])
if __name__=='__main__':
    main()

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

#define N 1100

char s[N], t[N];

int main() {
    while (scanf("%s%s", s, t) != EOF) {
        int ok = 0;
        int n = strlen(s);
        for (int i = 0; i < n; ++i) {
            if (ok) break;
            ok = 1;
            for (int j = 0; j < n; ++j) {
                if (s[(i + j) % n] != t[j]) ok = 0;
            }
        }
        if (ok) puts("Yes");
        else puts("No");
    }
    return 0;
}


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

class MinCostFlow {
public:
  struct edge { ll to, cap, cost, rev; };

private:
  typedef pair<ll, ll> pll;
  const ll INF = 1LL << 50;

  ll V;
  vector< vector<edge> > G;
  vector<ll> h, dist, prevv, preve;

public:
  MinCostFlow(ll V): V(V), G(V), h(V, 0), dist(V), prevv(V), preve(V) {}

  void add_edge(ll from, ll to, ll cap, ll cost) {
    G[from].push_back((edge) { to, cap, cost, (ll) G[to].size() });
    G[to].push_back((edge) { from, 0, -cost, (ll) G[from].size() - 1 });
  }

  ll min_cost_flow(ll s, ll t, ll f) {
    ll ret = 0;
    while(f > 0) {
      priority_queue<pll, vector<pll>, greater<pll> > q;
      REP(i, 0, V) dist[i] = INF;
      dist[s] = 0;
      q.push(pll(0, s));
      while(!q.empty()) {
        pll p = q.top();
        q.pop();
        ll v = p.second;
        if(dist[v] < p.first) continue;
        REP(i, 0, G[v].size()) {
          edge &e = G[v][i];
          if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
            dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
            prevv[e.to] = v;
            preve[e.to] = i;
            q.push(pll(dist[e.to], e.to));
          }
        }
      }
      if(dist[t] == INF) return -1;
      REP(v, 0, V) h[v] += dist[v];
      ll d = f;
      for(ll v = t; v != s; v = prevv[v]) d = min(d, G[prevv[v]][preve[v]].cap);
      f -= d;
      ret += d * h[t];
      for(ll v = t; v != s; v = prevv[v]) {
        edge &e = G[prevv[v]][preve[v]];
        e.cap -= d;
        G[v][e.rev].cap += d;
      }
    }
    return ret;
  }
};

int main(void) {
  ll N;
  string S, T;
  cin >> N >> S >> T;

  vector<ll> cntS(26, 0), cntT(26, 0);
  REP(i, 0, N) cntS[S[i] - 'a']++;
  REP(i, 0, N) cntT[T[i] - 'a']++;

  ll s = 26 * 2, t = 26 * 2 + 1;
  vector<ll> idxS(26), idxT(26);
  REP(i, 0, 26) idxS[i] = i;
  REP(i, 0, 26) idxT[i] = i + 26;

  MinCostFlow mcf(26 * 2 + 2);
  REP(i, 0, 26) mcf.add_edge(s, idxS[i], 1, 0);
  REP(i, 0, 26) mcf.add_edge(idxT[i], t, 1, 0);
  REP(i, 0, 26) REP(j, 0, 26) mcf.add_edge(idxS[i], idxT[j], 1, abs(cntS[i] - cntT[j]));

  ll f = mcf.min_cost_flow(s, t, 26) / 2;
  cout << f << endl;
}


Measured memory_bytes: 3348
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main (){
    string s;
    cin >>s;
    int a=s.size();
    int sum=0;
    for (int i=0;i<a;i++){
        if(i%2==1){
            if(s[i]=='L'||s[i]=='U'||s[i]=='D'){
                sum+=1;
            }

        }
        if(i%2==0){
            if(s[i]=='R'||s[i]=='U'||s[i]=='D'){
                sum+=1;
            }

        }
    }
    if(sum==s.size()){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

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

#define ll long long
#define f(i,a,n) for (int i=a;i<n;i++)
typedef pair<ll, ll> pa;
const ll mod=1000000007;
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll k, x;
    cin >> k >> x;

    for (int i = max(x - k, -1000000ll) + 1; i < min(k + x, 1000000ll); i++) {
        cout << i << " ";
    }
    return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
INF = 10000000000
grid = [["." for _ in range(W+1)]]
for _ in range(H):
    in_list = list("." + input())
    grid.append(in_list)

dp = [[INF for _ in range(W+1)] for _ in range(H+1)]
dp[1][0] = 0
dp[0][1] = 0

for j in range(1,W+1):
    for i in range(1,H+1):
        if grid[i][j] == ".": # 白の場合
            dp[i][j] = min(dp[i-1][j],dp[i][j-1])
        else: # 黒の場合
            if grid[i-1][j] == "#": # 上も黒ならそのまあ
                route_top = dp[i-1][j]
            else:
                route_top = dp[i-1][j] + 1
            if grid[i][j-1] == "#": # 上も黒ならそのまあ
                route_left = dp[i][j-1]
            else:
                route_left = dp[i][j-1] + 1
            dp[i][j] = min(route_top,route_left)
print(dp[-1][-1])

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

const int MAXH = 50;
const int MAXW = 50;
int W, H;
int G[MAXH][MAXW];

int dfs(int x, int y) {
  const static int dx[] = {1,0,-1,0,1,1,-1,-1};
  const static int dy[] = {0,1,0,-1,1,-1,1,-1};
  G[y][x] = 0;
  int res = 1;
  for(int k = 0; k < 8; ++k) {
    int nx = x + dx[k];
    int ny = y + dy[k];
    if(nx < 0 || nx >= W) continue;
    if(ny < 0 || ny >= H) continue;
    if(G[ny][nx] == 0) continue;
    res += dfs(nx, ny);
  }
  return res;
}

int main() {
  for(; cin >> W >> H && (W|H);) {
    int sx, sy;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cin >> G[i][j];
      }
    }
    int res = 0;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        if(G[i][j]) {
          dfs(j, i);
          ++res;
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int a;
    string s;
    cin >> a;
    cin >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())

l = []
for i in range(n):
    l.append(input())

print("AC x {}".format(l.count("AC")))
print("WA x {}".format(l.count("WA")))
print("TLE x {}".format(l.count("TLE")))
print("RE x {}".format(l.count("RE")))



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

using namespace std;

int main(){
	int a;
	string s;
	
	cin >> a;
	cin >> s;
	
	if (a >= 3200) {
		cout << s << endl;
	} else {
		cout << "red" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;typedef long long ll;typedef double ld;int INF=0x3f3f3f3f;int INF2=0x7fffffff;ll LNF=0x3f3f3f3f3f3f3f3f;ll LNF2=0x7fffffffffffffff;

int n,k;
int a[100001];

ll sum[100001],s2[100001],s3,ans;

int main(){
	scanf("%d%d",&n,&k);
	F(i,1,n) scanf("%d",a+i), sum[i]=sum[i-1]+a[i], s2[i]=s2[i-1]+max(0,a[i]);
	ans=max(ans,max(sum[n]-sum[n-k],0ll)+s2[n-k]);
	dF(i,n,k+1){
		s3+=max(0,a[i]);
		ans=max(ans,s2[i-k-1]+max(sum[i-1]-sum[i-k-1],0ll)+s3);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	n = abs(1-n);
	cout<<n;
	return 0;
}

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


int main()
{
    long double a, b, c;
    long double eps = 1.0e-14;
    cin >> a >> b >> c;
    if (sqrt(a) + sqrt(b) + eps < sqrt(c))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 10000

int main(){
  unsigned short *A, *B;

  int C[MAX+1];
  int k, i, j;
  scanf("%d", &k);

  A = malloc(sizeof(short)*k+1);
  B = malloc(sizeof(short)*k+1);

  for ( i = 0; i <= MAX; i++ ) C[i] = 0;

  for ( i = 0; i < k; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= MAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= k; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= k; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8464
#include<stdio.h>
void t(int A[],int n){
  int i;
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}
int main(){
  int i,j,n,key,k,A[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  t(A,n);
  for(i=1;i<n;i++){
    key=A[i];
    j=i-1;
    while(j>=0 && A[j]>key){
      A[j+1]=A[j];
      j--;
    }
     A[j+1]=key;
      t(A,n);
  }
  return 0;
}


      
  



Measured memory_bytes: 2140
#include<stdio.h>
#define MAX 101
int main(){
  int i, j;
  int n, id, k, v;
  int G[MAX][MAX];

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      G[i][j]=0;
    }
  }
    
  for(i=1;i<=n;i++){
    scanf("%d%d",&id,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      G[id][v]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      printf("%d ",G[i][j]);
    }
    printf("%d\n",G[i][n]);
  }

  return 0;
}

Measured memory_bytes: 636
//omajinai c++ atcoder
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define itn int
typedef long long ll;
constexpr auto mod = 1000000007;
using namespace std;
int main() {

int k,n;
  cin>>k>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  int md=k-a[n-1]+a[0];
  //cout<<"md="<<md<<endl;
  rep(i,n-1){
    md=max(md,a[i+1]-a[i]);
       // cout<<"md="<<md<<endl;;

  }
  
  cout<<k-md;
}
  


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.length();
    int ans=1000000000;
    for(char cha='a'; cha<='z'; cha++){
        string t=cha+s+cha;
        int ma=0, mon=0;
        for(int i=1; i<n+2; i++){
            if(t[i]==cha){
                ma=max(ma, i-mon-1);
                mon=i;
            }
        }
        ans=min(ans, ma);
    }
    cout << ans << endl;
}


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

int main(){
  int n, h, w;
  cin >> n >> h >> w;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    ans += (a >= h && b >= w);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    string s; cin >> s;
    int n=sz(s);
    int res=0;

    int s1=0,s0=0;
    rep(i,n){
        if(i%2==0 && s[i]!='1') s1++;
        if(i%2==1 && s[i]!='0') s1++;
    }
    rep(i,n){
        if(i%2==0 && s[i]!='0') s0++;
        if(i%2==1 && s[i]!='1') s0++;
    }
    cout<<min(s0,s1)<<endl;
}


Measured memory_bytes: 3744
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	int a, b;
	cin >> a >> b;
	cout << max({ a + b, a - b, a * b });
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public void Run()
        {
            var A = Input.ReadIntArray();
            Array.Sort(A);
            Console.WriteLine(A[A.Length-1] - A[0]);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define vecread(v) for(auto& e: v){cin >> e;}
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int >    vecint;
typedef vector<ll >      vecll;
typedef vector<double >   vecd;
typedef vector<string > vecstr;
typedef vector<char >  vecchar;
typedef vector<bool >  vecbool;
typedef vector<vector<bool> >  vec2bool;
typedef vector<vector<int> >    vec2int;
typedef vector<vector<double> >   vec2d;
////////////////////////////////////////////////
void init(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main()
{
  init();
  int n; cin >> n;
  vecll a(n,0); vecread(a);
  ll num1, num2;
  ll sum1, sum2;
  num1 = num2 = 0;
  sum1 = sum2 = 0;
  //////// plus
  if(a[0] <= 0){
    num1 = -a[0] + 1;
    sum1 = 1;
  }else{
    num1 = 0;
    sum1 = a[0];
  }
  // cout << a[0] << " " << sum1 << " " << num1 << endl;
  for(int i = 1; i < n ; i ++){
    if(sum1 > 0){
      if(sum1 + a[i] >= 0){
	num1 += a[i] + sum1 + 1;
	sum1 = -1;
      }else{
	sum1 = sum1 + a[i];
      }
    }else{
      if(sum1 + a[i] <= 0){
	// cout << sum1  << " " << a[i] << " " << num1 + 1 - sum1 - a[i] << endl;
	num1 = num1 + 1 - sum1 - a[i];
	sum1 = 1;
      }else{
	sum1 = sum1 + a[i];
      }
    }
    // cout << a[i] << " " << sum1 << " "<< num1 << endl;
  }
  // cout << num1 << endl;
  //////// minus
  if(a[0] >= 0){
    num2 = a[0] + 1;
    sum2 = -1;
  }else{
    num2 = 0;
    sum2 = a[0];
  }
  for(int i = 1; i < n ; i ++){
    if(sum2 > 0){
      if(sum2 + a[i] >= 0){
	num2 += a[i] + sum2 + 1;
	sum2 = -1;
      }else{
	sum2 = sum2 + a[i];
      }
    }else{
      if(sum2 + a[i] <= 0){
	num2 += 1 - sum2 - a[i];
	sum2 = 1;
      }else{
	sum2 = sum2 + a[i];
      }
    }
  }
  cout << min(num1, num2) << endl;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n, m, x;
  cin >> n >> m >> x;
  vi c(n);
  vvi a(n, vi(m));
  rep(i, n) {
    cin >> c[i];
    rep(j, m) {
      cin >> a[i][j];
    }
  }
  int ans = INF;
  for (int b = 0; b < (1<<n); b++) {
    int cnt = 0;
    int cost = 0;
    vi s(m);
    rep(i, n) {
      if (b & (1 << i)) {
        cnt++;
        cost += c[i];
        rep(j, m) {
          s[j] += a[i][j];
        }
      }
    }
    int ok = 0;
    rep(j, m) {
      if (x <= s[j]) ok++;
    }
    if (ok == m) {
      if (cost < ans) {
        ans = cost;
      }
    }
  }
  if (ans == INF) ans = -1;
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3664
n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = []
for i in range(m):
    b,c = map(int,input().split())
    bc.append([c,b])
bc.sort()

cnt = 0
for i in range(m-1,-1,-1):
    for _ in [0]*bc[i][1]:
        a.append(bc[i][0])
    cnt += bc[i][1]
    if cnt >= n:
        break

a.sort()
a = a[::-1]

ans = 0
for i in range(n):
    ans += a[i]
print(ans)



Measured memory_bytes: 86936
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
  int a ,b, c, d, e, X, Y;
//  long long  b, c, d, e, X, Y;
  //  double  c;
  long long  A[200003]={};
  int  B[100003]={};
  int  C[100003][11]={};

  int  flag[1003]={};

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
//  int flag=0;
//  int tmp=0;
  char tmp[101]={};
//  int min=1000000;
  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  int cnt=0;
  int num=0;
  int ans=0;
  int max=0;
  int addr=0;
  int ptn=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
//  scanf("%d%d", &a,&c);
//  cnt = strlen(t);
// printf("%d\n",a);
    scanf("%s", &s[0]);
    len=strlen(s);
  
  for(i=0;i<len;i++){
    if(s[0][i]=='o') cnt++;
  }
//   printf("%d %d %d\n",len,cnt, (cnt+(15-len)));
  if(cnt+(15-len)<8) printf("NO\n");
  else  printf("YES\n");

    
//    printf("%s %d %d\n", s[i],C[i][0],C[i][1]);
   // printf("%d\n", C[i][1]);
/*  for(i=0;i<addr;i++){
//  scanf("%lld%lld", &B[0][i],&B[1][i]);
//    ans=ans+A[i];
    printf("%lld ", A[i]);
  }
*/
//    printf("%d ", cnt);
   
//  ans=a*3;
//  ans=(ans+b)/2;
//  printf("%d\n", ans);

  
//  printf("%lf\n",ans);
  //  //  if(flag==0)   printf("TLE\n");
//    if(max < cnt - max)  printf("Yes\n");
//    else  printf("No\n");
  
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//actual solution is at bottom//
////<pbds>////
/*OPTIONAL
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, 
    rb_tree_tag, tree_order_statistics_node_update>; 
// change null_type for map
#define ook order_of_key
#define fbo find_by_order
*/
///</pbds>///

#define int long long int
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()

///<constants>///
const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5; 
const ll INF = 1e18; 
const ld PI = 4*atan((ld)1); 
const int xd[4] = {0,1,0,-1}, yd[4] = {1,0,-1,0};
///</constants>///

///<IO>/// 
namespace io {
    void setIn(string s) { freopen(s.c_str(),"r",stdin); }
    void setOut(string s) { freopen(s.c_str(),"w",stdout); }
    void setIO(string s = "") {
        ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
        // cin.exceptions(cin.failbit); // ex. throws exception when you try to read letter into int
        if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
    }
}
 
using namespace io;
///</IO>///

///<execution-time>///
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
/*example for clock usage
    clock_t z = clock();
    debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
*/
///</execution-time>///

inline void google(int i){
    cout<<"Case #"<<i<<" :";
}
signed main(){
    setIO("");
    string s,d;cin>>s>>d;
    int l=s.length(),ans=0;
    for(int i=0;i<l;i++){
    	if(s[i]!=d[i])ans++;
    }
    cout<<ans;
    return 0;
}
/* stuff you should look for
    * check whether you have read the problem correctly
    * int overflow, array bounds
    * special cases (n=1?), slow multiset operations
    * do smth instead of nothing and stay organized
*/

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

int main()
{
	int k, q;
	int d[5000];
	scanf("%d%d", &k, &q);
	for (int i = 0; i < k; ++i)
	{
		scanf("%d", d + i);
	}
	while (q--)
	{
		long long n, x, m;
		scanf("%lld%lld%lld", &n, &x, &m);
		long long last = x;
		long long eq = 0;
		for (int i = 0; i < k; ++i)
		{
			long long cnt = (n - 1 - i + k - 1) / k;
			last += (long long)d[i] % m * cnt;
			if (d[i] % m == 0) eq += cnt;
		}
		long long ans = (n - 1) - (last / m - x / m) - eq;
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    s = S()
    n = len(s)
    ans = 0
    i = 0
    pre = ""
    while i < n:
        if s[i] != pre:
            pre = s[i]
            i += 1
        else:
            if i == n-1:
                ans -= 1
            pre = s[i:i+2]
            i += 2
        ans += 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 62192
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

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

ll f(ll x) { return x * x * x * x * x; }

ll g(ll x) {
    ll l = -1 << 12, r = 1 << 12;
    while(l + 1 < r) {
        ll mid = l + r >> 1;
        (f(mid) <= x ? l : r) = mid;
    }
    if(f(l) == x) return l;
    return inf;
}

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

    ll x;
    cin >> x;

    for(ll i = -1 << 12; i <= 1 << 12; i++) {
        ll y = f(i) - x;
        ll z = g(y);
        if(z != inf) {
            cout << i << " " << z << endl;
            return 0;
        }
    }

    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n;cin>>n;
	vvl f(n,vl(10)),p(n,vl(10));
	rep(i,n){
		rep(j,10){cin>>f[i][j];}
	}
	rep(i,n){
		rep(j,11){cin>>p[i][j];}
	}
	ll ans=-1000000000;
	for(int i=1;i<(1<<10);++i){
		ll cnt=0;
		vi c(n,0);
		for(int j=0;j<10;++j){
			if((i>>j)&1){
				for(int k=0;k<n;++k){
					if(f[k][j])c[k]++;
				}
			}
		}
		for(int j=0;j<n;++j){
			cnt+=p[j][c[j]];
		}
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const int INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
class UnionFind{
    private:
        vector<ll> par;
        vector<ll> siz;
    public:
        UnionFind(ll sz){
            par.resize(sz);
            siz.assign(sz,1LL);
            rep(i,sz) par[i] = i;
        }

        ll find(ll x){
            if (par[x] == x) return x;
            else return par[x] = find(par[x]);
        }

        void unite(ll x,ll y){
            x = find(x);
            y = find(y);
            if (x == y) return;
            if (siz[x] < siz[y]) swap(x,y);
            siz[x] += siz[y];
            par[y] = x;
        }

        bool same(ll x,ll y){
            return find(x) == find(y);
        }

        ll size(ll x){
            return siz[find(x)];
        }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,a,b;
    cin >> n >> m;
    vector<P> edge;
    rep(i,m){
        cin >> a >> b;
        --a;
        --b;
        edge.push_back(P(a,b));
    }
    int cnt = 0;
    rep(i,m){
        UnionFind g(n);
        rep(j,m){
            if (i == j) continue;
            tie(a,b) = edge[j];
            g.unite(a,b);
        }
        if (g.size(0) < n) cnt++;
    }
    PRINT(cnt);
}


Measured memory_bytes: 256
a = list(map(int,input().split()))
b = [abs(a[0]-a[1])+abs(a[0]-a[2]),abs(a[0]-a[1])+abs(a[1]-a[2]),abs(a[1]-a[2])+abs(a[0]-a[2])]
b.sort()
print(b[0])

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define RLOOP(i, N) for (int i =(int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define pb push_back

typedef long long ll;

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
//cout<<"Yes"<<endl;
//cout<<"No"<<endl;

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

int main(){
  int x,n;
  cin>>x>>n;
  int v[102];
  memset(v,0,sizeof(v));
  REP(i,n){
    int tmp;
    cin>>tmp;
    v[tmp]=1;
  }
  if(v[x]!=1||n==0){
    cout<<x<<endl;
    return 0;
  }
  for(int i=0;;i++){
    if(x-i>=0){
      if(v[x-i]!=1){
        cout<<x-i<<endl;
        return 0;
      }
    }
    if(x+i<=101){
      if(v[x+i]!=1){
        cout<<x+i<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
n,c = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(c)]

cnt = {
    0: {},
    1: {},
    2: {}
}

for i in range(n):
    cl = list(map(int, input().split()))
    for j in range(n):
        k = (i+j)%3
        if cl[j] not in cnt[k]:
                cnt[k][cl[j]] = 0
        cnt[k][cl[j]] += 1

res = 10**3 * 500**2 + 10
for ci in range(c):
    for cj in range(c):
        if ci==cj:
            continue
        for ck in range(c):
            if ci==ck or cj==ck:
                continue

            t = 0
            cc = [ci, cj, ck]
            for r in range(3):
                for k in cnt[r].keys():
                    t += d[k-1][cc[r]]*cnt[r][k]
            res = min(res, t)
print(res)


Measured memory_bytes: 3064
#[derive(Debug)]
struct UnionFindBitset { bitset: Vec<usize> }
impl UnionFindBitset {
  fn new(size: usize) -> UnionFindBitset {
    let mut bitset = (0 .. size).collect::<Vec<usize>>();
    UnionFindBitset{ bitset: bitset }
  }
  
  fn next_clear_bit(&mut self, base : usize) -> Option<usize> {
    if base >= self.bitset.len() { 
      None 
    } else if base == self.bitset[base] { 
      Some(base) 
    } else {
      let t = self.bitset[base];
      let r = self.next_clear_bit(t);
      self.bitset[base] = r.unwrap_or(self.bitset.len());
      r
    }
  }
  
  fn extend_bits(&mut self, base : usize) ->  Option<usize> {
    let r = self.next_clear_bit(base);
    if r.is_none() { return r; }
    let i = r.unwrap();
    let j = self.next_clear_bit(i + 1).unwrap_or(self.bitset.len());
    self.bitset[i] = j;
    r
  }
}

fn main(){
  let mut stdin = String::new();
  std::io::Read::read_to_string(
      &mut std::io::stdin(),
      &mut stdin).unwrap();
  let mut stdin = stdin.split_whitespace();
  let mut get = || stdin.next().unwrap();
  
  macro_rules! get {
      () => {
        (get().parse::<usize>().unwrap(), get().parse::<usize>().unwrap())
      };
  }

  let (n, m) = get!();

  let mut bitset = UnionFindBitset::new(m + 1);
  let mut jobs = Vec::with_capacity(n);
  
  for i in 0 .. n {
    jobs.push(get!());  
  }
  jobs.sort_by_key(|x| x.1 );
  jobs.reverse();
  let mut ans = 0;
  
  for j in jobs.into_iter() {
    if let Some(_) = bitset.extend_bits(j.0) {
      ans += j.1;
    }
  }
  
  print!("{}", ans)
}

Measured memory_bytes: 10492
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		double a = scan.nextDouble();
		double b = scan.nextDouble();
		double C = scan.nextDouble();
		double rad = Math.toRadians(C);
		double cos_c = Math.cos(rad);
		double sin_c = Math.sin(rad);
		double S = (a * b * sin_c) / 2;
		double h = b * sin_c;
		double L = a + b + (Math.sqrt(a * a + b * b - 2 * a * b * cos_c));
		System.out.println(S);
		System.out.println(L);
		System.out.println(h);
	}
}



		

	

Measured memory_bytes: 28108
#define FOR(i, a, b) for(int i=a; i<b; i++)
#include<bits/stdc++.h>
using namespace std;

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

    if(n<m) swap(n, m);
    int r=0;
    while(m>0){
        r = m;
        m = n%m;
        n = r;
    }

    printf("%d\n", n);
}


Measured memory_bytes: 3192
import math,heapq,collections,sys,numpy as np
sys.setrecursionlimit(10**7)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def is_connected(npmat):
    mat = np.copy(npmat)
    dim = mat.shape[0]
    for i in range(dim):
        mat[i][i] = 0
    accessible = set([0])
    queue = [0]
    while len(queue) > 0:
        i = queue.pop()
        js = filter(lambda x:x[1], enumerate(mat[i] > 0))
        for j, bool in js:
            if not j in accessible:
                accessible.add(j)
                if len(accessible) == dim :
                    return True
                queue.append(j)
    return len(accessible) == dim

N,M = LI()
ma = [[0]*N for _ in range(N)]
Ms = []

for _ in range(M):
    a,b = LI_()
    ma[a][b] = 1
    ma[b][a] = 1
    Ms.append((a,b))

ans = 0
for m in Ms:
    ma[m[0]][m[1]] = 0
    ma[m[1]][m[0]] = 0
    if not is_connected(np.array(ma)):
        ans += 1
    ma[m[0]][m[1]] = 1
    ma[m[1]][m[0]] = 1
    
print(ans)


Measured memory_bytes: 12512
n, k = map(int, input().split())
L = [int(i) for i in input().split()]
L.sort(reverse=True)

flag = False
for i in range(len(L)):
  if L[i] >= k:
    continue
  else:
    print(i)
    flag = True
    break
if flag == False:
  print(n)

Measured memory_bytes: 11912
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

const double EPS = 1e-9;
bool EQ(double a, double b) { return abs(a - b) < EPS; }

double getHeight(double r, double x) {
	return sqrt(r * r - x * x);
}

int main(void) {
	int r, n;
	int T = 0;
	while(scanf("%d %d", &r, &n), r > 0) {
		T++;
		int left[20], right[20], height[20];
		for(int i = 0; i < n; i++) {
			scanf("%d %d %d", left + i, right + i, height + i);
		}

		vector<double> xs;
		const double GAPEPS = 1e-7;
		xs.push_back(-r + GAPEPS);
		xs.push_back(r - GAPEPS);
		xs.push_back(r);
		xs.push_back(-r);
		for(int i = 0; i < n; i++) {
			double cand = left[i] - GAPEPS;
			if(-r <= cand and cand <= r) xs.push_back(cand);
			cand = left[i] + GAPEPS;
			if(-r <= cand and cand <= r) xs.push_back(cand);
			cand = right[i] - GAPEPS;
			if(-r <= cand and cand <= r) xs.push_back(cand);
			cand = right[i] + GAPEPS;
			if(-r <= cand and cand <= r) xs.push_back(cand);
			cand = left[i];
			if(-r <= cand and cand <= r) xs.push_back(cand);
			cand = right[i];
			if(-r <= cand and cand <= r) xs.push_back(cand);
		}
		for(int i = 1; i < 10001; i++) xs.push_back(-r + 2 * r / 10001.0 * i);

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

		double s = 0, e = 100;
		for(int lv = 0; lv < 100; lv++) {
			double mid = (s + e) / 2;
			bool isAble = true;

			for(double x: xs) {
				bool isIncluded = false;

				double curHeight = getHeight(r, x) - r + mid;
				if(curHeight <= 0 or EQ(curHeight, 0)) continue;
				for(int i = 0; i < n; i++)
					if(left[i] <= x and x <= right[i] and height[i] > curHeight and !EQ(height[i], curHeight)) {
						isIncluded = true;
						break;
					}

				if(!isIncluded) {
					isAble = false;
					break;
				}
			}

			if(isAble) s = mid;
			else e = mid;
		}

		printf("%.4lf\n", s);
	}

	return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int h,m,s;
int main(){
	cin >> s;

	h = s / 3600;
	m = (s % 3600) / 60;
	s = s % 60;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

Measured memory_bytes: 1144
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

color = 0
cnt = 0
res = [[0] * w for _ in range(h)]
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            res[i][j] = color + 1
            cnt += 1
            if cnt == a[color]:
                color += 1
                cnt = 0
    else:
        for j in range(w-1, -1, -1):
            res[i][j] = color + 1
            cnt += 1
            if cnt == a[color]:
                color += 1
                cnt = 0

for i in range(h):
    for j in range(w):
        print(res[i][j], end=' ')
    print()

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cout<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cout<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&input,vector<T>&v){for(auto &elemnt:v)input>>elemnt;return input;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
void solve1();void solve2();
int main(){solve1();return 0;}

void solve1(){

  ll h,w,d;
  cin>>h>>w>>d;
  auto a = make_vector<ll>(h,w);
  cin>>a;
  ll q;
  cin>>q;
  vector<pair<ll,ll>> lr(q);
  rep(i,q)cin>>lr[i].first>>lr[i].second;

  vector<pair<ll,ll>> num(h*w+1);
  rep(i,h)rep(j,w){
    num[a[i][j]]=make_pair(i,j);
  }

  auto calc_cost = [](auto a,auto b){
    return abs(a.first-b.first)+abs(a.second-b.second);
  };
  vector<ll> dist(h*w+1);
  for(int i=d+1;i<=h*w;++i){
    dist[i] = calc_cost(num[i],num[i-d]);
  }

  vector<vector<ll>> table(d+1,vector<ll>(1,0));
  for(int i=1;i<=d;++i){
    for(int idx=i;idx<=h*w;idx+=d){
      table.at(i).emplace_back(dist.at(idx));
    }
    for(int j=1;j<table[i].size();++j){
      table[i][j]+=table[i][j-1];
    }
  }

  for(auto const& query:lr){
    ll l,r;
    tie(l,r) = query;
    ll idx = (l%d==0?d:l%d);
    l = (l-idx)/d+1;
    r = (r-idx)/d+1;
    ll t = table.at(idx).at(r)-table.at(idx).at(l);
    cout<<(t)<<endl;
  }

}

Measured memory_bytes: 9728
/*
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100;
const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

vi nbrs[MAX_N];
int dists[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    u--;

    for (int j = 0; j < k; j++) {
      int v;
      cin >> v;
      v--;
      nbrs[u].push_back(v);
    }
  }

  for (int i = 0; i < n; i++) dists[i] = INF;
  dists[0] = 0;

  qi q;
  q.push(0);

  while (! q.empty()) {
    int u = q.front(); q.pop();

    int vd = dists[u] + 1;
    vi &nbru = nbrs[u];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int &v = *vit;
      if (dists[v] > vd) {
	dists[v] = vd;
	q.push(v);
      }
    }
  }

  for (int i = 0; i < n; i++)
    printf("%d %d\n", i + 1, (dists[i] >= INF) ? -1 : dists[i]);

  return 0;
}

Measured memory_bytes: 1204
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  REP(i, 3) {
    string c; cin >> c;
    cout << c[i];
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 3592