akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;

    for(int i=0; i<dx; i++)
        cout << "R";
    for(int i=0; i<dy; i++)
        cout << "U";
    
    for(int i=0; i<dx; i++)
        cout << "L";
    for(int i=0; i<dy; i++)
        cout << "D";

    cout << "L";
    for(int i=0; i<dy+1; i++)
        cout << "U";
    for(int i=0; i<dx+1; i++)
        cout << "R";
    cout << "D";

    cout << "R";
    for(int i=0; i<dy+1; i++)
        cout << "D";
    for(int i=0; i<dx+1; i++)
        cout << "L";
    cout << "U";
    cout << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using lint=int64_t;
using namespace std;

int N,W;
int kinds;
lint wl[4];
map<lint,vector<lint>> m;
int num[4];
lint ans;

void dfs(int d)
{
	if(d==kinds)
	{
		lint wsum=0;
		for(int i=0;i<kinds;i++)
			wsum+=wl[i]*num[i];
		if(wsum>W)
			return;

		lint tans=0;
		for(int i=0;i<kinds;i++)
			for(int j=0;j<num[i];j++)
				tans+=m[wl[i]][j];
		ans=max(ans,tans);
		return;
	}

	for(int i=0;i<=m[wl[d]].size();i++)
	{
		num[d]=i;
		dfs(d+1);
	}

	return;
}

int main()
{
	cin >> N >> W;
	for(int i=0;i<N;i++)
	{
		lint w,v;
		cin >> w >> v;
		m[w].push_back(v);
	}

	for(auto&& j:m)
	{
		wl[kinds]=j.first;
		kinds++;
		sort(j.second.begin(),j.second.end(),greater<lint>());
	}

	dfs(0);

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


Measured memory_bytes: 256
N = int(input())
x_list=[]
y_list=[]
h_list=[]
hantei = 0
count=0
for i in range(N):
    a,b,c=map(int,input().split())
    x_list.append(a)
    y_list.append(b)
    h_list.append(c)
    if c>0: 
        judge_x = a
        judge_y = b
        judge_h = c

for x in range(101):
    for y in range(101):
        H = judge_h + abs(judge_x-x)+abs(judge_y-y)
        for j in range(N):
            if h_list[j] != max(0,H-abs(x-x_list[j])-abs(y-y_list[j])): break
            if j == N-1 : print(x,y,judge_h + abs(x-judge_x) + abs(y-judge_y))



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype (i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype (i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
int n;bool flg;
int main()
{
    scanf("%d",&n);flg=(n&1);
    printf("%d\n",n*(n-1)/2-n/2);
    rep(i,1,n) rep(j,i+1,n)
    if((!flg&&i+j!=n+1)||(flg&&i+j!=n)) printf("%d %d\n",i,j);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

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

const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

LL kaijo(LL n){
    LL ans=1;
    for(LL i=1;i<=n;++i){
        (ans*=i)%=MOD;
    }
    return ans;
}


int main(){
    int a,b;
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

ll h, w, k;

int main() {
    cin >> h >> w >> k;
    vector< vector<char> > cmap(h, vector<char>(w, '.'));
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> cmap.at(i).at(j);
        }
    }

    int cnt = 0;
    vector<int> hred(h, 0);
    vector<int> wred(w, 0);
    for(int hbit = 0; hbit < (1<<h); ++hbit) {
        for(int i = 0; i < h; ++i) {
            if(hbit&(1<<i)) {
                hred.at(i) = 1;
            }else hred.at(i) = 0;
        }
        for(int wbit = 0; wbit < (1<<w); ++wbit) {
            for(int j = 0; j < w; ++j) {
                if(wbit&(1<<j)) {
                    wred.at(j) = 1;
                }else wred.at(j) = 0;
            }
            int bcnt = 0;
            for(int k = 0; k < h; ++k) {
                if(hred.at(k) != 1) {
                    for(int l = 0; l < w; ++l) {
                        if(wred.at(l) != 1) {
                            if(cmap.at(k).at(l) == '#') bcnt++;
                        }
                    }
                }
            }
            if(bcnt == k) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)













int main(){
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    REP(i, h){
        cin >> s[i];
    }
    vector<vector<ll>> ans(h, vector<ll>(w));
    ll c = 0;
    REP(j, w){
        bool f = false;
        REP(i, h){
            if(s[i][j] == '#'){
                c++;
                if(!f){
                    f = true;
                    REP(l, i){
                        ans[l][j] = c;
                    }
                }
                ans[i][j] = c;
            }
            else{
                if(f){
                    ans[i][j] = c;
                }
            }
        }
        if(!f && j > 0){
            REP(i, h){
                ans[i][j] = ans[i][j - 1];
            }
        }
    }
    for(ll j = w - 2; j >= 0; j--){
        REP(i, h){
            if(ans[i][j] == 0){
                ans[i][j] = ans[i][j + 1];
            }
        }
    }
    
    REP(i, h){
        REP(j, w){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1664
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def nPr(n,r):
    num = 1
    for i in range(n,n-r,-1):
        num*=i
    return num

N,K = [int(x) for x in input().split()]
R = N-K
mod = 10**9+7
for i in range(1,K+1):
    ans = 0
    if(i==1):
        ans = R+1
    else:
        if(R==i-1):
            ans = combinations_count(K-1,i-1)
        elif(R<i-1):
            ans = 0
        else:
            ans = combinations_count(K-1,i-1)*math.factorial(R+1)//math.factorial(R-(i-1))//math.factorial(i)
    print(ans%mod)


Measured memory_bytes: 64856
/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs(string X, string Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
char lcs[index+1]; 
lcs[index] = '\0'; // Set the terminating character 

// Start from the right-most-bottom-most corner and 
// one by one store characters in lcs[] 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
cout <<lcs; 
} 

/* Driver program to test above function */
int main() 
{ 
string X,Y;
  cin>>X>>Y;
int m = X.length(); 
int n = Y.length(); 
lcs(X, Y, m, n); 
return 0; 
} 


Measured memory_bytes: 35456
#include <iostream>

using namespace std;

int main()
{
	int n, k;

	cin >> n >> k;

	int *a = new int[n];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];

		if (a[i] >= k) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int D, T, S;
  cin >> D >> T >> S;

  if (T * S >= D) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <cstdlib>
typedef long long ll;
#define fi first
#define se second
 
using namespace std;
 
int main(){
 
    string s;
    cin >> s;
  
  	int sz = s.size();

    int ans = 101;
    for(int i = 0;i<26;i++){
        int check = -1;
        int mx = 0;
        for(int k = 0;k<sz;k++){
            if(s[k] == 'a' + i){
                mx = max(mx,k-check-1);
                check = k;
            }
            if(k == sz - 1 && check != -1){
                mx = max(mx,sz-check-1);
                ans = min(ans,mx);
            }

        }
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
n.times {
	input=gets.split(" ")
        a,b,c=input[0].to_i,input[1].to_i,input[2].to_i
        a=a**2;b=b**2;c=c**2
        if a==b+c || b==a+c || c==a+b
	puts "YES"
	else
	puts "NO"
	end	}



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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


int main(){
    ll a,b,n;
    cin>>a>>b>>n;

    ll m = min(b-1,n);
    cout<<floor(a*m/b)-a*floor(m/b)<<endl;
}


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

void out(char a, char b){
    for(int i = 0; i < (b - '0'); i++){
        cout << a;
    }
    cout << endl;
    return;
}

int main(){
    char a, b;
    cin >> a >> b;

    string s;
    if(a < b){
        out(a, b);
    }
    else{
        out(b, a);
    }
    // else{
    //     s = a * a;
    // }

    // cout << s << endl;
    return 0;
}

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int N; string S, T; cin >> N >> S >> T;
   if (S == T) {
      cout << "0\n";
      return 0;
   }
   vector<int> cutS, cutT;
   int j = N - 1;
   for (int i = N - 1; i >= 0; --i) {
      if (i == 0 || T[i] != T[i - 1]) {
         j = min(j, i);
         while (j >= 0 && S[j] != T[i]) --j;
         if (j == -1) {
            cout << "-1\n";
            return 0;
         }
         cutS.emplace_back(j);
         cutT.emplace_back(i);
      }
   }
   reverse(cutS.begin(), cutS.end());
   reverse(cutT.begin(), cutT.end());
   int low = 0, high = int(cutS.size()) - 1;
   while (low < high) {
      int mid = (low + high) >> 1;
      bool ok = true;
      for (int i = 1; i + mid < int(cutS.size()); ++i) {
         ok &= (cutS[i + mid] - mid >= cutT[i]);
      }
      if (ok) high = mid;
      else low = mid + 1;
   }
   cout << low + 1 << '\n';
   return 0;
}


Measured memory_bytes: 13984
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
const int maxn = 1<<20, mod = 924844033;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	ll a, b, c;
	cin >> a >> b >> c;
	if(a&b&c&1) cout << min({a*b, b*c, c*a});
	else cout << 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  int Alice = 0;
  int Bob = 0;
  
  for (int i = 0; i < N; i++){
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  for (int j = 0; j < N; j++){
    
    if (j == 0){
      Alice += a.at(j);
    }
    else if (j % 2 == 0){
      Alice += a.at(j);
    }
    else{
      Bob += a.at(j);
    }
  }
  
  cout << Alice - Bob << endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define S stack<int>
#define Q queue<int>
#define V vector<int>
using namespace std;
signed main(){
	int a,b,c,d,ans=INT_MAX;
	cin>>a>>b;
	f(i,a){
		cin>>c>>d;
		if(d<=b) ans=min(ans,c);
	}
	if(ans==INT_MAX) puts("TLE");
	else cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
const double inf=1e9;
typedef long long ll;
typedef pair<ll,ll>pr;
const ll mod=1e9+7;
ll _pow(ll  a,ll b) {
    ll ans=1;
    while(b) {
        if(b&1)
            ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}

int main(){
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ll l,r;
  cin>>l>>r;
  if(r-l>=2019){
    cout<<"0"<<endl;
  }
  else{
    ll ans=0x3f3f3f3f;
    for(int i=l;i<=r;i++){
      for(int j=i+1;j<=r;j++){
        ans=min(ans,1ll*i*j%2019);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


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

void func144c() {
  long long n, ans = 1e18;
  cin >> n;
  for(long long i = 1; i*i <= n; i++) {
    //nがiで割り切れたとき続きをする
    if(n%i != 0) continue;
    long long j = n/i;
    ans = min(ans, i+j-2);
  }
  cout << ans << "\n";
}
int main() {
  func144c();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
 int t,x=0;
 cin>>t;
  int n[t],m[t];
  for(int i=0;i<t;i++){
   cin>>n[i]>>m[i];
  }
  for(int i=0;i<t;i++){
    if(n[i]==m[i]){
      if(n[i+1]==m[i+1]){
        if(n[i+2]==m[i+2]){
          x++;
        }
      }        
    }
  }
  if(x>0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define inf 1<<29
using namespace std;

class State{
public:
  int n,num,cost;
  State(int a,int b,int c):n(a),num(b),cost(c){}
  bool operator<(State s)const{
    return s.num<num;
  }
};

vector<pair<int,int> > v[101];
int dp[101][1001];
int n,m,c;

void init(){
  for(int i=0;i<n;i++){
    v[i].clear();
    for(int j=0;j<m;j++)dp[i][j]=inf;
  }
}

int main()
{
  int a,b,d;

  while(1){
    cin>>n>>m>>c;
    if(n+m+c==0)break;
    init();
    for(int i=0;i<m;i++){
      cin>>a>>b>>d;
      a--;b--;
      v[a].push_back(mp(b,d));
    }
    
    dp[0][0]=0;
    priority_queue<State> pq;
    pq.push(State(0,0,0));

    while(!pq.empty()){
      State u=pq.top();
      pq.pop();

      if(dp[u.n][u.num]<u.cost)continue;
      //cout<<u.n<<" "<<u.num<<" "<<u.cost<<endl;
      for(int i=0;i<v[u.n].size();i++){
        int next=v[u.n][i].f,cost=v[u.n][i].s;
	if(u.cost+cost<dp[next][u.num]){
	  dp[next][u.num]=u.cost+cost;
	  pq.push(State(next,u.num,u.cost+cost));
	}
	if(u.cost<dp[next][u.num+1]){
	  dp[next][u.num+1]=u.cost;
	  pq.push(State(next,u.num+1,u.cost));
	}
      }
    }

    int ans=inf;
    for(int i=0;i<1001;i++){
      if(dp[n-1][i]<=c){
	ans=i;
	break;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1652
#include <bits/stdc++.h>
using namespace std;
#define asc(i,a,n) for (I i=a;i<n;i++)
#define dsc(i,a,n) for (I i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define P auto
typedef vector<long long int> VI;
typedef long long int I;
typedef pair<long long int,long long int> PII;
typedef double D;
typedef set<long long int> OSI;
typedef unordered_set<long long int> USI;
typedef list<long long int> LI;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("cnsl/input.txt", "r", stdin);
    freopen("cnsl/output.txt", "w", stdout);
    #endif
    string s;
    cin>>s;
    I n=s.size();
    I a[n+1];
    a[0]=0;
    a[1]=(s[n-1]-'0')%2019;
    I b[n];
    b[0]=1;
    asc(i,1,n){
      b[i]=b[i-1]*10;
      b[i]%=2019;
    }
    asc(i,2,n+1){
      a[i]=a[i-1]+(b[i-1]*(s[n-i] -'0'));
      a[i]%=2019;
    }
    unordered_map<I,I> m;
    asc(i,0,n+1){
      P it=m.find(a[i]);
      if(it!=m.end()){
        (*it).se++;
      }else{
        m.insert(mp(a[i],1));
      }
    }
    I ans=0;
    for(P it=m.begin();it!=m.end();it++){
      ans+=(((*it).se)*((*it).se -1))/2;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6920
#include<iostream>
#include<algorithm>
#include <string>
#include<cstdio>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
typedef long long ll;

int main()
{
	int a, b, c; cin >> a >> b >> c;
	if ((100 * a + 10 * b + c) % 4 == 0) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  string str,text;
  for(int i=0;i<W+2;i++){
    text+="#";
  }
  cout <<text <<endl;
  for(int i =0; i<H; i++){
    cin >>str;
    cout <<"#"+str+"#"<<endl;
  }
  cout <<text <<endl;
}


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

using namespace std;

#define MAX 200000

void Solve(int* pArray, int size);
void BestSolve(int* pArray, int size);

int main()
{
	int n, R[MAX];
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> R[i];

	//Solve(R, n);
	BestSolve(R, n);

	return 0;
}

void Solve(int* pArray, int size)
{
	// 设置一个足够小的初始值
	int result = -1000000000;

	// 2层循环，复杂度为O(n^2)
	for (int i = 0; i < size - 1; ++i)
	{
		for (int j = i + 1; j < size; ++j)
			result = max(result, pArray[j] - pArray[i]);
	}

	cout << result << endl;
}

void BestSolve(int* pArray, int size)
{
	// 设置一个足够小的初始值
	int result = -1000000000;

	int minValue = pArray[0];
	// 1层循环，复杂度为O(n)
	for (int i = 1; i < size; ++i)
	{
		result = max(result, pArray[i] - minValue);
		minValue = min(minValue, pArray[i]);
	}

	cout << result << endl;
}


Measured memory_bytes: 3868
import java.io.*;
import java.math.BigDecimal;

public class Main{
    private static final BigDecimal pi = new BigDecimal(3.14159265358979);

    public static void main(String[] args) throws IOException{
        String str = getLine();
        BigDecimal r = new BigDecimal(str);
        double s = r.multiply(r).multiply(pi).doubleValue();
        double l = r.add(r).multiply(pi).doubleValue();
        System.out.printf("%.6f %.6f\n",s,l);
    }

    public static String getLine() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        return str;
    }
}


Measured memory_bytes: 24944
import java.io.IOException;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		
		//入力値を読み込む
		int a = scanner.nextInt();
		String op = scanner.next();
		int b = scanner.nextInt();
		
		//opが「+」か「-」か判定し計算結果を出力
		if(op.equals("+")){
			System.out.println(a+b);
		}else{
			System.out.println(a-b);
		}
	}
}

Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int ans = 0;
    if (a < b)
        ans += a;
    else
        ans += b;
    if (c < d)
        ans += c;
    else
        ans += d;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

vector<ll> V[110000],T,S;
ll sumT[110000],sumS[110000];

int main(){
  int N,K,t;
  ll d;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    cin>>t>>d;
    t--;
    V[t].push_back(d);
  }

  for(int i=0;i<N;i++){
    sort(V[i].begin(),V[i].end(),greater<ll>());
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<(int)V[i].size();j++){
      if(j==0) T.push_back(V[i][j]);
      else S.push_back(V[i][j]);
    }
  }

  sort(T.begin(),T.end(),greater<ll>());
  sort(S.begin(),S.end(),greater<ll>());

  for(int i=0;i<(int)T.size();i++){
    sumT[i+1]=sumT[i]+T[i];
  }
  for(int i=0;i<(int)S.size();i++){
    sumS[i+1]=sumS[i]+S[i];
  }
  ll ans=0;
  for(int i=0;i<=K;i++){
    if((int)T.size()>=i)
    ans=max(ans,sumT[i]+sumS[K-i]+i*i);
  }
  cout<<ans<<endl;






}


Measured memory_bytes: 8568
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int q = sc.nextInt();
		
		int[] sMod = new int[s.length()+1];
		sMod[0] = 0;
		for (int i=1;i<=s.length();i++) {
			sMod[i] = (sMod[i-1] + (s.charAt(i-1)=='A' ? 1 : 2))%3;
		}
		int[] tMod = new int[t.length()+1];
		tMod[0] = 0;
		for (int i=1;i<=t.length();i++) {
			tMod[i] = (tMod[i-1] + (t.charAt(i-1)=='A' ? 1 : 2))%3;
		}
		
		for (int i=0;i<q;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();

			int x = (sMod[b] - sMod[a-1] + 3) % 3;
			int y = (tMod[d] - tMod[c-1] + 3) % 3;
			
			System.out.println(x==y ? "YES" : "NO");
		}
	}

}


Measured memory_bytes: 97664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll lng(string s){
    int count = 0;
    for(int i = 0; s[i] != '\n' && s[i] != '\0'; i++){
        count++;
    }
    return count;
}

int main(){
    string s; cin >> s;
    ll Q; cin >> Q;
    ll Ti, Fi;
    string Ci;
    ll L = lng(s);
    bool inv = false;
    for(int i = 0; i < Q; i++){
        cin >> Ti;
        if(Ti == 1){
            inv = !inv;
        }else if(Ti == 2){
            cin >> Fi >> Ci;
            if(Fi == 1){
                if(inv) s.insert(L, Ci);
                else s.insert(0, Ci);
                L++;
            }else if(Fi == 2){
                if(inv) s.insert(0, Ci);
                else s.insert(L, Ci);
                L++;
            }
        }
    }
    if(inv){
        for(int i = L - 1; i >= 0; i--){
            printf("%c", s[i]);
        }
    }else{
        for(int i = 0; i < L; i++){
            printf("%c", s[i]);
        }
    }
    printf("\n");
}

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

using namespace std;

string str;

int w;
int main(void) {

	cin >> str;

	cin >> w;

	for (int i = 0; i < str.size(); i++) {
		if (i%w == 0) { cout << str.substr(i, 1); }
	}cout << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int MAX = 25;
const int NIL = -1;
enum Type { root, leaf, internalNode };
struct Node
{
	int parent;
	int sibling;
	int left;
	int right;
	int degree;
	Type type;
}T[MAX];
int getDepth(int u)
{
	if (T[u].parent == NIL)
		return 0;
	else
		return getDepth(T[u].parent) + 1;
}
int getHeight(int u)
{
	int h1=0,h2 = 0;
	if (T[u].left != NIL)
		h1 = getHeight(T[u].left) + 1;
	if (T[u].right != NIL)
		h2 = getHeight(T[u].right) + 1;
	return h1 > h2 ? h1 : h2;
}
void print(int u)
{
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", T[u].sibling);
	printf("degree = %d, ", T[u].degree);
	printf("depth = %d, ", getDepth(u));
	printf("height = %d, ",getHeight(u));
	if (T[u].type == root)
		printf("root\n");
	else if (T[u].type == leaf)
		printf("leaf\n");
	else
		printf("internal node\n");
}
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		T[i].parent = T[i].left = T[i].right = T[i].sibling = -1;
	}
	for (int i = 0; i < n; i++)
	{
		int p, l, r, d = 0;
		cin >> p >> l >> r;
		T[p].left = l;
		T[p].right = r;
		if (l != NIL)
		{
			d++;
			T[l].parent = p;
			if (r != NIL)
				T[l].sibling = r;
		}
		if (r != NIL)
		{
			d++;
			T[r].parent = p;
			if (l != NIL)
				T[r].sibling = l;
		}
		T[p].degree = d;
		T[p].type = (d != 0) ? internalNode : leaf;
	}
	int r;
	for (int i = 0; i < n; i++)
		if (T[i].parent == NIL)
		{
			r = i;
			T[i].type = root;
			break;
		}
	for (int i = 0; i < n; i++)
		print(i);
}


Measured memory_bytes: 3192
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n,i,j,a,b,d;
            cin>>n>>d;
            d=d*d;
            int ans=0;
            for(i=1;i<=n;++i)
            {
                cin>>a>>b;
                if(a*a+b*b<=d)
                    ++ans;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb2l(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



void solve(){
   ll n;
   cin>>n;
   set<ll>s;
   ll k;
   fr(i,0,n)
   cin>>k,s.insert(k);
   if(n==s.size())
   cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
    


  }
int main(){
    ll t=1;
   // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n],b[n],c[n-1];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  for(int i=0;i<n-1;i++){
    cin >> c[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int j = a[i];
    ans += b[j-1];
    if((a[i]-a[i-1])==1){
    ans += c[j-2];
    }
  }
  cout << ans << endl;
  return 0;
}

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

using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::vector;




int main(){
	int n,k;
	cin >> n >> k;
	int TN;
	int tmp;
	vector<int> people(n,0);
	for(int i=0;i<k;i++){
		cin >> TN;
		for(int ii=0;ii<TN;ii++){
			cin >> tmp;
			people[tmp-1]=1;
		}
	}
	int tt;
	tt=0;
	for(int i=0;i<n;i++){
		if(people[i]==0){
			tt=tt+1;
		}
	}
	cout << tt;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 123;
const ll LINF = (ll) 1e18 + 123;
const ld EPS = (ld) 1e-8;
const ll MOD = (ll) 1e9 + 7;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (auto i = f; i < t; i++)
#define per(i, f, t) for (auto i = f; i >= t; i--)

ll power(ll x, ll y, ll mod) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

inline void add(ll &x, ll y, ll mod) {
    x += y;
    if (x >= mod) x -= mod;
    if (x < 0) x += mod;
}

inline ll sum(ll x, ll y, ll mod) {
    add(x, y, mod);
    return x;
}

template<typename A, typename B> inline bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> inline bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

template<typename T> inline void read(T first, T last) {
    while (first != last) {
        cin >> *(first++);
    }
}

template<typename T> inline void print(T first, T last) {
    while (first != last) {
        cout << *(first++) << " ";
    }
    cout << "\n";
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(15);
    run();
    return 0;
}

// == SOLUTION == //

const int N = 5005;

int n;
vector<int> g[N];
int x[N], dp[N];
int cur[N][N];

void dfs(int v) {
    for (int u : g[v]) {
        dfs(u);
    }
    rep(i, 0, sz(g[v]) + 1) {
        fill(cur[i], cur[i] + N, INF);
    }
    cur[0][0] = 0;
    rep(i, 0, sz(g[v])) {
        int u = g[v][i];
        rep(w, 0, N) {
            if (w + dp[u] < N) mini(cur[i + 1][w + dp[u]], cur[i][w] + x[u]);
            if (w + x[u] < N) mini(cur[i + 1][w + x[u]], cur[i][w] + dp[u]);
        }
    }
    
    dp[v] = INF;
    rep(i, 0, x[v] + 1) {
        mini(dp[v], cur[sz(g[v])][i]);
    }
    
    if (dp[v] == INF) {
        cout << "IMPOSSIBLE\n";
        exit(0);
    }
}

void run() {
    cin >> n;
    rep(i, 2, n + 1) {
        int p;
        cin >> p;
        g[p].pb(i);
    }
    rep(i, 1, n + 1) {
        cin >> x[i];
    }
    dfs(1);
    cout << "POSSIBLE\n";
}


Measured memory_bytes: 20864
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))<eps)

#define pause cout << " press ansy key to continue...",  cin >> chh
#define file_r(x) freopen(x,  "r",  stdin)
#define file_w(x) freopen(x,  "w",  stdout)
#define lowbit(x) ((x) & (-x))
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repe(i, u) for (int i = head[u]; i != -1; i = nxt[i])
#define repd(i, n) for (int i = (n - 1); i >= 0; i--)
#define FOR(i, n, m) for (int i = (n); i <= (m); i++)
#define FORD(i, n, m) for (int i = (n); i >= (m); i--)
#define pb push_back
#define X first
#define Y second
#define ins insert
#define rb rbegin
#define be begin
#define er erase
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define SZ(c) (c).size()
#define ALL(c) (c).begin(), (c).end()
#define sqr(r) ((LL) (r) * (r))
#define dis(x1, y1, x2, y2) (((x1) - (x2)) * ((x1) - (x2)) + ((y1) - (y2)) * ((y1) - (y2)))
#define FASTIO ios::sync_with_stdio(false);cin.tie(0)

#define sc(x) cout << #x" = " << x << endl, system("pause")
#define sc2(x, y) cout << #x" = " << x << " " << #y" = " << y << endl, system("pause")
#define sc3(x, y, z) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << endl, system("pause")
#define sc4(x, y, z, w) cout << #x" = " << x << " " << #y" = " << y << " " << #z" = " << z << " " << #w" = " << w << endl, system("pause")

#define in(n) scanf("%d", &n)
#define in2(n, m) scanf("%d %d", &n, &m)
#define in3(x, y, z) scanf("%d %d %d", &x, &y, &z)

using namespace std;
int chh;

typedef vector<int> vi;
typedef set<int> si;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<int, pii> pi3;
typedef vector< pair<int, int> > vpii;
typedef long long LL;

int n, m;
int f[15];

int gao() {
    int x, flag;
    FOR (i, n, 999999) {
        x = i, flag = 1;
        while (x != 0) {
            if (f[x % 10]) {
                flag = 0;
                break;
            }
            x /= 10;
        }
        if (flag) return i;
    }
}

int main() {
    int x;
    while (~scanf("%d %d", &n, &m)) {
        memset(f, 0, sizeof(f));
        rep (i, m) {
            scanf("%d", &x);
            f[x] = 1;
        }
        printf("%d\n", gao());
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    int sum=700;
    cin>>s;
    if(s[0]=='o') sum+=100;
    if(s[1]=='o') sum+=100;
    if(s[2]=='o') sum+=100;
    cout<<sum<<endl;
}


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

typedef long long ll;
typedef vector<int> vi;

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

	vector<ll> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	int sum = n;
	vector<bool> good(n, true);

	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--; b--;
		if (h[a] <= h[b]) {
			if (good[a]) {
				sum--;
				good[a] = false;
			}
		}
		if(h[a] >= h[b]) {
			if (good[b]) {
				sum--;
				good[b] = false;
			}
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int K,X;
cin >> K >> X;
int a = X-K+1;
for (int i = 0;i < 2*K-1;i++) {
    cout << a << " ";
    a++;
}

cout << endl;
return 0;
}


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

int main(void)
{
  int N;
  std::string S;
  std::cin >> N >> S;

  int x = 0;
  int max_x = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'I') {
      x++;
    }
    else if (S[i] == 'D') {
      x--;
    }
    
    max_x = std::max(x, max_x);
  }
  std::cout << max_x << std::endl;

  return 0;
}

Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static final int MOD = 1_000_000_007;
   	public long countPaths(int h, int w, char[][] grid) {
        int[][] dp = new int[h][w];
        for (int i = h - 1; i >= 0; i--) {
            for (int j = w - 1; j >= 0; j--) {
                if (grid[i][j] == '#') {
                    continue;
                }
                if (i  == h - 1 && j == w - 1) {
                    dp[i][j] = 1;
                } else if (i == h - 1) {
                    dp[i][j] = (dp[i][j + 1]) % MOD;
                } else if (j == w - 1) {
                    dp[i][j] = (dp[i + 1][j]) % MOD;
                } else {
                    dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % MOD;
                }
            }
        }
        return dp[0][0];
    }
    public static void main(String[] args)  {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String[] split = br.readLine().split(" ");
            int h = Integer.parseInt(split[0]);
            int w = Integer.parseInt(split[1]);
          	char[][] grid = new char[h][w];
            for (int i = 0; i < h; i++) {
                grid[i] = br.readLine().toCharArray();
            }
          	Main app = new Main();
            long result = app.countPaths(h, w, grid);
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 34964
[N,K] = list(map(int,input().split()))
P= list(map(int,input().split()))

#期待値
E=[]
for i in range(0,N):
    E.append((1+P[i])/2)
    
wa=[]
wa.append(sum(E[0:K]))
for j in range(1, N-K+1):
    wa.append(wa[j-1] - E[j-1] + E[j+K-1])
print(max(wa))

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

const int mod=1e9+7;
#define ll long long

void U(auto &x,auto y){
    x=(x+y)%mod;
}

int f[5050][5050], f2[5050], g[5050], sz[5050];

int n;
vector<int>G[5050];

void dfs(int x,int fff){
    sz[x]=1; f[x][1]=1;
    for (auto y:G[x])
        if (y!=fff){
            dfs(y,x);
            memset(f2,0,sizeof f2);
            for (int i=0;i<=sz[x];++i)
                for (int j=0;j<=sz[y];++j)
                    U(f2[i+j],(ll)f[x][i]*f[y][j]);
            memcpy(f[x],f2,sizeof f2);
            sz[x]+=sz[y];
        }
    for (int i=1;i<=sz[x];++i)
        U(f[x][0],mod-(ll)f[x][i]*g[i]%mod);
}

int main(){
    cin>>n;
    for (int i=1;i<n;++i){
        int x, y; cin>>x>>y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    g[0]=1;
    for (int i=2;i<=n;++i)
        g[i]=(ll)g[i-2]*(i-1)%mod;
    dfs(1,0);
    int ans=(mod-f[1][0])%mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 99712
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Diagnostics;
using static System.Console;
using static System.Math;


namespace AtCoder
{
    class AtCoderrrrr
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());

            //t,x,y
            int[] now = { 0, 0, 0 };
            for (int i = 0; i < n; i++)
            {
                int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
                int t = s[0];
                int x = s[1];
                int y = s[2];
                int distance = Abs(now[1] - x) + Abs(now[2] - y);
                if (distance <= t)
                {
                    if (((t-now[0]) - distance) %2 != 0)
                    {
                        WriteLine("No");
                        return;
                    }
                }
                else
                {
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 15400
using namespace std;

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
using namespace std;


int main(void){
	long long int N;
	map<pair<string, int>, int> SP;

	cin >> N;

  int hoge = 180 * N - 360;
		cout << hoge << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
s = [int(input()) for _ in range(N)]

ans = sum(s)
minus = 10 ** 10 + 1
flag = True
if ans % 10 == 0:
    for i in range(N):
        if s[i] % 10 != 0:
            minus = min(minus,s[i])
            flag = False
            
    if flag:
        ans = 0
    else:
        ans -= minus
        
print(ans)
    



Measured memory_bytes: 3060
#include <stdio.h>

int main(){
  int x,y,k;
  
  scanf("%d",&x);
  scanf("%d",&y);
  
    while(x%y != 0){
      k=y;
      y=x%y;
      x=k;
    }
   printf("%d\n",y);
   
   return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#define pii pair<int,int> 
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define SZ(x) ((int)x.size())
using namespace std;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){c=Getchar();rev|=c=='-';if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	if(c=='.'){
		c=Getchar();double t=0.1;
		while(c>='0'&&c<='9') x=x+(c-'0')*t,c=Getchar(),t=t/10;
	}
	x=rev?-x:x;
	return 1;
}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c='\n'){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[20];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------head---------------------------------------------

const int inf=0x3f3f3f3f;
const int N=200005,M=100005,mod=1e9+7;
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,cnt[N];
char s[N];

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%s",s+1);n=strlen(s+1);
	ll ans=(ll)n*(n-1)/2+1;
	for(int i=1;i<=n;i++)
		cnt[s[i]-'a']++;
	for(int i=0;i<26;i++)
		ans-=(ll)cnt[i]*(cnt[i]-1)/2;
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s.at(0)==s.at(1) && s.at(2)==s.at(3) && s.at(0)!=s.at(2)) cout << "Yes" << endl;
    else if(s.at(0)==s.at(2) && s.at(1)==s.at(3) && s.at(0)!=s.at(3)) cout << "Yes" << endl;
    else if(s.at(0)==s.at(3) && s.at(1)==s.at(2) && s.at(0)!=s.at(1)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

double cross_product (xy_t a, xy_t b) {
    return (conj(a) * b).imag();
}

int main() {
    int n;
    cin >> n;
    pii c[n];
    int x, y;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        c[i] = pii(x, y);
    }
    sort(c, c + n);
    xy_t cc[n];
    for (int i = 0; i < n; i++) {
        cc[i] = xy_t(c[i].first, c[i].second);
    }
    vector<xy_t> down;
    down.push_back(cc[0]);
    for (int i = 1; i < n; i++) {
        while (true) {
            if (down.size() == 1) {
                down.push_back(cc[i]);
                break;
            } else {
                xy_t a = down[down.size() - 2];
                xy_t b = down[down.size() - 1];
                double diff = cross_product(b - a, cc[i] - a);
                if (diff > -1 * eps) {
                    down.push_back(cc[i]);
                    break;
                } else {
                    down.pop_back();
                }
            }
        }
    }
    vector<xy_t> up;
    up.push_back(down[down.size() - 1]);
    for (int i = n - 2; i >= 0; i--) {
        while (true) {
            if (up.size() == 1) {
                up.push_back(cc[i]);
                break;
            } else {
                xy_t a = up[up.size() - 2];
                xy_t b = up[up.size() - 1];
                double diff = cross_product(b - a, cc[i] - a);
                if (diff > -1 * eps) {
                    up.push_back(cc[i]);
                    break;
                } else {
                    up.pop_back();
                }
            }
        }
    }
    int num = down.size() + up.size() - 2;
    cout << num << endl;
    int bottom = 0;
    for (int i = 0; i < down.size() - 1; i++) {
        if (down[i].imag() <= down[i + 1].imag()) {
            break;
        }
        bottom++;
    }
    for (int i = bottom; i < down.size(); i++) {
        cout << down[i].real() << " " << down[i].imag() << endl;
    }
    for (int i = 1; i < up.size() - 1; i++) {
        cout << up[i].real() << " " << up[i].imag() << endl;
    }
    for (int i = 0; i < bottom; i++) {
        cout << down[i].real() << " " << down[i].imag() << endl;
    }
}



Measured memory_bytes: 6720
//quming
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=1005;
const double Pi=acos(-1.0);
int a[N],n,ans,m;
int main(){
	int a,b,x;scanf("%d%d%d",&a,&b,&x);
	if(x==a*a*b)return puts("0.0"),0;
	if(x*2<=a*a*b){
		double ar=1.0*x/a;
		double p=ar*2/b;
		printf("%.10lf\n",360*atan2(b,p)/(2*Pi));
	}else{
		double ar=1.0*(a*a*b-x)/a;
		double p=ar*2/a;
//		printf("%.10lf %d\n",p,b);
		printf("%.10lf\n",360*atan2(p,a)/(2*Pi));
	}
	return 0;
}

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

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

//?????§??¬?´???°
int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
//?????§??¬?´???° ?????°???
int gcd(const vector<int> &v) {
	int ret = v[0];
	rep(i, 1, v.size())ret = gcd(ret, v[i]);
	return ret;
}
//????°???¬?????°
int lcm(int x, int y) { return x*y / gcd(x, y); }
//????°???¬?????° ?????°???
int lcm(const vector<int> &v) {
	int ret = v[0];
	rep(i, 1, v.size())ret = lcm(ret, v[i]);
	return ret;
}

signed main() {
	for (int n; cin >> n&&n;) {
		vector<int> d(n), v(n); rep(i, 0, n) { cin >> d[i] >> v[i]; }
		int vg = gcd(v);
		vector<int> l(n);
		rep(i, 0, n) {
			l[i] = lcm(d[i], v[i] / vg) / (v[i] / vg);
		}
		int ll = lcm(l);
		rep(i, 0, n) {
			cout << ll*(v[i] / vg) / d[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2984