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

public class Main {

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

		String str = sc.next();

		if (str.equals("Sunny")) {
			System.out.println("Cloudy");
		} else if (str.equals("Cloudy")) {
			System.out.println("Rainy");
		} else {
			System.out.println("Sunny");
		}

	}

}


Measured memory_bytes: 22228
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner seer = new Scanner(System.in);
		int n = seer.nextInt();
		int m = seer.nextInt();
		int[] d = new int[n];
		int maxa = 0, minb = n+1;
		for(int i = 0; i < m; i++){
			int a = seer.nextInt();
			int b = seer.nextInt();
			maxa = Integer.max(maxa, a);
			minb = Integer.min(minb, b);
		}
		if(minb < maxa){
			System.out.println(0);
		}
		else{
			System.out.println(minb-maxa+1);
		}
	}
}


Measured memory_bytes: 65232
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

L = []
while True:
    line = stdin.readline()
    if line.startswith('0,0'):
        break
    L.append(tuple(int(s) for s in line.split(',')))

L.sort(key=lambda (id, point): point, reverse=True)
for line in stdin:
    n = int(line)
    order = 0
    p = 0
    for id, point in L:
        if p != point:
            p = point
            order += 1
        if n == id:
            break
    print(order)

Measured memory_bytes: 4280
import java.util.*;
import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double L = sc.nextDouble();
		//double taiseki = Math.pow(L/3.0,3.0);
		//System.out.println(taiseki);
		BigDecimal ans = new BigDecimal(Math.pow((L/3),3));
		System.out.println(ans.toPlainString());
	}
}

Measured memory_bytes: 23248
N = int(input())
As = list(map(int, input().split()))

a = list(filter(lambda x: x < 0, As))
As = list(map(lambda x: abs(x), As))
As.sort()
if len(a) % 2 == 0:
    print(sum(As))
else:
    print(sum(As[1:]) - As[0])

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

const int dy[] = { 1, 0, -1, 0}, dx[] = { 0, 1, 0, -1};
bool check[1 << 12];
int H, W, K, dp[4][50][50][1 << 12];
char Gifts[50][50];

int main(){

  cin >> H >> W >> K;
  const int mask = (1 << (K * 4)) - 1;
  for(int i = 0; i <= mask; ++i){
    bool flag = false;
    int y = 0, x = 0, bit = i;
    for(int j = 0; j < 2 * K; ++j){
      y -= dy[bit & 3], x -= dx[bit & 3];
      if(y == 0 && x == 0){
        flag = true;
        break;
      }
      bit >>= 2;
    }
    check[i] = !flag;
  }

  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      cin >> Gifts[i][j];
    }
  }
  fill_n( ***dp, 4 * 50 * 50 * (1 << 12), -1);
  // dp[i][j][S]: ( j, i)にいるときの前に訪れる方法Sにおいての最大値
  dp[K][0][0][0] = 0;
  for(int i = K; i >= 0; --i){
    for(int j = 0; j < H; ++j){
      for(int k = 0; k < W; ++k){
        for(int l = 0; l <= mask; ++l){
          if(dp[i][j][k][l] == -1) continue;
          int cost;
          if(isdigit(Gifts[j][k]) && check[l]){
            cost = Gifts[j][k] - '0';
          }

          else cost = 0;
          for(int m = 0; m < 4; ++m){
            int ny = j + dy[m], nx = k + dx[m];
            if((m > 1 && i == 0) || ny < 0 || ny >= H || nx < 0 || nx >= W || Gifts[ny][nx] == '#') continue;
            int& res = dp[i - (m > 1)][ny][nx][(l << 2 | m) & mask];
            res = max( res, dp[i][j][k][l] + cost);
          }
        }
      }
    }
  }
  int ret = 0;
  for(int i = 0; i <= mask; ++i){
    ret = max( ret, dp[0][H - 1][W - 1][i]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 161164
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
    string str;
    int ans = 0,t=0,s=0;
    cin >> str;
    int len = str.length();
    FOR(i,len){
         if(str[i]=='T'){
            if(!s){
                ans++;
            }else
                s--;
         }else{
             s++;
         }
    }
    cout << ans + s fin;

  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;




Measured memory_bytes: 720
//Curtain
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

int main()
{
    int A,B;
    cin >> A >> B;
    int x = A - 2 * B;
    cout << (x < 0 ? 0 : x) << endl;
    return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>

using namespace std;

#define MAX 303

int n;
int m;

#define MOD 1000000007

int dp[MAX][MAX][MAX];

vector<pair<int, int> > v[MAX];
#define ng 301
int main(){
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		int l, r, x;
		scanf("%d%d%d", &l, &r, &x);
		l--;
		r--;
		v[r].push_back(make_pair(l, x));
	}
	dp[0][ng][ng] = 3;
	int ans = 0;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < MAX; j++){
			for (int k = 0; k < MAX; k++){
				if (dp[i][j][k]){
					//check valid
					int siz = v[i].size();
					for (int jj = 0; jj < siz; jj++){
						int lef = v[i][jj].first;
						int X = 1;
						if (j != ng&&lef <= j)X++;
						if (k != ng&&lef <= k)X++;
						if (X != v[i][jj].second){
							dp[i][j][k] = 0;
							break;
						}
					}
				}
				if (dp[i][j][k]){
					if (i + 1 < n){
						//choose new color
							{
								int rest = 2;
								if (j != ng)rest--;
								int nex_j = i;
								int nex_k = j;
								long long int go = dp[i][j][k];
								go *= rest;
								if (go >= MOD)go -= MOD;
								if (go >= MOD)go -= MOD;
								go += dp[i + 1][nex_j][nex_k];
								if (go >= MOD)go -= MOD;
								dp[i + 1][nex_j][nex_k] = go;
							}
						//choose previous color
						if (j != ng){
							int nex_j = i;
							int nex_k = k;
							dp[i + 1][nex_j][nex_k] += dp[i][j][k];
							if (dp[i + 1][nex_j][nex_k] >= MOD)dp[i + 1][nex_j][nex_k] -= MOD;
						}
						//go
						dp[i + 1][j][k] += dp[i][j][k];
						if (dp[i + 1][j][k] >= MOD){
							dp[i + 1][j][k] -= MOD;
						}
					}
					else{
						ans += dp[i][j][k];
						if (ans >= MOD)ans -= MOD;
					}
				}
			}
		}
	}
	ans %= MOD;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    map<string,int>d;
    map<string,int>::iterator i;
    for (int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        d[s]++;
    }
    int m;
    m=d[d.begin()->first];
    for (i=d.begin();i!=d.end();i++)
    {
        if (i->second>m)
            m=i->second;
    }
    for (i=d.begin();i!=d.end();i++)
    {
        if (i->second==m)
            cout<<i->first<<endl;
    }

    return 0;
}


Measured memory_bytes: 23808
import sys

def main():
    N = sys.stdin.readline().rstrip('\n')
    line = sys.stdin.readline().rstrip('\n').split()

    for A in line:
        if int(A)%2 == 0:
            if not (int(A)%3==0 or int(A)%5==0):
                print('DENIED')
                return
    print('APPROVED')

main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*辺をデカイ順にソートし、前から最大辺を選び、残り二辺をその和
が最大辺より大きくなるように選ぶ
*/

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i,N){
      cin >> L[i];
  }
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());

  ll ans = 0;
  for(int i = 0;i<=N-3;i++){
      for(int j = i+1;j<=N-2;j++){
          for(int k = j+1;k<=N-1;k++){
              if(L[i] < L[j]+L[k]) ans++;
          }
      }
  }
  cout << ans << endl;
}

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

int main() {
	int N;
	cin >> N;
	
	int ten = N/10;
	int one = N%10;
	
	if(ten == 9 || one == 9) cout << "Yes";
	else cout << "No";
	
	
	cout << endl;
	

	return 0;
}

Measured memory_bytes: 256
class BinarySearch
  def initialize(t, &b)
    @t = t
    @b = b
  end
  def search(f, t, isMin)
    return isMin ? t : f if (t-f).abs == 1
    m = (f+t)/2
    n = @b.call(m)
    if n > @t || (n==@t && isMin) then
      search(f, m, isMin)
    else
      search(m, t, isMin)
    end
  end
end


N, K = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)

(puts A.max; exit) if K == 0
(puts 1; exit) if K >= A.inject(:+) - N

bs = BinarySearch.new(K){|x|
  A.inject(0){|r, a|
    dm = a.divmod(x)
    r + (dm[1]==0 ? dm[0]-1 : dm[0])
  }
}

puts bs.search(A.max, 1, false)


Measured memory_bytes: 35680
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        int tmp = 0;
        string s = to_string(i);
        for(int j = 0; j < s.length(); j++) {
            tmp += s[j] - '0';
        }
        if(tmp >= a && tmp <= b) {
            ans += i;
        }
    }
    cout << ans << endl;






}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ld,ld>;
//--GLOBAL---------------------------------
ll modpow(ll a, ll n, ll mod=MOD){ // a^n % MOD の計算
    ll res = 1;
    while (n > 0){
          if(n & 1) res = res * a % mod;
          a = a * a  % mod;
          n >>= 1;
    }
    return res;
}

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    deque<ll> dq;
    ll ans=1;
    rep(i,N){
        if(A[i]%2==0 and A[i]/2<=dq.size()){
            ans=ans*(dq.size()+1)%MOD;
        }
        else dq.emplace_back(A[i]);
    }
    while(!dq.empty()){
        ans*=dq.size();
        ans%=MOD;
        dq.pop_back();
    }
    cout<< ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 10005
 
#define PI 3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007



int main()
{
	FAST;
	string s;
	cin >> s;
	ll n;
	cin >> n;
	for(ll i = 0; i < s.size(); i ++){
		if(s[i] == '1'){
			n--;
		}
		else{
			n = 0;
		}
		if(n <= 0){
			cout << s[i]; return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
constexpr int kMax = 100000;

int main() {
  bool dp[kMax];
  int N, K; std::cin >> N >> K;
  std::vector<int> a(N);
  for (int i = 0; i < N; ++i) std::cin >> a[i];

  dp[0] = false;

  for (int j = 1; j <= K; ++j) {
    dp[j] = false;
    for (int i = 0; i < N; ++i) {
      if (j-a[i]<0) break;

      if (!dp[j-a[i]]) {
        dp[j] = true;
        break;
      }
    }

#if DEBUG
    std::cout << j << ":" << dp[j] << std::endl;
#endif
  }

  if (dp[K]) std::cout << "First" << std::endl;
  else       std::cout << "Second" << std::endl;
}


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

int main(void) {
  int n, m, x;
  int c[12], a[12][12];
  
  cin >> n >> m >> x;
  
  for(int i = 0; i < n; i++) {
    cin >> c[i];
    for(int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  
  int result = 1e9;
  
  for(int k = 0; k < pow(2, n); k++) {
    int sum_c = 0;
    int u[12];
    for(int j = 0; j < m; j++) {
      u[j] = 0;
    }
    for(int i = 0; i < n; i++) {
      if(k>>i & 1) {
        sum_c += c[i];
        for(int j = 0; j < m; j++) {
          u[j] += a[i][j];
        }
      }
    }
    
    bool flag = true;
    for(int j = 0; j < m; j++) {
      if(x > u[j]) flag = false;
    }
    if(flag) {
      if(result > sum_c) {
      	result = sum_c;
      }
    }
  }
  
  if(result == 1e9) {
    cout << -1 << endl;
  } else {
    cout << result << endl;
  }
    
  return 0;
}


Measured memory_bytes: 4032
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
    # ノードxのrootノードを見つける
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def unite(self, x, y):
    # 木の併合、入力は併合したい各ノード⇒(a,b)
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
    # ノードxが属する木のサイズを返す
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
    # 入力ノード(x,y)が同じグループに属するかを返す
        return self.find(x) == self.find(y)
 
    def members(self, x):
    #ノードxが属するメンバーをリスト形式で返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
    #親全てをリスト形式で返す
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
    #グループ数の合計を返す
        return len(self.roots())
 
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
 
 
 
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n,m=map(int,input().split())
u=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    u.unite(a,b)
print(len(u.roots())-1)

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<long> prime, sieve(31622, 1);
    for(long i = 2; i < 31622; ++i)
        if(sieve[i]){
            prime.push_back(i);
            for(auto j = i * i; j < 31622; j += i)sieve[j] = 0;
        }

    vector<long> a(N + 1);
    for(auto& i : a)cin >> i;
    long u{0};
    for(const auto i : a)u = __gcd(u, abs(i));
    
    vector<long> ans;
    for(const auto p : prime){
        if(u % p == 0){
            ans.push_back(p);
            while(u % p == 0)u /= p;
        }else if(p <= N){
            vector<long> v(p);
            for(unsigned long j = 0, k = 0; j < N; ++j){
                v[k] += a[j];
                if(++k == p - 1)k = 0;
            }
            auto tapi = (p + (a[N] % p)) % p;
            for(auto j : v)tapi += (p + (j % p)) % p;
            if(tapi == 0)ans.push_back(p);
        }
    }
    for(const auto i : ans)cout << i << endl;
    if(u != 1)cout << u << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>

using namespace std;

class UnionFind {
private:
	std::vector<int> parent;
	std::vector<int> height;
	std::vector<int> m_size;
 
public:
	UnionFind(int size_) : parent(size_), height(size_, 0), m_size(size_, 1) {
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	void init(int size_) {
		parent.resize(size_);
		height.resize(size_, 0);
		m_size.resize(size_, 1);
		for (int i = 0; i < size_; ++i) parent[i] = i;
	}
	int find(int x) {
		if (parent[x] == x) return x;
		return parent[x] = find(parent[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		int t = size(x) + size(y);
		m_size[x] = m_size[y] = t;
		if (height[x] < height[y]) parent[x] = y;
		else parent[y] = x;
       		if (height[x] == height[y]) ++height[x];
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		if (parent[x] == x) return m_size[x];
		return size(parent[x] = find(parent[x]));
	}
};
 
int main(){
  long long int n,m;cin>>n>>m;
  long long int a[m],b[m];
  long long int now=n*(n-1)/2;
  UnionFind uf(n);
  vector<long long int> ans;
  for(int i=m-1;i>=0;i--){
    cin>>a[i]>>b[i];
  }
  for(int i=0;i<m;i++){
    long long int x=a[i],y=b[i];
    --x;--y;
    ans.push_back(now);
 
    if(uf.same(x,y)){continue;}
    now-=uf.size(x)*uf.size(y);
    uf.unite(x,y);
  }
 
  reverse(ans.begin(),ans.end());
 
  for(int i=0;i<ans.size();i++){
    cout<<ans[i]<<endl;
  }
  
    
  return 0;
}

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

using lint = int64_t;

const int m = 100010;

struct Node {
    bool visited;
    vector<int> tos;
};

void dfs(int pos, vector<Node>& nodes, lint& num_x, lint& num_y, lint& num_edge) {
    nodes[pos].visited = true;
    if (pos < m) {
        num_x++;
        num_edge += nodes[pos].tos.size();
    } else {
        num_y++;
    }

    for (int nex: nodes[pos].tos) {
        if (nodes[nex].visited == false) {
            dfs(nex, nodes, num_x, num_y, num_edge);
        }
    }
}

int main() {
    int n;
    cin >> n;
    vector<Node> nodes(2 * m);
    for (int i = 0; i < 2 * m; i++) {
        nodes[i].visited = false;
    }
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        nodes[x].tos.push_back(m + y);
        nodes[m + y].tos.push_back(x);
    }

    lint ans = 0;
    for (int i = 0; i < 2 * m; i++) {
        if (nodes[i].visited == false) {
            lint num_x = 0, num_y = 0, num_edge = 0;
            dfs(i, nodes, num_x, num_y, num_edge);
            ans += num_x * num_y - num_edge;
        }
    }

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

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string n;
	cin >> n;
	rep(i, 3) {
		if (n[i] == '1') n[i] = '9';
		else if (n[i] == '9')n[i] = '1';
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
N,K=list(map(int,(stdin.readline().strip().split())))
A=list(map(int,(stdin.readline().strip().split())))
cycle=[1]
count=[0]*N
tele=0
count[tele] += 1
while(True):
    cycle.append(A[tele])
    tele=A[tele]-1
    count[tele] += 1
    if count[tele] == 2:
        break
a=cycle.index(tele+1)
if K<len(cycle):
    print(cycle[K])
else:
    num=len(cycle[a:-1])
    num=(K-len(cycle[:a]))%num
    print(cycle[num+len(cycle[:a])])

Measured memory_bytes: 32376
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//------------------------------------------
//------------------------------------------

int main() {

    int N;
    cin >> N;

    string S;
    cin >> S;

    int cnt = 1;
    for (int i = 0; i < S.size() - 1; i++) if (S[i] != S[i + 1])cnt++;
    cout << cnt << endl;

    return 0;
}





















































Measured memory_bytes: 512
import java.util.*;

class Main{

    int n, mod, a, b, c, t;

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            n = sc.nextInt(); mod = sc.nextInt();
            a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt();
            t = sc.nextInt();
            if(n==0 && mod==0 && a==0 && b==0 && c==0 && t==0) break;

            long[][] s = new long[n][1];
            for(int i=0; i<n; i++) s[i][0] = sc.nextLong();

            long[][] mat = new long[n][n];
            for(int i=0; i<n; i++){
                for(int j=-1; j<2; j++){
                    int idx = i + j;
                    if(idx<0 || idx>=n) continue;
                    if(j==-1) mat[i][idx] = a;
                    if(j==0) mat[i][idx] = b;
                    if(j==1) mat[i][idx] = c;
                }
            }

            mat = pow(mat, t);
            s = matmul(mat, s);
            for(int i=0; i<s.length-1; i++){
                System.out.print(s[i][0]+" ");
            }
            System.out.println(s[s.length-1][0]);
        }
    }

    //ティツ。ツ古・ツ按療」ツ?ョテヲツ篠崚」ツ?妥ァツョツ療」ツつ津」ツ?凖」ツつ?
    long[][] matmul(long[][] m1, long[][] m2){
        int a = m1.length, b = m2[0].length;
        long[][] res = new long[a][b];
        for(int i=0; i<a; i++){
            for(int j=0; j<b; j++){
                long sum = 0;
                for(int k=0; k<m1[0].length; k++){
                    sum += (m1[i][k] * m2[k][j]) % mod;
                }
                res[i][j] = sum % mod;
            }
        }
        return res;
    }

    //ティツ。ツ古・ツ按療」ツ?ョテァツエツッテ、ツケツ療」ツつ津ィツィツ暗ァツョツ療」ツ?凖」ツつ?
    long[][] pow(long[][] matrix, int l){
        long[][] ret = new long[matrix.length][matrix[0].length];
        for(int i=0; i<matrix.length; i++) ret[i][i] = 1;
        /*
          lテ」ツつ?テゥツ?イテヲツ閉ーテ」ツ?ァティツ。ツィテ」ツ?凖」ツ??
          テ」ツδ禿」ツδε」ツδ暗」ツ?ョ1テ」ツ?古ァツォツ凝」ツ?」テ」ツ?ヲテ」ツ??」ツつ凝」ツ?ィテ」ツ?禿」ツつ催」ツ??」ツ?妥ヲツ篠崚」ツ?妥」ツつ凝」ツ??
         テッツシツ暗、ツセツ凝ッツシツ瑛=19テ」ツ?ョテ」ツ?ィテ」ツ??
          l = 10011
          A^19 = A^1 * A^2 * A^16
        */
        for(; l>0; l>>=1){
            if((l&1)>0) ret = matmul(ret, matrix);
            matrix = matmul(matrix, matrix);
        }
        return ret;
    }

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

Measured memory_bytes: 54984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int a[3][3];
    for (int i=0; i<3; ++i) for (int j=0; j<3; ++j) cin >> a[i][j];
    int n, b;
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> b;
        for (int j=0; j<3; ++j) for (int k=0; k<3; ++k) {
            if (a[j][k] == b) a[j][k] = 0;
        }
    }
    for (int i=0; i<3; ++i) {
        if (a[i][0] + a[i][1] + a[i][2] == 0 || a[0][i] + a[1][i] + a[2][i] == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (a[0][0] + a[1][1] + a[2][2] == 0 || a[0][2] + a[1][1] + a[2][0] == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int cardA, cardB, cardC, numberOfCards;
	int sum;
	int Ai, Ci;

	scanf("%d", &cardA);
	scanf("%d", &cardB);
	scanf("%d", &cardC);
	scanf("%d", &numberOfCards);

	sum = 0;

	for (Ai = 0; Ai < cardA && Ai < numberOfCards; Ai++)
	{
		sum++;
	}

	for (Ci = 0; Ci < cardC && Ci + cardA +cardB < numberOfCards; Ci++)
	{
		sum--;
	}

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

	return 0;
}

Measured memory_bytes: 1728
from sys import stdin
from sys import setrecursionlimit
import bisect
setrecursionlimit(10 ** 7)

n = int(input())
c = input()

count = c.count("R")
point = 0

for i,j in enumerate(c,1):
    if j == "R":
        if i > count:
            point += 1

print(point)

Measured memory_bytes: 9468
N = int(input())
W = [int(i) for i in input().split()]
list = []


for i in range (N):
  s1 =0
  s2 =0
  slice1 =  W[0:i]
  for t in slice1:
    s1 += t
  slice2 = W[i:N]
  for t in slice2:
    s2 += t
  z = s1 - s2
  if z < 0:
    z*= -1
  list.append(z)
z =min(list)

print(z)

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

using namespace std;
typedef pair<int,int> pii;
int _w;

int n;
set<pii> st;

int main() {
	cin >> n;
	for( int i = 1; i <= n; ++i )
		for( int j = i+1; j <= n; ++j )
			st.insert( pii(i, j) );
	int L, R;
	if( n & 1 ) {
		L = 1, R = n-1;
	} else {
		L = 1, R = n;
	}
	while( L < R ) {
		st.erase( pii(L, R) );
		++L, --R;
	}
	printf( "%d\n", (int)st.size() );
	for( pii edge : st )
		printf( "%d %d\n", edge.first, edge.second );
	return 0;
}


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

int main(){
	int n, t = 0;
	int out[100] = {0};
	while(cin >> n){
		for(int a = 0; a < 10; a++){
			for(int b = 0; b < 10; b++){
				for(int c = 0; c < 10; c++){
					for(int d = 0; d < 10; d++){
						if(a+b+c+d == n){
							out[t]++;
						}
					}
				}
			}
		}
		t++;
	}
	for(int i = 0; i < t; i++){
		cout << out[i] << endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int main()
{
    int n, k, ans = 1;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        if(ans < k) ans *= 2;
        else        ans += k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//Get the highest value and key from a map.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const ll MAXN = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  int a[100010];
  rep(i, m) {
    int x;
    cin >> x;
    --x;
    a[x] = 1;
  }

  ll dp[100010];
  rep(i, 100010) dp[i] = 0;
  if(a[0] == 0) dp[0] = 1;
  if (a[1] == 0) {
    if (dp[0] == 1) {
      dp[1] = 2;
    } else {
      dp[1] = 1;
    }
  }
  
  for (int i = 2; i < n; i++) {
    if (a[i] == 1) continue;
    dp[i] = dp[i - 1] + dp[i - 2];
    dp[i] = dp[i] % MAXN;
  }

  cout << dp[n - 1] << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main(void){
  int N,S;
  scanf("%d",&N);
  S = N % 10;
  if(S == 3)
    printf("bon");
  if(S == 0)
    printf("pon");
  if(S == 1)
    printf("pon");
  if(S == 6)
    printf("pon");
  if(S == 8)
    printf("pon");
  if(S == 2)
    printf("hon");
  if(S == 4)
    printf("hon");
  if(S == 5)
    printf("hon");
  if(S == 7)
    printf("hon");
  if(S == 9)
    printf("hon");
  return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
template<class T>struct nCk{
	T pow(T x,T n,T mod=1e9+7LL){
		T ret=1;
		if(n>0){
			ret=pow(x,n/2,mod);
			if(n%2==0){
				(ret=(ret*ret))%=mod;
			}else{
				(ret=((ret*ret)%mod)*x)%=mod;
			}
		}
		return ret;
	}
	T inv(T n,T mod=1e9+7LL){
		return pow(n,mod-2,mod);
	}
	T nck(T n,T k,T mod=1e9+7LL){
		T ret=1;
		for(int i=n;i>n-k;i--){
			(ret*=i)%=mod;
		}
		for(int i=k;i>=1;i--){
			(ret*=inv(i,mod))%=mod;
		}
		return ret;
	}
	T nhk(T n,T k,T mod=1e9+7LL){
		return nck(n-1+k,n-1,mod);
	}
};
int main(){
  long long x,y;
  cin>>x>>y;
  long long s=x+y;
  if(s%3==0&&abs(x-y)<=s/3){
    nCk<long long> nii;
    cout<<nii.nck(s/3,x-s/3)<<endl;
  }else{
    cout<<0<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Object o = run();
        if (o != null)
            System.out.println(o);
    }

    static Object run() {
        try (Scanner sc = new Scanner(System.in)) {
            int x = sc.nextInt();
            if (x > 29) return "Yes";
            else return "No";
        }
    }
}

class ChenNumberUtil {
    static Collection<Integer> getDivisors(int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                al.add(i);
                if (n / i != i)
                    al.add(n / i);
            }
        }
        Collections.sort(al);
        return al;
    }
}

class ChenBitUtil {
    static int popCount(int bit) {
        return Integer.bitCount(bit);
    }

    static boolean isFlag(int bit, int i) {
        return 0 != (bit & (1 << i));
    }

    static int setTrue(int bit, int i) {
        return bit |= (1 << i);
    }

    static int setFalse(int bit, int i) {
        return bit &= ~(1 << i);
    }

    static int setReverse(int bit, int i) {
        return isFlag(bit, i) ? setFalse(bit, i) : setTrue(bit, i);
    }

    static int reverseAll(int bit) {
        return ~bit;
    }
}


Measured memory_bytes: 27048
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;



int main() {
	int k;
	string s;
	cin >> k >> s;
	if (s.size() <= k)cout << s;
	else {
		for (int i = 0; i < k; i++) {
			cout << s[i];
		}
		cout << "...";
	}
	
	return 0;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
ab = []
for _ in range(n):
    a,b = map(int, input().split())
    ab.append((a,b))

ab.sort()

res = 0
for a,b in ab:
    if b>=k:
        res = a
        break
    else:
        k -= b
print(res)


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

int abs(int a){return a < 0 ? -a : a;}
int main(){
	int n,a,b;
	int p[20];
	int mi = 0;
	while(cin >> n && n){
		mi = (1<<21);
		for(int i=0;i<n;i++)cin >> p[i];
		
		for(int i=0;i<(1<<n);i++){
			a = b = 0;
			for(int j=0;j<n;j++){
				if( (1<<j) & i)a+=p[j];
				else b+= p[j];
			}
			mi = min( mi,abs(a-b) );
		}
		cout << mi << endl;
	}
}

Measured memory_bytes: 864
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int a = 1; a <= n; a += 2) {
	  int d = 0;
	  for (int b = 1; b <= a; b++) {
		  if (a % b == 0) {
			  d++;
			}
		}
	  if (d == 8) {
		  ans++;
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
   int n ;
   cin >> n ;
   vector < int > a(n) ;
   for( int i = 0 ; i < n ; i++) cin >> a[i] ;
   a[0]--;
   for( int i = 1 ; i < n ; i++){
        if(a[i]<a[i-1]){
            cout << "No\n";
            return ;
        }
        else if( a[i] > a[i-1]){
            a[i]--;
        }
   }
   cout << "Yes\n";
   return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q = 1 ;
    //cin >> q;
   // while(q--)
        for( int i = 1 ; i <= q ; i++)
            solve();
}


Measured memory_bytes: 640
/*input
2
2
1 2
5
7 4 3 2 6
*/
#include <bits/stdc++.h>

using namespace std;

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


#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define syso(n) cout<<n<<endl;
#define sysom(message, n) cout<<message<<n<<\n;
#define all(c) c.begin(), c.end() 
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(all(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 


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

ll lcm(ll fir, ll sec){
	return (fir*sec)/(gcd(fir, sec));
}


const int MOD = 1e9 + 7;
const string small_alphabets = "abcdefghijklmnopqrstuvwxyz";
const int month_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(5) << f << '\n';


// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
int main(){
	ll x,y;
	cin>>x>>y;
	if(x%y==0){
		syso(-1);
		return 0;
	}
	syso(x);
	return 0;
}


Measured memory_bytes: 256
#include <climits>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
using namespace std;
typedef unsigned char byte;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

int cnt[128] = {0};

int main()
{
    string s;
    cin >> s;
    FO (i, s.size())
        if (++cnt[s[i]] > 1)
        {
            cout << "no" << endl;
            return 0;
        }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc161/tasks/abc161_b

N, M = gets.split.map(&:to_i)
As = gets.split.map(&:to_i)
sum = As.reduce(&:+)
cond = As.count { |a| a * (4 * M) >= sum } >= M
puts cond ? 'Yes' : 'No'


Measured memory_bytes: 14272
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
     long long int n,m;
     cin>>n>>m;
     if(n*2>m)
          printf("%lld\n",m/2);
    else if(n*2==m)
         printf("%lld\n",n);
    else
         printf("%lld\n",(m-2*n)/4+n);
    return 0;
}

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

int main()
{
    long long int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h), t(h);
    for(int i = 0;i < h;i++){
        vector<char> a(w);
        s[i] = a;
        t[i] = a;
        for(int j = 0;j < w;j++){
            cin >> s[i][j];
            t[i][j] = '0';
        }
    }

    for(int i = 0;i < h;i++){
        for(int j = 0;j < w - 1;j++){
            if(s[i][j] == '#' && s[i][j + 1] == '#'){
                t[i][j] = t[i][j + 1] = '#';
            }
            
            if(s[i][j] == '.'){
                t[i][j] = '.';
            }
            
            if(s[i][j + 1] == '.'){
                t[i][j + 1] = '.';
            }
        }
    }
    
    for(int i = 0;i < h - 1;i++){
        for(int j = 0;j < w;j++){
            if(s[i][j] == '#' && s[i + 1][j] == '#'){
                t[i][j] = t[i + 1][j] = '#';
            }
            
            if(s[i][j] == '.'){
                t[i][j] = '.';
            }
            
            if(s[i + 1][j] == '.'){
                t[i + 1][j] = '.';
            }
        }
    }

    bool f = true;

    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(s[i][j] != t[i][j]){
                f = false;
            }
        }
    }

    if(f){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
typedef long long int ll;
 
//typedef tree<pp, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
 
 
const ll N = 400005;
 ll mod = 1000000007;
const long long int inf = INT64_MAX;
#define pp pair<ll,ll>

typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
 
const ld pi = 3.14159265359;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

 
void fastIO(void);
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);


int main()
{
	ll a,b,n;
	cin>>a>>b;
	ld x,y;
	for(n=1;n<1000000;n++){
		x = 0.08*n;
		y = 0.1*n;
		ll x1,x2;
		x1 = x;
		x2 = y;
		// if(x-x1>=0.5) x1++;
		// if(y-x2>=0.5) x2++;
		if(x1==a && x2==b) break;
	}
	if(n<1000000) cout<<n<<endl;
	else cout<<-1<<endl;

	
}


	


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> s;
  if (isupper(s[0]))
  {
    cout << 'A' << endl;
  }
  else
  {
    cout << 'a' << endl;
  }
}

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

int main()
{
  int N,L ;
  cin>>N>>L ;
  
  int num_apple ;
  if(L+N-1<0) num_apple=L+N-1 ;
  else if(L>=0) num_apple=L ;
  else num_apple=0 ;
  
  int sum=0 ;
  for(int i=L;i<=L-1+N;i++) if(i!=num_apple) sum+=i ;
  
  cout<<sum<<endl ;
  
  return 0 ;
}


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

int main() {
  int N;
  cin >> N;
 
  int t = N, c = 0;
  while (t > 0){
    c += t%10;
    t /= 10;
  }
  if (N % c == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int sumr[n]= {}, sumg[n] = {}, sumb[n] = {};
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') sumr[i]++;
        else if (s[i] == 'G') sumg[i]++;
        else  sumb[i]++;
        if (i < n - 1) {
            sumr[i + 1] += sumr[i];
            sumg[i + 1] += sumg[i];
            sumb[i + 1] += sumb[i]; 
        }
    }
    long long ans = 0;
    for (int j = 1; j < n - 1; j++) {
        for (int i = 0; i < j; i++) {
            if (s[i] == 'R' && s[j] == 'G') { 
                ans += sumb[n-1] - sumb[j];
                if (s[2*j - i] == 'B') ans--;
            }
            else if (s[i] == 'R' && s[j] == 'B') { 
                ans += sumg[n-1] - sumg[j];
                if (s[2*j - i] == 'G') ans--;
            }
            else if (s[i] == 'G' && s[j] == 'R') { 
                ans += sumb[n-1] - sumb[j];
                if (s[2*j - i] == 'B') ans--;
            }
            else if (s[i] == 'G' && s[j] == 'B') { 
                ans += sumr[n-1] - sumr[j];
                if (s[2*j - i] == 'R') ans--;
            }
            else if (s[i] == 'B' && s[j] == 'R') { 
                ans += sumg[n-1] - sumg[j];
                if (s[2*j - i] == 'G') ans--;
            }
            else if (s[i] == 'B' && s[j] == 'G') { 
                ans += sumr[n-1] - sumr[j];
                if (s[2*j - i] == 'R') ans--;
            }
        }
    }
    cout << ans << endl; 
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,m,ans=0;
	vll d={0,1,2,3,4,5,6,7};
	cin >> n >> m;
	vvll to(n);
	rep(i,m){
		ll a,b;
		cin >> a >> b;
		a--;
		b--;
		to[a].pb(b);
		to[b].pb(a);
	}
	do{
		if(d[0]!=0) break;
		bool frag=true;
		rep(i,n-1){
			bool frag2=false;
			for(auto&& e:to[d[i]]){
				if(e==d[i+1]) frag2=true;
			}
			if(!frag2) frag=false;
		}
		if(frag) ans++;
	}while(next_permutation(d.begin(),d.begin()+n));
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define int long long

int k;

int ok[10005];

void dfs(int i, int N) {
    if (i == N + 1) {
        if (k == 1) {
            for (int j = 1; j <= N; ++j) cout << ok[j];
            exit(0);
        }
        k--;
        return;
    }
    if (i == 1) {
        for (int j = 1; j <= 9; ++j) {
            ok[i] = j;
            dfs(i + 1, N);
        }
    }
    else {
        ok[i] = ok[i - 1] - 1;
        if (ok[i] >= 0) dfs(i + 1, N);
        ok[i] = ok[i - 1];
        dfs(i + 1, N);
        ok[i] = ok[i - 1] + 1;
        if (ok[i] < 10) dfs(i + 1, N);
    }
}

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> k;
    for (int len = 1;; ++len) dfs(1, len);
    return 0;
}



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

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;
        mp[a]++;
        mp[a+1]++;
        mp[a-1]++;
    }

    int ans = -1e9;
    for(auto e : mp) ans = max(ans, e.second);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4736