akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

string N;
i64 memo[20][300][2];
i64 dp(int i, bool tight, i64 sum) {
    if (i >= N.size()) return sum;
    auto &ret = memo[i][sum][tight];
    if (~ret) return ret;

    ret = 0;
    for (int d = tight ? N[i]-'0' : 9; d >= 0; --d) {
        chmax(ret, dp(i+1, tight & (d == N[i] - '0'), sum + d));
    }
    return ret;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    read(N);
    memset(memo, -1, sizeof(memo));
    print(dp(0, true, 0));

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
int main(){

  int N;
  cin>>N;
  vector<string>W(N);
  for(int i=0;i<=N-1;i++){
  
    cin>>W[i];
    for(int j=0;j<=i-1;j++){
    
      if(W[i]==W[j]){
      
        cout<<"No";
        return 0;
      }
    }
  }
  for(int i=0;i<=N-2;i++){
  
    if(W[i][W[i].length()-1]!=W[i+1][0]){
    
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 3560
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const int INF = 1 << 30;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    rep(i, 0, A) {
        cin >> a[i];
    }
    rep(i, 0, B) {
        cin >> b[i];
    }
    vector<int> X(M), Y(M), C(M);
    rep(i, 0, M) {
        cin >> X[i] >> Y[i] >> C[i];
        --X[i], --Y[i];
    }
    vector<vector<int>> waribiki(101010);
    rep(i, 0, M) {
        waribiki[X[i]].push_back(b[Y[i]] - C[i]);
    }
    rep(i, 0, 101010) {
        sort(all(waribiki[i]));
    }
    sort(all(b));
    int ans = INF;
    rep(i, 0, A) {
        chmin(ans, a[i] + b[0]);
        if (waribiki[i].size()) {
            chmin(ans, a[i] + waribiki[i][0]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <map>
#include <cstring>
using namespace std;
map <string,int> m;
int main() {
	
	int n;
	cin>>n;
	
	while(n--)
	{
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<endl;
	cout<<"WA x "<<m["WA"]<<endl;
	cout<<"TLE x "<<m["TLE"]<<endl;
	cout<<"RE x "<<m["RE"]<<endl;
	
	return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define N 300005
#define vi vector<int>
#define all(v) v.begin(),v.end()

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   double r;
   cin>>r;
   cout<<2*pi*r<<endl;
}


Measured memory_bytes: 3796
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
    return 0;
}


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

int main() {

  string s;
  cin >> s;
  
  string b = "ABC";
  string r = "ARC";

 if(s == b) {
   cout << "ARC" << endl;
 }
  
 if(s == r) {
   cout << "ABC" << endl;
 }
}


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

typedef long long ll;
ll n, M = 1e9 + 7;
map<ll, ll> s;

ll f(ll p) {
	if (p < 2) return p + 1;
	if (s[p]) return s[p];
	return s[p] = (f(p / 2) + f((p - 2) / 2) + f((p - 1) / 2)) % M;
}

int main()
{
	cin >> n;
    cout << f(n) << endl;
    return 0;
}

Measured memory_bytes: 256
str=input()
strl=len(str)
k=u=p=c=0

for i in range(strl):
    a=str[i]
    if a=="K":
        k+=1
    elif a=="U":
        u+=1
    elif a=="P":
        p+=1
    elif a=="C":
        c+=1
    
print(min(k,u,p,c))


Measured memory_bytes: 5560
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const double PI=3.14159265358979323846;

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

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

		if(H == 0 && W == 0)
			break;

		REP(j, H){
			REP(i, W){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}




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


int main() {
	int a, b, c, k, ans = 0;

	cin >> a >> b >> c >> k;

	if (a >= k && b == 0 && c == 0)
	{
		cout << k << endl;
		return 0;
	}

	while (1)
	{
		if (k == 0)
		{
			break;
		}

		if (a > 0)
		{
			ans++;
			a--;

			k--;
			continue;
		}
		if (b > 0)
		{
			b--;
			k--;
			continue;
		}
		if (c > 0)
		{
			ans--;
			c--;
			k--;
			continue;
		}

		
	}

	cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>


int main()
{

    int N, tmp;
    char c;
    std::cin >> N;
    std::pair<char, int> c1[N], c2[N];

    for (int i = 0; i < N; i++) {
        std::cin >> c >> tmp;
        c1[i] = c2[i] = std::make_pair(c, tmp);
    }

    for (int i = 0; i < N; i++) {
        for (int j = N-1; j > i; j--) {
            if (c1[j].second < c1[j-1].second) std::swap(c1[j], c1[j-1]);
        }
    }

    int mini;
    for (int i = 0; i < N; i++) {
        mini = i;
        for (int j = i; j < N; j++) {
            if (c2[j].second < c2[mini].second) mini = j;
        }
        std::swap(c2[mini], c2[i]);
    }

    for (int i = 0; i < N; i++) {
        if (i > 0) std::cout << " ";
        std::cout << c1[i].first << c1[i].second;
    }
    std::cout << std::endl;
    std::cout << "Stable" << std::endl;

    bool isEqual = true;

    for (int i = 0; i < N; i++) {
        if (c2[i].first != c1[i].first || c2[i].second != c1[i].second) isEqual = false;
        if (i > 0) std::cout << " ";
        std::cout << c2[i].first << c2[i].second;
    }
    std::cout << std::endl;
    (isEqual) ? std::cout << "Stable" << std::endl : std::cout<< "Not stable" << std::endl;

    return 0;
}



Measured memory_bytes: 3088
#include <stdio.h>

int main(){
    int i, j, w, h, flag = 0;
    
    while(1){
        scanf("%d%d", &h, &w);
        if(w == 0 && h == 0) break;
        for(i = 0; i < h; i++){
            if(i % 2 == 0 || i == 0)  flag = 0;
            for(j = 0; j < w; j++){
                if(flag == 0){
                    printf("#");
                    flag = 1;
                }
                else {
                    printf(".");
                    flag = 0;
                }
            }
            printf("\n");
            flag = 1;
        }
        printf("\n");
    }
    
    return 0;
}


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

int n;
long int l[101];

int solve(){
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i] && 0<((l[i]+l[j]+l[k])-2*max(max(l[i],l[j]),l[k])))
                    ans++;
            }
        }
    }
    return ans;
}

int main(void){
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> l[i];
    printf("%d\n",solve());
    return 0;
}

Measured memory_bytes: 3764
#include "bits/stdc++.h"
using namespace std;


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

	string pattern;
	if (s[0] == '0') {
		if (s[n - 1] == '0') {
			pattern = "00";
		} else {
			pattern = "01";
		}
	} else {
		if (s[n - 1] == '0') {
			pattern = "10";
		} else {
			pattern = "11";
		}
	}

	vector<int> s0;
	vector<int> s1;
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			if (s[i] == '0') {
				s0.push_back(1);
			} else {
				s1.push_back(1);
			}
		} else {
			if (s[i] == s[i - 1] && s[i] == '0') {
				s0.at(s0.size() - 1) += 1;
			} else if (s[i] == s[i - 1] && s[i] == '1') {
				s1.at(s1.size() - 1) += 1;
			} else if (s[i] != s[i - 1] && s[i] == '0') {
				s0.push_back(1);
			} else {
				s1.push_back(1);
			}
		}
	}

	vector<int> s0new;
	vector<int> s1new;
	if (pattern == "00") {
		s0new = s0;
		s1new.push_back(0);
		for (auto s1_ele : s1) {
			s1new.push_back(s1_ele);
		}
		s1new.push_back(0);
	} else if (pattern == "01") {
		s0new = s0;
		s1new.push_back(0);
		for (auto s1_ele : s1) {
			s1new.push_back(s1_ele);
		}
	}else if (pattern == "10") {
		s0new = s0;
		for (auto s1_ele : s1) {
			s1new.push_back(s1_ele);
		}
		s1new.push_back(0);
	} else if (pattern == "11") {
		s0new = s0;
		s1new = s1;
	}

	int ns0new = s0new.size();
	int maxi = 0;
	if (k >= ns0new) {
		maxi = n;
	} else {
		for (int i = 0; i <= ns0new - k; i++) {
			int temp = 0;
			for (int j = i; j < i + k; j++) {
				temp += s1new[j] + s0new[j];
				if (j == i + k - 1) {
					temp += s1new[j + 1];
				}
			}
			maxi = max(maxi, temp);
		}
	}

	cout << maxi << endl;
}

Measured memory_bytes: 1468
#include <bits/stdc++.h>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18 

int main(){
    int n ;
    cin >> n ;
    set<string> st ; 
    rep(i, n){
        string s ;
        cin >> s ;
        st.insert(s) ;
    }
    cout << st.size() << endl ;
}

Measured memory_bytes: 19064
#include <cstdio>
#include <cmath>

#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main() {
	int n;
	vector<int> v, c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		v.push_back(t);
	
	}
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		c.push_back(t);
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] - c[i] >= 0)
			res += v[i] - c[i];
	}
	cout << res;
}


Measured memory_bytes: 256
def main(input = STDIN)
  while (str = input.gets)
    output = []
    str = str.chomp.split(//)
    while str.size != 0
      char = str.shift
      if char == "@"
        output << "".rjust(str.shift.to_i, str.shift)
      else
        output << char
      end
    end
    puts output.join
  end
end
main

Measured memory_bytes: 6088
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int[] a, int[] b) {
    long sum = 0;
    for (int i = cast(int)a.length - 1; i >= 0; i--) {
        long ai = sum + a[i];

/*
        if (ai > b[i]) {
            long m = ai % b[i];
            if (m > 0) {
                sum += b[i] - m;
            }
        }
        else {
            sum += b[i] - ai;
        }
        */

        long x = b[i] - ai % b[i];
        if (x < b[i])
            sum += x;
    }
    return sum;
}

void main() {
    int n = readint;
    int[] a, b;
    for (int i = 0; i < n; i++) {
        auto ab = readints;
        a ~= ab[0];
        b ~= ab[1];
    }
    writeln(calc(a, b));
}


Measured memory_bytes: 4348
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.abs;
import static java.lang.Math.min;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		long n = scanLong(), a = scanLong(), b = scanLong();
		out.print(((a + b) % 2 == 0 ? abs(b - a) : min(a + b - 1, 2 * n - a - b + 1)) / 2);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
#define ull unsigned long long
using namespace std;


int main() {
	ull X = 0;
	ull Y = 0;

	cin >> X >> Y;

	cout << (int)(log2l(Y / X) + 1 )<< endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    struct Connection{
        public List<long> list;
        public Connection(int index) {
            list = new List<long>();
        }
    }

    static void Main()
    {
        var nm = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var N = nm[0];
        var M = nm[1];
        var connection = new Connection[N];
        for (int i = 0; i < N; ++i) connection[i] = new Connection(i);
        for (int i=0;i<M;++i)
        {
            var a = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
            connection[a[0] - 1].list.Add(a[1] - 1);
            connection[a[1] - 1].list.Add(a[0] - 1);
        }

        var ans = "IMPOSSIBLE";
        foreach (var l in connection[0].list)
        {
            foreach (var m in connection[l].list) if (m == N - 1) ans = "POSSIBLE";
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 42112
function main(input) {
  const input_array = input.split('\n');
  var mochis = [];
  const mochi_count = input_array[0];

  for(i=0; i<mochi_count;i++){
    mochis[i] = input_array[i+1]
  }

  console.log(Array.from(new Set(mochis)).length);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	string s;
	cin >> s;
	if(s[0] == s[s.size()-1]){
		if(s.size()%2 == 1){
			puts("Second");
		}
		else puts("First");
	}
	else {
		if(s.size()%2 == 0){
			puts("Second");
		}
		else puts("First");
	}
}



Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
const int N=1e5+20;
int n,x,f[N],ans;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&x);
		f[x]++;
	}

	for(int i=1;i<N;i++)
	{
		f[i]+=f[i-1];
		if(f[i]==n/2) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

const int need[]={0,2,5,5,4,5,6,3,7,6};

int main(){

    int N,M; cin>>N>>M;
    vector<int> a(M);
    vector<char> b(M);
    for (int i = 0; i < M; ++i) {
        cin>>a[i];
        b[i]='0'+(char)a[i];
    }

    vector<string> dp(N+10,""); //dp[i]はi本で作れる最大の数

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            string cmp=dp[i]+b[j];
            int match=i+need[a[j]];
            if(match>N) continue;
            if(i!=0&&dp[i]=="") continue;
            if(cmp.length()>dp[match].length()||
                    (cmp.length()==dp[match].length()&&cmp>dp[match])){
                dp[match]=cmp;
            }
        }
    }

    cout<<dp[N]<<endl;

    return 0;
}

Measured memory_bytes: 43648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (b), _a = (a); i >= _a; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = (n) - 1; i >= 0; i--)
#define debug(x) cout<<"debug : "<<x<<endl
#define debug2(x,y) cout<<"debug : "<<x<<" | "<<y<<endl
#define debug3(x,y,z) cout<<"debug : "<<x<<" | "<<y<<" | "<<z<<endl
#define debug4(x,y,z,w) cout<<"debug : "<<x<<" | "<<y<<" | "<<z<<" | "<<w<<endl
#define all(ar) ar.begin(), ar.end()
#define rall(ar) ar.rbegin(), ar.rend()
#define sz(x) ((long long)x.size())
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define mp make_pair
#define ff first
#define ss second
#define M 1000000007          // 1e9+7
#define INF 10000000000       // 1e9
 
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<int> vint;
typedef vector<string> vs;
typedef vector<vi> vvi;
 
bool cus(pair<int,int> a, pair<int,int> b){
    if(a.ff<b.ff)
        return true;
    if(a.ff>b.ff)
        return false;
    return a.ss<b.ss;
}
 
ll gcd(ll a, ll b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}

void solve(){
  ll n;
  cin >> n;
  vi a(n);
  vi b(n);
  vi fqa(n+1, 0);
  vi fqb(n+1, 0);
  rep(i, n){
    cin >> a[i];
  }
  rep(i, n){
    cin >> b[i];
  }
  reverse(b.begin(), b.end());

  ll le= -1, re=-2, c;
  rep(i, n){
    if(a[i] == b[i]){
      le = i;
      c = a[i];
      break;
    }
  }

  repr(i, n){
    if(a[i] == b[i] && a[i] == c){
      re = i;
      break;
    }
  }

  rep(i, n){
    if(a[i] != c && b[i] != c && le <=re){
      swap(b[i], b[le]);
      le++;
    }
  }

  if(le <= re) cout << "No" << endl;
  else{
    cout << "Yes" << endl;
    rep(i, n) cout << b[i] << " ";
    cout << endl;
  }

  }

int main () 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<setprecision(11);
 
    //ll t = 1;
    //cin>>t;
    //while(t--)
        solve();
 
    return 0;
}
  

Measured memory_bytes: 9544
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <stack>
#include <deque>
#include <queue>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
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 main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; string s;
	cin >> n >> s;
	deque<char> Q;
	for (int i = 0; i < n; i++) {
		if (Q.size() && Q.back() == '(' && s[i] == ')') Q.pop_back();
		else Q.push_back(s[i]);
	}
	int countL = 0, countR = 0;
	while (Q.size()) {
		char now = Q.front();
		Q.pop_front();
		if (now == ')') countL++;
		else countR++;
	}
	while (countL--) cout << '(';
	cout << s;
	while (countR--) cout << ')';
}

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

using namespace std;

int main()
{
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		int a[101][101]={0}, m, p;
		for(int i = 1; i <= n; i++){
			cin >> m;
			for(int j = 0; j < m; j++){
				cin >> p;
				a[i][p] = 1;
			}
		}
		int b[201], k, ans=0;
		cin >> k;
		for(int l = 0; l < k; l++){
			cin >> b[l];
		}
		for(int s = 1; s <= n; s++){
			for(int t = 0; t < k; t++){
				if(a[s][b[t]] != 1) break;
				if(t == k-1){
					if(ans == 0) ans = s;
					else ans = -1;
				}
			}
		}
		if(ans == 0) ans = -1;
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> res(n, 0);
  for(int i=0; i<q; i++){
    int player;
    cin >> player;
    res[player-1]++;
  }
  for(int i=0; i<n; i++){
    if((k - (q - res[i])) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
ll N;
vi memo;
vector<vi> F;
vector<vi> P1;

ll rec(ll i){
    if(i==10){
        ll ans=0;
        REP(j,N){
            ll count=0;
            REP(k,10){
                if(F[j][k]==1&&memo[k]==1)count++;
            }
            ans+=P1[j][count];
        }
        return ans;
    }
    memo[i]=1;
    ll l1=rec(i+1);
    memo[i]=0;
    ll r1;
    if(i==9){
        bool ok=false;
        REP(i,10)if(memo[i]!=0){
            ok=true;
            break;
        }
        if (!ok)r1=-INF;
        else r1=rec(i+1);
    }else{
        r1=rec(i+1);
    }
    return max(l1,r1);
}

int main() {
    cin>>N;
    F=vector<vi>(N,vi(10));
    REP(i,N)REP(j,10)cin>>F[i][j];
    P1=vector<vi>(N,vi(11));
    REP(i,N)REP(j,11)cin>>P1[i][j];
    memo=vi(10,0);
    cout<<rec(0)<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>

using namespace std;
int main(void) {
  string s;
  int ans=0;
  cin>>s;
  for(int i=0; i<3; i++) {
    if(s[i]=='o') ans++;
  }
  cout<<700+ans*100<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n,m;
  int a[m];
  int i,sum,play;
  
  scanf("%d %d",&n,&m);
  i = 0;
  sum = 0;
  while(i<m){
    scanf("%d",&a[i]);
    sum += a[i];
    i++;
  }
  
  if(sum>n){
    printf("-1");
  }
  else{
    play = n - sum;
    printf("%d",play);
  }
  
  return 0;
}

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

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	long long A,B,N;
	scanf("%lld %lld %lld",&A,&B,&N);
	
	if ( B>N){
		printf("%lld",A*N/B);
		return 0;
	}
	
	if(B<=N){
		printf("%lld",A*(B-1)/B );
		return 0;
	}
}

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

using namespace std;

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

    vector<vector<int>> G(n);
    for(int i=0; i<n-1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> c(n);
    for(auto &x: c) cin >> x;
    sort(c.rbegin(), c.rend());

    vector<int> d(n, -1);

    auto dfs = [&] (auto dfs, int cur, int &idx) -> void {
        for(auto v: G[cur]) {
            if(d[v] != -1) continue;
            d[v] = c[idx++];
            dfs(dfs, v, idx);
        }
        return;
    };

    int idx = 1;
    d[0] = c[0];
    dfs(dfs, 0, idx);

    cout << accumulate(d.begin()+1, d.end(), 0LL) << endl;
    for(auto &x: d) cout << x << ' ';
    cout << endl;
}


Measured memory_bytes: 1280
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    StringBuilder sb = new StringBuilder(sc.next());
    for(int i=0; i<sb.length(); i++){
    	sb.setCharAt(i, 'x');
    }
    System.out.println(sb.toString());
  }
}

    
    


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

int main()
{
  int n,i;cin>>n;
  static double x[100],a[100],y;

  for(i=0;i<n;i++)cin>>x[i];
  for(i=0;i<n;i++)cin>>y,a[i]=abs(x[i]-y);

  static double p1,p2,p3,p4;
  for(i=0;i<n;i++) p1+=a[i],p2+=a[i]*a[i],p3+=a[i]*a[i]*a[i],p4=p4<a[i]?a[i]:p4;
  p2=sqrt(p2);
  p3=cbrt(p3);
  cout<<fixed<<p1<<endl<<p2<<endl<<p3<<endl<<p4<<endl;
  return 0;
}

Measured memory_bytes: 3464
from collections import defaultdict

memo = {}
def dfs(i, w, item_list, W):
    if i >= len(item_list):
        return 0

    if (i, w) in memo:
        return memo[(i, w)]

    ans = 0
    # use
    new_w = w + item_list[i][1]
    if new_w <= W:
        ans = max(ans, dfs(i + 1, new_w, item_list, W) + item_list[i][0])

    # not use
    ans = max(ans, dfs(i + 1, w, item_list, W))

    memo[(i, w)] = ans
    return ans


def main():
    N, W = map(int, input().split())
    item_list = []
    for _ in range(N):
        v, w = map(int, input().split())
        item_list.append((v, w))

    print(dfs(0, 0, item_list, W))

if __name__ == '__main__':
    main()

Measured memory_bytes: 136244
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)x.size())
using pii = pair<int, int>;
using vvi = vector<vector<int>>;
using vi  = vector<int>;
constexpr int INF = 1001001001001001001LL;

// ret: {ord, low}
pair<vi, vi> ord_lowlink(vvi &g, vector<pii> *bridge = nullptr, vi *artics = nullptr) {
    int N = sz(g);
    vector<bool> vis(N, false);
    vi ord(N), low(N);
    int k = 0;
    auto dfs = [&](auto f, int v, int p) -> void {
        vis[v] = true;
        ord[v] = low[v] = k++;
        int cnt = 0;
        bool is_artic = false;
        for (int w : g[v]) {
            if (!vis[w]) {
                cnt++;
                f(f, w, v);
                low[v] = min(low[v], low[w]);
                if (p != -1 && ord[v] <= low[w]) is_artic = true;
                if (bridge && ord[v] < low[w]) bridge->push_back({v, w});
            } else if (w != p) {
                low[v] = min(low[v], ord[w]);
            }
        }
        if (p == -1 && cnt > 1) is_artic = true;
        if (is_artic && artics) artics->push_back(v);
    };
    dfs(dfs, 0, -1);
    return {ord, low};
}

signed main() {
    int V, E;
    cin >> V >> E;
    vvi G(V);
    rep(i, 0, E) {
        int vs, vt;
        cin >> vs >> vt;
        G[vs].push_back(vt);
        G[vt].push_back(vs);
    }
    vector<pii> ans;
    ord_lowlink(G, &ans, nullptr);
    for (pii &p : ans) {
        if (p.first > p.second) swap(p.first, p.second);
    }
    sort(all(ans));
    for (pii x : ans) cout << x.first << " " << x.second << endl;
}



Measured memory_bytes: 5836
import java.util.*;
public class Main {
   
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int L = sc.nextInt();
        String[] arr = new String[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.next();
        }

        Arrays.sort(arr);


         String rslt = "";
        for(int i = 0; i < arr.length; i++) {
            rslt += arr[i];
        } 
        System.out.println(rslt);
    }
}	

Measured memory_bytes: 23892
#include <stdio.h>

int A,B,C;
int ok=0;

int main(){
	
	scanf("%d %d %d",&A,&B,&C);
if(A==7&&B==5&&C==5)ok=1;
else if(A==5&&B==7&&C==5)ok=1;
else if(A==5&&B==5&&C==7)ok=1;
	
	if(ok==0)printf("NO\n");
	else printf("YES\n");
return 0;
}

Measured memory_bytes: 128
#ifdef ONPC
    # define _GLIBCXX_DEBUG
#endif
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <unordered_set>
#include <complex>
#include <unordered_map>
#include <bitset>
#include <ctime>
#include <cassert>
#include <random>
#include <iomanip>

#ifdef ONPC
    #define deb(a) cerr << "      " << #a << " = " << a << endl;
#else
    #define deb(a)
#endif

#define sz(a) (a).size()

using namespace std;
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnd(time(0));

typedef long long ll;
typedef long double ld;

const ll MOD = 1e9 + 7;

vector<int> c;
vector<ll> dp, dp2;

int solve()
{
    int n;
    if (!(cin >> n))
        return 1;
    c.assign(n, 0);
    for (int i = 0; i < n; i++)
        cin >> c[i];
    dp.assign(n, 0);
    dp2 = dp;
    dp[0] = dp2[0] = 1;
    map<int, int> q;
    q[c[0]] = 0;
    for (int i = 1; i < n; i++)
    {
        dp2[i] = dp2[i - 1];
        if (q.count(c[i]) && q[c[i]] != i - 1)
        {
            dp2[i] = (dp2[i] + dp2[q[c[i]]]) % MOD;
        }
        q[c[i]] = i;
    }
    cout << dp2[n - 1] << endl;
    return 0;
}

int32_t main()
{
    #ifdef ONPC
        freopen("in.txt", "r", stdin);
    #endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1e9;
    //cin >> T;
    while (T--)
    {
        if (solve())
            break;
        #ifdef ONPC
            cout << "\n__________________________" << endl;
        #endif
    }
    #ifdef ONPC
        cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
    #endif
    return 0;
}



Measured memory_bytes: 13568
A, B, C, X, Y = map(int, input().split())

ans = 10**8

if(X>Y):
    if(A*X+B*Y>Y*C*2+(X-Y)*A):
        ans = (Y*C*2+(X-Y)*A)
    else:
        ans = (A*X+B*Y)
else:
    if(A*X+B*Y>X*C*2+(Y-X)*B):
        ans = (X*C*2+(Y-X)*B)
    else:
        ans = (A*X+B*Y)
    
ans = min(ans, max(X, Y)*C*2)
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
 
int main(void)
{
        int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x>=r&&x+r<=W&&y>=r&&y+r<=H){
        printf("Yes\n");
    }
else{
        printf("No\n");
    }
    return 0;
}

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

vector<pair<int,int>> dir = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h, w, k;
	cin >> h >> w >> k;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	--x1; --y1; --x2; --y2;
	vector<string> grid(h);
	for (int i = 0; i < h; ++i)
		cin >> grid[i];
	auto valid = [&](const pair<int, int>& p){ return p.first >= 0 && p.first < h && p.second >= 0 && p.second < w; };
	
	vector<vector<int>> dist(h, vector<int>(w, 1e9));
	auto bfs = [&](){
		queue<pair<int, int>> q;
		vector<vector<bool>> vis(h, vector<bool>(w));
		q.emplace(x1, y1);
		dist[x1][y1] = 0;
		vis[x1][y1] = 1;
		while (!q.empty()){
			auto u = q.front(); q.pop();
			for (int j = 0; j < 4; ++j){
				for (int i = 1; i <= k; ++i){
					int nr = u.first + i * dir[j].first;
					int nc = u.second + i * dir[j].second;
					if (!valid({nr, nc})) continue;
					if (grid[nr][nc] != '.' || dist[nr][nc] <= dist[u.first][u.second]) break;
					if (vis[nr][nc]) continue;
					dist[nr][nc] = dist[u.first][u.second] + 1;
					vis[nr][nc] = 1;
					q.emplace(nr, nc);
				}
			}
		}
		return (dist[x2][y2] >= (int) 1e9 ? -1 : dist[x2][y2]);
	};
	cout << bfs() << '\n';
}


Measured memory_bytes: 12152
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s; cin >> s;
  s.erase(4, 1); s.erase(6, 1);
  int n = stoi(s);
  if(n <= 20190430) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  
  return 0;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2150

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

#define PRIME_MAX 200000

using namespace std;


int matsuzaki(int n, int p, vector<int> &prime_list)
{
	vector<int> m_list;

	int border=0;
	rep(i,prime_list.size()){
		if(prime_list[i] > n){border=i; break; }
	}

	int tmp;
	REP(i,border,border+101)
	{
		tmp = prime_list[i] + prime_list[i];
		m_list.push_back(tmp);
		REP(j,i+1,border+101)
		{
			tmp = prime_list[i] + prime_list[j];
			if(i != j){ m_list.push_back(tmp); }
		}
	}

	sort(ALL(m_list));

	return m_list[p-1];	
}

int main()
{
	int N,P;

	bool is_prime[PRIME_MAX];

	is_prime[0] = false;
	is_prime[1] = false;
	REP(i,2,PRIME_MAX) is_prime[i] = true;
	REP(i,2,PRIME_MAX) {
		if (is_prime[i]) {
				for (int j=i+i; j<PRIME_MAX; j+=i) is_prime[j] = false;
		}
	}

	vector<int> prime_list;
	rep(i,PRIME_MAX){ 
		if(is_prime[i]){ prime_list.push_back(i);}
	}

	while(cin >> N >> P)
	{
		if(N == -1 && P == -1){ break; }
		cout << matsuzaki(N,P,prime_list) << endl;
	}
	return 0;
}

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

string ope[8] = {"+++", "++-", "+-+", "+--", "-++", "-+-", "--+", "---"};

int main() {
    char abcd[4];
    cin >> abcd;

    int a, b, c, d;
    a = abcd[0] - '0';
    b = abcd[1] - '0';
    c = abcd[2] - '0';
    d = abcd[3] - '0';

    int ans;
    for (int i = 0; i < 8; i++) {
        ans = a;
        if (ope[i][0] == '+') {
            ans += b;
        } else {
            ans -= b;
        }
        if (ope[i][1] == '+') {
            ans += c;
        } else {
            ans -= c;
        }
        if (ope[i][2] == '+') {
            ans += d;
        } else {
            ans -= d;
        }
        if (ans == 7) {
            cout << a << ope[i][0] << b << ope[i][1] << c << ope[i][2] << d
                 << "=7" << endl;
            return 0;
        }
    }

    return 0;
}

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

typedef long long           ll;
typedef vector < int >      vi;
typedef vector < ll >       vll;
typedef pair < int, int >   pii;
typedef pair < ll, ll >     pll;
typedef set<int>            sset;
typedef multiset<ll>        mset;

#define gcd(a,b)            __gcd(a,b)
#define lcm(a,b)            a/gcd(a,b)*b
#define pb                  push_back
#define mp                  make_pair
#define endl                "\n"
#define optimize            ios::sync_with_stdio(0); cin.tie(0)

void solve(){
        int  n;cin>>n;
        int tm=0;
            while(n>tm){
                tm+=1000;
            }
            cout<<tm-n<<endl;
}

int main() {
   //int t;cin>>t;
   //while()
   solve();

    return 0;
}




Measured memory_bytes: 3616
n = int(input())
v = list(map(int, input().split()))
# print(n)
# print(v)

#vを小さい順に並べる任意の並べ方にする
v.sort()

#左から徐々に計算する
for i in range(n):
    
    #もう計算できないときはbreak
    if len(v) == 1:
        break
        
    v = [(float(v[0]) + float(v[1]))/2] + v[2:]
    
#結果を格納
print(v[0])

Measured memory_bytes: 3060
// Copyright: lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int maxn = 200200;
int n;
char s[maxn];
int f[maxn];

void work() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	rrep(i, n, 1) {
		if (s[i] == 'B' && s[i + 1] == 'C') f[i] = f[i + 2] + 1;
		else if (s[i] == 'A') f[i] = f[i + 1];
	}
	ll ans = 0;
	rep(i, 1, n) if (s[i - 1] == 'A') ans += f[i];
	printf("%lld\n", ans);
}

int main(){
	#ifdef LZT
		freopen("in","r",stdin);
	#endif

	work();

	#ifdef LZT
		Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
	#endif
}


Measured memory_bytes: 1280
S = input()

partial = ""

conditions = ["A","T","G","C"]

conlist = []

con = 0

for i in range(0,len(S)):
	if S[i] in conditions:
		for j in range(0,i+1):
			if S[j] in conditions:
				con +=1
			if (S[j] not in conditions) or j == i:
				conlist.append(con)
				con = 0
				

if len(conlist) > 0:
	print(max(conlist))
else:print(0)



Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

long long int INF = 998244353;

long long int pow2(int n){
	if(n == 0){
		return 1;
	}
	long long int ret = (pow2(n - 1) * 2) % INF;
	return ret;
}

int main(){
	
	int N;
	
	cin >> N;
	
	long long int x[20000], y[20000];
	long long int cnt2[20000] = {};
	
	long long int score[20000];
	
	for(int i = 0; i < N; i++){
		cin >> x[i] >> y[i];
	}
	
	if(N < 3){
		cout << "0" << endl;
		return 0;
	}
	
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			int cnt = 0;
			for(int k = 0; k < N; k++){
				long long int x1, x2, y1, y2;
				x1 = x[i] - x[k];
				x2 = x[j] - x[k];
				y1 = y[i] - y[k];
				y2 = y[j] - y[k];
				if(x1 * y2 == x2 * y1){
					cnt++;
				}
			}
			cnt2[cnt]++;
		}
	}
	
	for(long long int i = 3; i < 300; i++){
		cnt2[i] /= i * (i - 1) / 2;
	}
	
	
	for(int i = 0; i < 300; i++){
		score[i] = pow2(i) - 1 - i - i * (i - 1) / 2;
	}
	
	long long int ans = score[N];
	
	for(int i = 1; i < 300; i++){
		ans -= cnt2[i] * score[i];
		ans %= INF;
		ans += INF;
		ans %= INF;
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 384
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 998244353
//#define mod2 20071027
//#define MOD 998244353
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case %lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=300010, M=1000005;
ll n,k, a[N], b[N];
int main()
{
    in1(n);
    for(int i=0;i<n;i++)
    {
        in2(a[i], b[i]);
        a[i]=b[i]-(a[i]%b[i]);
    }
    for(int i=n-1;i>=0;i--)
    {
        a[i]=(a[i]-k)%b[i];
        if(a[i]<0) a[i]+=b[i];
        k+=a[i];
    }
    printf("%lld\n",k);
    return 0;
}
/*

*/


Measured memory_bytes: 3072
#include <stdio.h>
 
int main () {
    int n;
    scanf("%d", &n);
    char s[n];
    scanf("%s", &s);
    
    if (n % 2 != 0) {
        printf("No");
        return 0;
    }
    
    for (int i = 0; i < n / 2;i++) {
        if (s[i] != s[n / 2 + i]) {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

// end of #define 

// define globals ...


//write function from here ...



int Main(){

 

int n;
cin>>n;




for(int i=1;i<=n;i++){

  if(i<6){
    cout<<0<<endl;
    continue;
  }

  int ans=0;

  for(int j=1;j<sqrt(i);j++){
    for(int k=1;k<sqrt(i);k++){
      for(int l = 1; l < sqrt(i);l++){

        if( j*j +l*l+ k*k +j*k+k*l+j*l == i  )
          ans+=1;
        if( j*j +l*l+ k*k +j*k+k*l+j*l > i  )
          break;


      }
    }
  }

  cout<<ans<<endl;
}










return 0;

}

















int main(){
 quick;

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

 Main();

 return 0;


}

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

void escape(string &s)
{
  if (s.find_first_of("\n") != string::npos)
    s.erase(s.end()-1);
  if (s.find_first_of("\r") != string::npos)
    s.erase(s.end()-1);
}

int main()
{
  string s;
  vector<string> line;
  while (getline(cin, s)) {
    escape(s);
    if (s == "END_OF_TEXT")
      break;
    line.push_back(s);
  }

  int x = 0, y = 0;
  string buffer = "";
  while (cin >> s) {
    if (s == "-")
      break;

    if (s == "a") {
      x = 0;
    } else if (s == "e") {
      x = line[y].size();
    } else if (s == "p") {
      x = 0;
      if (y > 0)
	--y;
    } else if (s == "n") {
      x = 0;
      if (y != line.size()-1)
	++y;
    } else if (s == "f") {
      if (x < line[y].size()) {
	  ++x;
      } else if (y != line.size()-1) {
	x = 0;
	++y;
      }
    } else if (s == "b") {
      if (x > 0) {
	--x;
      } else if (y > 0) {
	--y;
	x = line[y].size();
      }
    } else if (s == "d") {
      if (x < line[y].size()) {
	line[y].erase(x, 1);
      } else if (y != line.size()-1) {
	line[y] += line[y+1];
	line.erase(line.begin()+y+1);
      }
    } else if (s == "k") {
      if (x >= line[y].size() && y != line.size()-1) {
	line[y] += line[y+1];
	line.erase(line.begin()+y+1);
	buffer = "\n";
      } else if (x < line[y].size()) {
	buffer = line[y].substr(x);
	line[y].erase(x);
      }
    } else if (s == "y" && buffer != "") {
      if (buffer == "\n") {
	s = line[y].substr(x);
	line[y].erase(x);
	line.insert(line.begin()+y+1, s);
	x = 0;
	++y;
      } else {
	line[y].insert(x, buffer);
	x += buffer.size();
      }
    }
  }
  
  for (unsigned int i = 0; i < line.size(); ++i)
    cout << line[i] << endl;
  return 0;
}

Measured memory_bytes: 0
# 入力
N, M = map(int, input().split())
A, B = (
    zip(*(map(int, input().split()) for _ in range(M))) if M else
    ((), ())
)


class UnionFindTree:
    def __init__(self, n):
        self.p = [i for i in range(n + 1)]
        self.r = [1 for _ in range(n + 1)]

    def find(self, x):
        if self.p[x] != x:
            self.p[x] = self.find(self.p[x])
        return self.p[x]

    def union(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.r[px] < self.r[py]:
                self.p[px] = py
                self.r[py] += self.r[px]
            else:
                self.p[py] = px
                self.r[px] += self.r[py]

    def same(self, x, y):
        return self.find(x) == self.find(y)


# クエリを逆順に処理して不便さを求める
utf = UnionFindTree(N)
xs = []
d = N * (N - 1) // 2
for a, b in reversed(list(zip(A, B))):
    xs.append(d)
    if not utf.same(a, b):
        d -= utf.r[utf.find(a)] * utf.r[utf.find(b)]
        utf.union(a, b)
ans = '\n'.join(str(x) for x in reversed(xs))

# 出力
print(ans)


Measured memory_bytes: 57464
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		for (int i=N; 0<i; i--) {
			for (int j=0; j<N; j++) {
				if (i == Math.pow(2, j)) {
					System.out.println(i);
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 23636