akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

class dice{
    public:
    int d[7];

    dice(){ //??????????????????????????????
    	
    }

    void east(){
    	d[0]=d[1],d[1]=d[4],d[4]=d[6],d[6]=d[3],d[3]=d[0];
    }

    void north(){
    	d[0]=d[5],d[5]=d[1],d[1]=d[2],d[2]=d[6],d[6]=d[0];
    }

    void turn(){
        d[0]=d[2],d[2]=d[4],d[4]=d[5],d[5]=d[3],d[3]=d[0];    
    }

};

int main(){
    dice D1,D2;
    int c=0;
    for(int i=1; i<7; i++)cin >> D1.d[i];
    for(int i=1; i<7; i++)cin >> D2.d[i];

    for(int i=1; i<7; i++){ 
        if(D1.d[1]==D2.d[1]){
            for(int j=0; j<4; j++){
                if(D1.d[2]==D2.d[2]){
                    if( D1.d[3]==D2.d[3] && D1.d[4]==D2.d[4] && D1.d[5]==D2.d[5] && D1.d[6]==D2.d[6] )c++;
                }        
                D2.turn();
            }
        }
        if(i%2==1)D2.east();
        else D2.north();
    }

    if(c==0)cout << "No" <<endl;
    else cout << "Yes" <<endl;   

    return 0;
}

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

const int MAXN = 100005;

int a[MAXN], n, k;

struct node {
	int to, next;
} edge[MAXN*2];
int head[MAXN], top = 0;
inline void push(int i, int j)
{ edge[++top] = (node) {j, head[i]}, head[i] = top; }

int cnt = 0;

int dfs(int nd, int f)
{
	int dep = 1;
	for (int i = head[nd]; i; i = edge[i].next) {
		int to = edge[i].to;
		if (to == f) continue;
		dep = max(dep, dfs(to, nd)+1);
	}
	// cerr << nd << " " << dep << endl;
	if (dep == k && nd != 1 && f != 1) dep = 0, cnt++;
	return dep;
}

int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	if (a[1] != 1) cnt++;
	for (int i = 2; i <= n; i++) push(i, a[i]), push(a[i], i);
	dfs(1, 0);
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 7296
from collections import Counter as c
n = int(input())
x = list(map(int, input().split()))
d = dict(c(x))
q = int(input())
s = sum(x)
for i in range(q):
    x, y = list(map(int, input().split()))
    if y in d:
        if x in d:
            d[y] += d[x]
        else:
            d[x] = 0
    else:
        if x in d:
            d[y] = d[x]
        else:
            d[x] = 0
    s += d[x]*(y-x)
    print(s)
    d[x] = 0

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

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

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

signed main() {
		int n,m;
		cin >> n >> m;
		vector<int> x;
		vector<int> y;
		int X,Y;
		cin >> X >> Y;
		string ans = "No War";
		for(int i=0;i<n;i++){
				int tmp;
				cin >> tmp;
				x.push_back(tmp);
				if(tmp >= Y){
						ans = "War";
						break;
				}
		}
		for(int i=0;i<m;i++){
				int tmp;
				cin >> tmp;
				y.push_back(tmp);
				if(tmp <= X){
						ans = "War";
						break;
				}
		}
		auto x_max = max_element(x.begin(),x.end());
		auto y_min = min_element(y.begin(),y.end());
		if(*y_min <= *x_max){
				ans = "War";
		}
		cout << ans << endl;

}


Measured memory_bytes: 256
n, k = map(int, input().split())
data = [[int(input()), list(map(int, input().split()))] for i in range(k)]
person = list(range(1, n+1))

for d in data:
    for i in range(d[0]):
        if d[1][i] in person:
            person.remove(d[1][i])
        if person == []:
            print("0", end="")
            exit()
print(len(person), end="")


Measured memory_bytes: 9136
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N;
  cin>>N;
  LINT a[N];
  REP(i, N)cin>>a[i];
  if(N==2){
    cout<<abs(a[0]-a[1])<<endl;
    return 0;
  }

  LINT ans1=0;
  LINT ans2=0;
  sort(a, a+N);
  if(N%2){
    REP(i, N){
      if(i<N/2-1) ans1 -= 2*a[i];
      else if(i>N/2) ans1 += 2*a[i];
      else ans1 -=a[i];
      //cout<<a[i]<<" "<<ans1<<endl;
    }
    REP(i, N){
      if(i<N/2) ans2 -= 2*a[i];
      else if(i>N/2+1) ans2 += 2*a[i];
      else ans2 +=a[i];
      //cout<<a[i]<<" "<<ans2<<endl;
    }
    ans1 = max(ans1, ans2);
  }
  else{
    REP(i, N){
      if(i<N/2-1) ans1 -= 2*a[i];
      else if(i>N/2) ans1 += 2*a[i];
      else if(i==N/2-1) ans1 -=a[i];
      else ans1 += a[i];
      //cout<<a[i]<<" "<<ans1<<endl;
    }
  }
  cout<<ans1<<endl;


  return 0;
}


Measured memory_bytes: 1024
/*

*/
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<cmath>
#include<bitset>
#include<ctime>
using namespace std;
#define ll long long
#define N 100003
#define INF 0x3f3f3f3f
#define mod1 998244353
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
int n, a[N];
ll multiMod(ll a,ll b,ll mod){
    ll ret = 0LL;
    a %= mod;
    while( b ){
        if ( b & 1LL ) ret = ( ret + a ) % mod, --b;
        b >>= 1LL;
        a = ( a + a ) % mod;
    }
    return ret;
}
ll gcd(ll a,ll b){
    if (0L == a || 0L == b) return 1;
    if ( a < 0 ) a = -a;
    if ( b < 0 ) b = -b;
    while(b){
        ll t = a % b;
        a = b;
        b = t;
    }
    return a;
}

ll Pollard_Rho(ll n,ll c){
    ll i = 1, k = 2;
    ll x = rand() % n;
    ll y = x;
    while(1){
        ++i;
        x = ( multiMod(x,x,n) + c ) % n;
        ll d = gcd(y-x,n);
        if (d!=1LL && d!=n) return d;
        if (y == x) return n;
        if ( i == k ) y = x, k <<= 1;
    }
}

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int i, j, t;
	ll s, a, b;
	const ll N1 = 1000000000;
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	srand(time(NULL));
	cin>>s;
	a = (N1-s%N1)%N1;
	b = (s+a)/N1;
	
	cout<<"0 0 1000000000 1 "<<a<<' '<<b<<endl;
	//cout<<ret<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() {
    //init();

    int n; cin >> n;

    vector<string> s(n);
    cout << "0\n"; 
    fflush(stdout);
    cin >> s[0];
    if (s[0] == "Vacant")return 0;

    int l = 1, r = n;
    while (1) {
        int mid = (l + r) / 2;
        cout << mid << "\n";
        fflush(stdout);
        cin >> s[mid];
        if (s[mid] == "Vacant")return 0;

        if ((mid % 2 == 0 && s[0] == s[mid]) || (mid % 2 == 1 && s[0] != s[mid]))l = mid + 1;
        else r = mid;
    }
}


Measured memory_bytes: 1620
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>

double round(double r) {
    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}

using namespace std;




int main() {
	
	
	int a,b;
	cin>>a>>b;
	int t=0;
	if(a>b)swap(a,b);
	for(int i=a;i<=b;i++){
		if(i<0)t++;
		if(i==0){cout<<"Zero"<<endl;return 0;}
	}
	if(t%2==0)cout<<"Positive"<<endl;
	else cout<<"Negative"<<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[] cnt = new int[100];
		int max = 0;
		for(int i = 0;i<100;i++){
			cnt[i] = 0;
		}
		while(sc.hasNext()){
			int number = sc.nextInt();
			cnt[number-1] += 1;
		}
		for(int j = 0;j<100;j++){
			if(cnt[j] >= max){
				max = cnt[j];
			}
		}
		for(int k = 0;k < 100;k++){
			if(cnt[k] == max){
				System.out.println(k+1);
			}
		}
	}
}

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

int main(){
	int a;
	cin >> a;
	for(int i=1;i<=50000;i++){
		if(int(i * 1.08) == a){
			printf("%d",i);
			return 0;
		}
	}
	printf(":(");
	return 0;
} 

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

const long mod = 1000000007;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res = INT_MAX;

	long N, M; cin >> N >> M;

	res = pow(2, M) * (1900 * M + 100 * (N - M));

	cout << res << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
A =[a,b,c,d,e]
A.sort(reverse=True)
K = []
for i in range(len(A)-1):
  for j in range(i+1,len(A)):
    K.append(A[i]-A[j])
Max = 0
for n in range(len(K)):
  Max = max(Max,K[n])
if (Max <= k):
  print("Yay!")
else:
  print(":(")


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

int main(){
  vector<int> a(3);
  
  cin >> a[0] >> a[1] >> a[2];
  
  sort(a.begin(), a.end());
  
  cout << a[0] << " " << a[1] << " " << a[2] << endl;
  
  return 0;
}


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

int main()
{
  int h;
  int w;
  char c = '#';
  char point = '.';
  do 
  {
  cin >> h >> w;
  
  for(int i = 0; i < h; i++)
  {
    for(int j = 0; j < w; j++)
    {
      if((i + j) % 2 == 0)
      {
        cout << c;
      }
      else
      {
        cout << point;
      }
    }
    cout << endl;
  }
    if (h != 0 && w != 0)
      cout << endl;
  }while(h != 0 && w != 0);
}


Measured memory_bytes: 3116
#include <iostream>
using namespace std;
int main(){
    int a=0,cnt=0,i=0;
    string S;
    cin >> S;
    while(i<S.size()){
        if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T'){
            cnt++;
            i++;
        }else{
            a=max(a,cnt);
            cnt=0;
            i++;
        }
    }
    a=max(a,cnt);
    cout << a;
}

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

int main(){
  ll n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  ll ans = 0;
  while(true) {
    bool can = true;
    rep(i,n) {
      if(a[i] >= n) can = false;
    }
    if(can) break;
    ll sum = 0;
    rep(i,n) {
      ans += a[i]/n;
      sum += a[i]/n;
    }
    rep(i,n) a[i] = (a[i] % n) + sum - a[i]/n;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=100000+10;
ll n,k,A[MAXN],B[MAXN],ans;
inline void read(ll &x)
{
	ll data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((ll)data<<3)+((ll)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
inline void dfs(ll len,ll now,bool all)
{
	if(all&&len>=0)
	{
		if(k&(1ll<<len))
		{
			dfs(len-1,now^(1ll<<len),false);
			dfs(len-1,now,true);
		}
		else dfs(len-1,now^(1ll<<len),true);
	}
	else
	{
		ll res=0;
		for(register ll i=1;i<=n;++i)
			if((A[i]&now)==A[i])res+=B[i];
		if(ans<res)ans=res;
	}
}
int main()
{
	read(n);read(k);
	for(register int i=1;i<=n;++i)
	{
		read(A[i]);read(B[i]);
	}
	dfs(30,-1,1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a[3000][3000];
ll b[5000]; 
ll min(ll a1,ll b1,ll c1)
{
    
    return min(b1,min(a1,c1)); 
    
}
int main() 
{
ll n,x,y;
cin>>n>>x>>y;
    ll i=1;
    while(i<=n)
    {
        ll j=i+1;
        while(j<=n)
        {
            ll way1=abs(j-i);
            
            ll way2=abs(i-x)+1+abs(j-y);
            
            ll way3=abs(i-y)+1+abs(j-x);
            
            
            a[i][j]=min(way1,way2,way3);
            b[a[i][j]]++; 
            
                       
            
            
            j++;
        }
        
        i++;
    }
    

    i=1;
    while(i<=n-1)
    {
        cout<<b[i]<<"\n";
        i++;
    }
    
    
    return 0;
}

Measured memory_bytes: 46976
#ifndef ___Geometry_Library
#define ___Geometry_Library

// ------ Includes ------ //
#include <cmath>
#include <complex>
#include <utility>
#include <algorithm>

// ------ Defines ------ //
typedef long double GType;
typedef std::complex<GType> Point;
typedef std::pair<Point, Point> Segment;

// ------ Constants ------ //
const GType EPS = 1.0e-10L;

// ------ Functions Level 1 ------ //
GType dot(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).real();
}
GType cross(const Point& p1, const Point& p2) {
	return (std::conj(p1) * p2).imag();
}
int ccw(const Point& p1, const Point& p2, const Point& p3) {
	Point v1 = p2 - p1, v2 = p3 - p1;
	if (cross(v1, v2) > EPS) return +1;
	if (cross(v1, v2) < -EPS) return -1;
	if (dot(v1, v2) < -EPS) return +2;
	if (std::norm(v1) < std::norm(v2)) return -2;
	return 0;
}

// ------ Functions Level 2 ------ //
bool intersect(const Segment& s1, const Point& p1, bool segflag) {
	if (!segflag) return std::abs(cross(s1.second - p1, s1.first - p1)) < EPS;
	return (std::abs(s1.first - p1) + std::abs(s1.second - p1) - std::abs(s1.second - s1.first)) < EPS;
}
bool intersect(const Segment& s1, const Segment& s2, bool segflag) {
	if (!segflag) return cross(s1.second - s1.first, s2.first - s1.first) * cross(s1.second - s1.first, s2.second - s1.first) < EPS;
	return (ccw(s1.first, s1.second, s2.first) * ccw(s1.first, s1.second, s2.second)) <= 0 && (ccw(s2.first, s2.second, s1.first) * ccw(s2.first, s2.second, s1.second)) <= 0;
}
Point projection(const Segment& s1, const Point& p1) {
	GType mul = dot(p1 - s1.first, s1.first - s1.second) / norm(s1.first - s1.second);
	return s1.first + (s1.first - s1.second) * mul;
}
Point reflection(const Segment& s1, const Point& p1) {
	return p1 + (projection(s1, p1) - p1) * (GType)(2);
}

#endif

#include <iomanip>
#include <iostream>
using namespace std;
int q, xa, ya, xb, yb; Segment s; Point p1, p2;
int main() {
	cin >> xa >> ya >> xb >> yb; s = make_pair(Point(xa, ya), Point(xb, yb));
	cin >> q;
	while (q--) {
		cin >> xa >> ya; p1 = Point(xa, ya);
		p2 = projection(s, p1);
		cout << fixed << setprecision(15) << p2.real() << ' ' << p2.imag() << endl;
	}
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N, M;
	cin >> N >> M;
	if (N == M) {
	  cout << "Yes" << endl;
	} else {
	  cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  itn int
using ll=int64_t;
#define rep(i,n) for (int i = 0; i < (int) (n); i++)
using vi = vector<int>;
using vll = vector<ll>;
/*//再帰関数木構造定型
int complete_time(vector<vector<int>> &children, int x) {
  // ベースケース
  if (children.at(x).size() == 0) {
    return 1;  // 子組織が無いような組織について、報告書が揃う時刻は0
  }// 再帰ステップ
  int receive_maisuu = 1;  // 受け取った時刻の最大値
  // x番の組織の子組織についてループ
  for (int c : children.at(x)) {receive_maisuu  += complete_time(children, c) ;}
  return  receive_maisuu ;
}*/


// 組織の関係から2次元配列を作る
//二次元配列入力定型
/*
vector<vector<int>> children(N);  // ある組織の子組織の番号一覧
  for (int i = 1; i < N; i++) {
    int parent = p.at(i);  // i番の親組織の番号
    children.at(parent).push_back(i);  // parentの子組織一覧にi番を追加
  }

  // num個分のスペースからなる文字列を返す (字下げに用いる)
  string space(int num) {
    string ret = "";
    for (int i = 0; i < num; i++) {
      ret += " ";
    }
    return ret;
  }*/


int main(){
string t;
cin>>t;
rep(i,t.size()){
  if(t.at(i)=='?')t.at(i)='D';
}
  cout<<t;
  
  

  
  

}


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

const ll mod = 1000000007;
int main() {
    ll ans = 0;
    ll N;
    cin >> N;
    ll a,b,c;
    a=b=c=1;
    rep(i,N){
        a = a*10%mod;
        b = b*9%mod;
        c = c*8%mod;
    }
    a %= mod;
    b %= mod;
    c %= mod;
    ans = (c-3*b)%mod;
    ans = (ans+a)%mod;
    ans = (ans+b)%mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
import bisect
s = list(input())
t = list(input())
n = len(s)
m = len(t)
alphabet = [[] for _ in range(26)]
for i in range(n):
  alphabet[ord(s[i])-ord('a')] += [i] 
loop = 0
pre = -1
for i in range(m):
  c = ord(t[i]) - ord('a')
  if len(alphabet[c]) == 0:
    print(-1)
    exit()
  idx = bisect.bisect_left(alphabet[c], pre+1)
  if idx == len(alphabet[c]):
    loop += 1
    pre = alphabet[c][0]
  else:
    pre = alphabet[c][idx]

print(pre + loop * n + 1)

Measured memory_bytes: 60400
# -*- coding: utf-8 -*-
import sys
from itertools import permutations
from math import sqrt
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
N = int(input())
X = [0]*N
Y = [0]*N
for i in range(N):
    X[i], Y[i] = inpl()
sum_ = 0
cnt_ = 0
for P in permutations(range(N)):
    cnt_ += 1
    for i in range(N-1):
        sum_ += sqrt(pow(X[P[i+1]]-X[P[i]], 2) + pow(Y[P[i+1]] - Y[P[i]], 2))

print(sum_/cnt_)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,k;
  cin >> n >> k;
  ll cnt = 0;
  ll num[k];
  for(int i=0 ; i<k ; i++){
    num[i] = 0;
  }
  for(int i=1 ; i<=n ; i++){
    num[i%k]++;
  }
  ll res = 0;
  for(int a=0 ; a<k ; a++){
    ll b = (k-a) % k;
    ll c = (k-a) % k;
    if((b+c) % k != 0) continue;
    res += num[a] * num[b] * num[c];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
typedef long long ll;

ll a[MAXN];

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

	ll hj = (1+n) * n / 2;

	if (sum % hj != 0)
	{
		cout << "NO";
		return 0;
	}

	ll k = sum / hj;

	ll sum_ki = 0;
	for (int i = 0; i < n; i++)
	{
		ll d = a[i] - a[(i-1 + n) % n];
		if ( ((k - d) % n != 0) || (k - d < 0))
		{
			cout << "NO";
			return 0;
		}

		ll ki = (k - d) / n;
		sum_ki += ki;
	}

	if (sum_ki != k) cout << "NO";
	else cout << "YES";
	return 0;
}

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

int dp[2][2020];

int main(){
  string S;
  cin>>S;
  int ans=0;
  for(int i=0;i<S.size();i++){
    dp[i%2][S[i]-'0']+=1;
    for(int j=0;j<2020;j++){
      int s=(j*10+(S[i]-'0'))%2019;
      dp[i%2][s]+=dp[(i+1)%2][j];
    }
    for(int j=0;j<2020;j++)dp[(i+1)%2][j]=0;
    ans+=dp[i%2][0];
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 3768
import itertools
import math
import sys
from copy import copy
import numpy as np

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
skip_col = []
skip_row = []
for i in range(h):
    ok = True
    for j in range(w):
        if (a[i][j] == '#'):
            ok = False
    if (ok):
        skip_col.append(copy(i))

for j in range(w):
    ok = True
    for i in range(h):
        if (a[i][j] == '#'):
            ok = False
    if (ok):
        skip_row.append(copy(j))

xw = w - len(skip_row)
xh = h - len(skip_col)
ans = [['x' for _ in range(xw)] for _ in range(xh)]
xi = 0
xj = 0
for i in range(h):
    xj = 0
    added = False
    for j in range(w):
        if (i not in skip_col and j not in skip_row):
            ans[xi][xj] = a[i][j]
            added = True
            xj += 1
    if added:
        xi += 1

for s in ans:
    print(''.join(s))


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

using namespace std;

int main(void){
  string s, t;
  cin >> s >> t;
  
  string ns, nt;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  
  //cout << "s:" << s << " t:" << t << endl;
  
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

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

using namespace std;

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

	float count = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 2 == 1) {
			count++;
		}
	}

	cout << count / N << endl;

}





Measured memory_bytes: 3776
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

int main()
{
    int n,a;
  // string s,t; 
  // vector <long> v(n);
    
    cin >> n;
    int maxi=0,mini=10000000;
    for (int i = 0; i < n; ++i)
    {
        cin >> a;
        maxi = max(a,maxi);
        mini = min(a,mini);
    }



    cout <<  maxi-mini;
    
    return 0;
}






Measured memory_bytes: 256
N, W = map(int, input().split())
weights, values = [], []
for _ in range(N):
    w, v = map(int, input().split())
    weights.append(w)
    values.append(v)

def solve(n, w ,weights, values):
    def rec_solve(cw, cv, max_w, i):
        nonlocal weights, values
        #print(cw, cv, i)
        if i == -1:
            return cv
        
        # take
        if weights[i] + cw <= max_w:
            return max(rec_solve(cw+weights[i], cv + values[i], max_w, i-1),
                        rec_solve(cw, cv, max_w, i-1))

        else:
            # dont take
            return rec_solve(cw, cv, max_w, i-1)

    return rec_solve(0, 0, w, n-1)

def solve_fast(n_items, max_w, weights, values):
    dp =  [[0]*(max_w+1) for _ in range(n_items)]
    dp[0] = [values[0] if i >= weights[0] else 0 for i in range(max_w+1)]

    for r in range(1, n_items):
        cw, cv = weights[r], values[r]
        for c in range(max_w+1):
            if cw > c:
                dp[r][c] = dp[r-1][c]
            else:
                dp[r][c] = max(dp[r-1][c], dp[r-1][c-cw] + cv)

    #for r in dp:
        #print(r)

    return dp[-1][-1]


print(solve_fast(N, W, weights, values))

Measured memory_bytes: 119148
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

char c;

set<char> st;

int main()
{
   st.insert('a');
   st.insert('e');
   st.insert('i');
   st.insert('o');
   st.insert('u');

   cin >> c;

   if(st.count(c))
   {
       cout << "vowel" << endl;
   }
   else
   {
       cout << "consonant" << endl;
   }
}

Measured memory_bytes: 256
H, W, N = map(int,input().split())
sr, sc = map(int,input().split())
S = str(input())
T = str(input())
tk_ls = ['L', 'R', 'U', 'D']
ao_ls = ['R', 'L', 'D', 'U']
move_ls = [sc, W-sc+1, sr, H-sr+1]
limit_ls = [W, W, H, H]
for j in range(4):
    tk = tk_ls[j]
    ao = ao_ls[j]
    move = move_ls[j]
    limit = limit_ls[j]
    for i in range(N):
        if S[i] == tk:
            move -= 1
        if move == 0:
            print("NO")
            exit()
        if T[i] == ao and move < limit:
            move += 1
print("YES")


Measured memory_bytes: 42956
#include <bits/stdc++.h>
using namespace std;
const int N = (int) 1e5+5;

int n, m;
int u[N], v[N];
int f(int x,int i){
    return x == u[i] ? v[i] : u[i];
}
vector <int> G[N];
bool visited[N];
int mark[N];
bool s[N], considered[N];
void dfs(int cur){
    visited[cur] = 1;
    for(auto t: G[cur]){
        if (considered[t])
            continue;
        else
            considered[t] = 1;

        int nxt = f(cur, t);

        if (visited[nxt]){
            s[nxt] ^= 1;
            if (u[t] != nxt)
                mark[t] = 1;
        }
        else{
            dfs(nxt);
            if (s[nxt] == 0){
                s[cur] ^= 1;
                if (u[t] != cur)
                    mark[t] = 1;
            }
            else{
                s[nxt] ^= 1;
                if (u[t] != nxt)  
                    mark[t] = 1;
            }
        }
    }
}
void ngk(){
    cin >> n >> m;
    if (m % 2){
        cout << -1;
        return;
    }
    for(int i=1;i<=m;i++){
        cin >> u[i] >> v[i];
        G[u[i]].push_back(i);
        G[v[i]].push_back(i);
    }
    dfs(1);
    for(int i=1;i<=m;i++){
        if (!mark[i])
            cout << u[i] << ' ' << v[i] << '\n';
        else
            cout << v[i] << ' ' << u[i] << '\n';   
    }
} 

int main(){
    #ifdef NGKCP
        freopen("input.txt","r",stdin);
    #endif
    iostream::sync_with_stdio(0);
    ngk();
}
/*
    Array limits;
    Corner cases;
*/

Measured memory_bytes: 16128
#include <bits/stdc++.h>
#define int long long
#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++)
using namespace std;

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    set<string> a;
    string s;
    rep(i,n){
        cin >> s;
        a.insert(s);
    }
    cout << a.size() << endl;
    return 0;
}

Measured memory_bytes: 19232
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define SUM(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class DReplacing {
public:
  static void solve(istream &cin, ostream &cout) {
    int N;
    cin >> N;
    map<int, int> check;
    rep(i, N) {
      int temp;
      cin >> temp;
      check[temp]++;
    }
    int ans = 0;
    FOR(i, check) {
      ans += i.first * i.second;
    }
    int Q;
    cin >> Q;
    rep(i, Q) {
      int B, C;
      cin >> B >> C;
      ans -= B * check[B];
      check[C] += check[B];
      ans += check[B] * C;
      check.erase(B);
      cout << ans << endl;
    }
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  DReplacing solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using  vi = vector<int>;
using  vl = vector<ll>;
using  vd = vector<double>;
template<class T,class U>
using umap = unordered_map<T,U>;
template<class T>
using uset = unordered_set<T>;

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

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

template<class T>
inline void putv(const vector<T>&v,char c = '\n'){
  for(auto&&e:v){
    cout << e << c;
  }
}

int main(){
  int n,d;cin >> n >> d;
  cout << (n + 2*d)/(2*d+1) << endl;
  return 0;
}


Measured memory_bytes: 256
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
#include <regex> //正規表現
using namespace std;
#define _GLIBCXX_DEBUG //GCC環境下で[]による配列要素参照のエラーを出す
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
  int64_t a;
  double b;
  cin>>a>>b;
  int64_t c;
  c=int64_t(b*100);
  cout<<c*a/100<<endl;
}

  

Measured memory_bytes: 3732
// 2016/04/30 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int A, B, C, D, P;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;
	cin >> P;

	int X = A*P;
	int Y = B;
	if(P>C){
		Y += D*(P-C);
	}

	if(X<Y){
		cout << X << endl;
	}
	else{
		cout << Y << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
# C - Attention

N = int(input())
S = list(str(input()))
e = 0
ecum = [0] * (N+1)
wcum = [0] * (N+1)
for i, s in enumerate(S):
    if s == 'E':
        e += 1
        ecum[i+1] = ecum[i] + 1
        wcum[i+1] = wcum[i]
    else:
        ecum[i+1] = ecum[i]
        wcum[i+1] = wcum[i] + 1

ans = 10**18
for i in range(1, N+1):
    # 自分より左にいる西を向いてる人＋右にいる東を向いてる人
    cost = wcum[i-1] + (e - ecum[i])
    ans = min(ans, cost)
print(ans)

Measured memory_bytes: 25536
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

    int main(){
      int h,w;
      cin >> h >> w;
      int hh,ww;
      cin >> hh >> ww;
      cout << h*w-hh*w-h*ww+hh*ww << endl;
      return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  long long ans = 0;
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    long long t = 0;
    for(int j = 0; j < s.size()-i; j++){
      long long p = 1;
      for(int k = 0; k < j; k++) p *= 10;
      t += p*(j == s.size()-1-i ? 1 : 1<< s.size()-2-i-j);
    }
    ans += t*(1<<i)*(s[i] - '0');
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++) cin >> a.at(i);

    int ans = 0;
    vector<int> b(n+1);
    for(int i = 0;i < n;i ++){
        b.at(a.at(i)) ++;
    }

    for(int i = 1;i < n+1;i ++){
        ans += b.at(i) * (b.at(i) - 1) / 2;
    }

    for(int i = 0;i < n;i ++){
        int t = b.at(a.at(i));
        cout << ans - t * (t-1) / 2 + (t-1) * (t-2) /2 << endl;
    }
}



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

int N;
long long dp[2002][2002];

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

    cin >> N;
    vector<pair<long long int, int>> v(N);
    for (int i = 0; i < N; i++) cin >> v[i].first, v[i].second = i + 1;

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end()); // decreasing order

    for (int i = 0; i < N; i++) {
        int len = N - i + 1;
        for (int j = 0; j + len < N + 2; j++) {
            dp[j+1][j+len] = max(dp[j+1][j+len], dp[j][j+len] + v[i].first * abs(v[i].second - (j+1)));
            //cout << dp[j+1][j+len] << endl;
            dp[j][j+len-1] = max(dp[j][j+len-1], dp[j][j+len] + v[i].first * abs(v[i].second - (j+len-1)));
            //cout << dp[j][j+len-1] << endl;
        }
    }

    long long ans = 0;
    for (int i = 0; i<N+1;i++) ans = max(ans, dp[i][i+1]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 26312
n = int(input())
if n==2: print(1); exit()
Ans = set([n-1])
for i in range(2, int((n-1)**(1/2))+1):
    if (n-1)%i == 0: Ans.add(i); Ans.add((n-1)//i)
Div = set([n])
for i in range(2, int(n**(1/2))+1):
    if n%i == 0: Div.add(i); Div.add(n//i)
for d in Div:
    m = n
    while m%d == 0: m//=d
    if m%d == 1: Ans.add(d)
print(len(Ans))

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for(int i = a; i < b; i++)
#define fastio ios::sync_with_stdio(0); cin.tie(0);

int main() {
	fastio;
	int r;
	cin >> r;
	cout << r*r;
	return 0;
}

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

int main() {
  int n;
  int A[20];
  int high = 0;
  int can = 0;
  cin >> n;
  //cout << n << endl;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    //cout << A[i] << endl;
    if (A[i] >= high) {
      high = A[i];
      can += 1;
    }
  }
  
  cout << can << endl;
  
}

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

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

    auto adjacency_list = vector<vector<int>>(N);
    for (auto i = 0; i < M; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        adjacency_list[a].push_back(b);
        adjacency_list[b].push_back(a);
    }

    auto seen = vector<bool>(N);
    auto colors = vector<bool>(N);
    const function<bool(int, bool)> dfs = [&](const int v, const bool color)
    {
        if (seen[v]) return colors[v] == color;
        else
        {
            seen[v] = true;
            colors[v] = color;
        }

        auto is_bipartite = true;
        for (const auto w : adjacency_list[v])
            is_bipartite &= dfs(w, !color);
        return is_bipartite;
    };

    auto singletons = 0LL, bipartites = 0LL, nonbipartites = 0LL;
    for (auto v = 0; v < N; v++) if (!seen[v])
    {
        if (adjacency_list[v].size() == 0) singletons++;
        else if (dfs(v, true)) bipartites++;
        else nonbipartites++;
    }

    auto answer = 0LL;
    answer += 2*singletons*N - singletons*singletons;
    answer += (bipartites + nonbipartites) * (bipartites + nonbipartites);
    answer += bipartites * bipartites;
    cout << answer << endl;
}


Measured memory_bytes: 10496
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

typedef tuple<uint64_t, uint64_t, int> p;
int n;
p encode(char *buf, int c) {
  int hn = n >> 1;
  uint64_t a = 0, b = 0;
  for (int i = 0; i < hn; i++) {
    a *= 26;
    a += buf[i]-'a';
  }
  for (int i = hn; i < n ;i++) {
    b *= 26;
    b += buf[i]-'a';
  }
  return make_tuple(a, b, c);
}


int main() {
  scanf("%d", &n);
  char buff[256];
  scanf("%s", buff);
  map<p, int> lefts;
  // doing left
  char arr[256];
  for (int i = 0; i < (1 << n); i++) {
    int a = 0, b = 0;
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        arr[a] = buff[j];
        a++;
      }
      else {
        arr[n - b - 1] = buff[j];
        b++;
      }
    }
    ++lefts[encode(arr, b)]; // 0 count
  }

  long long ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    int bcnt = 0;
    for (int j = 0; j < n; j++) {
      if (i&(1 << j)) {
        bcnt++;
      }
    }
    int a = 0, b = 0;
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        arr[(n - bcnt) + a] = buff[j + n];
        a++;
      }
      else {
        arr[(n - bcnt) - b - 1] = buff[j + n];
        b++;
      }
    }
    auto I = lefts.find(encode(arr, bcnt));
    if (I != lefts.end()) {
      ans += I->second;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 20736
import kotlin.math.abs

fun main(){
    val (x, n) = readLine()!!.split(" ").map { it.toInt() }
    if (n > 0){
        val p = readLine()!!.split(" ").map { it.toInt() }
        var min = 10000
        var ans = -1
        var flag = 0
        for (i in -100 until 200){
            if (min > abs(x - i)){
                for (j in 0 until n){
                    if (p[j] == i){
                        flag = 1
                        break
                    }
                }
                if (flag == 1){
                    flag = 0
                    continue
                } else {
                    min = abs(x - i)
                    ans = i
                }
            } else if (min == abs(x - i)){
                for (j in 0 until n){
                    if (p[j] == i){
                        flag = 1
                        break
                    }
                }
                if (flag == 1){
                    flag = 0
                    continue
                } else {
                    if (ans > i){
                        ans = i
                    }
                }

            }
        }
        println(ans)
    } else {
        println(x)
    }

}

Measured memory_bytes: 36460
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int m,f,r;
		//?????????????¨????
		m = 0;
		f = 0;
		r = 0;
		
		while(true){//??\???????????¨???-1????????£??????????????????
			
			m = scan.nextInt();
			f = scan.nextInt();
			r = scan.nextInt();
			
			if((m == -1) & (f == -1) & (r == -1)){
				break;
			}
			
			if((m == -1) | (f == -1)){//??????F
				sb.append("F");
				sb.append("\n");
			}else if((m + f)>=80){//??????A
				sb.append("A");
				sb.append("\n");
			}else if((m + f)>=65){//??????B
				sb.append("B");
				sb.append("\n");
			}else if((m + f)>=50){//??????C
				sb.append("C");
				sb.append("\n");
			}else if((m + f)>=30){//??????D ???r???50??\????????´????????????C
				if(r >= 50){//??????C
				sb.append("C");
				sb.append("\n");
				}else{//??????D
					sb.append("D");
					sb.append("\n");
				}
			}else if((m+f)<30){//??????F
				sb.append("F");
				sb.append("\n");
			}
		}
		System.out.print(new String(sb));
		
	}
}

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

int main (){
  string S;
  cin >> S;
  int ctr, ans = 0;
  for (int i = 0; i < S.size(); i++){
    if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') ctr++;
    else ctr = 0;
    ans = max (ans, ctr);
  }
  
  cout << ans << endl;
  return 0;
}

  

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define len(x) ((int)(x).size())
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;
 
const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
 
const int MOD = 1;
inline int mod (ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}
 
////////////////////////// Solution starts below. //////////////////////////////
 
const int N = 1e5+10;
 
int n;
int a[N][3];
int dp[N][3];
 
int solve (int day, int bef) {
	if (day > n)
		return 0;
	
	int &r = dp[day][bef];
	if (r != -1) return r;
	for (int i = 0; i < 3; i++)
		if (i != bef)
			r = max (r, solve (day+1, i) + a[day][i]);
		
	return r;
}
 
int main () {
	memset (dp, -1, sizeof dp);
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < 3; j++)
			scanf ("%d", &a[i][j]);
		
	int ans = -1;
	for (int i = 0; i < 3; i++)
		ans = max (ans, solve (2, i) + a[1][i]);
	printf ("%d\n", ans);
 
	return 0;
}

Measured memory_bytes: 13916
N, M = map(int, input().split())
H = list(map(int, input().split()))
ma = [0]*N

for i in range(M):
    a, b = map(int, input().split())
    ma[a-1] = max(ma[a-1], H[b-1]) 
    ma[b-1] = max(ma[b-1], H[a-1])
ans = 0
for i in range(N):
    if ma[i] < H[i]:
        ans += 1
print(ans)

Measured memory_bytes: 84624
#include<stdio.h>
#include<string.h>

int main(){
	int n;
	int i;
	int tp=0, hp=0;
	char t[105],h[105];
	scanf("%d",&n);
	
	for(i=0; i<n; i++){
		int p;
		scanf("%s %s",t,h);
		p=strcmp(t,h);
		if(p==0){
			tp+=1;
			hp+=1;
		}
		else if(p>0){
			tp+=3;
		}
		else{
			hp+=3;
		}
	}
	printf("%d %d\n",tp,hp);
	
	return 0;
}


Measured memory_bytes: 2052
nums = [int(e) for e in input().split()]
n = nums[0]
m = nums[1]
x = nums[2]

books = []
c = []

min_score = 100000000000000000000

for i in range(n):
    book = [int(e) for e in input().split()]
    c += book[:1]
    books += [book[1:]]

understand = [0] * m
noruma = [x] * m

def calc_understand(a):
    understand = [0] * m
    for i in range(n):
        for j in range(m):
            understand[j] += a[i] * books[i][j]
    return understand


def calc_score(a):
    score = 0
    for i in range(n):
        score += a[i] * c[i]
    return score

# 配列＊配列で全部がX以上になるn個の01からなる配列ができればよい
# DFS
def dfs(a):
    global count
    global min_score
    if len(a) == n+1:
        # トータル数と金額を出す
        understand = calc_understand(a[1:])
        understand.sort()
        if noruma <= understand:
            tmp_score = calc_score(a[1:])
            min_score = min(min_score, tmp_score)
        return

    a.append(0)
    while a[len(a) - 1] <= 1:
        dfs(a)
        a[len(a) - 1] += 1

    a.pop(-1)
    return

a = [0]
dfs(a)

if min_score < 100000000000000000000:
    print(min_score)
else:
    print(-1)


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1e9+7
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'

struct custom_hash {    // anti-hack for unordered_map. To declare: unordered_map<long long, int, custom_hash> safe_map;
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//

void solve()
{
	string s,t;
	cin >> s >> t;
	int c = INT32_MAX;
	for(int i=0; i<s.size(); i++)
	{
		string temp = s.substr(i,t.size());
		if(temp.size() == t.size())
		{
			int x = 0;
			for(int j=0; j<t.size(); j++)
			{
				if(temp[j] != t[j])
					x++;
			}
			c = min(c, x);
		}
	}
	cout << c;
   
}


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

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n, m;

const int MAXN = 200005;
int a[MAXN], lb[MAXN], cnt[MAXN], cover;

void add(int x) {
    lb[x]--;

    if (lb[x] >= 0) {
        cnt[lb[x]]++;

        if (cnt[lb[x]] == 1) {
            cover++;
        }
    }
}

void rem(int x) {
    if (lb[x] >= 0) {
        if (cnt[lb[x]] == 1) {
            cover--;
        }

        cnt[lb[x]]--;
    }

    lb[x]++;
}

int main() {
    GI(n);
    GI(m);

    FORN(i, MAXN) {
        lb[i] = i;
    }

    memset(cnt, 0, sizeof cnt);

    cover = 0;

    FOR1(i, n) {
        GI(a[i]);
        add(a[i]);
    }

    int x, y;

    while (m--) {
        GI(x);
        GI(y);

        rem(a[x]);
        a[x] = y;
        add(y);

        printf("%d\n", n-cover);
    }
    
    return 0;
}

Measured memory_bytes: 3840
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	int ans = 0;

	for (int i = 1; i <= N / 2; i++) {
		ans++;
	}

	if (N % 2 == 0) {
		ans--;
	}

	cout << ans;

	return 0;
}

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

int tax(int p, int x){
    return (p * (100 + x)) / 100;
}

void solve(int x, int y, int s){
    int ans = 0;
    for (int a = 1; a < s; a++){
        for (int b = 1; b < s ; b++){
            if (tax(a, x) + tax(b, x) == s){
                ans = max(ans, tax(a, y) + tax(b, y));
            }
        }
    }
    cout<<ans<<endl;
}

int main()
{
    int x,y,s;
    while(true){
        cin>>x>>y>>s;
        if(x == y && y == s && s == 0) break;
        solve(x, y, s);
    }
}


Measured memory_bytes: 3084