akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

#define MAX 101

int todo[MAX], seen[MAX], adj[MAX][MAX], d[MAX], f[MAX], stack[MAX];
int top=0, Time=1, n;

int pop();
void push(int);
void CreateAdj(int);
void dfs(int);

int main(){
  int a, b, u;
  
  scanf("%d",&n);
  CreateAdj(n);
  for(a = 0; a < n; a++) seen[a] = 0;
  for(a = 0; a < n; a++){
    if(seen[a] == 0) dfs(a+1);
  }
  for(a = 0; a < n; a++){
    printf("%d %d %d\n",a+1,d[a],f[a]);
  }
  return 0;
}

int pop(){
  return stack[top--];
}

void push(int n){
  stack[top++] = n;                                                             
}

void CreateAdj(int n){
  int a, b, u, k, v;
  for(a = 0; a < n; a++){
    for(b = 0; b < n; b++){
      adj[a][b] = 0;
    }
  }
  
  for(a = 0; a < n; a++){
    scanf("%d%d",&u,&k);
    for(b = 0; b < k; b++){
      scanf("%d",&v);
      adj[u-1][v-1] = 1;
    }
  }
}

void dfs(int v){
  int a;
  d[v-1] = Time++;

  seen[v-1] = 1;
  for(a = 0; a < n; a++){
    if(adj[v-1][a] == 1){
      if(seen[a] == 1) continue;
      else dfs(a+1);
    }
  }
  f[v-1] = Time++;
}



Measured memory_bytes: 2128
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stack>
#include <deque>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pii pair<pi,int>
#define sqr(x) ((x)*(x))
#define FOR for(int i=0;i<n;i++)for(int j=0;j<m;j++)
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;
int asd[100100];
inline int lb(int x){return x&-x;}
int sum[200100];
void fix(int x){
    while(x<=2*n+1){sum[x]++;x+=lb(x);}}
int que(int x){
    int ret=0;
    while(x){ret+=sum[x];x-=lb(x);}
    return ret;}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>asd[i];
    int l=0,r=1e9;
    ll wtd=((ll)n*n+n)/2+1>>1;
    while(l!=r){
        int mid=(l+r)/2+1;
        ll atd=0;
        memset(sum,0,sizeof(sum));
        int cnt=n+1;
        fix(cnt);
        for(int i=1;i<=n;i++){
            cnt+=(asd[i]>=mid?1:-1);
            atd+=que(cnt);
            fix(cnt);}
        if(atd>=wtd)l=mid;
        else r=mid-1;}
    cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#define INFTY 1000000001
using namespace std;

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

int main() {
	int n, A[100000] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	int k = partition(A, 0, n - 1);
	for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		if (i == k) cout << "[";
		cout << A[i];
		if (i == k) cout << "]";

	}
	cout << endl;
}


Measured memory_bytes: 3488
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int llu;
typedef long double ld;
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define pb push_back
#define pf push_front
#define mp map<ll,ll>
#define INF 1000000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
ll gcd(ll a,ll b)
{
    if(a==0)
    {
        return b;
    }
    else
    {
        return gcd(b%a,a);   
    }
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);
}
int f(char c)
{
    return (int)c-96;
}
/**********************************************************************
***********************************************************************
*********************ACTUAL CODE BEGINS HERE***************************/
int main()
{   
    fast;
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(k<=(x/d))
        cout<<x-(k*d);
    else
    {
        k-=x/d;
        if(k%2)
            cout<<abs((x%d)-d);
        else
        {
            cout<<x%d;
        }
        
    }
    return 0;
}

Measured memory_bytes: 3620
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


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

    int n, m, l;
    int d[310][310];
    int q;
    int s[95000], t[95000];
    rep(i, 310) rep(j, 310) d[i][j] = INF;
    scanf("%d %d %d", &n, &m, &l);
    rep(i, m) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        if (c > l) continue;
        a--; b--;
        d[a][b] = d[b][a] = c;
    }
    scanf("%d", &q);
    rep(i, q) scanf("%d %d", &s[i], &t[i]);

    rep(k, n) rep(i, n) rep(j, n) {
        int p = d[i][k] + d[k][j];
        if (d[i][j] > p && p <= l) d[i][j] = p;
    }

    rep(i, n) rep(j, n) if (d[i][j] <= l) d[i][j] = 1;

    rep(k, n) rep(i, n) rep(j, n) {
        if (d[i][j] > d[i][k] + d[k][j]) d[i][j] = d[i][k] + d[k][j];
    }

    rep(i, q) {
        int ans = d[s[i] - 1][t[i] - 1];
        cout << (ans < INF ? ans - 1 : -1) << '\n';
    }


    return 0;
}



Measured memory_bytes: 1664
h,w = map(int, input().split())

if w == 1 or h == 1:
    print(1)
    exit()
    
if w == 2 and h == 2:
    print(2)
    exit()

if w % 2 == 1:
    idle = int((w - 1) / 2)
    can = w - idle
    second = can - 1
    num = can + second
elif w % 2 == 1 and h == 1:
    idle = int((w - 1) / 2)
    can = w - idle
    print(can)
    exit()
elif w % 2 == 0 and h == 1:
    print(1)
    exit()
else:
    idle = int(w / 2)
    num = idle * 2

if h % 2 == 1 and w % 2 == 0:
    print(int((w / 2) * h))
    exit()

if h % 2 == 1:
    row = int(h // 2)
    print(num * row + can)
else:
    row = int(h / 2)
    print(num * row)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
  int a,b;cin>>a>>b;
  if(a>=13) cout<<b<<endl;
  else if(a<=12 and a>=6) cout<<b/2<<endl;
  else cout<<0<<endl;

}


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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int a[200][2], d[200][2];
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> a[j][i];
        }
    }
    d[0][0] = a[0][0];
    d[0][1] = a[0][0] + a[0][1];
    for (int i = 1; i < n; ++i) {
        d[i][0] = d[i - 1][0] + a[i][0];
        d[i][1] = max(d[i - 1][1], d[i][0]) + a[i][1];
    }
    cout << d[n - 1][1];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
#define int lli
void solve();
signed main(){
  // ios_base::sync_with_stdio(false);cin.tie(0);
    solve();
}
int N, M , Q;
vector<int> cur;
lli fans = 0;
int a[100], b[100], c[100], d[100];
void generate(int pos, int prev){
  if(pos == N){
    lli ans = 0;
    for(int i=0;i<Q;i++){
      int ai = a[i]-1;
      int bi = b[i]-1;
      int ci = c[i];
      int di = d[i];
      if(cur[bi] - cur[ai] == ci){
        ans+=di;
      }
    }
    fans = max(fans, ans);
    return;
  }
  for(int i=prev;i<=M;i++){
    cur.push_back(i);
    generate(pos+1, i);
    cur.pop_back();
  }
}
void solve(){
  cin>>N>>M>>Q;
  for(int i=0;i<Q;i++){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
  }
  generate(0, 1);
  cout<<fans<<Endl;
}


Measured memory_bytes: 3640
sosu = [2]
now = 3

while now ** 2 <= 10 ** 9:

    for i in sosu:

        flag = True
        if now % i == 0:
            flag = False
            break

    if flag:
        sosu.append(now)

    now += 1

#print (sosu)

sosu.insert(0,1)



S = int(input())

lis = []


r = int(S ** 0.5)

st1 = r
st2 = r
mode = 0

while True:

    if st1 * st2 - S >= 0:

        cd = ( st1 * st2 ) - S

        for i in sosu:

            flag = False

            if cd % i == 0 and cd // i <= 10 ** 9 and st1 <= 10 ** 9 and st2 <= 10 ** 9:

                print (0,0,st1,cd // i,i,st2)
                flag = True
                break

    if flag:
        break

    if st2 == 10 ** 9 and st1 == 10 ** 9:
        mode = 1
        st1 = 10 ** 9
        st2 = r

    if mode == 1 and st1 * st2 < S:
        st1 -= 1
        st2 = r

    elif mode == 1:
        st2 -= 1

    elif st1 >= 10 ** 9:
        st2 += 1
        st1 = r

    else:
        st1 += 1




    




Measured memory_bytes: 41196
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var K = int.Parse(ReadLine());
        
        var ans = 1;
        var num = 7;
        var find = false;

        for (int i = 0; i < K; i++)
        {
            if (num % K == 0)
            {
                find = true;
                break;
            }

            num = (num * 10 + 7) % K;
            ans++;
        }
        if (find)
            WriteLine(ans);
        else
            WriteLine(-1);
    }
}


Measured memory_bytes: 27480
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<climits>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF LLONG_MAX
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define ARRAY_MAX 100005


int main(){

    ll a,b,c;
    cin >> a >> b >> c;
    ll ans = INF;
    ll a_small = a/2;
    ll b_small = b/2;
    ll c_small = c/2;

    ans = min(ans, abs(a_small-(a-a_small))*b*c);
    ans = min(ans, abs(b_small-(b-b_small))*a*c);
    ans = min(ans, abs(c_small-(c-c_small))*a*b);

  
    cout << ans << endl;
   
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl "\n"
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<ll> > matrix;
// const ll S = 3e5 + 20;
// const ll N = 1e6 + 1;
const ll PRIME = 1e9 + 7;
void swap(int &x, int &y)
{
    ll sum = x + y;
    x = sum - x;
    y = sum - y;
}
void power(int a[], ll s, ll r)
{
    int i, j;

    i = s;
    j = r - 1;
    if (i == j)
        return;
    swap(a[i], a[j]);
    power(a, s + 1, r - 1);
}
void solve()
{

    ll a, b;
    cin >> a >> b;
    cout << a * b;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    // cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3656
<?php
$firstGoal = [];
$secondStart = [];
fscanf(STDIN, "%d %d", $n, $m);
for ($i = 0; $i < $m; $i++) {
  fscanf(STDIN, "%d %d", $a, $b);
  if ($a == 1) {
    $firstGoal[] = $b;
  } else if ($b == $n) {
    $secondStart[$a] = true;
  }
}
$cnt = count($firstGoal);
$res = 'IMPOSSIBLE';
for ($i = 0; $i < $cnt; $i++) {
  if (isset($secondStart[$firstGoal[$i]])) {
    $res = 'POSSIBLE';
    break;
  }
}
echo $res;

Measured memory_bytes: 32628
N = int(input())
H = list(map(int, input().split()))

tans = 0
ans = 0

for i in range (N-1):
  if H[i] >= H[i+1]:
    tans += 1
    if i == N-2 and ans < tans:
      ans = tans
  else:
    if ans < tans:
      ans = tans
    tans = 0
    
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define maxn 400010
using namespace std;
template<typename T> inline void read(T &x)
{
    x=0;char c=getchar();bool flag=false;
    while(!isdigit(c)){if(c=='-')flag=true;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    if(flag)x=-x;
}
int n,cnt;
int fa[maxn];
set<int> e[maxn];
queue<pair<int,int> > q;
int find(int x)
{
    return fa[x]==x?x:fa[x]=find(fa[x]);
}
void add(int x,int y)
{
    if(!e[x].count(y)) e[x].insert(y),e[y].insert(x);
    else q.push(make_pair(x,y)),cnt++;
}
int main()
{
    read(n);
    for(int i=1;i<=n;++i) fa[i]=i;
    for(int i=1;i<=2*n-2;++i)
    {
        int x,y;
        read(x),read(y),add(x,y);
    }
    while(!q.empty())
    {
        int x=find(q.front().first),y=find(q.front().second);
        q.pop();
        if(e[x].size()>e[y].size()) swap(x,y);
        fa[x]=y,e[y].erase(x);
        for(set<int>::iterator it=e[x].begin();it!=e[x].end();++it)
        {
            int p=*it;
            if(p==y) continue;
            e[p].erase(x),add(p,y);
        }
    }
    puts(cnt==n-1?"YES":"NO");
    return 0;
}

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

public class Main {
  private static int solve(int n, int[][] am) {
    int answer = 0;
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = 0; j <= i; j++) {
        sum += am[0][j];
      }
      for (int j = i; j < n; j++) {
        sum += am[1][j];
      }
      answer = Math.max(answer, sum);
    }
    return answer;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[][] am = reader.nextInt(2, n);
    out.println(solve(n, am));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

using namespace std;

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

void sayYes() {puts("Yes");}
void sayNo() {puts("No");}
template<class T> bool chmin(T&a,T b) {if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b) {if(a<b){a=b;return true;}return false;}

class FastIO {
public:
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
    }
    ~FastIO() {}

    template <class T>
    void scan(T &v) {
        cin >> v;
    }
    template <class T, class... Rest>
    void scan(T &v, Rest&... rest) {
        scan(v);
        scan(rest...);
    }

    template <class T>
    void print(T v) {
        cout << v;
    }
    template <class T, class... Rest>
    void print(T v, Rest... rest) {
        print(v);
        print(" ");
        print(rest...);
    }
    template <class T>
    void prints(vector<T> v) {
        for (T t: v) {
            print(t);
            print(" ");
        }
        print("\n");
    }
    template <class T>
    void prints(T v) {
        print(v);
        cout << "\n";
    }
    template <class T, class... Rest>
    void prints(T v, Rest... rest) {
        print(v);
        print(" ");
        prints(rest...);
    }
};
FastIO io;


int main() {
    int N; io.scan(N);
    string S; io.scan(S);
    
    int count, max = 0;
    for (int shift=1; shift<N; shift++) {
        count = 0;
        for (int i=shift; i<N; i++) {
            if (S[i] == S[i-shift]) {
                count++;
            }
            else {
                if (count > shift) count = shift;
                if (count > max) {
                    max = count;
                }
                count = 0;
            }
        }
        if (count > shift) count = shift;
        if (count > max) {
            max = count;
        }
    }
    
    io.print(max);
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define MaxN 100010
//#define MOD 998244353
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define endl '\n'
#define LL long long
#define PII pair<int,int>
#define rint register int 
#define ULL unsigned long long
const int MOD=1e9+7;
//int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
//int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
template<class T> inline void read(T& x){
    x=0;int f=0;char ch=getchar();
    while( !isdigit(ch) ) f|=( ch == '-' ) , ch=getchar();
    while( isdigit(ch) )  x = ( x<<1 ) + ( x<<3 ) + ( ch^48 ) , ch=getchar();
    x = f ? -x : x;
}
template<class T> inline void print(T x){
	if ( x < 0 ) { putchar('-'); x = -x; }
	if ( x >= 10 ) print( x / 10 );
	putchar(x % 10 + '0');
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    int x;
    cin>>x;
    if( x >= 30 ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0; 
}


Measured memory_bytes: 3620
n, m = map(int, input().split())
f = [0]*200020
s = [0]*200020


for i in range(m):
    a, b = map(int, input().split())
    if a == 1 or b == 1:
        f[max(a, b)] = 1
        if s[max(a, b)] == 1:
            print("POSSIBLE")
            exit()
    if a == n or b == n:
        s[min(a, b)] = 1
        if f[min(a, b)] == 1:
            print("POSSIBLE")
            exit()
print("IMPOSSIBLE")

Measured memory_bytes: 6132
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	int h, w;
	cin >> h >> w;

	vector<vector<char>> a(h, vector<char>(w, '.'));
	vector<bool> h_bool(h, true);
	vector<bool> w_bool(w, true);

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
			if (a[i][j] == '#') {
				h_bool[i] = false;
			}
		}
	}

	for (int j = 0; j < w; j++) {
		for (int i = 0; i < h; i++) {
			if (a[i][j] == '#') {
				w_bool[j] = false;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (h_bool[i]) {
				break;
			}
			else if (w_bool[j]) {
			}
			else {
				cout << a[i][j];
			}
		}
		if (!h_bool[i]) {
			cout << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 2e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

int n,a[N],ans[N],u,v;
vector<int> g[N];
vector<int> qu(N);

void dfs(int now,int fa){
  int idx = lower_bound(qu.begin(),qu.end(),a[now])-qu.begin();
  int cnt = qu[idx];
  qu[idx] = a[now];
  ans[now] = lower_bound(qu.begin(),qu.end(),inf)-qu.begin();
  for(int i = 0;i < g[now].size();i++){
    int nex = g[now][i];
    if(nex != fa) dfs(nex,now);
  }
  qu[idx] = cnt;
}

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>n;
  for(int i = 1;i <= n;i++) cin>>a[i];
  for(int i = 1;i < n;i++){
    cin>>u>>v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  fill(qu.begin(),qu.end(),inf);
  dfs(1,0);
  for(int i = 1;i <= n;i++) cout<<ans[i]<<endl;
  return 0;
}


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

int main() {
	string S;

	cin >> S;

	if (S == "Sunny") cout << "Cloudy" << endl;
	if (S == "Cloudy") cout << "Rainy" << endl;
	if (S == "Rainy") cout << "Sunny" << endl;

	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int N; cin >> N;
    if(N<30) {A1;}
    else{A2;}
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
int a[25];
signed main() {
	int n,sum,ans=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sum = a[0];
	for (int i = 1; i < n; i++) {
		if (a[i] >= sum) {
			ans++;
			sum = a[i];
		}
	}
	cout << ans + 1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char s[1201];
	int i;
	fgets(s,sizeof(s),stdin);
	for(i=0;s[i]!='\0';i++){
		if('a'<=s[i]&&s[i]<='z')s[i]-='a'-'A';
		else if('A'<=s[i]&&s[i]<='Z')s[i]+='a'-'A';
	}
	printf("%s",s);
	return 0;
}


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

using namespace std;

int main()
{
  int n;
  cin>>n;
  vector <int> vec(n);
  for(int i=0;i<n;i++)
  {
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int Ap=0,Bp=0;
  for(int i=0;i<n;i++)
  {
    if(i%2==0)
      Ap+=vec.at(i);
    else
      Bp+=vec.at(i);
  }
  cout<<Ap-Bp<<endl;
}

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

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        String S = next();

        char[] list = S.toCharArray();

        int count = 0;
        int max = 0;
        for (int i=0; i<list.length; i++) {
            if(list[i]=='R'){
                count++;
            }
            else {
                count = 0;
            }
            max = Math.max(max, count);
        }

        System.out.println(max);


    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 32744
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int x[n],m=100,M=0;
  for(int i=0;i<n;i++){
    cin>>x[i];
    if(M<x[i])M=x[i];
    if(x[i]<m)m=x[i];
  }
  int min=1000000;
  for(int p=m;p<=M;p++){
    int sum=0;
    for(int i=0;i<n;i++)sum+=(x[i]-p)*(x[i]-p);
    if(sum<min)min=sum;
  }
  cout<<min<<endl;
}

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

typedef long long ll;

const int mod = 1000000007;
const int Maxn = 200005;

int fac[Maxn], inv[Maxn];
int n, m, k;

int toPower(int a, int p)
{
    int res = 1;
    while (p) {
        if (p & 1) res = ll(res) * a % mod;
        p >>= 1; a = ll(a) * a % mod;
    }
    return res;
}

int Inv(int x) { return toPower(x, mod - 2); }

int C(int n, int k)
{
    if (n < 0 || k < 0 || k > n) return 0;
    return ll(fac[n]) * inv[k] % mod * inv[n - k] % mod;
}

int main()
{
    fac[0] = inv[0] = 1;
    for (int i = 1; i < Maxn; i++) {
        fac[i] = ll(i) * fac[i - 1] % mod;
        inv[i] = Inv(fac[i]);
    }
    cin >> n >> m >> k;
    int res = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            int ways = ll(n - i) * (m - j) % mod * (i + j) % mod;
            if (i && j) ways = ll(ways) * 2 % mod;
            res = (res + ways) % mod;
        }
    res = ll(res) * C(n * m - 2, k - 2) % mod;
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 1792
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll unsigned long long
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
int main()
{
	fast;
	ll n, q, sum = 0;
	cin >> n;
	ll a[n + 1];
	ll h = 100010;
	vi ele(h + 1, 0);
	rep(i, 0, n)
	cin >> a[i], sum += a[i], ele[a[i]]++;
	cin >> q;
	while (q--)
	{
		ll b, c;
		cin >> b >> c;
		sum = sum - ele[b] * b;
		sum += ele[b] * c;
		ele[c] += ele[b];
		ele[b] = 0;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 4776
#include <stdio.h>

int swap(int x, int y)
{
    int temp;
    temp = x;
    x = y;
    y = temp;
    
    return x, y;
}

int main(void)
{
    int x, y, r;
    scanf("%d %d", &x, &y);
    
    if ( x < y) {
    swap(x, y);
    }

    while ( y > 0) {
    r = x % y;
    x = y;
    y = r;
    }
    
    printf("%d\n", x);
    
    return 0;
}


Measured memory_bytes: 2140
hw = gets.chomp.split(" ").map { |e| e.to_i }
arr = Array.new()

hw[0].times do
  arr << gets.chomp!
end

hw[0] += 2
hw[1] += 2

hw[0].times do |i|
  hw[1].times do |j|
    if i == 0 || i == hw[0]-1 then
      print "#"
    else
      if j == 0 || j == hw[1]-1 then
        print "#"
      elsif j == 1 then
        print  arr[i-1]
      end
    end
  end
  puts ""
end


Measured memory_bytes: 1788
N,M = map(int,input().split())
A =list(map(int,input().split()))
A.sort(reverse=True)
A_len =len(A)
count =0
if A_len ==1:
    for l in range(0,M):
        A[0]=A[0]/2
else:
    for l in range(0,M):
        comp = A[0]/2
        for i in range(0,A_len-1,1):
            if count >= M:
                break
            if A[i+1]<comp:
                break
            while True:
                count +=1
                if A[i]/2 > A[i+1]:
                    A[i] = A[i]/2
                else:
                    A[i] = A[i]/2
                    break
        A.sort(reverse=True)
        if count>=M:
            break
A = [int(i) for i in A]
sumN =sum(A)
print(sumN)

Measured memory_bytes: 14480
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void){
  string str;
  char c;
  while(cin >> str >> c){
    int t;
    vector<string> v;
    string buf = "";
    bool isOneWord = true;
    if(c == 'X')break;
    if('A' <= str[0] && str[0] <= 'Z'){
      //upper camel case
      for(int j=0;j<str.size();j++){
	if('A' <= str[j] && str[j] <= 'Z'){
	  if(j!=0)v.push_back(buf);
	  buf = "";
	  buf += str[j] - 'A' + 'a';
	}else{
	  buf += str[j];
	}
      }
      v.push_back(buf);
    }else{
      for(int i=0;i<str.size();i++){
	if(str[i] == '_'){
	  //snake case
	  for(int j=0;j<str.size();j++){
	    if(str[j] == '_'){
	      v.push_back(buf);
	      buf = "";
	    }else{
	      buf += str[j];
	    }
	  }
	  v.push_back(buf);
	  isOneWord = false;
	  break;
	}else if('A' <= str[i] && str[i] <= 'Z'){
	  //lower cames case
	  for(int j=0;j<str.size();j++){
	    if('A' <= str[j] && str[j] <= 'Z'){
	      if(j!=0)v.push_back(buf);
	      buf = "";
	      buf += str[j] - 'A' + 'a';
	    }else{
	      buf += str[j];
	    }
	  }
	  v.push_back(buf);
	  isOneWord = false;
	  break;
	}
      }
      if(isOneWord){
	v.push_back(str);
      }
    }
    //convert
    if(c == 'L'){
      for(int i=0;i<v.size();i++){
	if(i==0){
	  cout << v[i];
	}else{
	  v[i][0] -= 'a' - 'A';
	  cout << v[i];
	}
      }
    }else if(c == 'U'){
      for(int i=0;i<v.size();i++){
	v[i][0] -= 'a' - 'A';
	cout << v[i];
      }
    }else{
      for(int i=0;i<v.size();i++){
	cout << v[i];
	if(i != v.size()-1) cout << "_";
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
 
  int i, j, tmp, c;
  int N;
  int A[100];
 
  scanf("%d", &N);
  
  for(i=0; i<N; i++){
  scanf("%d",&A[i]);
  }

  for(i=0; i<N-1; i++){
    for(j=N-1; j>i; j--){
      if(A[j]<A[j-1]){
	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;
	c++;
      }
    }
  }

  for(i=0; i<N-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);
  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i,n) for(int i=0;i<(n);++i)


using namespace std;

typedef long long ll;

int main(){

    int N,tmp,ans;
    scanf("%d",&N);
    
    int A[N+1];
    int B[N+1];
    A[0]=0;
    B[0]=0;

    for(int i=1;i!=N+1;++i){
        scanf("%d",&tmp);
        A[i]=A[i-1]+tmp;
    }
    for(int i=1;i!=N+1;++i){
        scanf("%d",&tmp);
        B[i]=B[i-1]+tmp;
    }
    /*
    rep(i,N+1)cout<<A[i]<<" ";
    cout<<endl;
     rep(i,N+1)cout<<B[i]<<" ";
    cout<<endl;
    */
    ans=0;

    for(int i=0;i!=N+1;++i){
        //cout<<"tmp:"<<tmp<<endl;
        tmp=A[i]-A[0]+B[N]-B[i-1];
        ans=tmp>=ans?tmp:ans;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long w = sc.nextLong();
		if (w == 1 || h == 1) {
			System.out.println(1);
		} else {
			long res = (h / 2L + h % 2L) * (w / 2L + w % 2L);
			--h;
			--w;
			res += (h / 2L + h % 2L) * (w / 2L + w % 2L);
			System.out.println(res);
		}
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

struct UnionFind{
    vector<int> parents;

    UnionFind(int size)
        : parents(size){
        for(int i = 0; i < size; i++){
            parents[i] = i;
        }
    }

    int root(int x){
        if(parents[x] == x){
            return x;
        }

        return parents[x] = root(parents[x]);
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);

        if(rx != ry){
            parents[rx] = ry;
        }
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }
};


int main(void)
{
    int people_cnt;
    int connect_cnt;

    cin >> people_cnt >> connect_cnt;

    UnionFind uf(people_cnt);

    for(int i = 0; i < connect_cnt; i++){
        int a;
        int b;

        cin >> a >> b;

        uf.unite(a - 1, b - 1);
    }

    int biggest_friends = 1;
    unordered_map<int, int> friends_size;
    for(int i = 0; i < people_cnt; i++){
        int belong = uf.root(i);

        if(friends_size.find(belong) == friends_size.end()){
            friends_size[belong] = 1;
        }else{
            friends_size[belong] += 1;
            if(biggest_friends < friends_size[belong]){
                biggest_friends = friends_size[belong];
            }
        }
    }

    cout << biggest_friends << endl;

    return 0;
}

Measured memory_bytes: 12060
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 100, MOD = 998244353;
typedef long long ll;
ll n, a, b, k, ans, fac[N];
ll power(int a, int b) {
	if(!b)
		return 1;
	if(b == 1)
		return a;
	ll p = power(a, b / 2);
	p = (p * p) % MOD;
	if(b % 2)
		p = (p * a) % MOD;
	return p % MOD;
}
ll choose(int a, int b) {
	if(a > b)
		return 0;
	ll A = fac[b], B = (fac[a] * fac[b - a]) % MOD;
	return (A * power(B, MOD - 2)) % MOD;
}
int main() {
	fac[0] = 1;
	for (int i = 1; i < N; i++)
		fac[i] = (fac[i - 1] * i) % MOD;
	cin >> n >> a >> b >> k;
	for (int i = 0; i <= n; i++) {
		ll remain = k - (i * a);
		if(remain >= 0 && remain % b == 0) {
			ll add = (choose(i, n) * choose(remain / b, n)) % MOD;
			ans = (ans + add) % MOD;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

    if(x == 1) {
        cout << 1 << endl;
        return 0;
    } 
    
    int res = -1;
    for (int i = 2; i <= x; i++) {
        int count = 2;
        int ans = -1;
        while ((int)pow(i, count) <= x) {
            ans = max(ans , (int)pow(i, count));
            count += 1;
        }
        res = max(res, ans);
    }

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
N,K=map(int,input().split())
H=list(map(int,input().split()))
DP=[0]*(N+1)
for i in range(2,N+1):
  L=[DP[i-j-1]+abs(H[i-1]-H[i-j-2])for j in range(min(K,i-1))]
  DP[i]=min(L)
print(DP[-1])


Measured memory_bytes: 52576
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
	int N;
	int A[20];
	int B[50];
	int C[50];
	int sum = 0;
	int before=100;

	scanf("%d", &N);

	for (int i = 0; i < N; i++)
		scanf("%d", &A[i]);

	for (int i = 0; i < N; i++)
		scanf("%d", &B[i]);

	for (int i = 0; i < N-1; i++)
		scanf("%d", &C[i]);

	for (int i = 0; i < N; i++)
	{
		
		sum += B[A[i]-1];
		if (before + 1 == A[i])
			sum += C[before-1];
			
		before = A[i];
		//printf("%d\n", sum);

	}

	printf("%d", sum);

}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    d = abs(A - B)
    r = 16 - A - B
    if d <= (r // 2):
        print("Yay!")
    else:
        print(":(")
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n,k = map(int,input().split())

a  = [0]*n

a = [int(s) for s in input().split()]

nxt = a[0]

seen = [1]
load = set()
load.add(1)
res = 0
flag = 0
for i in range(k-1):
    #print(seen)
    #print(nxt)
    if not(nxt in load):
        seen.append(nxt)
        load.add(nxt)
        nxt = a[nxt-1]
    else:
        root = i - seen.index(nxt) + 1
        #print(root)
        #print(k-1-i)
        zansa = (k-1-i)%root
        res = seen[seen.index(nxt)+zansa]
        flag = 1
        break


if(flag == 1):
    print(res)
else:
    print(nxt)

Measured memory_bytes: 33832
#include <iostream>

using namespace std;

int k, n, a[200001], m;

int main () {
  cin >> k >> n;
  cin >> a[1];
  for (int i = 2; i <= n; i++) {
    cin >> a[i];                  //[ideea de rezolvare] e
    m = max (m, a[i] - a[i - 1]); //(perimetru - distana maxima dintre doua case)
  }
  m = max (m, a[1] + k - a[n]); // daca te intoarci din casa (1) in casa (n)
  cout << k - m << endl;
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
S = input()

def get_purified(string):
    replaced = string.replace("()", "")
    if replaced == string:
        return replaced
    else:
        return get_purified(replaced)

purified_str = get_purified(S)
right_braces = purified_str.count("(")
left_braces = purified_str.count(")")
out = "(" * left_braces + S + ")" * right_braces
print(out)


Measured memory_bytes: 3060
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("op.txt","w",stdout);
	#endif

	clock_t startTime=clock();

	ll a;
	double b;
	cin>>a>>b;
	ll c=(b*100)+0.5;

	ll ans=a*c;
	cout<<(ans/100)<<endl;

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 300 + 10, mod = 998244353;
void add(ll &x,ll y){
    (x += y) %= mod;
}
char s[N];
int n,k;
ll f[N][N],s1[N][N],s2[N][N];
void calc(){
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            s1[i][j] = s2[i][j] = f[i][j];
            if(i-1>=0&&j-1>=0) add(s1[i][j],s1[i-1][j-1]);
            if(j-1>=0) add(s2[i][j],s2[i][j-1]);
        }
    }
}
int main(){
    cin>>s>>k;
    n = strlen(s);
    f[0][0] = 1;
    calc();
    for(int i=0,j=0;i<n;i=j=j+1){
        while(s[j]=='1') j++;
        int c = j - i;
        for(int x=0;x<=n;x++){
            for(int y=0;y<=n;y++){
                f[x][y] = 0;
                add(f[x][y],s2[x][min(y+c,n)]-s2[x][y]+mod);
                add(f[x][y],s1[x][y]);
            }
        }
        calc();
    }
    ll ans = 0;
    for(int i=0;i<=min(n,k);i++) add(ans,f[i][0]);
    cout<<ans<<endl;
}


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

int main() {

	char S[100001];
	int cnt_odd[2] = {0}, cnt_even[2] = {0};
	
	cin >> S;
	
	int i = 0;
	for(;;){
		
		if(S[i] == '\0'){
			break;
		}
		
		if(i % 2){
			cnt_odd[(int)(S[i] - '0')]++;
		}
		else{
			cnt_even[(int)(S[i] - '0')]++;
		}
		
		i++;
		
	}

	int i0 = cnt_odd[0] + cnt_even[1];
	int i1 = cnt_odd[1] + cnt_even[0];
	
	if(i0 < i1){
		cout << i0 << "\n";
	}
	else{
		cout << i1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 384
use strict;
my($a,$b,$c)=glob <>;
my $k=<>;
my $count=0;
while($a>=$b){$b=$b*2;$count=$count+1;}
while($b>=$c){$c=$c*2;$count=$count+1;}
if($count<=$k){print"Yes";}else{print"No";}

Measured memory_bytes: 5356
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int a = Character.getNumericValue(s.charAt(0));
        int b = Character.getNumericValue(s.charAt(1));
        int c = Character.getNumericValue(s.charAt(2));
        int d = Character.getNumericValue(s.charAt(3));
        if(a + b + c + d == 7) System.out.println(a + "+" + b + "+" + c + "+" + d + "=7");
        else if(a + b + c - d == 7) System.out.println(a + "+" + b + "+" + c + "-" + d + "=7");
        else if(a + b - c + d == 7) System.out.println(a + "+" + b + "-" + c + "+" + d + "=7");
        else if(a - b + c + d == 7) System.out.println(a + "-" + b + "+" + c + "+" + d + "=7");
        else if(a + b - c - d == 7) System.out.println(a + "+" + b + "-" + c + "-" + d + "=7");
        else if(a - b - c + d == 7) System.out.println(a + "-" + b + "-" + c + "+" + d + "=7");
        else if(a - b + c - d == 7) System.out.println(a + "-" + b + "+" + c + "-" + d + "=7");
        else if(a - b - c - d == 7) System.out.println(a + "-" + b + "-" + c + "-" + d + "=7");
        scan.close();
    }
}

Measured memory_bytes: 26976
#include <cstdio>
#include <queue>
using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	vector <int> a(n);
	int ans=0;
	for(int i = 1;i <= n;i ++){
		scanf("%d", &a[i]);
		if(i&1)if(a[i]&1)
			ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3220
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto N=vecin(5);
	
	REP(i,5){
		if(N[i]==0){
			out(i+1);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   string S;
   cin >> S;
   if(S=="AAA" || S== "BBB") cout << "No"<<endl;
   else cout << "Yes" <<endl;
   return 0;
}


Measured memory_bytes: 256
n = int(input())
plot = [0]*n
ans = 0.0
for i in range(n):
    plot[i] = list(map(int,input().split()))
for i in range(n):
    for j in range(n-i-1):
        l = (plot[i][0]-plot[i+j+1][0])**2 + (plot[i][1]-plot[i+j+1][1])**2
        l = l ** 0.5
        ans += l*2
ans = ans/n
print(ans)

Measured memory_bytes: 62432