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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;


int main(void)
{
    IOS
    int n,m; cin >> n >> m;
    vector<set<int>> vs(n+1);
    REP(i,m) {
        int u,v; cin >> u >>v;
        vs[u].emplace(v);
    }
    int s,t; cin >> s >> t;

    int dp[3][100010];
    memset(dp,0,sizeof dp);
    dp[0][s] = 1;

    set<int> next(vs[s]);

    int ans = 1;
    while(true) {
        FOR(i,0,3) {
            set<int> tmp;
            //cerr << next.size() << endl;
            int j = i == 2 ? 0:i+1;
            for(auto x:next) {
                if (dp[j][x]!=1) {
                    dp[j][x] = 1;
                    tmp.insert(ALL(vs[x]));
                }
            }
            next = tmp;
        }
        if (dp[0][t]== 1) break;
        //cerr << next.size()<<endl;
        if (next.size() == 0) {
            ans = -1;
            break;
        }
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13184
N=int(input())
A=list(map(int,input().split()))
b=0
ans=0
m=abs(A[0])
for a in A:
    ans+=abs(a)
    m=min(m,abs(a))
    if a<0:
        b+=1

if b%2==0:
    print(ans)
else:
    print(ans-m*2)


Measured memory_bytes: 14332
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<lint,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
priority_queue<lint> q;
lint a[114514],b[114514],c[114514];
lint to[114514],bo[114514];
vector<pint> v;
int main()
{
	int x,y,z;
	cin>>x>>y>>z;
	rep(i,x+y+z){
		cin>>a[i]>>b[i]>>c[i];
		v.pb(mp(a[i]-b[i],i));
	}
	sort(All(v));
	lint sum=0;
	rep(i,y){
		int id=v[i].se;
		q.push(c[id]-b[id]);
		sum+=b[id];
	}
	REP(i,y,y+z){
		int id=v[i].se;
		to[i]=sum;
		sum+=b[id];
		if(q.top()>c[id]-b[id]){
			sum+=q.top();q.pop();q.push(c[id]-b[id]);
		}
		else sum+=c[id]-b[id];
	}
	to[y+z]=sum;
	
	sum=0;
	while(!q.empty()) q.pop();
	for(int i=x+y+z-1;i>=y+z;i--){
		int id=v[i].se;
		q.push(c[id]-a[id]);
		sum+=a[id];
	}
	bo[y+z]=sum;
	for(int i=y+z-1;i>=y;i--){
		int id=v[i].se;
		sum+=a[id];
		if(q.top()>c[id]-a[id]){
			sum+=q.top();q.pop();q.push(c[id]-a[id]);
		}
		else sum+=c[id]-a[id];
		bo[i]=sum;
	}
	lint out=0;
	REP(i,y,y+z+1){
		out=max(out,to[i]+bo[i]);
	}
	cout<<out<<endl;
}


Measured memory_bytes: 6384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long ans;
int n,c;
int read(){
	int num = 0, flag = 1; char c = getchar();
	for(; c < '0' || c > '9'; c = getchar())
		if(c == '-') flag = 0;
	for(; c >= '0' && c <= '9'; c = getchar())
		num = (num<<3)+(num<<1)+c-48;
	return flag ? num : -num;
}

int main(){
	n = read(); c = read();
	if(c==0){
		printf("%lld",1LL*n*n);
		exit(0);
	}
	for(int i = c+1; i <= n; ++i){
		ans += 1LL*n/i*(i-c);
		ans += max(0,n%i-c+1);
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 256
loop {
	n = gets.to_i
	break if n == 0
	stone = (1..n).map { gets.to_i }
	a = []
	(0..n-1).each{|i|
		if i.even?
			if !a.empty? && a[-1][0] == stone[i]
				a[-1][1] += 1
			else
				a << [stone[i], 1]
			end
		else
			if a[-1][0] == stone[i]
				a[-1][1] += 1
			else
				_, k = a.pop
				if a.empty?
					a << [stone[i], k+1]
				else
					a[-1][1] += k + 1
				end
			end
		end
	}
	p a.map{|c, k| c == 0 ? k : 0}.inject(:+)
}

Measured memory_bytes: 7024
#include<stdio.h>

int n, q, a, b, z;
int X[1000];
int count(int n, int a, int b);
int main(void) {
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d", &X[i]);
        
    }
    scanf("%d", &q);
    while(q--){
        scanf("%d%d%d", &n, &a, &b);
        printf("%d\n", count(n, a, b));
        //if (q != 0)printf("\n");
    }
    return 0;
}

int count(int n, int a, int b){
    //if (a == 0) a = 1;
    z = 0;
    for (int i = n; i < a; i++){
        if (i == a) break;//printf("%d %d \n",i , z);
        if (b == X[i]) z++;
    }
return z;
}


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

int main(){
  int n ,b, f, r, v;
  v = 0;
  int number[4][3][10] = {};
  cin >> n;
  
  for(int i=0;i<n;i++){
    cin >> b >> f >> r >> v;
    number[b -1][f - 1][r - 1] += v;
      }
  for(int i=0;i<4;i++){
    if(i) cout << "####################" << endl;
    for(int  j=0;j<3;j++){
      for(int k=0;k<10;k++){
	cout << " "  << number[i][j][k] ;
      }
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3072
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

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

int main(void) {
    int A, B;
    cin >> A >> B;
    int C = 1, cnt = 0;
    while (C < B) {
        cnt++;
        C += A-1;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <bitset>
#include <random>
#include <stack>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <ctime>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define sc second
#define fs first
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<class T> T sqr(T x) { return x*x; }
ld pi = 3.1415926535897932384626433832795;
ll mod = 1e9 + 7;
const int N = 3e5 + 10;

typedef vector<vector<ll> > mtrx;

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

int n, a[N];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i+1];
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] == i) {
			ans++;
			swap(a[i], a[i + 1]);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
// Created by Sharat Sachin
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(ll i=0;i<(n);++i)
#define repA(i,a,n) for(ll i=a;i<=(n);++i)
#define repD(i,a,n) for(ll i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,l;
    cin>>n>>l;
    vector<string> v(n);
    rep(i,n) cin>>v[i];
    sort(v.begin(), v.end());
    rep(i,n) cout<<v[i];
    
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int x = 0;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if ('I' == S[i]) x += 1;
		else x -= 1;
		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
i = count = 0
a = b = c = ''


line = input()

while line[i] != ' ':
    a = a + line[i]
    i += 1

i += 1
while line[i] != ' ':
    b = b + line[i]
    i += 1

i += 1    
while i < len(line):
    c = c + line[i]
    i += 1
    
a = int(a)
b = int(b)
c = int(c)

while a <= b:
    if c%a == 0:
        count += 1
    a += 1

print(count)

Measured memory_bytes: 7680
#include "bits/stdc++.h"
using namespace std;
 
typedef long long ll;
 
 
int main() {
	int n, m;
	cin >> n >> m;
	int v[m][2];
	for (int i = 0; i < m; ++i) {
		cin >> v[i][0] >> v[i][1];
	}
	int left = v[0][0];
	int right = v[0][1];
//bool d = 1;
	for (int i = 1; i < m; ++i) {
		left = max(left,v[i][0]);
		right = min(right,v[i][1]);
	}
	cout << max(right - left + 1, 0);
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int n;
  string s,t;
  while(cin >> n >> s >> t){
    REP(i,n){
      cout << s[i] << t[i];
    }
    cout << endl;
    
  }

  return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

a = i()
b = i()
h = i()
print((a+b)*h//2)

Measured memory_bytes: 72656
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
long long int a,b,c,d;
int main( )
{
	cin>>a>>b>>c>>d;
	if(a+b>c+d) cout<<"Left"<<endl;
	if(a+b==c+d) cout<<"Balanced"<<endl;
	if(a+b<c+d) cout<<"Right"<<endl;
	cout<<endl; 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long
ll a[600000], vs[600000], dp[4000][4000], fs[500][500];
map<int,int>mp;

int main()
{
    IO;
    ll j=0, n, m, k, m1, m2, a1=0, a2=0, l  = 1, t=3, mn, cnt=0, mx=0, h=0, mod=1e8+7, i; int tc=0;
    //cin>>t;
    //while(t--){
        cin>>m>>n;
        for(i=1; i<=n; i++) {
            cin>>j; a[j]=1;
        }
        for(i=m; i<=101; i++)
        if(a[i]!=1) {
            j=i; break;
        }
        for(i=m; i>=0; i--)
          if(a[i]!=1) {
            l=i; break;
        }
        if(m-l<=j-m) cout<<l<<endl;
        else cout<<j<<endl;
    //}
    return 0;
}



Measured memory_bytes: 3616
#include <stdio.h>

int main(void)
{
	int n, k, i, x, sum;
	char tmp[5];

	scanf("%d%*c", &n);
	scanf("%d%*c", &k);

	i = 0; sum = 0;
	while(1) {
		scanf("%c", &tmp[i]);
		if(tmp[i] == '\n' || tmp[i] == ' ') {
			x = 0;
			if(i == 3) {
				x += (tmp[0]-'0') * 100;
				x += (tmp[1]-'0') * 10;
				x += (tmp[2]-'0');
			}
			else if(i == 2) {
				x += (tmp[0]-'0') * 10;
				x += (tmp[1]-'0');
			}
			else {
				x += (tmp[0]-'0');
			}
			//printf("%d\n", x);

			if(x > (k-x)) sum += (k-x) * 2;
			else sum += x * 2;

			if(tmp[i] == '\n') break;
			i = 0;
			continue;
		}
		i++;
	}

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

	return 0;
}


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

template <typename T>
void print(const T &v);

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> cnt(n, 1);
    vector<bool> ans(n, 0);
    ans[0] = true;
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        --x, --y;
        if (ans[x])
        {
            ans[y] = true;
        }
        --cnt[x];
        ++cnt[y];
        if (cnt[x] == 0)
        {
            ans[x] = false;
        }
    }
    int a = 0;
    for (int i = 0; i < n; i++)
    {
        if (ans[i])
        {
            ++a;
        }
    }
    cout << a << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b;
    cin >>a>>b;
    if(a>b){
        cout<<"a > b"<<endl;
    }else{
        if(a<b){
            cout<<"a < b"<<endl;
        }else{
            cout<<"a == b"<<endl;
        }
    }
}

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

int main(){
  int A,B ,C,K;
  cin >> A>> B >> C >> K;
  int bai = max(A,max(B,C));
  int del = A+B+C-bai;
  for(int i=0;i<K;i++){
    bai *=2;
  }
  cout << del +bai << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define fo(i,s,e) for (int i=(s); i < (e); i++)
#define ALL(obj) (obj).begin(), (obj).end()
/*卍卍卍 #define int long long 卍卍卍*/
signed main () {
  int n;
  cin >> n;
  vector<int> v(n,0);
  rep(i,n){
    cin >> v[i];
  }
  sort(ALL(v));
  cout<< v[n/2]-v[n/2-1] << endl;
}

Measured memory_bytes: 640
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
const int N = 1005;
const int inf = 1e9;
#define singleCase
// #define multipleCase
int h,n,a[N],b[N],dp[N][10005];

int f(int cur , int health) {
   if (health <= 0) return 0;
   if (cur > n) return inf;
   int &sol = dp[cur][health];
   if (sol != -1) return sol;
   return sol = min(f(cur + 1 , health) , f(cur , health - a[cur]) + b[cur]);
}

void work() {
   in(h); in(n);
   for (int i = 1 ; i <= n ; i++) {
      in(a[i]); in(b[i]);
   }
   memset (dp , -1 , sizeof dp);
   printf("%d\n" , f(1 , h));
   return;
}

int main() {
   #ifdef multipleCase
      int nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(int &x) {
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


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

int main(){
    string S;
    cin>>S;
    int result = 700;
    if (S[0] == 'o'){
        result +=100;
    }
    if (S[1] == 'o'){
        result +=100;
    }
    if (S[2] == 'o'){
        result +=100;
    }
    cout << result << endl;

}

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

int ceil(int n) {
    return n + (n % 10 ? (10 - n % 10) : 0);
}

int main() {
    int m = 10;
    int res = 0;
    for(int i=0; i<5; ++i) {
        int A;
        cin >> A;
        res += ceil(A);
        if(A % 10) m = min(m, A % 10);
    }
    if(m < 10) res += m - 10;
    cout << res << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::cmp;

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

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

fn main() {
    let n = read::<usize>();
    let mut a = read_vec::<i32>();
    let mut total = 0;
    a.insert(0,0);
    a.push(0);
    for i in 1..n+2 {
        total += (a[i]-a[i-1]).abs();
    }
    for i in 1..n+1 {
        let x = a[i-1]-a[i];
        let y = a[i+1]-a[i];
        if x * y > 0 {
            println!("{}",total - cmp::min(x.abs(),y.abs()) * 2);
        } else {
            println!("{}",total);
        }
    }
}


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

const int MOD = 1000000007;
const int INF = 1e9;

string s;
int k;

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

  vector<string> subst;

  int n = s.size();
  for(int i = 0; i < n; i++){
    string tmp;
    for(int j = 1; j <= k; j++){
      if(i + j > n) continue;
      tmp = s.substr(i, j);
      // cout << tmp << endl;
      subst.push_back(tmp);
    }
  }
  
  sort(subst.begin(), subst.end());
  subst.erase(unique(subst.begin(), subst.end()), subst.end());

  cout << subst[k-1] << endl;


  return 0;
}

Measured memory_bytes: 4340
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;
string s;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> s;
	int cntR = 0, cntW = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') cntR++;
		else cntW++;
	}
	int ans = cntR;
	int curR = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') curR++;
		int curW = i + 1 - curR;
		int resR = cntR - curR;
		if (curW <= resR) {
			ans = min(ans, resR);
		}
		else {
			ans = min(ans, curW);
		}
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3772
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    N = int(input())
    v = list(map(int, input().split()))

    ans = []

    for x in range(N):
        for y in range(x + 1, N):
            ans.append(v[x] * v[y])

    print(sum(ans))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3828
fun main(args: Array<String>) {
    val (n, x) = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val mList = (0 until n).map { readLine()?.toInt()!! }
    val minM = mList.min() ?: 1
    val total = mList.sum()
    println(n + ((x - total) / minM))
}

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

long long solve(size_t n)
{
    vector<long long> A(n + 1, 0);
    for (size_t i = 1; i <= n; i++)
    {
        cin >> A[i];
    }

    vector<vector<long long>> dp(n + 1, vector<long long>(3, -1e15));
    dp[0][0] = 0;
    for (size_t i = 1; i <= n; i++)
    {
        if (i % 2 == 0)
        {
            {
                // j = 0
                dp[i][0] = max(dp[i][0], dp[i - 1][0]);
            }
            {
                // j = 1
                dp[i][1] = max(dp[i][1], dp[i - 1][1] + A[i]);
                dp[i][2] = max(dp[i][2], dp[i - 1][1]);
            }
            {
                // j = 2
                dp[i][2] = max(dp[i][2], dp[i - 1][2]);
            }
        }
        else
        {
            {
                // j = 0
                dp[i][0] = max(dp[i][0], dp[i - 1][0] + A[i]);
                dp[i][1] = max(dp[i][1], dp[i - 1][0]);
            }
            {
                // j = 1
                dp[i][1] = max(dp[i][1], dp[i - 1][1]);
            }
            {
                // j = 2
                dp[i][2] = max(dp[i][2], dp[i - 1][2] + A[i]);
            }
        }
    }
    if (n % 2 == 0)
    {
        return max(dp[n][0], dp[n][1]);
    }
    else
    {
        return max(dp[n][1], dp[n][2]);
    }
}

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

    cout << solve(N) << endl;
}


Measured memory_bytes: 15656
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <bitset>
#include <cmath>
#include <ctime>
#define ff first
#define ss second
#define i1 fgvhdsjklfgh
#define j1 hvfdjsklfkgh
#define MAXN 100005
#define INF 1000000000000000071LL
#define ll long long
#define int long long

using namespace std;

const int mod = 1000000007;
int n, ans = 1, i, a[MAXN], cnt[MAXN];

main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("terminator.in", "r", stdin);
    //freopen("terminator.out", "w", stdout);

    cin >> n;

    for(i = 0; i < n; i++){
        cin >> a[i];
        
        if(i == 0 && a[i] != 0){
            cout << 0;
            return 0;
        }
        
        cnt[a[i]]++;
    }

    sort(a, a + n);

    if(cnt[0] > 1){
        cout << 0;
        return 0;
    }

    for(i = 1; i < n; i++){
        //cout << a[i] << " " << cnt[a[i] - 1] << endl;

        ans = (ans * cnt[a[i] - 1]) % 998244353;
    }

    cout << ans;

    return 0;
}





Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, X; cin >> N >> X; 
	int S[210] = {}; 
	for(int i = 0; i < N; i++) cin >> S[i]; 
	sort(S, S+N); 
	long long P = 1000000007; 
	long long dp[205][100010] = {}; 
	dp[0][X] = 1; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= X; j++){
			if(dp[i][j] == 0) continue; 
			for(int k = 0; k < N; k++){
				if(j < S[k]){
					dp[i+1][j] += dp[i][j] * (N - k - i); 
					if(dp[i+1][j] >= P) dp[i+1][j] %= P; break; 
				}
				dp[i+1][j % S[k]] += dp[i][j]; 
				if(dp[i+1][j % S[k]] >= P) dp[i+1][j % S[k]] -= P; 
			}
		}
	}
	long long ans = 0; 
	for(int i = 1; i <= X; i++){
		ans += dp[N][i] * i % P; 
		ans %= P; 
	}
	cout << ans << endl; 
}

Measured memory_bytes: 160384
// Problem : G - Longest Path
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_g
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull ;
typedef long double ld;

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 1e6 + 1;
vll v[N];
ll n ,m;
ll dp[N];
bool vis[N];
vll indx;
void dfs(ll node){
	vis[node] = 1;
	for(auto child : v[node]){
		if(!vis[child]) dfs(child);
	}
	indx.pb(node);
}
void solve(){
	cin >> n >>m ;
	rep(i , m){
		ll a , b;
		cin >> a >> b;
		v[a].pb(b);
	}
	for(ll i = 1 ; i <= n ; i++){
		if(!vis[i]) dfs(i);
	}
	reverse(all(indx));
	for(ll i = 0 ; i < n ; i++){
		for(auto child : v[indx[i]]){
			dp[child] = max(dp[child] , dp[indx[i]] + 1);
		}
	}
	ll ans = 0;
	for(ll i = 1 ; i <= n ; i++) ans = max(ans , dp[i]);
	cout << ans << endl;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC=1;
    // cin>>NTC;
    ll PTC=0;
    while(PTC++<NTC){
        // cout<<"Case #"<<PTC<<":"<<' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

    scanf("%d" , &n);

    printf("%d\n" , n / 500 * 1000 + (n%500) / 5 * 5);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a=0,b;
    cin>>n;
    b=n;
    while(b){
        a+=b%10;
        b/=10;
    }
    if(n%a) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    int flag=0;
    rep(i,n){
        if(a.at(i)%2!=0){
            continue;
        }else{
            if(a.at(i)%3!=0&&a.at(i)%5!=0){
                flag++;
            }
        }
    }
    if(flag>0){
        cout << "DENIED";
    }else{
        cout << "APPROVED";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int a,b;
	double f,a1,b1;
	scanf("%d%d",&a,&b);
	a1=a;
	b1=b;
	f=a1/b1;
	printf("%d %d %.5lf\n",a/b,a%b,a1/b1);
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ld> a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    ld up=1000000010;
    ld lb=0;
    while(up-lb>0.1){
        ld med=(up+lb)/2;
        ll num=0;
        for(ll i=0;i<n;i++){
            ld buf=a[i]/med;
            num+=(ll)buf;
            if(num>k){
                lb=med;
                break;
            }
        }
        if(num>k){
            lb=med;
        }else{
            up=med;
        }
        //cout<<"up"<<up<<" lb"<<lb<<endl;
    }
    ll ans=(ll)lb+1;
    cout<<ans<<endl;
}

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

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

    int ans = 0;
    for(int i=0; i<s.length()-1; i++){
        if(s[i] != s[i+1]) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
	int n;
	bool res = true;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;++i)cin >> a[i];
	sort(a.begin(),a.end());
	for(int i=1;i<n;++i){
		if(a[i-1] == a[i]){
			res = false;
			break;
		}
	}
	if(res)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

vector<lint> factorial(2001);
const lint mod=1000000007;

lint inv(lint a) {
    lint b = mod, u = 1, v = 0;
    while(b){
        lint t=a/b;
        a-=t*b;swap(a,b);
        u-=t*v;swap(u,v);
    }
    u%=mod; 
    if(u<0)u+=mod;
    return u;
}


//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    factorial[0]=1;
    for(int i=1;i<=2000;i++)factorial[i]=factorial[i-1]*i%mod;
    lint n,k,r,bunsi,bunbo;cin>>n>>k;
    r=n-k;
    for(int i=1;i<=k;i++){
        lint ans;
        if(i-1>r)ans=0;
        else{
            bunsi=factorial[k-1]*factorial[r+1]%mod;
            bunbo=factorial[k-i]*factorial[i-1]%mod;
            bunbo=bunbo*factorial[r+1-i]%mod;
            bunbo=bunbo*factorial[i]%mod;
            ans=bunsi*inv(bunbo)%mod;
        }
        cout<<ans<<endl;
    }
    
}


Measured memory_bytes: 3632
#include<iostream>
#include<queue>
#include<string>
#include<map>
using namespace std;
typedef pair<string,int> P;
int main(){
	map<string,int> mp;
	string s,arr,mo;
	int now;
	char c;
	while(cin>>s,s[0]!='0'){
		queue<P> que;
		que.push(P(s,0));
		while(!que.empty()){
			P pre=que.front();
			que.pop();
			now=pre.second;
			arr=pre.first;
			if(mp[arr]==1)
				continue;
			else
				mp[arr]=1;
			int j;
			for(j=1;j<(int)arr.size();j++)
				if(arr[j-1]!=arr[j])
					break;
			if(j==(int)arr.size()){
				cout<<now<<endl;
				goto end;
			}
			for(int i=1;i<(int)arr.size();i++){
				mo=arr;
				if(arr[i-1]!=arr[i]){
					if((arr[i-1]=='b'&&arr[i]=='g')||(arr[i-1]=='g'&&arr[i]=='b'))
						c='r';
					else if((arr[i-1]=='r'&&arr[i]=='g')||(arr[i-1]=='g'&&arr[i]=='r'))
						c='b';
					else c='g';
					mo[i-1]=c;
					mo[i]=c;
					que.push(P(mo,now+1));
				}
			}
		}
		cout<<"NA"<<endl;
		end:
		mp.clear();
	}
	return 0;
}

Measured memory_bytes: 2200
/*input
10 10
2 5 6 5 2 1 7 9 7 2
5 5
2 4
6 7
2 2
7 8
7 9
1 8
6 9
8 10
6 8
*/

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

// antbook p161, ABC174F
// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T> // T: type of cost
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  // adds x to i
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  // returns sum of [0, i]
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  // returns sum of [l, r)
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> pi(n+1, -1);
  vector<vector<int>> ps(n);
  rep(i, n) {
    int l = pi[a[i]];
    if (l != -1) ps[l].push_back(i);
    pi[a[i]] = i;
  }

  vector<vector<P>> qs(n);
  rep(qi, q) {
    int l, r;
    cin >> l >> r;
    --l; --r;
    qs[l].emplace_back(r, qi);
  }

  vector<int> ans (q);
  BIT<int> d(n);
  for (int x = n-1; x >= 0; x--) {
    for (int y: ps[x]) d.add(y, 1);
    for (P query: qs[x]) {
      int r = query.first, i = query.second;
      ans[i] = (r-x+1)-d.sum(r);
    }
  }

  rep(i, q) cout << ans[i] << endl;
}

Measured memory_bytes: 59812
#include <bits/stdc++.h>
#define pb push_back
#define sc1(x) scanf("%lld",&x)
#define sc2(x,y) scanf("%lld%lld",&x,&y)
#define sc3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)

using namespace std;

typedef long long int ll;
ll arr[100005],brr[100005];
int main()
{
    ll a,b,M;
    sc3(a,b,M);
    ll ac=INT_MAX;
    for(ll i=1;i<=a;i++)
    {
        sc1(arr[i]);
        ac=min(arr[i],ac);
    }
    ll rf=INT_MAX;
    for(ll i=1;i<=b;i++)
    {
        sc1(brr[i]);
        rf=min(rf,brr[i]);
    }
    ll ans=ac+rf;
    for(ll i=1;i<=M;i++)
    {
        ll x,y,z;
        sc3(x,y,z);
        ans=min(ans,arr[x]+brr[y]-z);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#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 <iomanip>
using namespace std;
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;
const ll INF = 1LL << 60;


int main() {
	
	ll sum = 0;
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	vector<ll> cum(n+1);
	cum[0] = 0;
	for (int i = 1; i <= n; i++)cum[i] += cum[i - 1] + a[i - 1];

	ll ans = INF;
	for (int i = 1; i < n; i++) ans = min(ans, abs(2 * (cum[i] - cum[0]) - sum));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int v[]={6000,4000,3000,2000};
    for(int i=0;i<4;i++){
        int n,m;
        cin>>n>>m;
        cout<<v[n-1]*m<<endl;
    }
}

Measured memory_bytes: 1160
import array


def is_prime_number(num):
    limit = int(num ** 0.5)

    for lp in range(3, limit + 1, 2):
        if num % lp == 0:
            return False

    return True


LENGTH = 1000000
prime_number_list = array.array("i", [True] * (LENGTH + 1))

prime_number_list[0] = False
prime_number_list[1] = False

for lp in range(4, LENGTH + 1, 2):
    prime_number_list[lp] = False

limit = int((LENGTH + 1) ** 0.5)

for lp in range(3, limit + 1, 2):
    if is_prime_number(lp):
        for lp2 in range(lp * 2, LENGTH + 1, lp):
            prime_number_list[lp2] = False

while True:
    input_num = int(input())

    if input_num == 0:
        break

    count = 0

    for lp in range(2, input_num // 2 + 1):

        if prime_number_list[lp] and prime_number_list[input_num - lp]:
            count += 1

    print(count)



Measured memory_bytes: 17128
R = lambda: map(int, input().split())

n = int(input())
if n % 3:
    ans = 'YNeos'[any(R())::2]
else:
    a = sorted(map(int, input().split()))
    m = n // 3
    if a[0] ^ a[m] ^ a[2 * m]:
        ans = 'No'
    elif any(len(set(a[i:i + m])) > 1 for i in range(0, n, m)):
        ans = 'No'
    else:
        ans = 'Yes'
print(ans)


Measured memory_bytes: 14212
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S>& p) {
	os << '(' << p.first << ',' << p.second << ')';
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

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

	vector<int> a(n);
	cin >> a;

	vector<int> dp(n, 1e9);
	dp[0] = 0;
	rep(i, n) {
		if (i + 1 < n) dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
		if (i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
	}
	cout << dp.back() << endl;
}


Measured memory_bytes: 1792
x, n = map(int,input().split())
li = list(map(int,input().split()))
ans = []

for i in range(n):
    ans.append(abs(li[i]-x))

ans.sort()
if 0 not in ans:
    print(x)
else:
    for i in range(1,1000):
        if ans.count(i) == 0:
            print(x-i)
            exit()
        elif ans.count(i) == 1:
            if x+i in li:
                print(x-i)
            else:
                print(x+i)
            exit()


Measured memory_bytes: 9076
#include <iostream>

bool prime(int x)
{
    for (int i = 2; i * i <= x; ++i)
    {
        if (x % i == 0)
            return 0;
    }

    return 1;
}

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

    std::cout << "2 ";
    --n;

    for (int i = 11; n > 0; i += 5)
    {
        if (prime(i))
        {
            std::cout << i << " ";
            --n;
        }
    }
}


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

using namespace std;

#define MAX_N 200000
#define MAX_M 200000

int par[MAX_N];
int urank[MAX_N];
int size[MAX_N];

void init(int n){
  for(int i=0;i<n;i++){
    par[i] = i;
    urank[i] = 0;
    size[i] = 1;
  }
}

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

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;

  if(urank[x] < urank[y]){
    par[x] = y;
    size[y] += size[x];
  }else{
    par[y] = x;
    size[x] += size[y];
    if(urank[x] == urank[y]) urank[x]++;
  }
}

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

int get_size(int x){
  return size[find(x)];
}

int main(){
  int N, M;
  cin >> N >> M;
  long long ret[MAX_M];
  init(N);
  int A[MAX_M], B[MAX_M];
  for (int i=0;i<M;i++){
    cin >> A[i] >> B[i];
  }

  ret[M-1] = (long long)N*(long long)(N-1) / 2;
  for(int i=M-1;i>0;i--){
    int a = A[i]-1;
    int b = B[i]-1;
    if(!same(a, b)){
      ret[i-1] = ret[i] - (long long)get_size(a) * (long long)get_size(b);
    }else{
      ret[i-1] = ret[i];
    }
    unite(a, b);
  }

  for(int i=0;i<M;i++){
    cout << ret[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    string s1,s2;
    cin>>s1;
    s2=s1;
    reverse(s2.begin(),s2.end());
    int a;
    a=s1.find("A");
    int z;
    z=s2.find("Z");
    int ans;
    ans=s1.length()-z-a;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 772
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    s = S()
    if s.isupper():
        print("A")
    else:
        print("a")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9952
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        String w = cin.next();
        char[] clist = w.toCharArray();
        Arrays.sort(clist);
        System.out.println(Arrays.equals(clist, new char[] {'a', 'b', 'c'}) ? "Yes" : "No");
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//#include <vector>
struct union_find {
	std::vector<long long> parent;
	std::vector<long long> sizes;
	long long num_of_trees;

	//コンストラクタ
	union_find(long long n) {
		for (long long i = 0; i < n; i++) {
			parent.push_back(i);
			sizes.push_back(1);
		}
		num_of_trees = n;
	}

	//頂点nの根
	long long root_of(long long n) {
		if (parent[n] == n) return n;
		return parent[n] = root_of(parent[n]); //パス圧縮
	}

	//頂点nを含む木の頂点数(自身含む)
	long long size_of(long long n) {return sizes[root_of(n)];}

	//頂点a, bが間接的に繋がっているか判定
	bool is_united(long long a, long long b) {return (root_of(a) == root_of(b));}

	//頂点aを含むグラフに頂点bを含むグラフを結合
	void unite(long long a, long long b) {
		if (is_united(a, b)) return;
		num_of_trees--;
		if (size_of(a) < size_of(b)) std::swap(a, b); //マージテク
		sizes[root_of(a)] += size_of(b);
		parent[root_of(b)] = root_of(a);
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, m;
	cin >> n >> m;
	vector<vector<ll>> lang(m, vector<ll>(0));
	for (ll i = 0; i < n; i++) {
		ll k;
		cin >> k;
		while (k--) {
			ll l;
			cin >> l;
			l--;
			lang[l].push_back(i);
		}
	}

	union_find uf(n);
	for (ll i = 0; i < m; i++) {
		for (ll j = 1; j < lang[i].size(); j++) {
			uf.unite(lang[i][0], lang[i][j]);
		}
	}

	if (uf.num_of_trees == 1) YES();
	else NO();
}


Measured memory_bytes: 5748
/*
  Warn - Don't change next line else you will get WA verdict. Online Judge is configured to give WA if next line is not present.
  Author - Aryan Choudhary (@aryanc403)
 
  const short DEBUG { 0 };
  #define debug(x) if (DEBUG) cout << #x << " = " << x << '\n'
*/

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"
#define PI 3.1415926535897932384626433832795
typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

//const lli [3] ={ 999119999L,1000000007L,1000992299L};
//const lli [3] ={ 97L,101L,103L};
//const lli  = chrono::high_resolution_clock::now().time_since_epoch().count();
clock_t time_p=clock();
void aryanc403()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

class CMP
{
public:
    bool operator()(lli a , lli b) //For min priority_queue .
    {
        return ! ( a <= b );
    }
};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt==m.end())         m.insert(mp(x,cnt));
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}
const lli INF = 0xFFFFFFFFFFFFFFFL;
const lli mod = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,t;
    lli m;
    string s;
    vi a;
    vi :: iterator it;
    //priority_queue < lli , vector < lli > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    cin>>t>>m;
    a.clear();a.reserve(n);
    
    fo(i,n)
    {
        cin>>in;
        a.pb(in);
    }
    
    lli ans=0;
    
    fo(i,n)
    {
        if(abs(t-0.006*a[i]-m)<abs(t-0.006*a[ans]-m))
            ans=i;
    }
    
    cout<<ans+1<<endl;
}   aryanc403();
    return 0;
}

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

int main()
{
    string s;
    int n;
    cin >> n;
    cin >> s;
    int l = s.length();
    int count = 0;
    for (int i = 0; i < l - 2; i++)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long d[3];
    for(long long i=0;i<3;i++){
        cin>>d[i];
    }
    sort(d,d+3);
    cout<<d[0]<<" "<<d[2]<<endl;
    return 0;
}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int X;
    std::cin >> X;

    int n = 1;
    while(true) {
        if(X <= n * (n + 1) / 2) {
            std::cout << n << std::endl;
            break;
        }
        n++;
    }

    return 0;
}


Measured memory_bytes: 256
n,a = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

dp = [[[0 for _ in range(2555)] for _ in range(55)] for _ in range(55)]
dp[0][0][0]=1
for j in range(n):
    for k in range(n):
        for s in range(a*n+1):
            dp[j+1][k][s] += dp[j][k][s]
            dp[j+1][k+1][s+x[j]] += dp[j][k][s]

ans=0
for k in range(1,n+1):
    ans+=dp[n][k][a*k]
print(ans)

Measured memory_bytes: 104440
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program3
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());

            long cnt_r = 0;
            long cnt_g = 0;
            long cnt_b = 0;

            string str = Console.ReadLine();
            for (int i = 0; i< input; i++)
            {
                if (str[i] == 'R')
                    cnt_r++;
                else if (str[i] == 'G')
                    cnt_g++;
                else
                    cnt_b++;
            }
            long total = cnt_r * cnt_g * cnt_b;

            for (int i = 0; i < input; i++)
            {
                for (int d = 1; i + 2*d < input ; d++)
                {
                    if (str[i] != str[i+d] && str[i] != str[i+2*d] && str[i+d] != str[i+2*d])
                        total--;
                }
            }
            Console.WriteLine(total);
        }

    }
}


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

int main()
{
	int h = 0, w = 0;

	cin >> h >> w;

	while ((h != 0) | (w != 0)) {
		for (int j = 0; j < h; j++) {
			if ((j == 0) | (j == h - 1)) {
				for (int i = 0; i < w; i++)
					cout << "#";
				cout << endl;
			}
			else {
				cout << "#";
				for (int i = 0; i < w - 2; i++)
					cout << ".";
				cout << "#" << endl;
			}
		}
		cout << endl;
		cin >> h >> w;
	}

    return 0;
}

Measured memory_bytes: 3080