akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL << 60;

bool num[110];

int main(){

  int n;cin>>n;

  rep(i,1,10){
    rep(j,1,10){
      num[i*j]=true;
    }
  }

  if(num[n])out("Yes");
  else out("No");



  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

class dice{
public:
	int me[6];
	int set();
	int roll(char c);
	int show();
};

int dice::set(){
	int i;

	for (i = 0; i < 6; i++)
		cin >> me[i];

	return 0;
}

int dice::roll(char c){
	int temp;
	if (c == 'S'){
		temp = me[0];
		me[0] = me[4];
		me[4] = me[5];
		me[5] = me[1];
		me[1] = temp;
	}
	else if (c == 'N'){
		temp = me[0];
		me[0] = me[1];
		me[1] = me[5];
		me[5] = me[4];
		me[4] = temp;
	}
	else if (c == 'W'){
		temp = me[0];
		me[0] = me[2];
		me[2] = me[5];
		me[5] = me[3];
		me[3] = temp;
	}
	else if (c == 'E'){
		temp = me[0];
		me[0] = me[3];
		me[3] = me[5];
		me[5] = me[2];
		me[2] = temp;
	}
	else{
		temp = me[1];
		me[1] = me[2];
		me[2] = me[4];
		me[4] = me[3];
		me[3] = temp;
	}

	return 0;
}

int dice::show(){

	cout << me[0] << endl;
	return 0;
}

int main(){
	dice d1,d2;
	string s="SSSSWSSSSWSSSS",spin="ssss";
	int i;

	d1.set();
	d2.set();

	for (i = 0; i < s.length(); i++){
		if (d1.me[0] == d2.me[0] && d1.me[5] == d2.me[5])
			break;
		else{
			d2.roll(s[i]);
		}
	}
	for (i = 0; i < spin.length(); i++){
		if (d1.me[1] == d2.me[1] && d1.me[2] == d2.me[2] && d1.me[3] == d2.me[3] && d1.me[4] == d2.me[4])
			break;
		else{
			d2.roll(spin[i]);
		}
	}

	if (d1.me[0] == d2.me[0] && d1.me[1] == d2.me[1] && d1.me[2] == d2.me[2] && d1.me[3] == d2.me[3] && d1.me[4] == d2.me[4] && d1.me[5] == d2.me[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int a,b;
  cin>>a>>b;
  if(a>8||b>8) cout<<":("<<endl;
  else cout<<"Yay!"<<endl;

}

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

using namespace std;
using ll = long long;
using ld = long double;
const int N = 606;

int n, m;
vector<int> g[N], gt[N];

ld dp[N];
ld fac[N];

int main() {
	scanf("%d %d", &n, &m);
	for(int i = 0; i < m; i++) {
		int s, t;
		scanf("%d %d", &s, &t);
		g[s].push_back(t);
		gt[t].push_back(s);
	}

	fac[1] = 1;

	for(int i = 1; i < n; i++) {
		for(int j : g[i]) {
			fac[j] += fac[i] / g[i].size();
		}
	}

	dp[n] = 0;
	for(int i = n - 1; i >= 1; i--) {
		for(int j : g[i]) {
			dp[i] += (dp[j] + 1) / g[i].size();
		}
	}

	ld ans = dp[1];
	for(int i = 1; i < n; i++) {
		if(g[i].size() <= 1) continue;
		for(int j : g[i]) {
			ld tmp = dp[i] - (dp[j] + 1) / g[i].size();
			tmp *= g[i].size();
			tmp /= g[i].size() - 1;
			ans = min(ans, dp[1] + fac[i] * (tmp - dp[i]));
		}
	}

	printf("%.20Lf\n", ans);

	return 0;
}


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

int a[305][305], cnt[305], ind[305];
bool notok[305];
int main() {
    int n, m, res = INT_MAX;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            scanf("%d", a[i] + j);
    for (int j = 0; j < m; j++) {
        memset(cnt, 0, sizeof cnt);
        for (int i = 0; i < n; i++) cnt[a[i][ind[i]]]++;
        int mx = 0;
        for (int i = 1; i <= m; i++)
            if (cnt[i] > cnt[mx]) mx = i;
        res = min(res, cnt[mx]);
        notok[mx] = 1;
        for (int i = 0; i < n; i++)
            while (notok[a[i][ind[i]]]) ind[i]++;
    }
    printf("%d", res);
}

Measured memory_bytes: 640
#include <stdio.h>
#pragma warning(disable:4996)
//FILE *in = fopen("input.txt", "r"), *out = fopen("output.txt", "w");
FILE *in = stdin, *out = stdout;
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 0x7fffffff
#define NM 100005
#define MOD 1000000007
#define FOR(i,n,m) for (int i=(n);i<=(m);i++)
#define si(n) fscanf(in,"%d",&n)
#define sd(n) fscanf(in,"%lf",&n)
typedef long long int ll;

int ans=123;
char test(ll X) {
	//*
	fprintf(out, "? %lld\n", X);
	fflush(stdout);
	char ch[5]; fscanf(in, "%s", ch);
	//*/
	return ch[0];
}
void Find(int X) {
	fprintf(out, "! %d\n", X);
}

int getLen() {
	int L = 0, R = 8, len = 9;
	while (L <= R) {
		int m = (L + R) >> 1;
		int X = 1;
		FOR(i, 1, m) X *= 10;
		if (test(X) == 'N') {
			len = min(len, m);
			R = m - 1;
		}
		else {
			L = m + 1;
		}
	}
	/*for (ll X = 1; len < 9; len++, X *= 10) {
		if (test(X) == 'N') {
			return len;
		}
	}*/
	return len;
}
int main() {
	int len = getLen();
	if (len == 9 && test(1000000000) == 'Y') { // 10^k 꼴 or 9자리
		len = 0;
		for (ll X = 2; len <= 9; len++, X *= 10) {
			char ch = test(X);
			if (ch == 'Y') {
				Find(X / 2);
				return 0;
			}
		}
	}
	int ans = 0;
	FOR(k, 1, len - 1) {
		int L = 0, R = 9, v = 9;
		if (k == 1) L = 1;
		while(L<=R){
			int m = (L + R) >> 1;
			int X = ans * 10 + m;
			if (test(X) == 'N') {
				v = min(v, m - 1);
				R = m - 1;
			}
			else {
				L = m + 1;
			}
		}
		ans = ans * 10 + v;
	}
	{ // last digit
		int L = 0, R = 9, v = -1;
		if (len == 1) L = 1;
		FOR(i, L, R) {
			ll X = ((ll)ans * 10 + i) * 10;
			if (test(X) == 'Y') {
				Find(ans * 10 + i);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll t, x;
    cin >> t >> x;
    cout << (double)t / x << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, m = gets.chomp.split.map(&:to_i)
ai = gets.split.map(&:to_i)
bi = gets.split.map(&:to_i)
w = []
ans = []
ans.push(ai.min.to_i + bi.min.to_i)
m.times do |i|
  w.push(gets.split.map(&:to_i))
  ans.push(ai[w[i][0] - 1] + bi[w[i][1] - 1] - w[i][2])
end
p ans.sort[0]


Measured memory_bytes: 20444
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    Map<String, List<Integer>> m=new TreeMap<String, List<Integer>>();
	    String[] S=new String[N];
	    int[] P=new int[N];


        for (int i=0; i<N; i++) {
        	S[i]=gs();
        	P[i]=gi();
        	if(m.containsKey(S[i])) {
        		List l=m.get(S[i]);
        		l.add(P[i]);
        	} else {
        		List l=new ArrayList();
        		l.add(P[i]);
        		m.put(S[i], l);
        	}
        }
        
        for(String str : m.keySet()) {
        	List<Integer> l=m.get(str);
        	Collections.sort(l);
        	for (int i=0; i<l.size();i++) {
        		int p=l.get(l.size()-1-i);
        		int r=0;
        		for (int j=0; j<N; j++) {
        			if(S[j].equals(str) && p==P[j]) {
        				r=j+1;
        				break;
        			}
        		}
        		System.out.println(r);
        	}
        }

        //System.out.print(v);

//        if (b>=1 && b<=12) {
//        	if(a>=1 && a<=12) {
//        	    System.out.println("AMBIGUOUS");
//        	} else {
//        		System.out.println("MMYY");
//        	}
//        }else {
//        	if(a>=1 && a<=12) {
//        	    System.out.println("YYMM");
//        	} else {
//        		System.out.println("NA");
//        	}
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35856
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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; }

int N;
ll A, B, C;
vll l;

ll rec(int n, ll a, ll b, ll c)
{
    if (n == N)
    {
        if (a == 0 || b == 0 || c == 0)
        {
            return INF;
        }

        return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    }

    ll ans = rec(n + 1, a, b, c);
    chmin(ans, rec(n + 1, a + l[n], b, c) + 10);
    chmin(ans, rec(n + 1, a, b + l[n], c) + 10);
    chmin(ans, rec(n + 1, a, b, c + l[n]) + 10);

    return ans;
}

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    in1(N);
    in3(A, B, C);
    
    l.resize(N);
    inN(l, N);

    outl(rec(0, 0, 0, 0));

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const int MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	char s[5];
	cin >> s;
	int a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
	if (a - b - c - d == 7) printf("%d-%d-%d-%d=7\n ", a, b, c, d);
	else if (a - b - c + d == 7) printf("%d-%d-%d+%d=7\n ", a, b, c, d);
	else if (a - b + c - d == 7) printf("%d-%d+%d-%d=7\n ", a, b, c, d);
	else if (a - b + c + d == 7) printf("%d-%d+%d+%d=7\n ", a, b, c, d);
	else if (a + b - c - d == 7) printf("%d+%d-%d-%d=7\n ", a, b, c, d);
	else if (a + b - c + d == 7) printf("%d+%d-%d+%d=7\n ", a, b, c, d);
	else if (a + b + c - d == 7) printf("%d+%d+%d-%d=7\n ", a, b, c, d);
	else if (a + b + c + d == 7) printf("%d+%d+%d+%d=7\n ", a, b, c, d);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

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

  std::vector<std::tuple<std::string, int, int>> v(n);

  for (int i = 0; i < n; ++i) {
    auto& e = v[i];
    std::cin >> std::get<0>(e) >> std::get<1>(e);
    std::get<2>(e) = i + 1;
  }

  std::sort(v.begin(), v.end(), [](const auto& e1, const auto& e2) {
    const auto& s1 = std::get<0>(e1);
    const auto& s2 = std::get<0>(e2);
    const auto p1  = std::get<1>(e1);
    const auto p2  = std::get<1>(e2);
    return s1 == s2 ? p1 > p2 : s1 < s2;
  });

  for (auto&& e : v) std::cout << std::get<2>(e) << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
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(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}
template<class T>istream&operator>(istream&i,T&t){return i>>t;}
#ifndef LOCAL
struct ostdmy{
template<class T>ostdmy&operator<<(const T&t){return*this;}
template<class T>ostdmy&operator<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif



ll n;

template<class T>
void prime_factors(T n, map<T, int>&out) {
    if(n == 1) { // n=1 の素因数分解はなし
        return;
    }
    for(T i = 2, _n = n; i*i <= _n; ++i) {
        while(n % i == 0) {
            ++out[i]; // 素数i^{out[i]}
            n /= i;
        }
    }
    if(n != 1) out[n] = 1;
}

ll saiki(ll a, const map<ll,int>& ps, map<ll,int>::iterator iter){
    if(iter == ps.end()){
        if((n/a-1)<=a)return /*cerr<<":(",*/0;
        //cerr<n/a-1<endl;
        return n/a-1;
    }
    ll ret=0;
    auto nx=next(iter);
    REP(i,iter->S+1){
        ret+=saiki(a, ps, nx);
        a*=iter->F;
    }
    return ret;
}

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

    cin>n;
    map<ll,int> primes;
    prime_factors(n, primes);
    cout<saiki(1, primes, primes.begin())<endl;
    //while()
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  vector<int>l(N);
  for(int i=0;i<N;i++){
   cin>>l.at(i);
  }sort(l.begin(),l.end());
  int ans=0;
  for(int i=N-K;i<N;i++)
    ans+=l.at(i);
  cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
 int a,b;
 scanf("%d %d",&a,&b);
 int c = a-b;
 if(c==0) printf("Draw");
 else if(a==1) printf("Alice");
 else if(b==1) printf("Bob");
 else if(c>0) printf("Alice");
 else printf("Bob");
 return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<std::string> W){
    string ans = YES;
    set<string> memo;
    memo.insert(W[0]);
    REP1(i, N) {
        if(W[i-1][W[i-1].length()-1] != W[i][0] || memo.count(W[i]) == 1){
            ans = NO;
        }
        memo.insert(W[i]);
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> W(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> W[i];
    }
    solve(N, std::move(W));
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = 0
mod = 10**9+7
sa = [0]
for i in range(n):
    sa.append((sa[i]+a[i])%mod)
for i in range(n-1):
    ans += a[i]*(sa[-1]-sa[i+1])
print(ans%mod)

Measured memory_bytes: 31612
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
const int MAXM = 4e2 + 5;
const int MAXN = 26 + 5;
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;

int n=26, m;
int c[MAXN];
int a[MAXM][MAXN];

int p[MAXM];
set<int> idx[MAXN];
int ans;

void init(void)
{
	for(int i=1; i<=n; ++i)
	{
		idx[i].clear();
		idx[i].insert(0);
		idx[i].insert(m+1);
	}
	
	for(int k=1; k<=m; ++k)
		idx[ p[k] ].insert(k);
}

int recalc(register int pos, register int x)
{
	register int old = p[pos];
	if(old == x) return ans;
	
	register int res = ans;
	
	idx[old].erase(pos);
	
	set<int>::iterator it = idx[old].upper_bound(pos);
	register int nxt = *it;
	register int lst = *(--it);
	
	res -= (pos - lst) * c[old] * (nxt - pos) + a[pos][old];
	
	it = idx[x].upper_bound(pos);
	nxt = *it;
	lst = *(--it);
	
	res += (pos - lst) * c[x] * (nxt - pos) + a[pos][x];
	
	idx[x].insert(pos);
	
	p[pos] = x;
	return res;
}

int main(void)
{
	srand(time(0));
	
	scanf("%d",&m);
	for(int i=1; i<=n; ++i) scanf("%d",&c[i]);
	for(int i=1; i<=m; ++i)
		for(int j=1; j<=n; ++j)
			scanf("%d",&a[i][j]);
	
	static int lst[MAXN];
	
	ans = 0;
	for(int k=1; k<=m; ++k)
	{
		int mx = -inf;
		int mxi = -1;
		for(int i=1; i<=n; ++i)
		{
			int res = a[k][i];
			for(int j=1; j<=n; ++j) if(j!=i)
				res -= c[j] * (k-lst[j]);
			
			if(mxi==-1 || mx < res)
				mxi = i, mx = res;
		}
		lst[mxi] = k;
		
		ans += mx;
		p[k] = mxi;
	}
	
	init();
	
	register int T = 3e6;
	while(T--)
	{
		int pos = rand()%m + 1;
		int x = rand()%n + 1;
		
		int old = p[pos];
		int res = recalc(pos, x);
		if(res < ans) recalc(pos, old);
		else ans = res;
	}
	
	for(int i=1; i<=m; ++i) printf("%d\n",p[i]);
	return 0;
}

Measured memory_bytes: 3324
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

double ans = 0;
int n, m;

void func(int s[], double d[20][20], int beforenum, int cnt)
{
	if(cnt == m){
		double sum = 0;
		for(int i = 0; i < cnt - 1; i++){
			for(int j = i + 1; j < cnt; j++){
				sum += d[s[i]][s[j]];
			}
		}
		ans = max(ans, sum);
		return;
	} else {
		for(int i = beforenum + 1; i < n; i++){
			s[cnt] = i;
			func(s, d, i, cnt + 1);
		}
	}
}

int main()
{
	double l[20], a[20], b[20];
	double distance[20][20];
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> l[i] >> a[i] >> b[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			distance[i][j] =  pow((l[i] - l[j]), 2) + pow((a[i] - a[j]), 2) + pow((b[i] - b[j]), 2);
			distance[j][i] = distance[i][j];
		}
	}
	int select[20];
	func(select, distance, -1, 0);
	cout.setf(std::ios_base::fixed,std::ios_base::floatfield);
	cout << setprecision( 6 ) <<  ans << endl;
	return 0;
}

Measured memory_bytes: 1296
s = input()
ans =0
if 'N' in s and 'S' not in s:
  ans =1
elif 'S' in s and 'N' not in s:
  ans =1
elif 'W' in s and 'E' not in s:
  ans =1
elif 'E' in s and 'W' not in s:
  ans =1
print('No' if ans ==1 else 'Yes')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) {
    int x;
    cin >> x;
    a[i] = x-1;
  }

  vector<int> visited(n,INF);
  ll ct = 0;
  visited[0] = ct;
  ll pos = 0;
  ll loop = 0;
  while(1){
    ct += 1;
    pos = a[pos];
    if(ct == k){
      cout << pos+1 << endl;
      return 0;
    }
    if(visited[pos] != INF){
      loop = ct - visited[pos];
      break;
    }else{
      visited[pos] = ct;
    }
  }

  k -= visited[pos];
  k %= loop;
  while(k > 0){
    pos = a[pos];
    k--;
  }
  cout << pos+1 << endl;

  return 0;
}


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int n,k;
	string s;
	cin >> n >> k >> s;
	vector<int> nums;
	if(s[0]=='0') nums.push_back(0);
	for(int i=0;i<s.size();){
		int j = i;
		while(j < s.size() && s[j]==s[i]) j++;
		nums.push_back(j-i);
		i = j;
	}
	//cout << endl;
	if(s.back()=='0') nums.push_back(0);
	//cout << endl;
	vector<int> sums((int)nums.size()+1,0);
	for(int i = 0; i < nums.size();i++) sums[i+1] = sums[i] + nums[i];
	//for(int i = 0; i < nums.size();i++) cout << nums[i] << endl;
	int res = 0;
	for(int left = 0 ; left < sums.size(); left += 2){
		int right = left + k*2 + 1;
		if(right >= sums.size()) right = (int)sums.size() - 1;
		res = max(res, sums[right] - sums[left]);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1272
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int n,a[200000],b[200000];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            b[i]=a[i];
        }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        if(b[i]==a[n-1])
            printf("%d\n",a[n-2]);
        else
            printf("%d\n",a[n-1]);
    }
	return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }

lli cnt[10000100];

void func(long long N){

    lli ans = 0;
    REP(i,1,N+1){
        for(lli j=1;i*j <N+1;j++){
            ans += (i*j);
        }
    }

    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    func(N);
    return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int h, w, m;
    cin >> h >> w >> m;

    vector<int> x(h), y(w);
    set<pair<int, int>> st;
    for (int k = 0; k < m; k++) {
        int i, j;
        cin >> i >> j;
        i--; j--;

        x[i]++;
        y[j]++;
        st.insert({ i, j });
    }

    int mx = *max_element(x.begin(), x.end());
    int my = *max_element(y.begin(), y.end());

    vector<int> a, b;
    for (int i = 0; i < h; i++) {
        if (x[i] == mx) a.push_back(i);
    }
    for (int j = 0; j < w; j++) {
        if (y[j] == my) b.push_back(j);
    }

    int r = mx + my - 1;
    for (auto i : a) {
        for (auto j : b) {
            if (st.count({ i, j }) == 0) {
                r++;
                goto L;
            }
        }
    }

L:
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 23772
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
vector<pair<int,int> > red,blue;
int used[MAX];
int N;
// int H;
// vector<int> thrower;

// int Rx[MAX];
// int Ry[MAX];
// int Bx[MAX];
// int By[MAX];
// int dp[1000000001];

int main(void){
    // Your code here!
    cin >> N;
    int a,b;
    REP(i,0,N){
        cin >> a >> b;
        red.push_back({a,b});
    // cin >> C[i] >> S[i] >> F[i];
    }
    
    REP(i,0,N){
        cin >> a >> b;
        // cout << blue[0].first << endl;
        blue.push_back({a,b});
    // cin >> C[i] >> S[i] >> F[i];
    }
    
    sort(blue.begin(),blue.end());
    
    int ans = 0;
    // cout << blue[0].first << endl;
    for (auto b : blue) {
        int maxRy = -1; 
        int temp = -1;
        
        REP(i,0,N) {
            if (used[i] == 1) continue;
            if (red[i].first <= b.first && red[i].second <= b.second) {
                if (red[i].second > maxRy) {
                    temp = i;
                    maxRy = red[i].second;
                }
            }
            
        }
        if (temp != -1){
            ans++;
            used[temp] = 1;
        }
        
    }
    // ans[N-1] = 0;
    // ans[N-2] = S[N-2] + C[N-2];
    // for(int i = N-3; i >= 0; i--) {
    //     if (S[i] + C[i] < ans[i+1]) { // 次の駅の最短時間に間に合う場合
    //         ans[i] = ans[i+1];
    //         // cout << S[i] + C[i] << endl;
    //     }
    //     else {
    //         // cout << i <<  S[i] + C[i] << endl;
    //         S[i] + C[i] ;
    //         S[i+1] + F[i+1];
    //     }
    // }
    
    // REP(i,0,N){
    cout << ans << endl;
    // }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main()
{
  int a, b, k;
  set<int> numbers;
  cin >> a >> b >> k;
  for(int i = a, pos = 1; a <= i && i <= b && pos <= k; ++i, ++pos)
    numbers.insert(i);
  for(int i = b - k + 1, pos = 1; a <= i && i <= b && i <= b && pos <= k; ++i, ++pos)
    numbers.insert(i);
  for (auto e : numbers)
    cout << e << endl;
}


Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<int>::max()/4;
constexpr ll n_max = 2e5+10;
// #define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    ll n = s.size();
    vector<ll> a(n);
    ll hash = 0;
    rep(i,0,n){
        ll t = s[i] - 'a';
        hash ^= (1LL << t);
        a[i] = hash;
    }
    debug(a);
    vector<int> dp(n+1, INF);
    dp[0] = 0;
    // map<ll, ll> mp;
    vector<int> mp(1LL << 26, INF);
    mp[0] = 0;
    rep(i,0,n){
        ll h = a[i];
        rep(j,0,26){
            chmin(dp[i+1], mp[(1LL << j) ^ h] + 1);
        }
        chmin(dp[i+1], mp[h] + 1);
        chmin(mp[h], dp[i+1]);
    }
    debug(dp);
    cout << dp[n] << endl;
}

Measured memory_bytes: 265236
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();
        boolean ok = true;
        for(int i = 0;i < s.length();i++){
            if(i == a && s.charAt(a) != '-'){
                ok = false;
            }
            if(i != a && s.charAt(i) == '-'){
                ok = false;
            }
        }

        if(ok){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23892
// https://atcoder.jp/contests/abc078/tasks/arc085_a

#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

ll N, M;

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

  cout << ((N + 18 * M) * 100 << M) << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

priority_queue<int, vector<int>, greater<int>> pq;
vector<int> v;

char vi[201];

int main() {
    int n, x;
    scanf("%d %d", &x, &n);

    for (int i = 0; i < n; i++) {
        int t;
        scanf("%d", &t);
        vi[t]++;
    }

    int mav = 1e9;
    int mavi;
    for (int i = -100; i <= 0; i++) {
        if (mav > abs(i-x)) {
            mav = abs(i-x);
            mavi = i;
        }

    }
    for (int j = 1; j <= 200; j++) {
        if (!vi[j] && mav > abs(j-x)) {
            mav = abs(j-x);
            mavi = j;
        }
        else if (!vi[j] && mav == abs(j-x))
            mavi = min(mavi, j);
    }

    printf("%d", mavi);
}

Measured memory_bytes: 3840
#include<stdio.h>
int main(void)
{
  int m,n;
  int a[10000];
  int sum=0;
  int cnt=0;
  
  scanf("%d %d",&n,&m);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
  }
  for(int i=0;i<n;i++){
    if((double)a[i]>=(double)sum/(4.0*(double)m)){
      cnt++;
    }
  }
  cnt>=m?printf("Yes\n"):printf("No\n");
  return 0;
}


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

#define bitGet(a, i) a & (1 << i)
#define bitOn(a, i) a != (1 << i)
#define bitOff(a, i) a &= ~(1 << i)
#define bitMake(a, i) a = (1 << N)
#define fto(i, a, b) for(int i = a; i <= b; ++i)
#define fdto(i, a, b) for(int i = a; i >= b; --i)
#define ull unsigned long long
#define ll long long
#define ld long double
#define pri(a) cout << a << " "
#define pril(a) cout << a << " "
#define pb push_back
#define mp make_pair
#define vi vector<int> 
#define pi pair<int, int>
#define oo INT_MAX
#define maxN

using namespace std;


int main() {
    #ifndef ONLINE_JUDGE
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    #endif // !ONLINE_JUDGE

    ld d, t, s;
    cin >> d >> t >> s;

    ld x = d / s;

    if(x <= t) pril("Yes");
    else pril("No");
    
    return 0;
}


Measured memory_bytes: 3720
def main():
    s = list(input())

    cnt = 0
    if s[0] == 'R':
        cnt = 1

    if s[1] == 'R':
        if s[0] == 'R':
            cnt = 2
        else:
            cnt = 1

    if s[2] == 'R':
        if s[0] == 'R' and s[1] == 'R':
            cnt = 3
        elif s[1] == 'R':
            cnt = 2
        else:
            cnt = 1

    print(cnt)    

 

if __name__ == '__main__':
    main()

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

int main(){
    long long n,m;
    cin >> n >> m;
    long long x[n] , y[m];
    for (int  i = 0; i < n; i++)
    {
        cin >> x[i];
    }
    for (int  i = 0; i < m; i++)
    {
        cin >> y[i];
    }
    const long long mod = 1e9+7;
    long long ans=0;

    long long s=0,t=0;
    for(int i=0;i<n;i++){
        s += (i*x[i])%mod - ((n-1-i)*x[i])%mod;
        s += mod;
        s%=mod;
    }
    for(int i=0;i<m;i++){
        t += (i*y[i])%mod - ((m-i-1) * y[i])%mod;
        t += mod;
        t %= mod;
    }
    ans = t*s;
    ans%=mod;
    cout<<ans<<endl;
    
    
    
}

Measured memory_bytes: 1792
from numpy import*
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    n,k=map(int,input().split())
    a=array(sorted(map(int,input().split())))
    b=array(sorted(map(int,input().split())))[::-1]
    ok=max(a)*max(b)
    ng=-1
    s=sum(a)
    def check(a,b,mid,k):
        if s-sum(minimum(a,mid//b))<=k:
            return 1
        else:
            return 0
            
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if check(a,b,mid,k):
            ok=mid
        else:
            ng=mid
    print(ok)

if __name__ == '__main__':
    main()

Measured memory_bytes: 35644
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    char C[2][4];

    scanf("%s", C[0]);
    scanf("%s", C[1]);

    if(C[0][0] == C[1][2] && C[0][1] == C[1][1] && C[0][2] == C[1][0]){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 1592
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
int main()
{
	int n, ans = 0;
	string s[200001];
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		cin >> s[i];
	}
	sort(s, s + n);
	for(int i = 1, j = 1; i < n; ++i)
	{
		if(s[i - 1] == s[i])
		{
			++j;
		}
		else
		{
			j = 1;
		}
		ans = max(ans, j);
	}
	for(int i = 0; i < n - ans + 1; ++i)
	{
		if(s[i] == s[i + ans - 1])
		{
			cout << s[i] << "\n";
			i += ans - 1;
		}
	}
}

Measured memory_bytes: 14208
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    int a,b,c,d,start,end,ans;
    cin >> a >> b >> c >> d;
    start = max(a,c);
    end = min(b,d);
    if(end < start)ans = 0;
    else ans = end - start;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define 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 INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  ll now ;
  vector<ll> v;
  if(s[0] == '<'){
    now = 0;
  }else{
    now = 1;
  }
  ll cnt= 1;
  FOR(i,1,(ll)s.size()){
    if(s[i]=='<'){
      if(now == 0){
        cnt++;
      }else{
        v.pb(cnt);
        cnt = 1;
        now = 0;
      }
    }else{
      if(now == 1){
        cnt++;
      }else{
        v.pb(cnt);
        cnt = 1;
        now = 1;
      }
    }
  }
  v.pb(cnt);
  ll ans = 0;
  if(s[0]=='>'){
    v.insert(v.begin(),1);
  }
  for(ll i = 0; i<v.size()-1; i+=2){
    ll ma = max(v[i],v[i+1]);
    ll mi = min(v[i],v[i+1]);
    ans += ma*(ma+1)/2;
    ans += mi*(mi-1)/2;
  }
  if(v.size()%2 && v.size()){
    ll la = v[v.size()-1];
    ans += la*(la+1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char c,k;
    int ans(0);
    scanf("%c",&c);
    printf("%c",c);
    while(c=getchar())
	{
        if(c==' '||c=='\n')break;
        ++ans;
        k=c;
    }
    printf("%d%c",ans-1,k);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>

using namespace std;

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

int n;

int main()
{
	n=read();
	if(n%10==7||n/10%10==7||n/100==7)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
const ll INF = 1LL << 62;

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

template <typename T>
T gcd(T a, T b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

int x;
void input() {
    cin >> x;
}

void solve() {
    int target = x;
    int flag = 0;
    do {
        flag = 0;
        int limit = sqrt(target);
        for(int i = 2; i <= limit; i++) {
            if( target % i == 0) {
                flag = 1;
                break;
            }

        }
        if(flag == 1) {
            flag = 0;
            ++target;
        } else {
            cout << target;
            return;
        }
    } while(1);

}



int main() {
    input();
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
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);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int N;
    cin >> N;
    string S;
    cin >> S;
    rep(i,S.size()){
        int x=S[i]-'A';
        int n=(x+N)%26;
        cout << char(n+'A');
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
string S;
cin >> S;
int count = 0;
for(int i = 0; i < N - 2;i++){
 if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {count++;
 }
}
 cout << count << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict

N=sys.stdin.readline().strip()
N=N[::-1]
#Lの先頭の0を入れるのは、何も数を選択しない状態はmod2019がゼロになるの意味
#19行目でx=0の際に、ans+=C[x]で1足されることになるので都合が良い
L=[0] 
val=0
for i,x in enumerate(N):
    val+=pow(10,i,2019)*int(x)
    L.append(val%2019)

C=defaultdict(lambda: 0)    #mod2019の値の出現個数を記録
ans=0
for x in L:
    ans+=C[x]   #自分とmod2019の結果が同じ値となる出現個数をansに足す
    C[x]+=1     #自分のmod2019の値を出現個数に+1カウント
print ans


Measured memory_bytes: 85628
#include <iostream>
#include <cstring>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <assert.h>
#include <stdlib.h>
using namespace std;

void smain();
int main() {
    ios_base::sync_with_stdio(0);
#ifdef TASK
    freopen(TASK".in","rt",stdin);
    const clock_t start = clock();
#endif
    smain();
#ifdef TASK
    cerr << "\nTotal Execution Time: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

#ifndef M_PI
#define M_PI 3.14159265358979311599796346854418516
#endif
#define forn(i,n) for (int i=0;i<n;i++)
#define rforn(i,n) for (int i=n-1;i>=0;i--)
#define LL long long
#define int long long
#define mp(a,b) make_pair(a,b)
#define INF 2305843009213693951LL
#define MOD 1000000007
#define EPS 1E-9
#define N 400002
/* --------- END TEMPLATE CODE --------- */
int a[N], b[N], n;

void smain() {
    for (; cin >> n; ) {
        forn(i, n) cin >> a[i];
        forn(i, n) b[i] = a[i];
        sort(b, b + n);
        int res = 0;
        forn(i, n) {
            int j = lower_bound(b, b + n, a[i]) - b;
            if (j % 2 != i % 2) res += 1;
        }
        cout << res / 2 << endl;
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

int main(){
  string S, T;
  cin>>S>>T;
  ll Sz=S.size();
  ll Cnt=0;
  rep(i, Sz){
    if(S.at(i)!=T.at(i))Cnt++;
  }
  cout<<Cnt<<endl;
}

Measured memory_bytes: 3852
N, Y = map(int, input().split())
ans = (-1, -1, -1)
for i in range(0, N + 1):
    for j in range(0, N + 1 - i):
        if N - i - j >= 0 and 10000 * i + 5000 * j + 1000 * (N - i - j) == Y:
            ans = (i, j, N - i - j)

print(ans[0], ans[1], ans[2])

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

using namespace std;

typedef long long int ll;

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

  int n, K;
  cin >> n >> K;
  vector < ll > a(n + 1);
  for(int i = 1; i <= n; i++) cin >> a[i];

  int ans = 0;
  for(int k = 1; k <= K; k++){
    for(int i = 0; i <= k; i++){
      vector < int > v;
      for(int j = 1; j <= i && j <= n; j++) v.push_back(a[j]);
      for(int j = n; j >= 1 && j > n - (k - i) && j > i; j--) v.push_back(a[j]);
      int left = K - k, sum = 0;
      sort(v.begin(), v.end());
      for(int j = 0; j < v.size(); j++){
        sum += v[j];
        if(left > 0 && v[j] < 0){
          sum -= v[j];
          left--;
        }
      }
      ans = max(ans, sum);
    }
  }

  cout << ans << '\n';
}


Measured memory_bytes: 892
#include<cstdio>
#include<cstring>
using namespace std;
char s[50];

int main()
{
	scanf("%s",s+1);
	int l=strlen(s+1);
	if(l<4)	puts("No");
	else
	if(s[1]!='Y')	puts("No");
	else
	if(s[2]!='A')	puts("No");
	else
	if(s[3]!='K')	puts("No");
	else
	if(s[4]!='I')	puts("No");
	else	puts("Yes");
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    string s;
    cin>>s;
    vector<bool> exist(26,false);
    REP(i,s.size()) {
        exist[(s[i]-'a')] = true;
    }
    REP(i,26) {
        if (!exist[i]) {
            cout<<(char)('a' + i)<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}

Measured memory_bytes: 512