akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

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

    map<ll,ll> mp;

    for(int i = 2; i <= n; i++){
        int x = 2;
        int y = i;
        while(y > 1){
            if(y%x == 0){
                y /= x;
                if(mp.find(x) != mp.end()){
                    mp[x]++;
                }else{
                    mp[x] = 1;
                }
                x--;
            }
            x++;
        }
    }

    vector<ll> t;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        t.push_back((*itr).second);
    }

    ll ans = 0;
    vector<ll> s(77,0);
    for(int i = 1; i < 77; i++){
        for(int k = 0; k < t.size(); k++){
            if(i <= t[k]){
                s[i]++;
            }
        }
    }

    if(s[4] > 1 && s[2] > 2){
        ans += (s[2]-2)*s[4]*(s[4]-1)/2;
    }
    if(s[14] > 0 && s[4] > 1){
        ans += s[14]*(s[4]-1);        
    }
    if(s[24] > 0 && s[2] > 1){
        ans += s[24]*(s[2]-1);
    }
    if(s[74] > 0){
        ans += s[74];
    }

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

Measured memory_bytes: 256
using System;

namespace Problem_A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            Console.WriteLine($"{(x - a) % b}");
        }
    }
}


Measured memory_bytes: 11092
H, W = map(int, input().split())
S = []
for h in range(H):
    S_h = list(input())
    S.append(S_h)

d = [-1, 1]
for h in range(H):
    for w in range(W):
        if S[h][w] == '#':
            ls = []
            for i in range(2):
                for j in range(2):
                    hs = h + d[i]
                    ws = w + d[j]
                    if 0 <= hs < H and 0 <= ws < W:
                        ls.append(S[hs][w])
                        ls.append(S[h][ws])
            if '#' not in ls:
                print('No')
                exit()
print('Yes')


Measured memory_bytes: 9252
import java.util.*;
public class Main {
	public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			while (true) {
				int n = sc.nextInt();
				int w = sc.nextInt();
				int d = sc.nextInt();
				if(n == 0 && w == 0 && d== 0) break;
				ArrayList<Data> list = new ArrayList<Data>();
				list.add(new Data(w, d, 0));
				for (int i = 1; i <= n; i++) {
					int p = sc.nextInt();
					int s = sc.nextInt();
					Data tmp = list.get(p - 1);
					int nw = 0;
					int nd = 0;
					int status = 0;
					for (int j = 0; j < s; j++) {
						if (status == 0) {
							nw++;
							if (nw == tmp.w) {
								status++;
							}
						} else if (status == 1) {
							nd++;
							if (nd == tmp.d) {
								status++;
							}
						} else if (status == 2) {
							nw--;
							if (nw == 0) {
								status++;
							}
						} else {
							nd--;
							if (nd == 0) {
								status = 0;
							}
						}
					}

					if (status == 0 || status == 2) {
						Data p1 = new Data(nw, tmp.d, i);
						Data p2 = new Data(tmp.w - nw, tmp.d, i);
						if (p1.d * p1.w < p2.d * p2.w) {
							list.add(p1);
							list.add(p2);
						} else {
							list.add(p2);
							list.add(p1);
						}
					} else {
						Data p1 = new Data(tmp.w, nd, i);
						Data p2 = new Data(tmp.w, tmp.d - nd, i);
						if (p1.d * p1.w < p2.d * p2.w) {
							list.add(p1);
							list.add(p2);
						} else {
							list.add(p2);
							list.add(p1);
						}
					}
					list.remove(p - 1);

				}
				Collections.sort(list, new MyComp());
				System.out.print(list.get(0).d * list.get(0).w);
				for (int i = 1; i < list.size(); i++) {
					System.out.print(" " + list.get(i).d * list.get(i).w);
				}
				System.out.println();
			}
			
	}
	
	static class Data {
		int w;
		int d;
		int t;
		Data(int a, int b, int c) {
			w = a;
			d = b;
			t = c;
		}
	}
	
	static class MyComp implements Comparator<Data> {

		@Override
		public int compare(Data o1, Data o2) {
			return o1.d*o1.w - o2.d*o2.w;
		}
		
	}
}

Measured memory_bytes: 50664
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>

using namespace std;

template<typename T>void read(T&x){x=0;int fl=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')
fl=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}x*=fl;}
template<typename T,typename...Args>inline void read(T&t,Args&...args){read(t);read(args...);}

typedef long long LL;

double L;

int main(){
    scanf("%lf", &L);
    printf("%.11f\n", L * L * L / 27);
    return 0;
}

Measured memory_bytes: 256
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;



int main() {
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << endl;
}

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

for n10000 in range(n+1):
    for n5000 in range(n - n10000 + 1):
        n1000 = n - n5000 - n10000
        money_total = n10000 * 10000 + n5000 * 5000 + n1000 * 1000
        if money_total == y:
            print(n10000, n5000, n1000)
            exit()

print(-1, -1, -1)


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

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

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    ll R;
    cin >> R;

    double res = (double)M_PI * R * 2;
    cout << res << endl;
}


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

struct StList
{
  int  m_nKey;
  StList *m_poPrev;
  StList *m_poNext;
  
  StList() :
    m_nKey(0), m_poPrev(nullptr), m_poNext(nullptr)
  { }

  StList(int nNum, StList &roHead) :
    m_nKey(nNum), m_poPrev(&roHead), m_poNext(roHead.m_poNext)
  { }

  ~StList() { }
};

void fnLinkedListSet(StList &roHead, StList &roTrail)
{
  char acCmd[80];
  int nMaxCmd, nNum;

  cin >> nMaxCmd;
  for (int i = 0; i < nMaxCmd; i++)
  {
    cin >> acCmd;
    if (acCmd[0] == 'i')
    {
      cin >> nNum;
      StList *poList = new StList(nNum, roHead);
      roHead.m_poNext->m_poPrev = poList;
      roHead.m_poNext = poList;
    }
    else if (acCmd[6] == 'F')
    {
      StList *poList = roHead.m_poNext;
      if (poList != &roTrail)
      {
        poList->m_poNext->m_poPrev = poList->m_poPrev;
        roHead.m_poNext          = poList->m_poNext;
        delete poList;
      }
    }
    else if (acCmd[6] == 'L')
    {
      StList *poList = roTrail.m_poPrev;
      if (poList != &roHead)
      {
        roTrail.m_poPrev         = poList->m_poPrev;
        poList->m_poPrev->m_poNext = poList->m_poNext;
        delete poList;
      }
    }
    else if (acCmd[0] == 'd')
    {
      cin >> nNum;
      StList *poList = roHead.m_poNext;
      while (poList != &roTrail)
      {
        if (poList->m_nKey == nNum)
        {
          poList->m_poNext->m_poPrev = poList->m_poPrev;     
          poList->m_poPrev->m_poNext = poList->m_poNext;
          delete poList;
          break;
        }
        poList = poList->m_poNext;
      }
    }
  }
}

void fnLinkedListGet(StList &roHead, StList &roTrail)
{
  StList *poList = roHead.m_poNext;
  while (poList != &roTrail)
  {
    if (poList != roHead.m_poNext) cout << " ";
    cout << poList->m_nKey;
    poList = poList->m_poNext;
    delete poList->m_poPrev;
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  StList oHead, oTrail;
  oHead.m_poNext  = &oTrail;
  oTrail.m_poPrev = &oHead;
 
  fnLinkedListSet(oHead, oTrail);
  fnLinkedListGet(oHead, oTrail);

  return 0;
}

Measured memory_bytes: 32460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int n,a,b,c,d;
  string s;
  cin>>n>>a>>b>>c>>d>>s;

  bool ok=false;
  if(c<d){
    if(c<b){
      for(int i=a;i<c-1;i++){
        if(s[i]=='#'&&s[i-1]=='#'){
          cout<<"No"<<endl;
          return 0;
        }
      }
      for(int i=b;i<d-1;i++){
        if(s[i]=='#'&&s[i-1]=='#'){
          cout<<"No"<<endl;
          return 0;
        }
      }      
    }else{
      for(int i=a;i<c-1;i++){
        if(s[i]=='#'&&s[i-1]=='#'){
          cout<<"No"<<endl;
          return 0;
        }
      }
      for(int i=b;i<d-1;i++){
        if(s[i]=='#'&&s[i-1]=='#'){
          cout<<"No"<<endl;
          return 0;
        }
      }

    }
    ok=true;
  }else{
    for(int i=a;i<c-1;i++){
      if(s[i]=='#'&&s[i-1]=='#'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    for(int i=b;i<d-1;i++){
      if(s[i]=='#'&&s[i-1]=='#'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    for(int i=b-1;i<d;i++){
      if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')
        ok=true;
    }
  }
  cout<<(ok?"Yes":"No")<<endl;
}


Measured memory_bytes: 640
from itertools import groupby

S = input()
N = len(S)

T = [len(tuple(v)) for _, v in groupby(S)]

ans = []
for i in range(0, len(T), 2):
    r = T[i]
    l = T[i + 1]

    ans += [0] * (r - 1)
    t = (r + 1) // 2 + l // 2
    ans.append(t)
    ans.append(r + l - t)
    ans += [0] * (l - 1)

print(*ans)


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

#define ll long long
#define ld long double
#define xx first
#define yy second
#define vi vector<int>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()

#define MAX 400005

ll f[MAX];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll n, c=0;
    cin >> n;

    for(ll i=1;i<=100;i++)
    {
        for(ll j=1;j<=100;j++)
        {
            for(ll k=1;k<=100;k++)
            {
                ll wh = i*i + j*j + k*k +i*j + j*k +k*i;
                if(wh<=n)
                f[wh]++;
            }
        }
    }

    for(int i=1;i<=n;i++) cout << f[i] << endl;

    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<fstream>
#include<vector>
#include<stack>

using namespace std;
#define ll long long
#define mem(i,j) memset(i,j,sizeof i)
#define up(i,j,k) for(int i=j;i<k;i++)
#define uup(i,j,k) for(int i=j;i>=k;i--)
#define mod(x) (x)%mod
#define sfi(i) scanf("%d",&i)
#define sfs(i) scanf("%s",i)
#define sfc(i) scanf("%c",&i)
#define sfl(i) scanf("%lld",&i)
#define sfd(i) scanf("%lf",&i)
#define sff(i) scanf("%f",&i)
#define wt(a) cout<<"This is:"<<a<<endl
#define sf() cout<<"This is a flag"<<endl

const int N = 1010;
const ll llinf = 0x7fffffffffffffff;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const int MAX = 5e2 + 5;

int main()
{
	int n, d, x;
	sfi(n);
	sfi(d);
	sfi(x);
	int sum = 0;
	int xx;
	up(i, 0, n)
	{
		sfi(xx);
		int a = xx;
		sum++;
		xx++;
		while(xx <= d)
		{
			sum++;
			xx += a;
		}
	}
	printf("%d\n", sum+x);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
    return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      
      int c;
      
      if(b > a){
        c = a;
       	a = b;
       	b = c;
      }
      
      int count = 0;
      
      for(int i = 1; i <= b; i++){
        if(a % i == 0 && b % i == 0)
        count++;
      }
      
      
      
      int[]d = new int[count];
      int i;
      
      for(i = 0; i < count; i++){
        if(i == 0){
          d[i] = 1;
        } else {
          for(int l = d[i-1]+1; l <= b; l++){
            if(a % l == 0 && b % l == 0){
              d[i] = l;
              break;
        	} 
          }
        }
      }
      
     
     System.out.println(d[count - k]);
      
    }
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int H, W;
char m[52][52];

void solve(){
	rep(i, H + 2){
		m[i][0] = m[i][W + 1] = '.';
	}
	rep(i, W + 2)
		m[0][i] = m[H + 1][i] = '.';
	reps(i, H){
		reps(j, W){
			if(m[i][j] == '#'){
				bool b = false;
				rep(k, 4){
					if(m[i + dx[k]][j + dy[k]] == '#')
					{
						b = true;
						break;
					}
				}
				if(!b){
					cout << "No" << endl;
					return;
				}
			}
		}
	}
	cout << "Yes" << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> H >> W;
	reps(i, H) {
		reps(j, W)
			cin >> m[i][j];
	}
		solve();
	return 0;
}


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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	ll q, h, s, d, n, a, ans;
	cin >> q >> h >> s >> d >> n;
	
	a = min(min(q * 8, h * 4), min(s * 2, d));
	ans = (n / 2) * a;
	if (n % 2) {
		ans += min(min(q * 4, h * 2), min(s, INFL));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define elif else if
#define lli long long int
#define ld long double
#define vec vector
#define forn(a) for(lli a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main(){
  IOS;
  
  int a, b; cin>>a>>b;
  
  cout<<max(a+a-1, max(b+b-1, a+b))<<endl;

  return 0;
}

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

long attack(long H, long cnt);

int main(){
    long H;
    cin >>H;
    
    long count=0;
 	count=attack(H,0);
  
    cout << count;
                 
  	return 0;
}

long attack(long H, long cnt){

  if(H<=1){
    return (cnt+1);
  }

  cnt=2*attack(H/2,cnt)+1;
  
  return cnt;
}

Measured memory_bytes: 256
A=str(input())
if int(A[0])+int(A[1])+int(A[2])+int(A[3])==7:#+++
  print('{}+{}+{}+{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])+int(A[1])+int(A[2])-int(A[3])==7:#++-
  print('{}+{}+{}-{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])+int(A[1])-int(A[2])+int(A[3])==7:#+-+
  print('{}+{}-{}+{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])+int(A[1])-int(A[2])-int(A[3])==7:#+--
  print('{}+{}-{}-{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])-int(A[1])+int(A[2])+int(A[3])==7:#-++
  print('{}-{}+{}+{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])-int(A[1])+int(A[2])-int(A[3])==7:#-+-
  print('{}-{}+{}-{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])-int(A[1])-int(A[2])+int(A[3])==7:#--+
  print('{}-{}-{}+{}=7'.format(A[0],A[1],A[2],A[3]))
elif int(A[0])-int(A[1])-int(A[2])-int(A[3])==7:#---
  print('{}-{}-{}-{}=7'.format(A[0],A[1],A[2],A[3]))

Measured memory_bytes: 3192
import math
K = int(input())
A = [int(_) for _ in input().split()]
l = r = 2
'''
if x children form groups consisting of y children each
 then z children are left
=> z=y*(x//y)
=> y*(math.ceil(z/y))<=x<y*(math.floor(z/y)+1)
'''
#necessary conditions
for a in A[::-1]:
    l = a * math.ceil(l / a)
    r = a * (math.floor(r / a) + 1) - 1
#sufficient conditions
for x in [l, r]:
    for a in A:
        x = a * (x // a)
    if x != 2:
        print(-1)
        exit()
print(l, r)


Measured memory_bytes: 14252
n, k = map(int, input().split())
arr = list(map(int, input().split()))
l = [-1]*(n+1)  # 何回目にそれぞれの頂点に到達したか
tmp = []  # 頂点の移動経路
pos = 1  # 初期位置
cnt = 0  # 移動回数
while 1:
    if l[pos] != -1:  # ある頂点に2回到達したとき
        t = cnt-l[pos]  # ループの長さ
        if k < cnt:
            print(tmp[k])
        else:  # 経路の長さより大きいとき、2回到達した頂点を始点として、最終的にループのどの頂点に到達するかを求める
            print(tmp[l[pos]+(k-cnt) % t])
        break
    l[pos] = cnt
    cnt += 1
    tmp.append(pos)
    pos = arr[pos-1]


Measured memory_bytes: 32316
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    long long N;cin >> N;
    long long ans = 0;
    long long M = sqrt(N);
    if(N == 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 1;i<=M;i++){
        if(N % i == 0){
            ans += (N/i)-1;
            if(N/((N/i)-1) != N%((N/i)-1)) ans-= (N/i)-1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        int b=scanner.nextInt();
        int c=scanner.nextInt();
        int x=scanner.nextInt();
        int y=x/50;
        int result=0;
        for(int i=0;i<=y/10;i++){
            if(i>a){
                break;
            }
            int a1=i;
            int y1=y-a1*10;
            int b1=y1/2;
            for(int j=b1;j>=0;j--){
                int b2=j;
                int c2=y1-2*b2;
                if(b2<=b&&c2<=c){
                    result++;
                }
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 24788
#include <stdio.h>
#include <vector>
 
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)

int main(void)
{
  int A,B,C,ans;

  scanf("%d %d %d",&A,&B,&C);
  
  ans = C - (A-B);
  if(ans<0) ans=0;
  
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  if ((n - 1) * (n - 2) / 2 < k) {
    cout << -1 << endl;
    return 0;
  }

  vector<pair<int,int>> v;
  for (int i = 2; i <= n; ++i) v.emplace_back(1, i);
  int rest = (n - 1) * (n - 2) / 2 - k;
  for (int i = 2; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (rest == 0) break;
      rest--;
      v.emplace_back(i, j);
    }
  }

  cout << v.size() << endl;
  for (auto&& itr : v) {
    cout << itr.first << " " << itr.second << endl;
  }
}


Measured memory_bytes: 384
# AGC 006: A – Prefix and Suffix
n = int(input())
s, t = [input() for _ in range(2)]

if s == t:
    print(len(s))
else:
    number_overlaps = 0

    for i in range(n):
        if s[i] == t[0]:
            if s[i:] in t:
                print(n * 2 - len(s[i:]))
                break
    else:
        print(n * 2)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1);
//or-> ||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

//int n;
//int ans;
//string s;
signed main(){
	IO_STREAM;
	int sum_a[3]={0};
	int sum_b[3]={0};
	int c[3][3];
	rep(i,0,3){
		rep(j,0,3){
			cin>>c[i][j];
			sum_a[i]+=c[i][j];
		}
	}
	rep(j,0,3){
		rep(i,0,3){
			sum_b[j]+=c[i][j];
		}
	}
	string ans="Yes";
	if((sum_a[0]-sum_a[1])%3) ans="No";
	if((sum_a[0]-sum_a[2])%3) ans="No";
	if((sum_a[1]-sum_a[2])%3) ans="No";
	if((sum_b[0]-sum_b[1])%3) ans="No";
	if((sum_b[0]-sum_b[2])%3) ans="No";
	if((sum_b[1]-sum_b[2])%3) ans="No";
	DBG("","","","");
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vi vn(n);
  vi vr(n);
  int i = 0;
  int cntn = 0;
  while(i<n && cntn<k) {
    if(s[i]=='o') {
      cntn++;
      vn[i] = cntn;
      i += (c+1);
    }
    else i++;
  }
  int j = n-1;
  int cntr = 0;
  while(j>=0 && cntr<k) {
    if(s[j]=='o') {
      cntr++;
      vr[j] = cntr;
      j -= (c+1);
    }
    else j--;
  }
  // rep(i,n) cout << vn[i];
  // cout << endl;
  // rep(i,n) cout << vr[i];
  // cout << endl;
  rep(i,n) if(vn[i]!=0 && vn[i]+vr[i]==k+1) cout << i+1 << endl;
  return 0;
}

Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001

typedef long long ll;
int n, a, b, c, d;

// char X[100][100];
// int dp[1000000001];

int main(void){
    cin >> n >> a >> b >> c >> d;
    int gap = abs(a-b);
    bool ans = false;
    // cout << abs(a-b) << endl;
    // cout << n-2 << endl;
    // REP(i,0,n) {
    ll i = 0;
    while (i * 2LL <= n - 1LL) { 
        ll ma = d * (n - 1 - 2 * i);
        ll mi = c * (n - 1- 2 * i);
        ll mma = abs(c-d) * i;
    
        if (mi - mma <= gap && gap <= ma + mma) ans = true;
        
        i++;
    }
    if (ans) cout << "YES" << endl;
    else cout << "NO" << endl;
    // }
    

    

}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(Math.abs(x-a)<Math.abs(x-b)?"A":"B");
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,mx = 0;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<n-1;i++)
    for(int j=i+1;j<n;j++)
	  mx = max(abs(a[i]-a[j]), mx);
  cout << mx << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int k=s.size();
	int x=0,y=0;
	if(k==1){
		cout<<"0";
		return 0;
	} 
	for(int i=0;i<k;i++){
		if(s[i]=='0')x++;
		else y++;
	}
	if(x<y)cout<<x*2;
	else cout<<y*2;
}

Measured memory_bytes: 512
N = gets.to_i
S = N.times.map{gets.chomp}
c = {}

S.each do |s|
  if c.has_key?(s)
    c[s] = c[s] + 1
  else
    c.store(s, 1)
  end
end

m = c.max{ |x, y| x[1] <=> y[1] }
res = c.select{|k,v| v == m[1]}.sort

res.each do |r|
  puts(r[0])
end

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

#define sz(x) (int)(x.size())
#define int long long

const int N = 1e5 + 2, inf = 1e18;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  

    int k;
    string s;
    cin >> k >> s;
    if(sz(s) <= k){
        cout << s;
    }else{
        cout << s.substr(0, k);
        cout << "...";
    }
}


Measured memory_bytes: 3656
# -*- coding: utf-8 -*-
"""
Created on Mon Oct  7 08:53:00 2019

@author: avina
"""

s = input()
n = len(s)
l = []
for i in range(n):
    l.append(0)
e = 'R';initial = 0
index = 1
for i in range(1,n):
    if e == s[i]:
        index+=1
    else:
        e = s[i]
        if s[i-1] == 'R':
            l[i-1] = index
        else:
            l[initial] = index
        initial = i
        index = 1;e = s[i]

l[initial] = index      
i = 0
while i < n:
    if l[i] != 0:
        a = l[i];b=l[i+1]
        l[i] = (a+b)//2;l[i+1] = (a+b)//2
        if abs(a-b)%2 !=0:
            if a>b :
                if a%2 == 0:
                    l[i+1]+=1
                else:
                    l[i] +=1
            else:
                if b%2 == 0:
                    l[i] +=1
                else:
                    l[i+1] +=1
        i+=2
    else:
        i+=1
print(*l)

Measured memory_bytes: 6408
a,b,c,d=map(int,input().split())
if b<=c or d<=a:
  print(0)
elif a<=c and d<=b:
  print(d-c)
elif c<=a and b<=d:
  print(b-a)
elif a<=c:
  print(abs(b-c))
else:
  print(abs(a-d))

Measured memory_bytes: 3060
n, m, x = map(int, input().split())
c = []
a = []
for i in range(n):
    l = list(map(int, input().split()))
    c.append(l[0])
    a.append(l[1:])

ans=float("inf")

for i in range(2 ** n):
    cost = 0
    r = [0 for _ in range(m)]
    for j in range(n):
        if (i >> j) & 1:
            cost += c[j]
            for k in range(m):
                r[k] += a[j][k]
    flag = True
    for k in r:
        if k < x:
            flag = False
    if flag:
        ans = min(ans, cost)
if ans!=float("inf"):
    print(ans)
else:
    print(-1)


Measured memory_bytes: 68436
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}


int n,k,a[1005],ma,b[1005]={};
int c[1005];
int ans=0;
string s;
vector<P> v[1005][1005];
int main() {
	cin>>n>>k;
	cin>>s;
	int co=1,p=0;
	rep(i,1,n){
		if(s[i]!=s[i-1]){
			ans+=co-1;
			p+=1;
			co=0;
		}
		++co;
	}
	ans+=co-1;
	p+=1;
	if(p!=1){
		if(p%2==1){
			int g=(p-2)/2+1;
			ans+=min(g,k)*2;
		}else{
			int g=(p-2)/2;
			if(g>=k)ans+=k*2;
			else ans+=g*2+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 24192
#include<bits/stdc++.h>
using namespace std;
long long n;
double ans,d,x;
int main()
{
    cin>>n>>d>>x;
    for(int i=n;i>=1;i--)
    {
        ans+=(d+(i-0.5)*x);
        d=((2*i+2)*d+5*x)/(2*i);
        x=(2*i+4)*x/(2*i);
    }
    printf("%.15lf",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	int A, B; cin >> A >> B;
	if (abs(A - B) % 2 == 0) cout << (A + B) / 2 << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define re return
#define ll long long
#define ull unsigned ll
#define ld long double
#define f first
#define s second
#define pi acos(-1)
#define oo (ll)1e9
#define OO 1e18
#define EPS 1e-6
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=5205;

int main()
{
    IO;
    int n,a,b;
    cin >> n >> a >> b;
    cout<<min(a,b)<<" "<<max(a+b-n,0)<<endl;
    re 0;
}

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

int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel\n";
    }else cout << "consonant\n";
}


Measured memory_bytes: 256
# ABC052B - Increment Decrement
def main():
    _, S = tuple(input() for _ in range(2))
    ans, x = [0], 0
    for i in S:
        x += 1 if i == "I" else -1
        ans += [x]
    print(max(ans))


if __name__ == "__main__":
    main()

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

int main () {
  
  int N;
  cin >> N;
  
  vector<int> a(N);
  
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  vector<int> ans(N);
  
  for (int i = N; i > 0; i--) {
    
    ans[i - 1] = a[i - 1];
    int count = 2 * i;
    
    while (count <= N) {
      
      ans[i - 1] += ans[count - 1];
      count += i;
      
    }
    
    ans[i - 1] %= 2;
    
  }
  
  int M = 0;
  
  for (int i = 0; i < N; i++) {
    if (ans[i] == 1) M++;
  }
  
  cout << M << endl;
  
  for (int i = 0; i < N; i++) {
    if (ans[i] == 1) cout << i + 1 << " ";
  }
    
  
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define pll pair<ll,ll>
#define pii pair<int,int>
#define F first
#define S second
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,k,m;
    cin>>n>>k>>m;
    int tar=m-k+1;
    int cnt[n+5]={};
    f(m){
        int x;
        cin>>x;
        cnt[x]++;
    }
    f1(n){
        if(cnt[i]>=tar){
            cout<<"Yes\n";
        }
        else{
            cout<<"No\n";
        }
    }
}


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

int main(){
  int x,n;
  cin >>x >>n;
  int num[102] = {0};
  rep(i,n){
    int p; cin >>p;
    num[p] = 1;
  }
  pair<int, int> ans(99999, -1);
  rep(i,102){
    if(num[i]==1) continue;
    int dif = abs(x-i);
    ans = min(ans, pair<int, int>(dif, i));
  }
  cout << ans.second << endl;
  return 0; 
}


Measured memory_bytes: 3592
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

extern inline char gc() {
    static char RR[23456], *S = RR + 23333, *T = RR + 23333;
    if(S == T) fread(RR, 1, 23333, stdin), S = RR;
    return *S ++;
}
inline int read() {
    int p = 0, w = 1; char c = gc();
    while(c > '9' || c < '0') { if(c == '-') w = -1; c = gc(); }
    while(c >= '0' && c <= '9') p = p * 10 + c - '0', c = gc();
    return p * w;
}

#define ri register int
#define ll long long

ll ans; int n, mx;
map <int, int> num;

int main() {
    n = read();
    for(ri i = 1; i <= n; i ++) num[read()] ++;
    for(map<int, int> :: iterator it = num.begin(); it != num.end(); it ++) {
        int p1 = it -> first, p2 = it -> second;
        if(p2 >= 4) ans = max(ans, 1ll * p1 * p1);
        if(p2 >= 2) ans = max(ans, 1ll * p1 * mx), mx = p1;
    }
    printf("%lld\n", ans);
    return 0;
}

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

#define ll long long
#define mx 100005

int ar[mx],br[mx],cr[mx];
char ch[mx];

int n,m,a,b,c,x,y;

void solve()
{
    scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
    for(int i=0; i<a; i++)
        scanf("%d",&ar[i]);
    for(int i=0; i<b; i++)
        scanf("%d",&br[i]);
    for(int i=0; i<c; i++)
        scanf("%d",&cr[i]);

    sort(ar,ar+a);
    sort(br,br+b);
    sort(cr,cr+c);
    reverse(ar,ar+a);
    reverse(br,br+b);
    reverse(cr,cr+c);
    vector<ll>v;

    ll re=0;

    for(int i=0; i<x; i++)
        v.push_back(ar[i]);
    for(int j=0; j<y; j++)
        v.push_back(br[j]);
    sort(v.begin(),v.end());
    //reverse(v.begin(),v.end());

    for(int i=0,j=0; i<x+y; i++)
    {
        if(j<c && v[i]<cr[j])
        {
            re+=cr[j++];
        }
        else re+=v[i];
    }
    cout<<re<<endl;
}

int main()
{
    int t=1;
    while(t--)
        solve();

    return 0;
}


Measured memory_bytes: 3572
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())

INF = 10**18


def main():

    N, K = in_nn()
    P = in_nl()
    C = in_nl()

    if K < N + 10:
        ans = -INF
        for i in range(N):
            score = 0
            max_score = -INF
            now = i

            for j in range(K):
                now = P[now] - 1
                score += C[now]
                max_score = max(score, max_score)
            ans = max(ans, max_score)

        print(ans)
        exit()

    else:

        ans = -INF
        for i in range(N):
            score = 0
            max_score = -INF
            now = i
            search = {now}
            move_cnt = 0

            for _ in range(N + 10):
                now = P[now] - 1
                score += C[now]
                max_score = max(score, max_score)
                move_cnt += 1

                if now in search:
                    break
                search.add(now)

            if score < 0:
                ans = max(ans, max_score)
            else:
                tk = (K % move_cnt) + move_cnt
                score = score * (K // move_cnt - 1)
                max_score = score
                now = i
                for x in range(tk):
                    now = P[now] - 1
                    score += C[now]
                    max_score = max(score, max_score)
                ans = max(ans, max_score)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 129560
S = input()
ans = 0
for i in range(len(S)-2)[::-1]:
    if i % 2 == 0:
        SL = S[:(i//2+1)]
        SR = S[(i//2+1):i//2+1+i//2+1]
        # print(SL, SR)
        if SL == SR:
            print((i//2+1)*2)
            exit()

Measured memory_bytes: 3060
#x軸の選び方がm*(m-1)/2,y軸がn*(n-1)/2、よって長方形の面積計算はO(m^2*n^2)で当然のTLE。
#サンプル１を例にして考える。
#まずx軸の辺は2,1,3の3通り(m*(m-1)/2=3)、同様にy軸は2,3,5。
#ans=2*2+2*3+2*5+1*2+1*3+1*5+3*2+3*3+3*5=60
#上記の式はans=(2+1+3)*(2+3+5)=60と変形できることに気付く。これでO(m|n^2)まで計算量を落とせる。
#ただし、m<=10**5なので、まだTLE。ここでm*(m-1)/2通りの各辺の長さを効率的に求めることを考える。
#m0,m1,m2がソートされていたとして、3通りの辺はm1-m0,m2-m0,m2-m1。
#ここで各点が加算に使われる場合と減算に使われる場合に法則があると気付く。
#具体的に長さNの数列において、点iが加算に使われる回数はi回,減算に使われる回数は(N-i-1)回
#つまりans+=A[i]*i-A[i]*(N-i-1)としてi=0~N-1までの総和を取ればよいことが分かる。
#これはO(N)なので、全体としてO(N+N)=O(N)で答えを求められると思われる。

MOD=10**9+7

N,M=map(int,input().split())
X=[int(x) for x in input().split()]
Y=[int(y) for y in input().split()]

#Y軸に平行な線分の集合の総和を求める
sumX=0
for i in range(N):
  sumX+=(X[i]*i-X[i]*(N-i-1))%MOD
  sumX%=MOD
  
#X軸に平行な線分の集合の総和を求める
sumY=0
for i in range(M):
  sumY+=(Y[i]*i-Y[i]*(M-i-1))%MOD
  sumY%=MOD
  
print((sumX*sumY)%MOD)



Measured memory_bytes: 19472
using System;

namespace ABC102A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            if (a % 2 == 0)
                Console.WriteLine(a);
            else
                Console.WriteLine(a * 2);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define MAX 21

int main() {
    int N;
    int A[MAX], B[MAX], C[MAX];

    cin >> N;
    for (int i=1; i<=N; i++) cin >> A[i];
    for (int i=1; i<=N; i++) cin >> B[i];
    for (int i=1; i<=N-1; i++) cin >> C[i];

    int a_ = -1;
    int ans = 0;
    for (int i=1; i<=N; i++) {
        int a = A[i];
        ans += B[a];
        if (a_+1 == a) ans += C[a_];
        a_ = a;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = str(input())
num = N[-1]
num = int(num)
 
if num == 3:
  print('bon')
elif num == 0:
  print('pon')
elif num == 1:
  print('pon')
elif num == 6:
  print('pon')
elif num == 8:
  print('pon')
elif num ==2:
  print('hon')
elif num == 4:
  print('hon')
elif num==5:
  print('hon')
elif num==7:
  print('hon')
elif num==9:
  print('hon')

Measured memory_bytes: 9208
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

pair<int, int> solve(const string &s) {
  for (int i = 0; i < s.size() - 1; ++i) {
    if (s[i] == s[i + 1]) {
      return make_pair(i + 1, i + 2);
    }
  }

  for (int i = 0; i < s.size() - 2; ++i) {
    if (s[i] == s[i + 2]) {
      return make_pair(i + 1, i + 3);
    }
  }

  return make_pair(-1, -1);
}

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

  auto ans = solve(s);

  cout << ans.first << ' ' << ans.second << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner stdId = new Scanner(System.in);
        int a = stdId.nextInt();
        int b = stdId.nextInt();
        int c = stdId.nextInt();

        String j = "No";

        if (a < b && b < c) {
            j = "Yes";
        }

        System.out.println(j);

    }
}

Measured memory_bytes: 26316
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
using P=pair<int,int>;


ll i,j,k,ans;
vector<ll> size;
vector<ll> island;

//Union find(begin)
void makeTree(ll x,vector<ll>& parents) {
    parents[x] = x;  // the parent of x is x
    size[x] = 1;
}
ll findRoot(ll x,vector<ll>& parents) {
    if (x != parents[x]) {
        parents[x] = findRoot(parents[x],parents);
    }
    return parents[x];
}
bool isSame(ll x,ll y,vector<ll>& parents) { return findRoot(x,parents) == findRoot(y,parents); }
bool unite(ll x,ll y,vector<ll>& parents) {
    x = findRoot(x,parents);
    y = findRoot(y,parents);
    if (x == y) return false;
    if (size[x] > size[y]) {
        parents[y] = x;
        size[x] += size[y];
    } else {
        parents[x] = y;
        size[y] += size[x];
    }
    return true;
}

ll treeSize(ll x,vector<ll>& parents) { return size[findRoot(x,parents)]; }
//Union find(end)

int main(){
    ll n,m;cin>>n>>m;
    vector<ll> ans(m);//答え
    vector<P> p(m);//橋の順番を記憶する
    
    size.assign(n,1);
    island.resize(n);

    for(i=0;i<n;i++){
        makeTree(i,island);
    }

    for(i=0;i<m;i++){//島をつなぐデータを保存
        ll a,b;cin>>a>>b;
        a--;b--;
        p[i]=make_pair(a,b);
    }

    ll number=n*(n-1)/2;
    ans[m-1]=number;
    for(i=m-1;i>=1;i--){
        if(!isSame(p[i].first,p[i].second,island)){//崩落する橋
            number-=treeSize(p[i].first,island)*treeSize(p[i].second,island);
            unite(p[i].first,p[i].second,island);
        }
        ans[i-1]=number;
    }
    
    for(i=0;i<m;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

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

using namespace std;

int n;


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

    int sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n;
    cin>>n;
    vector<pair<ll,ll> > neighbors[n];
    ll d[n];
    rep(i,n)d[i]=1LL<<60;
    rep(i,n-1){
        ll ts,tt,tw;
        cin>>ts>>tt>>tw;
        ts--;tt--;
        neighbors[ts].push_back(make_pair(tt,tw));
        neighbors[tt].push_back(make_pair(ts,tw));
    }
    DEBUG{printf("graph end\n");}
    ll q,k;
    cin>>q>>k;
    k--;
    d[k]=0;
    ll query[q][2];
    rep(i,q){
        cin>>query[i][0]>>query[i][1];
    }
    priority_queue<ll> pq;
    pq.push(k);
    DEBUG{printf("dijkstra start\n");}
    while(!pq.empty()){
        ll now = pq.top();
        pq.pop();
        for(auto x:neighbors[now]){
            if(d[x.first]>d[now]+x.second){
                pq.push(x.first);
                d[x.first]=d[now]+x.second;
                d[x.first]=d[x.first];
            }
        }
    }
    rep(i,q){
        cout << (d[query[i][0]-1]+d[query[i][1]-1]) << endl;
    }
    return 0;
}


Measured memory_bytes: 12528