akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int N;
  string S;
  cin >> N >> S;
  int s = S.size();

  string ans = "";

  for (int i = 0; i < s; i++) {
    char t = S[i];
    char new_t = (S[i] - 'A' + N) % 26 + 'A';
    ans += new_t;
  }
  cout << ans << endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int cnt = 0;

    rep(i, n - 1)
    {
        int minv = i;
        for (int j = i; j < n; j++)
        {
            if (a[j] < a[minv])
                minv = j;
        }
        if (minv != i)
        {
            swap(a[minv], a[i]);
            cnt++;
        }
    }

    rep(i, n) i != n - 1 ? cout << a[i] << " " : OP(a[i]);
    OP(cnt);

    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll  long long
#define inf 0x3f3f3f3f
#define mod 1000000007
#define PI acos(-1)
#define fi first
#define se second
#define lowbit(x) (x&(-x))
#define mp make_pair
#define pb push_back
#define ins insert
#define si size()
#define E exp(1.0)
#define fixed cout.setf(ios::fixed)
#define fixeds(x) setprecision(x)
#pragma GCC optimize(2)
using namespace std;
inline ll read(){ll s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();return s*w;}
void put1(){ puts("Yes") ;}void put2(){ puts("No") ;}void put3(){ puts("-1"); }
ll qp(ll a,ll b, ll p){ll ans = 1;while(b){if(b&1){ans = (ans*a)%p;--b;}a =
(a*a)%p;b >>= 1;}return ans%p;}ll Inv(ll x,ll p){return qp(x,p-2,p);}
ll Cal(ll n,ll m,ll p){if (m>n) return 0;ll ans = 1;for(int i = 1; i <= m; ++i)
ans=ans*Inv(i,p)%p*(n-i+1)%p;return ans%p;}

const int manx=3e5+5;

ll n,k=1;
string s="          ";
void dfs(ll x){
    if(x==n+1){
        for(int i=1;i<=n;i++) cout<<s[i];
        cout<<endl;
        return;
    }
    for(int j=0;j<=k;++j) {
        s[x]='a'+j;
        ll tmp=k;
        if(j==k)k++;
        dfs(x+1);
        k=tmp;
    }
}
int main(){
    n=read();
    s[1]='a';
    dfs(2);
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main(void) {
    int antena[5] = {0};
    int k = 0;

    cin >> antena[0];
    cin >> antena[1];
    cin >> antena[2];
    cin >> antena[3];
    cin >> antena[4];
    cin >> k;

    for (int i=0; i<5; i++) {
        for (int j=i+1; j<5; j++) {
            if (k < abs(antena[i] - antena[j])) {
                cout << ":(";
                return 0;
            }
        }
    }
    cout << "Yay!";
    return 0;
}

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

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

const int N = 3e3+10 , mod = 1e9+7;

ll dp[N][N][4];
int v[N][N];

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int r , c , k;
   cin >> r >> c >> k;
   for(int i = 0 ; i < k ; i++){
      int r , c , val;
      cin >> r >> c >> val;
      r--; c--;
      v[r][c] = val;
   }
   for(int i = 0 ; i < r ; i++){
      for(int j = 0 ; j < c ; j++){
         if(i == 0 && j == 0){
            dp[i][j][1] = v[0][0];
            continue;
         }
         for(int k = 0 ; k <= 3 ; k++){
            if(i > 0){
               dp[i][j][1] = max(dp[i][j][1] , dp[i - 1][j][k] + v[i][j]);
               dp[i][j][0] = max(dp[i][j][0] , dp[i - 1][j][k]);
            }
            if(j > 0){
               if(k != 3)
                  dp[i][j][k + 1] = max(dp[i][j][k + 1] , dp[i][j - 1][k] + v[i][j]);
               dp[i][j][k] = max(dp[i][j][k] , dp[i][j - 1][k]);
            }
         }
      }
   }
   ll ans = 0;
   for(int i = 0 ; i < 4 ; i++)
      ans = max(ans , dp[r - 1][c - 1][i]);
   cout << ans;
   return 0;
}


Measured memory_bytes: 321008
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int x = scanner.nextInt();
        int count = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    if (i * 500 + j * 100 + k * 50 == x) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}

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

int comp(const void *a, const void *b){return *(int*)b-*(int*)a;}

int main(void){
	int n, m, i;
	scanf("%d%d", &n, &m);
	int l=0, r=n;
	for(i=0; i<m; i++){
		int L, R;
		scanf("%d%d", &L, &R);
		if(L>l) l=L;
		if(R<r) r=R;
	}
	printf("%d\n", l<=r?r-l+1:0);
}


Measured memory_bytes: 128
from collections import Counter

n = int(input().strip())

cnt = Counter()
result = 0
for i in range(1, n + 1):
    s = str(i)
    result += cnt[s[-1], s[0]] * 2
    if s[0] == s[-1]:
        result += 1
    cnt[s[0], s[-1]] += 1
print(result)

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, k);
    string st;
    cin >> st;
    
    int ans = 0;
    Rep(i, st.size()) {
        if (st[i-1] == st[i]) ans++;
    }

    cout << min(n-1, ans + k * 2) << endl;

    return 0;
}


Measured memory_bytes: 512
import math
import fractions
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
from_left = [0 for i in range(N)]
from_right = [0 for i in range(N)]
from_left[0] = A[0]
from_right[-1] = A[-1]
for i in range(1, N):
    from_left[i] = fractions.gcd(A[i], from_left[i-1])
for i in range(N-2, -1, -1):
    from_right[i] = fractions.gcd(A[i], from_right[i+1])
# print(from_left)
# print(from_right)
ans = max(from_left[-2], from_right[1])
for i in range(1, N-1):
    ans = max(ans, fractions.gcd(from_left[i-1], from_right[i+1]))
print(ans)


Measured memory_bytes: 16120
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x = int(readline())
    s = input()

    if x >= 3200:
        print(s)
    else:
        print("red")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61784
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		if(a==b && b==c) {
			System.out.println(1);
		}else if(a!=b && b!=c && a!=c) {
			System.out.println(3);
		}else {
			System.out.println(2);
		}
	}

}


Measured memory_bytes: 21332
n = STDIN.gets.to_i
s = STDIN.gets.chomp.split("");
x = 0;
sums = [0];

for i in 0..(n-1) do
  if s[i] == "I"
    x += 1
  elsif s[i] == "D"
    x -= 1
  end
  sums.push(x)
end
puts sums.max

Measured memory_bytes: 1788
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
 string s;
  cin>>s;
  sort(s.begin(),s.end());
  if(s[1]==s[0]&& s[2]==s[3]&&s[1]!=s[2])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    long n = scan.nextLong();

    long start = (long) Math.sqrt(n);
    
    for (long i = start; i >= 1; i--) {
      if (n % i == 0) {
        String str = Long.toString(Math.max(i, n / i));
        System.out.println(str.length());
        return;
      }
    }

  }

}

Measured memory_bytes: 23380
#include <iostream>
#include <cstring>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int dp[maxn];
int h[maxn];
int path[maxn];
int main()
{
   int n,k;
   cin>>n>>k;
   memset(dp,0x3f,sizeof(dp));
   for(int i=1;i<=n;++i){
       cin>>h[i];
   }
   dp[1]=0;
   dp[2]=abs(h[1]-h[2]);
   for(int i=3;i<=k;++i){
       for(int j=i-1;j>=1;--j){
           if(dp[i-j]+abs(h[i]-h[i-j])<dp[i]){
               dp[i]=dp[i-j]+abs(h[i]-h[i-j]);
           }
       }
   }
   for(int i=k+1;i<=n;++i){
       for(int j=k;j>=1;--j){
           if(dp[i-j]+abs(h[i]-h[i-j])<dp[i]){
               dp[i]=dp[i-j]+abs(h[i]-h[i-j]);
           }
       }
   }
   cout<<dp[n]<<endl;
   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using  namespace std;
int main(){
    long long n, a, check, ans = 0;
    cin >> n;
    map<long long, long long> A;
    for(int i=0;i<n;i++){
        cin >> a;
        A[a]++;
    }
    for(auto itr = A.begin(); itr != A.end(); itr++){
        check = itr->second - itr->first;
        if(check<0){
            ans += itr->second;
        }else{
            ans += check;
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

int main()
{
    string s;
    cin >> s;

    for (int bit = 0; bit < 8;  bit++) {
        int result = s[0] - '0';
        for (int i = 0; i < 3; i++) {
            if (bit & (1 << i)) result += s[i+1] - '0';
            else result -= s[i+1] - '0';
        }
        if (result == 7) {
            printf("%d", s[0]-'0');
            for (int i = 0; i < 3; i++) {
                if (bit & (1 << i)) printf("+");
                else printf("-");
                printf("%d", s[i+1]-'0');
            }
            printf("=7\n");
            break;
        }
    }
    return 0;
}

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

#define N 246913

int main(){
    vector<bool> prim(N,true);
    
    for(int i=2; i<sqrt(N); i++){
        if(prim[i]){
            for(int j=2; j*i<N; j++){
                prim[i*j]=false;
            }
        }
    }
    
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        int count=0;
        for(int i=n+1; i<=2*n; i++){
            if(prim[i]){
                count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a,a+N);
  if (a[N-1] - a[0] >= 2) {
    cout << "No" << endl;
  } else if (a[N-1] - a[0] == 1) {
    int cnt = 0;
    int num = a[N-1];
    for (int i = 0; i < N; i++) {
      if (a[i] == a[0]) {
        cnt++;
      }
    }
    int c = num - 1;
    if (N == num) {
      c = num;
    }
    if (max(num*2 - N,0) <= cnt && cnt <= c) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    if (2 * a[0] <= N || a[0] == N - 1) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
    #include<algorithm>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<climits>
    using namespace std;
    void File(){
        freopen("ARC97E.in","r",stdin);
        freopen("ARC97E.out","w",stdout);
    }
    #define REP(i,a,b) for(register int i = a;i <= b;++i)
    #define DREP(i,a,b) for(register int i = a;i >= b;--i)
    #define MREP(i,x) for(register int i = beg[x];i;i = E[i].last)
    #define mem(a) memset(a,0,sizeof(a))
    #define ll long long
    #define inf INT_MAX
    const int maxn = 2000 + 10;
    int n,c[maxn << 1],a[maxn << 1],pos0[maxn],pos1[maxn];
    int dp[maxn][maxn],cost0[maxn << 1][maxn],cost1[maxn << 1][maxn];
    int main(){
        //File();
        scanf("%d",&n);
        REP(i,1,n * 2){
            char s[5];
            scanf("%s%d",s,&a[i]);
            c[i]= s[0] == 'W' ? 0 : 1;
            if(c[i] == 0)pos0[a[i]] = i;
            else pos1[a[i]] = i;
        }
        REP(i,1,n * 2)
            REP(j,0,n){
                cost0[i][j] = cost0[i - 1][j] + (a[i - 1] > j && c[i - 1] == 0);
                cost1[i][j] = cost1[i - 1][j] + (a[i - 1] > j && c[i - 1] == 1);
            }
        REP(i,0,n)
            REP(j,0,n){
                if(i == 0 && j == 0)continue;
                int p0 = pos0[i],p1 = pos1[j];
                dp[i][j] = inf;
                if(i)dp[i][j] = min(dp[i][j],dp[i - 1][j] + cost0[p0][i - 1] + cost1[p0][j]);
                if(j)dp[i][j] = min(dp[i][j],dp[i][j - 1] + cost1[p1][j - 1] + cost0[p1][i]);
            }
        printf("%d\n",dp[n][n]);
        return 0;
    }

Measured memory_bytes: 79104
#include<iostream>
#include<cmath>
#define INF 1000000000

using namespace std;

int main(void){

  int n;
  double i,h,w,ans,bmi;

  while(cin >> n,n){
    ans=INF,bmi=INF;

    for(int j=0;j<n;j++){
      cin >> i >> h >> w;
      if(abs(22-bmi)>abs(22-w/(h*h/10000))||
	 (abs(22-bmi)==abs(22-w/(h*h)/10000) && i<ans)){
	ans=i,bmi=w/(h*h/10000);
      }
    }
    cout << ans << endl;
  }

  return 0;
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

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

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
int main(){
	set<int> data;
	int n;
	for(int i=0;i<28;i++){
		cin>>n;
		data.insert(n);
	}
	for(int i=1;i<=30;i++){
		if(!data.count(i))cout<<i<<endl;
	}
}

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

int main()
{
  long h,n,a,sum=0;
  cin >> h >> n;
  for(int i=0; i<n; i++)
  {
    cin >> a;
    sum += a;
  }
  if(sum >= h)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 700;
    rep(i, 0, 3) if(s[i] == 'o') ans += 100;
    cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  long long int a[n],b[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  long long int c[n];
  for(int i=0;i<n;i++){
    if(a[i]>b[i]){
      c[i]=0;
    }
    else{
      c[i]=(b[i]-a[i]+1)/2;
    }
  }
  long long int suma=0;
  long long int sumb=0;
  long long int sumc=0;
  for(int i=0;i<n;i++){
    suma+=a[i];
  }
  for(int i=0;i<n;i++){
    sumb+=b[i];
  }
  for(int i=0;i<n;i++){
    sumc+=c[i];
  }
  if(sumb-suma>=sumc){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << a << endl

ll mod=998244353;

ll com(ll N, ll K, ll L) {
  ll d=1,e=(L*K)%mod,m_=mod-2;
  while(m_!=0) {
    if(m_&1) d=(d*e)%mod;
    e=e*e%mod;
    m_=m_>>1;
  }
  return (N*d)%mod;
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,k,ans=0;cin>>n>>m>>k;
  if(m==1) {
    if(k==n-1) print(1);
    else print(0);
    return 0;
  }
  lvector fact(n+10,1);rep(i,n+5) fact[i+1]=(fact[i]*(i+1))%mod;
  lvector m_m1(n+10,m);rep(i,n+5) m_m1[i+1]=(m_m1[i]*(m-1))%mod;
  ans+=m_m1[n-1]%mod;
  for(ll v=1;v<=k;++v) {
    ans+=(com(fact[n-1],fact[v],fact[n-1-v])*m_m1[n-1-v])%mod;
    ans%=mod;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 6280
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int count=0;
  int ans=0;
  for(int i=1;i<=N;i+=2)
  {
    count=0;
    for(int j=1;j<=i;j++)
    {
     if(i%j==0) count++;
    }
    if(count==8) ans++;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
  let n: usize = read();
  let s: Vec<char> = read::<String>().chars().collect();

  let counts = split_same_element(&s);

  println!("{}", counts.len());
}



fn split_same_element<T: Eq + Copy>(v: &Vec<T>) -> Vec<(T, usize)> {
  let mut res: Vec<(T, usize)> = Vec::new();
  if v.len() == 0 {
    return res;
  }

  let mut now: T = v[0];
  let mut count: usize = 0;
  for &e in v {
    if e == now {
      count += 1;
    }
    else {
      res.push((now, count));
      count = 1;
      now = e;
    }
  }
  res.push((now, count));

  res
}

Measured memory_bytes: 6396
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

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

    int N = scanner.nextInt();

    int[][] red = new int[N][2];
    int[][] blue = new int[N][2];

    for (int i = 0; i < N; i++) for (int j = 0; j < 2; j++) red[i][j] = scanner.nextInt();
    for (int i = 0; i < N; i++) for (int j = 0; j < 2; j++) blue[i][j] = scanner.nextInt();

    boolean[][] connectivity = new boolean[N][N];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (red[i][0] < blue[j][0] && red[i][1] < blue[j][1]) connectivity[i][j] = true;
      }
    }

    System.out.println(solveFF(N, N, connectivity).length);
  }

  public static int[][] solveFF(int N, int M, boolean[][] connectivity) {
    int NN = N + M + 2;
    int[][] graph = new int[NN][NN];
    for (int i = 0; i < N; i++) graph[0][i + 1] = 1;
    for (int i = 0; i < N; i++)
      for (int j = 0; j < M; j++)
        if (connectivity[i][j]) graph[i + 1][j + N + 1] = 1;
    for (int j = 0; j < M; j++) graph[j + N + 1][NN - 1] = 1;

    int[][] flow = new FordFulkerson().solve(NN, graph, 0, NN - 1);
    List<int[]> pairs = new ArrayList<>();
    for (int i = 0; i < N; i++)
      for (int j = 0; j < M; j++)
        if (flow[i + 1][j + N + 1] > 0) pairs.add(new int[] {i, j});
    return pairs.toArray(new int[pairs.size()][2]);
  }

  private static class FordFulkerson {
    public int[][] solve(int N, int[][] graph, int src, int dst) {
      int[][] flow = new int[N][N];

      int[] path = findPath(N, graph, flow, src, dst);
      while (path != null) {
        int inc = Integer.MAX_VALUE;
        int v = dst;
        while (v != src) {
          int u = path[v];
          int cf = graph[u][v] - flow[u][v];
          if (cf < inc) inc = cf;
          v = u;
        }

        v = dst;
        while (v != src) {
          int u = path[v];
          flow[u][v] += inc;
          flow[v][u] -= inc;
          v = u;
        }

        path = findPath(N, graph, flow, src, dst);
      }

      for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) if (flow[i][j] < 0) flow[i][j] = 0;
      return flow;
    }

    private int[] findPath(int N, int[][] graph, int[][] flow, int src, int dst) {
      Queue<Integer> queue = new LinkedList<>();
      int[] path = new int[N];
      for (int i = 0; i < N; i++) path[i] = -1;
      path[src] = src;
      queue.add(src);
      while (!queue.isEmpty()) {
        int from = queue.poll();
        if (from == dst) {
          return path;
        }
        for (int to = 0; to < N; to++) {
          if (path[to] >= 0) continue;
          if (graph[from][to] - flow[from][to] > 0
              || flow[to][from] > 0) {
            path[to] = from;
            queue.add(to);
          }
        }
      }
      return null;
    }
  }
}


Measured memory_bytes: 25344
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <string>
#include <cmath>
#include <vector>
#include <list>

#include <random>
using namespace std;

vector<vector<long long>> dist;
vector<vector<long long>> road;

long long validate(int from, int to, int n, long long min) {
	bool flg = false;
	for (int i = 0; i < n; i++) {
		if (i == from || i == to) {
			continue;
		}
		if (dist[from][i] + dist[i][to] < min) {
			return -1;
		}
		else if(dist[from][i] + dist[i][to] == min){
			flg = true;
		}
	}
	return flg ? min : 0;
}

int main(void) {
	int N, buf;
	scanf("%d", &N);

	dist = vector<vector<long long>>(N, vector<long long>(N, 0));

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			scanf("%d", &buf);
			dist[i][j] = buf;
		}
	}
	long long sum = 0;
	for (int from = 0; from < N; from++) {
		for (int to = from + 1; to < N; to++) {
			int res = validate(from, to, N, dist[from][to]);
			if (res < 0) {
				printf("-1\n");
				return 0;
			}
			else {
				sum += dist[from][to] - res;
			}
		}
	}

	printf("%lld\n", sum);

	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const LL MOD = 1000000007;

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

    if(W == 1) {
        cout << 1 << endl;
        return 0;
    }

    LL dp[2][W];
    REP(i, 2) REP(j, W) dp[i][j] = 0;
    dp[0][0] = 1LL;

    REP(lp, H){
        REP(i, (1<<(W-1))){
            bool skip = false;
            REP(j, W-1){
                if((i & (1<<j)) != 0 && (i & (1<<(j+1))) != 0) skip = true;
            }
            if(skip) continue;

            REP(j, W){
                if(j != 0 && (i & (1<<(j-1))) != 0) dp[1][j-1] = (dp[0][j] + dp[1][j-1]) % MOD;
                else if(j+1 != W && (i & (1<<j)) != 0) dp[1][j+1] = (dp[0][j] + dp[1][j+1]) % MOD;
                else dp[1][j] = (dp[0][j] + dp[1][j]) % MOD;
            }
        }


        REP(i, W){
            dp[0][i] = dp[1][i];
            dp[1][i] = 0;
        }
    }

    cout << dp[0][K-1] << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int N;
    cin >> N;
    map<int, int> memo;
    REP(i,N){
        int d;
        cin >> d;
        if(memo.count(d)==0)memo[d] = 0;
        memo[d]++;
    }
    int M;
    cin >> M;
    bool ok = true;
    REP(i,M){
        int t;
        cin >> t;
        if(memo.count(t)==0 || memo[t]==0){
            ok = false;
        }else{
            memo[t]--;
        }
    }
    cout << (ok ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 9600
N,X = map(int,input().split())
A = list(map(int,input().split()))

INF = float('inf')
dp = [[INF]*N for i in range(N+1)]
dp[0] = A[:]

ans = sum(A)
for k in range(N):
    cost = k*X
    if cost > ans: break
    for i in range(N):
        dp[k+1][i] = min(dp[k][i], A[i-k])
    cost += sum(dp[k+1])
    ans = min(ans, cost)

print(ans)

Measured memory_bytes: 137948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 205, P = 1e9 + 7;
struct edge {
	int nxt, to, f;
} e[maxn * 2];
int n, m, k, top, cnt = 1, dfs_clock;
ll ans = 1;
int h[maxn], low[maxn], dfn[maxn], vis[maxn], st[maxn];
ll c[maxn][maxn];
void link(int u, int v) {
	e[++cnt].nxt = h[u];
	h[u] = cnt;
	e[cnt].to = v;
}
int gcd(int a, int b) {
	return !b ? a : gcd(b, a % b);
}
ll power(ll x, ll t) {
	ll ret = 1;
	for(; t; t >>= 1, x = x * x % P) if(t & 1) ret = ret * x % P;
	return ret;
}
void tarjan(int u, int f) {
	dfn[u] = low[u] = ++dfs_clock;
	for(int i = h[u]; i; i = e[i].nxt) if(!e[i].f && !e[i ^ 1].f) {
		int v = e[i].to;
		e[i].f = e[i ^ 1].f = 1;
		st[++top] = i;
		if(!dfn[v]) {		
			tarjan(v, u);
			low[u] = min(low[u], low[v]);
			if(low[v] >= dfn[u]) {
				int cnt = 0, f = 0;
				for(int j = top; st[j + 1] != i; --j, ++cnt) if(vis[e[st[j]].to]) f = 1; else vis[e[st[j]].to] = 1;
				if(f) ans = ans * c[cnt + k - 1][k - 1] % P;	
				else {
					ll t = 0;
					for(int i = 0; i < cnt; ++i) t = (t + power(k, gcd(i, cnt))) % P;
					ans = ans * t % P * power(cnt, P - 2) % P;
				}
				while(st[top + 1] != i) vis[e[st[top--]].to] = 0;
			}
		} else low[u] = min(low[u], dfn[v]);
	}
}
int main() {
	scanf("%d%d%d", &n, &m, &k);
	c[0][0] = 1;
	for(int i = 1; i <= 200; ++i) {
		c[i][0] = 1;
		for(int j = 1; j <= i; ++j) c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % P; 
	}
	for(int i = 1; i <= m; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		link(u, v);
		link(v, u);
	}
	for(int i = 1; i <= n; ++i) if(!dfn[i]) tarjan(i, 0);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 512
import sys

N, X = [int(item) for item in input().split()]
x = sorted([int(item) for item in input().split()])

def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)

        return divisor_list
      
distance = [0] * N
diffs = [0] * (N-1)
for i in range(len(x)):
  distance[i] = abs(x[i] - X)
  if i > 0:
    diffs[i-1] = x[i] - x[i-1]

if N == 1:
  print(distance[0])
  sys.exit()
else:
  nearest = min(min(distance), min(diffs))

divisor = make_divisor_list(nearest)

for item in divisor[::-1]:
  for d in distance:
    if d%item != 0:
      break
    print(item)
    sys.exit()

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

using namespace std;

int n;
double a[1005], s = 0;

int main(void) {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lf", &a[i]);
    s += 1 / a[i];
  }
  printf("%.10lf\n", 1 / s);
  return 0;
}


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

int main(int argc, char* argv[]) {
	int input;
	int count = 1;
	
	while(1){
		cin >> input;
		if(input == 0) break;
		cout << "Case " << count << ": " << input << endl;
		count += 1;
	}
	
	return 0;
}

Measured memory_bytes: 1160
import java.io.IOException;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int w = scanner.nextInt();
			int h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			PriorityQueue<Player> pq = new PriorityQueue<Player>();
			char[][] map = new char[h][w];
			for (int i = 0; i < h; i++) {
				map[i] = scanner.next().toCharArray();
				for (int j = 0; j < w; j++) {
					if (map[i][j] != '#' && map[i][j] != '.'
							&& map[i][j] != 'X') {
						char c = map[i][j];
						int dir = c == 'W' ? 0 : c == 'S' ? 1 : c == 'E' ? 2
								: 3;
						map[i][j] = 'P';
						pq.add(new Player(i, j, dir));
					}
				}
			}
			String ans = "NA";
			int step = 1;
			while (step <= 180) {
				PriorityQueue<Player> next = new PriorityQueue<Player>();
				pl: while (!pq.isEmpty()) {
					Player player = pq.poll();
					for (int k = 3; k < 7; k++) {
						int y = player.y;
						int x = player.x;
						int dir = player.dir;
						int ny = y + move[(k + dir) % 4][0];
						int nx = x + move[(k + dir) % 4][1];
						if (map[ny][nx] == '.' || map[ny][nx] == 'X') {
							player.dir = (k + dir) % 4;
							player.ny = ny;
							player.nx = nx;
							next.add(player);
							continue pl;
						}
					}
					player.b = false;
					next.add(player);
				}
				pq = next;
				next = new PriorityQueue<Player>();
				while (!pq.isEmpty()) {
					Player player = pq.poll();
					if (!player.b) {
						player.b = true;
						next.add(player);
					} else {
						int y = player.y;
						int x = player.x;
						int ny = player.ny;
						int nx = player.nx;
						map[y][x] = '.';
						if (map[ny][nx] == 'X') {
							map[ny][nx] = 'x';
							continue;
						}
						if (map[ny][nx] == '.') {
							map[ny][nx] = 'P';
							player.y = ny;
							player.x = nx;
							next.add(player);
						} else {
							map[y][x] = 'P';
							next.add(player);
						}

					}

				}
				if (next.isEmpty()) {
					ans = String.valueOf(step);
					break;
				}
				pq.addAll(next);
				for (int i = 0; i < h; i++)
					for (int j = 0; j < w; j++)
						if (map[i][j] == 'x')
							map[i][j] = 'X';
				step++;
			}
			System.out.println(ans);

		}
	}

	int[][] move = { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 } };

	class Player implements Comparable<Player> {
		int y;
		int x;
		int dir;
		int ny;
		int nx;
		boolean b = true;

		public Player(int y, int x, int dir) {
			super();
			this.y = y;
			this.x = x;
			this.dir = dir;
		}

		@Override
		public int compareTo(Player o) {
			return this.dir - o.dir;
		}

	}
}

Measured memory_bytes: 27716
H, W = map(int, input().split())
S = []
for _ in range(H):
  S.append(input())

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
  
flg = False
for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      flg = False
      for k in range(4):
        if i+dy[k]>=0 and i+dy[k]<H and j+dx[k]>=0 and j+dx[k]<W:
          if S[i+dy[k]][j+dx[k]]=='#':
            flg = True
      if flg == False:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3064
import math
a,b,h,m=map(int,input().split())
hm=h*5
totaldegree=0
if(hm>=m):
 
  mdegree=min((hm-m),3600-hm-m)*6
  hdegree=m/2
  totaldegree=mdegree+hdegree
else:
  mdegree=(m-hm)*6
  hdegree=m/2
  totaldegree=mdegree-hdegree
#print(totaldegree)
rad=math.radians(totaldegree)
#print(rad)
#print(math.cos(rad))
c=math.sqrt(a*a+b*b-(2*a*b*math.cos(rad)))
print('{0:.9f}'.format(c))

Measured memory_bytes: 9516
info=list(map(int,input().split()))
p_name=[]
p_time=[]
time=0
for i in range(info[0]):
	input_pro=input().split()
	p_name.append(input_pro[0])
	p_time.append(int(input_pro[1]))

while len(p_time)!=0:
	nt=p_time.pop(0)
	nn=p_name.pop(0)
	if nt<=info[1]:
		time+=nt
		print(nn+' '+str(time))

	else:
		p_name.append(nn)
		p_time.append(nt-info[1])
		time+=info[1]



Measured memory_bytes: 9308
import sys
input = sys.stdin.readline
S = input()[: -1]
N = len(S)

def SuffixArray(n, s):
  order = [n - 1 - i for i in range(n)]
  order.sort(key = lambda x: s[x])
  sa = [0] * n
  classes = [0] * n
  for i in range(n):
    sa[i] = order[i]
    classes[i] = S[i]
  k = 1
  while k < n:
    c = classes[: ]
    for i in range(n): 
      if i > 0 and (c[sa[i - 1]] == c[sa[i]]) and ((sa[i - 1] + k) < n) and ((c[sa[i - 1] + k // 2]) == c[sa[i] + k // 2]):
        classes[sa[i]] = classes[sa[i - 1]]
      else: classes[sa[i]] = i
    cc = [i for i in range(n)]
    ss = sa[: ]
    for i in range(n):
      if ss[i] - k >= 0:
        sa[cc[classes[ss[i] - k]]] = ss[i] - k
        cc[classes[ss[i] - k]] += 1
    k <<= 1
  return sa

def LCPArray(n, s, sa):
  r = [0] * n
  for i in range(n): r[sa[i]] = i
  lcp = [0] * (n - 1)
  x = 0
  for i in range(n):
    if x > 0: x -= 1
    if r[i] == 0: continue
    j = sa[r[i] - 1]
    while max(i, j) + x < n:
      if s[i + x] != s[j + x]: break
      x += 1
    lcp[r[i] - 1] = x
  return lcp 
sa = SuffixArray(N, S)
lcp = LCPArray(N, S, sa)
print(N * (N + 1) // 2 - sum(lcp))

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

int main() {
  string S;
  cin >> S;
  sort(S.begin(), S.end());
  bool b = true;
  for(int i = 0; i < S.size()-1; i++) {
    if(S.at(i) == S.at(i+1)) {
      b = false;
      break;
    }
  }
  if(b) {
    cout << "yes";
  }
  else {
    cout << "no";
  }
}



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

typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

int P[N],A[N],n,i,ans,p;

signed main(){
    cin >> n;
    for(i=1;i<=n;i++) { cin >> P[i]; P[i] += P[i-1]; }
    for(i=1;i<=n;i++) { cin >> A[i]; }
    for(i=n; i ;i--){
        p += A[i];
        ans = max(ans , p + P[i]);
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n,i;
	double x1,x2,x3,y1,y2,y3,A1,A2,B1,B2,C1,C2,Px,Py,r;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
		A1=2.0*(x2-x1);
		B1=2.0*(y2-y1);
		C1=pow(x1,2.0)-pow(x2,2.0)+pow(y1,2.0)-pow(y2,2.0);
		A2=2.0*(x3-x1);
		B2=2.0*(y3-y1);
		C2=pow(x1,2.0)-pow(x3,2.0)+pow(y1,2.0)-pow(y3,2.0);
		Px=(B1*C2-B2*C1)/(A1*B2-A2*B1);
		Py=(C1*A2-C2*A1)/(A1*B2-A2*B1);
		r=sqrt(pow((Px-x1),2.0)+pow((Py-y1),2.0));
		printf("%.3f %.3f %.3f\n",Px,Py,r);
	}
	return 0;
}

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

#define long long long

template<class T> inline void MIN(T &a, T b) { if (a > b) a = b; }
template<class T> inline void MAX(T &a, T b) { if (a < b) a = b; }

const int N = (int)1e5 + 5;
const long THR = (long)1e5 + 5;
const long MXF = 2160;
const long MX = (long)1e10;

int n;
long a[N];
map<long, pair<int, int>> mp;

int main() {

	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
	}

	for (int i = 0; i < n; i++) {
		long cur = 1, op = 1;
		for (long j = 2; j * j <= a[i] and j < MXF; j++) {
			int cnt = 0;
			while (a[i] % j == 0) {
				cnt++; a[i] /= j;
			}
			cnt %= 3;
			if (cnt == 1) cur *= j, op *= j * j;
			else if (cnt == 2) cur *= j * j, op *= j;
			if (op > MX) op = 0;
		}
		long sq = (long)sqrt(a[i]);
		if (sq * sq == a[i]) cur *= a[i], op *= sq;
		else if ((sq + 1) * (sq + 1) == a[i]) cur *= a[i], op *= sq + 1;
		else cur *= a[i], op *= (a[i] < THR ? a[i] * a[i] : 0);
		if (cur < op or op == 0) mp[cur].first++;
		else if (cur > op) mp[op].second++;
		else mp[cur] = make_pair(1, 0);
		// printf("%lld %lld\n", cur, op);
	}

	int ans = 0;
	for (auto p : mp) {
		// printf("we got %lld got %d %d\n", p.first, p.second.first, p.second.second);
		ans += max(p.second.first, p.second.second);
	}

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

}

Measured memory_bytes: 7552
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    vector<int> d;

    cin >> n;

    d.resize(n);

    for(int i = 0; i < n; ++i)
    {
        cin >> d[i];
    }

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

    cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>

using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;
ll pre[N];
int main()
{

	ll n;
	cin>>n;
	map<string,ll> x;
	vll v;
	for(int i =1;i<=n;i++){
		string s;
		cin>>s;
		ll a;
		cin>>a;
		x[s]=i;
		v.pb(a);
	}
	for(int i =n-1;i>=0;i--) pre[i+1]=pre[i+2]+v[i];
	string s;
	cin>>s;
	ll idx = x[s];
	if(idx == n) cout<<0<<endl;
	else cout<<pre[idx+1]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    using ll = long long;
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> a(n+1);
    for(int i = 0; i < m; i++)
    {
        ll x, y;
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    ll s = n+1;
    for(int i = 1; i <= n; i++)
    {
        ll tmp = a[i].size();
        s = min(s, tmp);
    }

    vector<ll> ans_l;
    vector<ll> ans_r;
    vector<bool> used(n+1);
    used[s] = true;
    ll cand = s;
    while(true)
    {
        bool upd = false;
        for(int i = 0; i < a[cand].size(); i++)
        {
            if(!used[a[cand][i]])
            {
                cand = a[cand][i];
                ans_l.push_back(cand);
                used[cand] = true;
                upd = true;
                break;
            }
        }
        if(upd) continue;
        break;
    }
    cand = s;
    if(a[s].size() >= 2)
    {
        while(true)
        {
            bool upd = false;
            for(int i = 0; i < a[cand].size(); i++)
            {
                if(!used[a[cand][i]])
                {
                    cand = a[cand][i];
                    ans_r.push_back(cand);
                    used[cand] = true;
                    upd = true;
                    break;
                }
            }
            if(upd) continue;
            break;
        }
    }
    cout << ans_l.size() + 1 + ans_r.size() << endl;
    for(int i = 0; i < ans_l.size(); i++)
    {
        cout << ans_l[ans_l.size()-1-i] << " ";
    }
    cout << s;
    for(int i = 0; i < ans_r.size(); i++)
    {
        cout << " " << ans_r[i];
    }
    cout << endl;
}


Measured memory_bytes: 7156
#include<bits/stdc++.h>
#define ll long long 
#define P pair<ll ,ll>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a%3==0){
        cout<< "Possible"<<endl;
    }else if(b%3==0){
        cout<< "Possible"<<endl;
    }else if((a+b)%3==0){
        cout<< "Possible"<<endl;
    }else{
        cout << "Impossible"<<endl;
    }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)

	for i := 0; i < len(s); i++ {
		r := s[i:] + s[:i]
		if r == t {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


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

int main(){
    int A, B;
    cin >> A >> B;
    int n[5];
    int counter=0;
    for(int i=A; i<=B; i++){
        int I = i;
        n[0] = I % 10;
        I /= 10;
        n[1] = I % 10;
        I /= 10;
        n[2] = I % 10;
        I /= 10;
        n[3] = I % 10;
        I /= 10;
        n[4] = I % 10;
        if(n[0] == n[4] && n[1] == n[3]){
            ++counter;
        }
    }
    
    cout << counter << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	ans := 0
	for i := 1; i < n; i++ {
		mp := map[byte]bool{}
		for j := 0; j < i; j++ {
			mp[s[j]] = true
		}
		sum := 0
		for j := i; j < n; j++ {
			if mp[s[j]] {
				sum++
				mp[s[j]] = false
			}
		}
		if ans < sum {
			ans = sum
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
package main

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

func main() {
	In := readLineInt()
	if In[0]%3 == 0 || In[1]%3 == 0 || (In[0]+In[1])%3 == 0 {
		fmt.Println("Possible")
	} else {
		fmt.Println("Impossible")
	}
}

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

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;
constexpr double EPS = 1e-10;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b; cin >> a>>b;
    int ans = 0, cnt = 0;
    int c = b*2 + 1;
    ans = a / c;
    if(a%c) ++ans;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
module ABC119

	! <module>s to import
	use, intrinsic :: iso_fortran_env


	! require all variables to be explicitly declared
	implicit none


	! accessibility of <subroutine>s and <function>s in this <module>
	public :: ABC119_A


	! constants for this <module>
	character(len=6, kind=1), parameter, private :: word_before = 'Heisei'
	character(len=3, kind=1), parameter, private :: word_after  = 'TBD'

	integer( kind=INT8 ), parameter, private :: day_border   = 30
	integer( kind=INT8 ), parameter, private :: month_border =  4


	! contained <subroutine>s and <function>s are below
	contains


	subroutine ABC119_A

		! variables for this <subroutine>
		character(len=10, kind=1) :: buffer
		integer( kind=INT8 )      :: month

		! STEP.01
		! read out the the date
		read( unit=INPUT_UNIT, fmt='(A)' ) buffer

		! STEP.02
		! convert the day and month to integer
		read( unit=buffer(6:7), fmt=* ) month

		! STEP.02
		! judge the read date
		if( month .le. month_border ) then
			write( unit=OUTPUT_UNIT, fmt='(A)', advance='yes' ) word_before
		else
			write( unit=OUTPUT_UNIT, fmt='(A)', advance='yes' ) word_after
		end if

		! STEP.END
		return

	end subroutine ABC119_A

end module ABC119


program main

	! <module>s to import
	use, non_intrinsic :: ABC119

	! require all variables to be explicitly declared
	implicit none

	call ABC119_A

end program main


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll k;
	cin>>k;
	ll pow=1,now=0;
	rep(i,1e8){
		now+=pow*7;
		now%=k;
		if(now==0){
			cout<<i+1<<endl;
			return 0;
		}
		pow*=10;
		pow%=k;
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int a,b,c,d;
  cin>>a>>b>>c>>d;
long long int max=a*c;
  if(a*d>=max)max=a*d;
  if(b*c>=max)max=b*c;
  if(b*d>=max)max=b*d;
  cout<<max;
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  string s;
  cin >> s;
  map<char, int> cnt;
  for (auto&& u : s) cnt[u]++;
  bool flg = true;
  if (cnt.size() != 2) flg = false;
  for (auto&& u : cnt)
    if (u.second != 2) flg = false;
  cout << (flg ? "Yes" : "No") << endl;
}

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

l = [0] * 9
mn = 0
for i in A:
    t = min(i // 400, 8)
    l[t] += 1
for i in range(8):
    if l[i] != 0:
        mn += 1
if mn == 0:
    mn = 1
    mx = l[8]
else:
    mx = mn + l[8]

print(mn, mx)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,k,l,m,n;
    vector<long long int>v,v1;
    cin>>n;
    v.clear();
    for(i=0;i<n;i++){
        cin>>j;
        v.push_back(j);
    }
    if(n%2==0){
    for(k=n-1;k>=0;k-=2){
            cout<<v[k]<<" ";
        }
    for(l=0;l<n-2;l+=2){cout<<v[l]<<" ";}
        cout<<v[n-2]<<endl;
      }
   else if(n%2==1&&n!=1){
    for(k=n-1;k>=0;k-=2){
            cout<<v[k]<<" ";
        }
    for(l=1;l<n-2;l+=2){cout<<v[l]<<" ";}
        cout<<v[n-2]<<endl;
        }
    else{cout<<v[0]<<endl;}
    
}

Measured memory_bytes: 3824