akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const llong MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
int range_check(int val, int min, int max) {
	if (val < min) {
		return -1;
	}
	if (val > max) {
		return -1;
	}
	return val;
}
template<class T,class T1>
bool array_find(const T& array, const T1& dst) {
	auto result = find(array.first(), array.end(), dst);
	if (result == array.end()) {
		return false;
	}
	else {
		return true;
	}
}
int main() {
	string str;
	cin >> str;
	if (str == "AAA" || str == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll N;
  cin >> N;
  int ans = mod;

  for(int i=1;i<sqrt(N)+1; i++){
    if(N % i == 0){
      ans = min(ans, (max((int)(to_string(i).size()),(int)(to_string(N/i).size()))));
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> strs(n);
    for(int i=0;i<n;++i)
    {
        cin >> strs[i];
        sort(strs[i].begin(), strs[i].end());
    }
    sort(strs.begin(), strs.end());

    ll res = 0;
    ll cont = 1;
    for(int i=1;i<n;++i)
    {
        if(strs[i-1] == strs[i]) {
            cont++;
        }
        else
        {
            res += cont * (cont - 1) / 2;
            cont = 1;
        }
        
    }
    res += cont * (cont - 1) / 2;

    cout << res << endl;
}

Measured memory_bytes: 5760
import sys
input=sys.stdin.readline
n,m,x=map(int,input().split())
A=[]
for i in range(n):
    c=list(map(int,input().split()))
    A.append(c)
C=10**10
for i in range(2**n):
    al=[0]*m
    cost=0
    for j in range(n):
        if (i>>j)%2==1:
            cost+=A[j][0]
            for k in range(m):
                al[k]+=A[j][k+1]
    if min(al)>=x:
        if C>cost:
            C=cost
if C==10**10:
    print(-1)
else:
    print(C)


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

int main() {
    int K,S;
    cin >> K >> S;
    int count = 0;
    for (int i = 0; i <= K; i++){
        for (int j = 0; j <= K; j++){
            if ((0 <= (S - i - j)) && ((S -i - j) <= K)){
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
    int n;  cin >> n;
    string c[] = {"AC", "WA", "TLE", "RE"};
    map<string , int> mp;
    for (int i = 0; i < n; i++) {
        string s;   cin >> s;
        mp[s]++;
    }
    for (int i = 0; i < 4; i++)
        cout << c[i] << " x " << mp[c[i]] << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Node {
	int key;
	struct Node* parent;
	struct Node* left;
	struct Node* right;
	struct Node* sibling;
	int degree;
	
	//int depth;
	//int height;
	//char type[15];
};
typedef struct Node * NodePointer;

void preorder ( NodePointer t){
	if ( t == NULL ){ return; }
	printf(" %d", t -> key);
	preorder( t -> left);
	preorder( t -> right);
};	

void inorder (NodePointer t){
	if ( t == NULL ){ return; }
	inorder( t -> left);
	printf(" %d", t -> key);
	inorder( t -> right);
};

void postorder (NodePointer t){
	if ( t == NULL ){ return; }
	postorder( t -> left);
	postorder( t -> right);
	printf(" %d", t -> key);
};


int main (){
	int n;
	scanf("%d\n",&n);
	
	//setting part
	NodePointer array [n];
	for (int i = 0; i < n;i++)
	{
		array[i] = (NodePointer) malloc (sizeof(struct Node));
		array[i]->parent = NULL;
		array[i]->sibling = NULL;
		array[i]->left = NULL;
		array[i]->right = NULL;
		array[i]->degree = 0;
	}
	
	//input part
	for (int i = 0; i < n;i++)
	{
		int id ,left_id,right_id;
		scanf("%d %d %d\n",&id,&left_id,&right_id);
		
		array[id]->key = id;
		if (left_id != -1){
			array[id]->left = array[left_id];
			array[left_id]->parent =  array[id];
			array[id]->degree++;
		}
		if (right_id != -1){
			array[id]->right = array[right_id];
			array[right_id]->parent =  array[id];
			array[id]->degree++;
		}
		if (left_id != -1 && right_id != -1){
			array[left_id]->sibling =  array[right_id];
			array[right_id]->sibling =  array[left_id];
		}
	}
	
	//print part
	for (int i = 0; i < n;i++)
	{
		if(array[i]->parent == NULL) {
			//strcpy(array[i]->type ,"root");
			printf("Preorder\n");
			preorder(array[i]);
			printf("\n");
			
			printf("Inorder\n");
			inorder(array[i]);
			printf("\n");
			
			printf("Postorder\n");
			postorder(array[i]);
			printf("\n");
			
			break;
		}
	}

	
	return 0;
}




Measured memory_bytes: 2104
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    int n;
    cin >> n;
    int number = n;
    int sum    = 0;
    while (n > 0) {
        int digit = n % 10;
        sum += digit;
        n /= 10;
    }

    cout << (number % sum == 0 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
# ABC100 C - Pyramid
n=int(input())
xyh=[]
idx=-1
for i in range(n):
    x,y,h=map(int,input().split())
    xyh.append([x,y,h])
    if h>=1:
        idx=i
for cx in range(101):
    for cy in range(101):
        H=abs(xyh[idx][0]-cx)+abs(xyh[idx][1]-cy)+xyh[idx][2]
        H=max(H,0)
        ok=True
        for i in range(n):
            t_height=H-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy)
            if xyh[i][2]==0 and t_height>0:
                ok=False
            if xyh[i][2]>0 and xyh[i][2]!=t_height:
                ok=False
        if ok:
            print(cx,cy,H)

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

using namespace std;

int main()
{
  while(1){
    int n,m;
    cin>>n>>m;
    if(n == 0){
      break;
    }

    vector<string> number;
    vector<int> money;
    for(int i = 0;i < n;++i){
      string a;
      int b;
      cin>>a>>b;

      number.push_back(a);
      money.push_back(b);
    }

    vector<string> ticket;
    for(int i = 0;i < m;++i){
      string a;
      cin>>a;

      ticket.push_back(a);
    }

    int sum = 0;
    for(int i = 0;i < number.size();++i){
      int e = 0;
      string c = number.at(i);

      for(int j = 0;j < c.size();++j){
        char d = c.at(j);
        if(d == '*'){
          ++e;
        }
      }
      c.erase(c.begin(), c.begin() + e);

      for(int j = 0;j < ticket.size();++j){
        string f = ticket.at(j);
        f.erase(f.begin(), f.begin() + e);

        if(f == c){
          sum += money.at(i);
        }
      }
    }

    cout<<sum<<endl;
  }

  return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <string>
#include <map>//map<int, int> x;
#include <numeric>
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using ll = long long;
using namespace std;
 int main(){
int n;
int count=0;
 cin>>n;
  string a;
vector<string> strlist(10000000);
rep(i,n)cin>>strlist[i];

sort( strlist.begin(), strlist.end() );
strlist.erase(unique(strlist.begin(), strlist.end()), strlist.end());

cout << int(strlist.size()-1)<<endl;
return 0;
}

Measured memory_bytes: 315832
#include<bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
int64_t op(int64_t a,int64_t b){
  return a+b;
}
int64_t e(){
  return 0;
}
int main(){
  int n,q;
  cin>>n>>q;
  vector<int64_t> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  segtree<int64_t,op,e> t(a);
  for(int _=0;_<q;_++){
    int f,x,y;
    cin>>f>>x>>y;
    if(f==0)
      t.set(x,t.get(x)+y);
    if(f==1)
      cout<<t.prod(x,y)<<endl;
  }
}

Measured memory_bytes: 16424
#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define sz size()
#define f first
#define s second
#define mp make_pair
#define kz ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1e9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector <int> vi;

const int N = 3e6;

ll q, h, s, d, n;

int main(){
	cin >> q >> h >> s >> d >> n;
	h = min(h, 2 * q);
	s = min(s, 2 * h);
	d = min(d, 2 * s);
	cout << (n / 2) * d + (n & 1) * s;
	return 0;
}

Measured memory_bytes: 256
void main()
{
    long n = rdElem;
    Train[] train = rdCol!Train(n-1);

    long[] list = new long[n];
    foreach (i; 0 .. n-1)
    {
        foreach (t; train[i..$])
        {
            list[i] = t.c + t.s + max(0, (list[i]-t.s+t.f-1)/t.f) * t.f;
        }
    }

    foreach (l; list)
    {
        l.writeln;
    }
}

struct Train
{
    long c, s, f;
}

enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

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

int main()
{
    int n;
    cin>>n;
    vector<int> b(n-1);
    int i;
    for(i=0;i<n-1;i++)cin>>b.at(i);
    int ans=0;
    for(i=0;i<n-2;i++)
    {
        ans+=min(b.at(i),b.at(i+1));
    }
    ans+=b.at(0)+b.at(n-2);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
s=input()
x=len(s)-7
if x==0:
  if  s=='keyence':
    print('YES')
    exit()
  else:
    print('NO')
    exit()

if s[:7]=='keyence':
    print('YES')
    exit()


for i in range(len(s)-5):
  if s[:i]+s[i+x:]=='keyence':
    print('YES')
    exit()
    
print('NO')


Measured memory_bytes: 61672
#include<bits/stdc++.h>
using namespace std;
int vis[100001];
vector <int> g[100001];
int ans[100001];
int graph(int i)
{
	int max=0,k;
	for(auto it:g[i])
	{
		if(vis[it]==0)
		{vis[it]=1;
		k=graph(it)+1;}
		else
		k=ans[it]+1;
		if(k>max)
		max=k;
	}
	return ans[i]=max;
}

int main()
{
	
	int n,m,i,max,x,y,k;
	cin>>n>>m;
	
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		g[x].push_back(y);
	}
	max=0;
	
	memset(vis,0,100001);
	for(i=1;i<=n;i++)
	{
		if(vis[i]==0)
		{
		k=graph(i);vis[i]=1;
		}
		else
		k=ans[i];
		if(k>max)
		max=k;
	}

	cout<<max;
}

Measured memory_bytes: 8576
const solve = (input) => {
  const [head, ...lines] = input.split("\n")
  const [n, k] = head.split(" ").map(Number)
  const l = lines.map(Number)
  l.sort((a, b) => a - b)
  let result
  l.map((_, i) => {
    if (l[i + k - 1] === undefined) {
      return
    }
    let d = l[i + k - 1] - l[i]
    if (result === undefined) {
      result = d
    }
    result = Math.min(d, result)
  })
  return result
}

if (process.env.NODE_ENV === "test") {
  module.exports = (input) => solve(input.trim())
} else {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(solve(input.trim()))
}


Measured memory_bytes: 29968
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted([A[i] - B[i] for i in range(N)])
if sum(C) < 0:
    print(-1)
elif min(C) >= 0:
    print(0)
else:
    D = sorted([i for i in C if i > 0], reverse=True)
    r = [D[0]]
    for i in range(len(D)-1):
        r.append(r[i] + D[i+1])
    print(len([i for i in C if i < 0])+bisect.bisect_left(r, sum(-i for i in C if i < 0))+1)


Measured memory_bytes: 95008
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
map< string , int > mp;
int main()
{
	dhoom;
	ll n , k;
	cin >> n >> k;
	if(k & 1)
		cout << (n/k)*(n/k)*(n/k) << endl;
	else
		cout << (n/k)*(n/k)*(n/k) + ((n+(k/2))/k)*((n+(k/2))/k)*((n+(k/2))/k) << endl;
	return 0;
} 



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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-indexか1-indexでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-index昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-index昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-index降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-index降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
/*GRAPH_TEMPLATE=============================================*/
template<typename T>
class Edge {
public:
    int srch; //searched?探索状態記録「null = -1」
    int to; //辺の行き先
    T cost; //辺の重み
    Edge(int t, T w) : srch(-1), to(t), cost(w) {}
    Edge(int src, int t, T w) : srch(src), to(t), cost(w) {}
};
template<typename T>
using W_Graph = vector<vector<Edge<T>>>;   //重み付きグラフ
using Graph = vector<vector<int>>;         //通常グラフ
template<typename T>
using Matrix = vector<vector<T>>;          //隣接行列(使わなさそう...)

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n, m; cin >> n >> m;
    W_Graph<ll> G(n);
    for(int j = 0; j < n-1; ++j) {
        G[j+1].push_back(Edge<ll>(j, 0));  //こうすればl~r間の全ての頂点が
                                           //重みcの辺で結ばれたことになる
    }
    rep(i,m) {
        int l, r;
        ll c;
        cin >> l >> r >> c;
        --l; --r;
        G[l].push_back(Edge<ll>(r, c));
        G[r].push_back(Edge<ll>(l, c));
    }

    //dijkstra
    using p = pair<ll,int>;
    priority_queue<p, vector<p>, greater<p>> que;
    vll min_dist(n, infll);
    min_dist[0] = 0;
    que.emplace(min_dist[0], 0);
    while(que.size()) {
        ll dist;
        int index;
        tie(dist, index) = que.top();
        que.pop();
        if(dist > min_dist[index]) continue;

        for(auto edge : G[index]) {
            ll new_dist = dist+edge.cost;
            if(min_dist[edge.to] <= new_dist) continue;
            chmin(min_dist[edge.to], new_dist);
            que.emplace(min_dist[edge.to], edge.to);
        }
    }
    if(min_dist[n-1]!=infll) cout << min_dist[n-1] << '\n';
    else cout << -1 << '\n';
}

Measured memory_bytes: 13044
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {

    long long n, m;
    cin >> n >> m;
    ll modn = n % m;
    ll dif = abs(modn - m);
    if(dif < modn){
        cout << dif;
    } else {
        cout << modn;
    }

    return 0;
}


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

using namespace std;

int A[2000];
int n, q, m;
int t=0;

bool solve(int j){
	if (j==n) return false;
	t += A[j];
	if (t==m) return true;
	if (t<m){
		if (solve(j+1)) return true;
	}
	t -= A[j];
	return solve(j+1);
}

int main(){
	cin >> n;
	for (int i=0;i<n;i++) cin >> A[i];
	
	cin >> q;
	for (int i=0;i<q;i++) {
		t = 0;
		cin >> m;
		cout << (solve(0) ? "yes" : "no") << endl;
	}
}

Measured memory_bytes: 1156
N, W = map(int, input().split())
lst = [[0, 0]] 
for i in range(N):
    lst.append(list(map(int, input().split())))
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(1, N+1):
    for j in range(1, W+1):
        if j - lst[i][0] >= 0:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-lst[i][0]]+lst[i][1])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[N][W])

Measured memory_bytes: 120300
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int a,b;
int sv;
int main(){
	ios_base::sync_with_stdio(0);
	cin>>a>>b;
	sv=b;
	int cnt=1;
	while(sv>0){
		cnt*=10;;
		sv/=10;
	}
	a=a*cnt+b;
	int sq=sqrt(a);
	if(sq*sq==a) cout<<"Yes";
	else cout<<"No";
}


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

using namespace std;

int main(){
    int H,W,ans=0;
    cin >> H >> W;
    vector<string> S(H);
    int v[H][W]={0},p[H][W]={0};
    for(int i=0;i<H;i++){
        cin >> S[i];
    }

    for(int i=0;i<H;i++){
        int lst = 0;
        for(int j=0;j<W;j++){
            if(S[i][j]=='#'){
                p[i][j]=0;
                for(int k=lst;k<j;k++){
                    p[i][k] = j-lst;
                }
                lst = j+1;
            }else if(j==W-1){  
                for(int k=lst;k<=j;k++){
                    p[i][k] = j-lst+1;
                }
            }
        }
    }

    for(int i=0;i<W;i++){
        int lst = 0;
        for(int j=0;j<H;j++){
            if(S[j][i]=='#'){
                v[j][i]=0;
                for(int k=lst;k<j;k++){
                    v[k][i] = j-lst;
                }
                lst = j+1;
            }else if(j==H-1){
                for(int k=lst;k<=j;k++){
                    v[k][i] = j-lst+1;
                }
            }
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ans = max(p[i][j]+v[i][j],ans);
        }
    }

    cout << ans-1 << endl;
}

Measured memory_bytes: 37504
import java.util.Scanner;

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

    void run() {
        String s = sc.next();
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'C') {
                for (int j = i + 1; j < s.length(); j++) {
                    if (s.charAt(j) == 'F') {
                        System.out.println("Yes");
                        return;
                    }
                }
            }
        }
        System.out.println("No");
    }

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

Measured memory_bytes: 8916
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<int,int>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define ceili(x,y) (x+y-1)/y  
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,L,R,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  Sort(P);
  rep(i,0,N)sum+=P[i];
  if(sum%10==0){
    rep(i,0,N){
    if(P[i]%10!=0){
      sum-=P[i];
      break;
    }
  }
  if(sum%10==0)sum=0;
  }
  Out(sum);
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h.at(i);
  
  vector<int> dp(n);
  
  for (int i = 1; i < n; i++) {
    int keep = 1e9 + 5;
    for (int j = 1; j <= min(i, k); j++) {
      keep = min(keep, dp.at(i - j) + abs(h.at(i) - h.at(i - j)));
    }
    dp.at(i) = keep;
  }
  
  cout << dp.at(n - 1) << '\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[200010], maxm;
  long long sum = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  maxm = a[0];
  for (int i = 1; i < n; i++) {
    if (a[i] > maxm) maxm = a[i];
    sum += (maxm - a[i]);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4356
#include <iostream>
#include <algorithm>
#include <cstdio> 
#include <string>
#include <vector>

#define MAX 1010001000

using namespace std;

int a[101];

int main()
{
    int K, T;

    cin >> K >> T;

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

    sort(a, a+T);

    int mx = a[T-1]-1;

    for (int i = 0; i < T-1; i++) {
        mx -= a[i];
    }

    if (mx < 0) {
        cout << 0 << endl;
    } else {
        cout << mx << endl;
    }



    return 0;
}


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

using namespace std;

typedef long long int lli;

int n,t,sol;
vector<int> all(3);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    for(int i=0;i<3;i++)cin>>all[i];
    int a,b,c,d,e,f;
    a=abs(all[2]-all[0])+abs(all[1]-all[2]);
    b=abs(all[1]-all[0])+abs(all[2]-all[1]);
    c=abs(all[1]-all[0])+abs(all[2]-all[0]);
    d=abs(all[2]-all[1])+abs(all[0]-all[2]);
    e=abs(all[2]-all[0])+abs(all[1]-all[0]);
    f=abs(all[1]-all[2])+abs(all[0]-all[1]);
    a=min(a,b);b=min(c,d);c=min(e,f);
    cout<<min(a,min(b,c));
     return 0;
}


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

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

Measured memory_bytes: 3600
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N;
	getval(N);

	LLONG Z, W;
	getval(Z, W);

	LLONG last2Val = 0, lastVal = 0;
	LLONG ai = 0;
	for (int i = 0; i < N; i++) {
		getval(ai);
		if (i == N - 2) {
			last2Val = ai;
		}
	}
	lastVal = ai;


	LLONG ans = 0;
	LLONG x, y;
	
	x = lastVal;
	y = W;
	ans = tp_abs(x - y);
	if (N == 1) {
		printf("%lld\n", ans);
		return;
	}

	x = lastVal;
	y = last2Val;
	ans = std::max(ans, tp_abs(x - y));

	printf("%lld\n", ans);
}


Measured memory_bytes: 3772
#include <stdio.h>
#include <string.h>
main(){
	int N;
	char target[10];
	scanf("%s",target);
	scanf("%d",&N);
	int i,j;
	int ans=0;
	int mojisu=0;
	char ring[N][10];
	char temp;
	for(i=0;i<N;i++){
		scanf("%s",ring[i]);
		mojisu=strlen(ring[i]);
		for(j=0;j<mojisu;j++){
			if(strstr(ring[i],target)!=NULL){
				ans++;
				break;
			}
			temp=ring[i][0];
			strcpy(ring[i],ring[i]+1);
			ring[i][mojisu-1]=temp;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<double, int>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<P> graph[1005];
using T = tuple<double, double, double>;
vector<T> vect;
vector<double> length(1005, LLONG_MAX);

double calc(double x1, double x2, double y1, double y2) {
  auto x = (x2-x1)*(x2-x1);
  auto y = (y2-y1)*(y2-y1);
  return sqrt(x+y);
}

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

  int x1, y1; cin >> x1 >> y1;
  int x2, y2; cin >> x2 >> y2;
  int n; cin >> n;
  //debugln(n);
  vect.resize(n+2);

  vect[0] = make_tuple(x1, y1, 0);
  vect[n+1] = make_tuple(x2, y2, 0);

  rep(i, n) {
    double x, y, r; cin >> x >> y >> r;
    vect[i+1] = make_tuple(x, y, r);
  }

  for(int i=0; i<=n+1; i++) {
    for(int j=i+1; j<=n+1; j++) {
      auto xi = get<0>(vect[i]);
      auto xj = get<0>(vect[j]);
      auto yi = get<1>(vect[i]);
      auto yj = get<1>(vect[j]);
      auto r = get<2>(vect[i]) + get<2>(vect[j]);
      auto len = max(0.0, calc(xi, xj, yi, yj)-r);
      //debug(i); debug(j); debugln(len);
      graph[i].emplace_back(len, j);
      graph[j].emplace_back(len, i);
    }
  }

  length[0] = 0;
  priority_queue<P, vector<P>, greater<>> que;
  que.emplace(0.0, 0);
  while(!que.empty()) {
    P p = que.top(); que.pop();
    auto u = p.second;
    auto l = p.first;
    if (l > length[u]) continue;
    for(auto e: graph[u]) {
      auto v = e.second;
      if (l + e.first < length[v] ) {
        length[v] = l + e.first;
        que.emplace(l+e.first, v);
      }
    }
  }
  cout << setprecision(10) << length[n+1] << endl;
}

Measured memory_bytes: 22804
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

inline ll cnt (ll x) {
    ll ans = 1;
    for (ll i = 2; i * i <= x; i++) {
        int c = 0;
        while (x % i == 0) {
            x /= i;
            ++c;
        }
        ans *= c + 1;
    }
    if (x > 1) ans *= 2;
    return ans;
}

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll ans = cnt(n - 1) - 1;
    auto do_it = [&] (ll k) {
        if (k == 1) return;
        ll x = n;
        while (x % k == 0) x /= k;
        if (x % k == 1) {
            ++ans;
        }
    };
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            do_it(i);
            if (n / i != i) {
                do_it(n / i);
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3588
#include <iostream>
#include <fstream>
#include <stdio.h>

using namespace std;


int ch_len(char ch[]){
    int cnt = 0;
    for(int i=0; i<20; i++){
        if(ch[i] == '\0' || ch[i] == '\n')break;
        cnt++;
    }
    return cnt;
}

int cir(char w[][20], int first, int n){
    
    int now_vocab = 0;
    int mojisu = 0;
    
    for(int i=first; i<n; i++){
        int len = ch_len(w[i]);
        
        
        mojisu+=len;
        switch(now_vocab){
            case 0:
                if(mojisu == 5){
                    now_vocab++;
                    mojisu = 0;
                }
                else if(mojisu >5){
                    return cir(w, first+1, n);
                }
                break;
            case 1:
                if(mojisu == 7){
                    now_vocab++;
                    mojisu = 0;
                }
                else if(mojisu >7){
                    return cir(w, first+1, n);
                }
                break;
            case 2:
                if(mojisu == 5){
                    now_vocab++;
                    mojisu = 0;
                }
                else if(mojisu >5){
                    return cir(w, first+1, n);
                }
                break;
            case 3:
                if(mojisu == 7){
                    now_vocab++;
                    mojisu = 0;
                }
                else if(mojisu >7){
                    return cir(w, first+1, n);
                }
                break;
            case 4:
                if(mojisu == 7){
                    now_vocab++;
                    mojisu = 0;
                }
                else if(mojisu >7){
                    return cir(w, first+1, n);
                }
                break;
        }
        
        if(now_vocab >=5)return first;
    }
    
    return 0;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    
    
    /////////
    //write//
    /////////
    
    int res;
    
    while(1){
        int n;cin >> n;
        char w[50][20];//<50
        if(n==0)break;
        
        for(int i=0; i<n; i++){
            cin >> w[i];
        }
        
        res = cir(w, 0, n)+1;
        cout << res << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i<b ;i++)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lli long long
#define pb push_back

using namespace std;

int main()
{
    fast
    string s;
    cin>>s;
    int count =0;
    rep(i,0,3){
        if(s[i]=='S')
        count++;
    }
    if(count ==3)
    cout<<"0";
    else if(count ==0)
    cout<<"3";
    else if(count ==2)
    cout<<"1";
    else if(count ==1 && s[1]=='S' )
    cout<<"1";
    else if(count ==1 )
    cout<<"2";
    

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    string s; cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll n; cin >>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  int key=a[0];
  int count =1;
  rep(i,n){
    if(key==2){
     cout<< count<<endl;
     return 0;
    }
    key=a[key-1];
    count++;
  }
  cout <<-1<<endl;
}

Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n,x;
  cin >> n >> x;
  ll l[n];
  REP(i,n) cin >> l[i];
  ll pos = 0;
  REP(i,n){
    pos += l[i];
    if(pos>x){
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << n+1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int[] place = new int[100001];
    for (int i = 0; i < M; i++) {
      int tmp = sc.nextInt();
      place[tmp]++;
    }
    int count1 = 0;
    for (int i = 1; i < X; i++) {
      if (place[i] > 0) {
        count1++;
      }
    }
    int count2 = 0;
    for (int i = X + 1; i < N; i++) {
      if (place[i] > 0) {
        count2++;
      }
    }
    System.out.println(Integer.min(count1, count2));
  }
}

Measured memory_bytes: 23124
#pragma GCC optimize (2)
#include<bits/stdc++.h>
using namespace std;

inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

int main()
{
	int n=read(), mx=0, sum=0;
	for (int i=1; i<=n; i++) 
	{
		int x=read();
		mx=max(mx, x); sum+=x;
	}
	if (sum<=2*mx) puts("No"); else puts("Yes");
	return 0;
}


Measured memory_bytes: 256
n,w=map(int, input().split())
g=[0]
v=[0]
for i in range(n):
    G,V=map(int, input().split())
    g.append(G)
    v.append(V)

dp=[[0]*(w+1) for i in range(n+1)]

for i in range(1,n+1):
    for j in range(w+1):
        if j-g[i]>=0:dp[i][j]=max(dp[i-1][j],dp[i-1][j-g[i]]+v[i])
        else:dp[i][j]=dp[i-1][j]

print(dp[n][w])

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

int main() {
    int N;
    string s;
    cin >> N;
    cin >> s;
    int r = 0;
    int b = 0;
    for (char c: s) {
        if (c == 'R') {
            ++r;
        } else {
            ++b;
        }
    }
    if (r > b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << 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++)

using ll=long long;

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

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

struct Point{
	double x;
	double y;
};

Point roll(Point div1,Point div2){
	Point tmp_start = { div2.x-div1.x,div2.y-div1.y };
	Point tmp_end = { tmp_start.x*cos(M_PI/3) -tmp_start.y*sin(M_PI/3),
			tmp_start.x*sin(M_PI/3) + tmp_start.y*cos(M_PI/3) };
	Point ret = { tmp_end.x + div1.x,tmp_end.y + div1.y };
	return ret;
}

void outPut(Point point){
	printf("%.8f %.8f\n",point.x,point.y);
}

void calc(Point left,Point right,int count){
	Point div1 = {	(2*left.x + right.x)/3,(2*left.y + right.y)/3 };
	Point div2 = {(2*right.x + left.x)/3,(2*right.y + left.y)/3	};
	Point peek = roll(div1,div2);

	if(count > 1){
		calc(left,div1,count-1);
		calc(div1,peek,count-1);
		calc(peek,div2,count-1);
		calc(div2,right,count-1);
	}else{
		outPut(left);
		outPut(div1);
		outPut(peek);
		outPut(div2);
	}
}

int main(){
	int n;
	Point left = {0,0},right = {100,0};
	scanf("%d",&n);
	if(n == 0){
		outPut(left);
		outPut(right);
	}else{
		calc(left,right,n);
		outPut(right);
	}
}




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

int main() {
	string s; cin >> s;
	int n = s.size() + 1;
	vector<int>a(n,-1);
	for (int i = 0; i < n - 1; i++) {
		if (s[i] == '<') {
			if (a[i] == -1) a[i] = 0;
			a[i + 1] = a[i] + 1;
		}
	}
	for (int i = n - 2; i >= 0; i--) {
		if (s[i] == '>') {
			if (a[i + 1] == -1) a[i + 1] = 0;
			a[i] = max(a[i], a[i + 1] + 1);
		}
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		ans += a[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2820
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long
int n,x,y;

signed abs(int i){
  if(i<0) return -i;
  return i;
}

signed dist(int i,int j){
  return min(abs(i-x)+abs(j-y)+1, abs(j-i));
}

signed main(){
  string s;
  cin >> s;
  LOOP(i,3){
    if(s[i]=='7'){
      cout << "Yes" << endl;return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3628
<?php

while (true) {
    fscanf(STDIN, '%d', $d);
    if (feof(STDIN)) {
        break;
    }
    $sum = 0;
    for ($i = $d; $i < 600; $i += $d) {
        $sum += $i * $i;
    }
    echo $sum * $d . "\n";
}

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

using namespace std;
using i64 = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const i64 INFL = (1LL<<62);
const i64 MOD = 1000000007;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> i64 mod_pow(i64 a, i64 n, T mod) { mod=(i64)mod; i64 res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
void print() { std::cout << std::endl; }
template <typename T, typename... A> void print(const T& first, const A&... rest) { cout << sizeof...(rest) << endl; std::cout << first; if (sizeof...(rest)) std::cout << " "; print(rest...); }
template <typename... A> void print(const A&... rest) { print(rest...); }
template <typename A> void print(const std::vector<A>& v) { std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; }); std::cout << std::endl; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  char grid[100][100];
  rep(col, 100){
    rep(row, 100){
      if(col < 50){
        grid[col][row] = '#';
      }else{
        grid[col][row] = '.';
      }
    }
  }
  // 白塗り
  int x = 1, y = 1;
  rep(i, a-1){
    grid[y][x] = '.';
    y += 2;
    if(y >= 49){
      y = 1;
      x += 2;
    }
  }
  x = 1, y = 51;
  rep(i, b-1){
    grid[y][x] = '#';
    y += 2;
    if (y > 100){
      y = 51;
      x += 2;
    }
  }
  cout << 100 << " " << 100 << endl;
  rep(y, 100)rep(x, 100){
    cout << grid[y][x];
    if(x == 99){
      cout << "\n";
    }
  }



  return 0;
}

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

int main(){
 int n, x[100], y[100];
 cin>>n;
 for(int i=0; i<n; i++)cin >> x[i];
 for(int i=0; i<n; i++)cin >> y[i];
 double d[4];
 for(int i=0; i<4; i++) d[i]=0.0;
 for(int p=1; p<=3; p++){
  for(int i=0; i<n; i++){
   d[p]+=pow(fabs(x[i]-y[i]),p);
  }
  d[p]=pow(d[p], 1.0/p);
 }
 for(int i=0; i<n; i++){
  d[0]=(d[0] < fabs(x[i]-y[i])?fabs(x[i]-y[i]):d[0]);
 }
 printf("%lf\n", d[1]);
 printf("%lf\n", d[2]);
 printf("%lf\n", d[3]);
 printf("%lf\n", d[0]);
 return 0;
}


Measured memory_bytes: 3352
M,s=998244353,0
d=[1]+[0]*7**6
e=d[:]
n=input()
for _ in'_'*n:
 a=input();s+=a;i=s
 while~i:d[i]+=d[i-a]*2%M;e[i]+=e[i-a]%M;i-=1
print(3**n+~s%2*e[s/2]*3-3*sum(d[:s/2+1]))%M

Measured memory_bytes: 35436
#include <stack>
#include <queue>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cmath>
#include <random>
#include <algorithm>
#include <vector>
#include <iostream>
#include <fstream>
#include <chrono>

#define fio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define ri(x) i64 x; cin >> x
#define rii(x, y) i64 x, y; cin >> x >> y
#define ri3(x, y, z) i64 x, y, z; cin >> x >> y >> z
#define ri4(x, y, z, u) i64 x, y, z, u; cin >> x >> y >> z >> u
#define rvi(x, n) vi x(n); cin >> x
#define rvvi(x, n, m) vvi x(n, vi(m)); cin >> x
#define rx(x, t) t x; cin >> x

#define ws(x) cout << x << ' '
#define wl(x) cout << x << '\n'
#define wln cout << '\n'

#define dbg(x) cerr << '[' << #x << "]: " << x << '\n'

#define fa(x, v) for (auto &x : v)
#define fi(i, n) for (i32 i = 0; i < n; i++)
#define fp(i, n) for (i32 i = 1; i < n; i++)
#define fr(i, n) for (i32 i = n - 1; i >= 0; i--)
#define fu(x) ri(_x); fi(x, _x)

#define l first
#define r second
#define all(x) x.begin(), x.end()
#define bit(x) ((u64) 1 << (u32) (x))

using namespace std;

typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t i32;
typedef int64_t i64;
typedef vector<i64> vi;
typedef vector<vi> vvi;
typedef pair<i64, i64> pi;

template<typename T>
inline istream &operator>>(istream &in, vector<T> &v) {
    fa(x, v) in >> x;
    return in;
}

template<typename T>
inline ostream &operator<<(ostream &out, const vector<T> &v) {
    fa(x, v) ws(x);
    wln;
    return out;
}

int main() {
    fio;

    ri(n);
    rvvi(a, n, 3);
    vi res(n + 1, numeric_limits<i64>::max());
    u32 state = 0;

    vvi xmin(bit(n), vi(n));
    vvi ymin(bit(n), vi(n));

    fi(t, bit(n)) {
        fi(i, n) {
            xmin[t][i] = abs(a[i][0]);
            ymin[t][i] = abs(a[i][1]);
            fi (j, n) {
                if (t & bit(j)) xmin[t][i] = min(xmin[t][i], abs(a[i][0] - a[j][0]));
                if (t & bit(j)) ymin[t][i] = min(ymin[t][i], abs(a[i][1] - a[j][1]));
            }
            xmin[t][i] *= a[i][2];
            ymin[t][i] *= a[i][2];
        }
    }

    fi(i, bit(n)) {
        u32 d = __builtin_popcountll(i);
        fr(j, i + 1) {
            j &= i;
            i64 cost = 0;
            fi (k, n) {
                cost += min(xmin[j][k], ymin[i - j][k]);
            }
            res[d] = min(res[d], cost);
        }
    }

    fa(x, res) wl(x);

    return 0;
}


Measured memory_bytes: 12960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int main(){
    string s;
    cin >> s;
    if(s.size() < 4){
        cout << "No" << endl;
        return 0;
    }
    if(s.substr(0,4) == "YAKI"){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

const int MAX_N = 1001;
int f[MAX_N+1] = {2,3};

int par[MAX_N];
int rank[MAX_N];

// フィボナッチ数列の計算
void fib_init(){
	for(int i = 2 ; i < MAX_N+1 ; i++ ){
		f[i] = (f[i-1] + f[i-2]) % MAX_N;
	}
}

// 初期化
void init(int n){
	for(int i=0 ; i < n ; i++ ){
		par[i] = i;
		rank[i] = 0;
	}	
}

// x の root を求める
int find(int x){
	if( par[x] == x ){
		return x;
	}else{
		return par[x] = find( par[x] );
	}
}

// x と y の属する集合の併合
void unite(int x, int y){
	x = find(x);
	y = find(y);
	if( x == y ) return ;
	
	if( rank[x] < rank[y] ){
		par[x] = y;
	}else{
		par[y] = x;
		if( rank[x] == rank[y] )
			rank[x]++;
	}
}

// x と y が同じ集合に属するかどうか 
bool same(int x, int y){
	return find(x) == find(y);
}

int main(){
	fib_init();
	
	int v, d;
	while( cin >> v >> d ){
		init( v );
		int memo[MAX_N+1] = {0};
		
		// |f(i) - f(j)| < d となるとき i と j は同じ集合に属する
		for(int i=0 ; i < v ; i++ ){
			for(int j=i+1 ; j < v ; j++ ){
				if( abs( f[i] - f[j] ) < d ){
					unite( i , j );
				}
			}
		}
		
		// 集合の個数を数える
		int ans=0;
		for(int i=0 ; i < v ; i++ ){
			int root = find(i);
			if( memo[root] == 0 ){
				memo[root] = 1;
				ans++;
			}
		}
		// 出力
		cout << ans << endl;
	}
}

Measured memory_bytes: 880
N, X, M = [int(x) for x in input().split()]

A = [0] * (M + 1)
firstApearAt = {i:0 for i in range(M)}
A[1] =  X
firstApearAt[X] = 1
l, r = 1, 2
for i in range(2, M + 1):
    A[i] = (A[i - 1] * A[i - 1]) % M
    if firstApearAt[A[i]] > 0:
        r = i
        l = firstApearAt[A[i]]
        break
    firstApearAt[A[i]] = i

ans = 0
if N <= l - 1:
    ans = sum(A[1:N + 1])
else:
    q, p = (N - l + 1) // (r - l), (N - l + 1) % (r - l)
    ans = sum(A[1:l]) + q * sum(A[l:r]) + sum(A[l:l + p])

print(ans)

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

int main() {
	int n;
	cin >> n;
	ll ans = 0;
	const double PI = acos(-1);
	const double eps = 1e-10;
	double x = 0.0, y = 0.0;
	int deg = 0;
	do {
		x += cos(PI*deg/180.0);
		y += sin(PI*deg/180.0);
		deg += n;
		deg %= 360;
		ans++;
		// cout << ans << ": " << x << ", " << y << endl;
	} while(x>eps || y>eps);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3956